Skip to content

Commit 10cd1c4

Browse files
chore(api): fix realtime GA types
1 parent d9bd542 commit 10cd1c4

38 files changed

+2420
-2661
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 118
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-7807ec6037efcee1af7decbfd3974a42b761fb6c6a71b4050fe43484d7fcbac4.yml
3-
openapi_spec_hash: da6851e3891ad2659a50ed6a736fd32a
4-
config_hash: 74d955cdc2377213f5268ea309090f6c
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-16cb18bed32bae8c5840fb39a1bf664026cc40463ad0c487dcb0df1bd3d72db0.yml
3+
openapi_spec_hash: 4cb51b22f98dee1a90bc7add82d1d132
4+
config_hash: 930dac3aa861344867e4ac84f037b5df

openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioInputTurnDetection.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private constructor(
9595

9696
/**
9797
* Optional idle timeout after which turn detection will auto-timeout when no additional audio
98-
* is received.
98+
* is received and emits a `timeout_triggered` event.
9999
*
100100
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
101101
* server responded with an unexpected value).
@@ -298,7 +298,7 @@ private constructor(
298298

299299
/**
300300
* Optional idle timeout after which turn detection will auto-timeout when no additional
301-
* audio is received.
301+
* audio is received and emits a `timeout_triggered` event.
302302
*/
303303
fun idleTimeoutMs(idleTimeoutMs: Long?) = idleTimeoutMs(JsonField.ofNullable(idleTimeoutMs))
304304

openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeClientEvent.kt

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ private constructor(
3434
private val responseCancel: ResponseCancelEvent? = null,
3535
private val responseCreate: ResponseCreateEvent? = null,
3636
private val sessionUpdate: SessionUpdateEvent? = null,
37-
private val transcriptionSessionUpdate: TranscriptionSessionUpdate? = null,
3837
private val _json: JsonValue? = null,
3938
) {
4039

@@ -175,10 +174,6 @@ private constructor(
175174
*/
176175
fun sessionUpdate(): Optional<SessionUpdateEvent> = Optional.ofNullable(sessionUpdate)
177176

178-
/** Send this event to update a transcription session. */
179-
fun transcriptionSessionUpdate(): Optional<TranscriptionSessionUpdate> =
180-
Optional.ofNullable(transcriptionSessionUpdate)
181-
182177
fun isConversationItemCreate(): Boolean = conversationItemCreate != null
183178

184179
fun isConversationItemDelete(): Boolean = conversationItemDelete != null
@@ -201,8 +196,6 @@ private constructor(
201196

202197
fun isSessionUpdate(): Boolean = sessionUpdate != null
203198

204-
fun isTranscriptionSessionUpdate(): Boolean = transcriptionSessionUpdate != null
205-
206199
/**
207200
* Add a new Item to the Conversation's context, including messages, function calls, and
208201
* function call responses. This event can be used both to populate a "history" of the
@@ -340,10 +333,6 @@ private constructor(
340333
*/
341334
fun asSessionUpdate(): SessionUpdateEvent = sessionUpdate.getOrThrow("sessionUpdate")
342335

343-
/** Send this event to update a transcription session. */
344-
fun asTranscriptionSessionUpdate(): TranscriptionSessionUpdate =
345-
transcriptionSessionUpdate.getOrThrow("transcriptionSessionUpdate")
346-
347336
fun _json(): Optional<JsonValue> = Optional.ofNullable(_json)
348337

349338
fun <T> accept(visitor: Visitor<T>): T =
@@ -367,8 +356,6 @@ private constructor(
367356
responseCancel != null -> visitor.visitResponseCancel(responseCancel)
368357
responseCreate != null -> visitor.visitResponseCreate(responseCreate)
369358
sessionUpdate != null -> visitor.visitSessionUpdate(sessionUpdate)
370-
transcriptionSessionUpdate != null ->
371-
visitor.visitTranscriptionSessionUpdate(transcriptionSessionUpdate)
372359
else -> visitor.unknown(_json)
373360
}
374361

@@ -440,12 +427,6 @@ private constructor(
440427
override fun visitSessionUpdate(sessionUpdate: SessionUpdateEvent) {
441428
sessionUpdate.validate()
442429
}
443-
444-
override fun visitTranscriptionSessionUpdate(
445-
transcriptionSessionUpdate: TranscriptionSessionUpdate
446-
) {
447-
transcriptionSessionUpdate.validate()
448-
}
449430
}
450431
)
451432
validated = true
@@ -509,10 +490,6 @@ private constructor(
509490
override fun visitSessionUpdate(sessionUpdate: SessionUpdateEvent) =
510491
sessionUpdate.validity()
511492

512-
override fun visitTranscriptionSessionUpdate(
513-
transcriptionSessionUpdate: TranscriptionSessionUpdate
514-
) = transcriptionSessionUpdate.validity()
515-
516493
override fun unknown(json: JsonValue?) = 0
517494
}
518495
)
@@ -533,8 +510,7 @@ private constructor(
533510
inputAudioBufferCommit == other.inputAudioBufferCommit &&
534511
responseCancel == other.responseCancel &&
535512
responseCreate == other.responseCreate &&
536-
sessionUpdate == other.sessionUpdate &&
537-
transcriptionSessionUpdate == other.transcriptionSessionUpdate
513+
sessionUpdate == other.sessionUpdate
538514
}
539515

540516
override fun hashCode(): Int =
@@ -550,7 +526,6 @@ private constructor(
550526
responseCancel,
551527
responseCreate,
552528
sessionUpdate,
553-
transcriptionSessionUpdate,
554529
)
555530

556531
override fun toString(): String =
@@ -574,8 +549,6 @@ private constructor(
574549
responseCancel != null -> "RealtimeClientEvent{responseCancel=$responseCancel}"
575550
responseCreate != null -> "RealtimeClientEvent{responseCreate=$responseCreate}"
576551
sessionUpdate != null -> "RealtimeClientEvent{sessionUpdate=$sessionUpdate}"
577-
transcriptionSessionUpdate != null ->
578-
"RealtimeClientEvent{transcriptionSessionUpdate=$transcriptionSessionUpdate}"
579552
_json != null -> "RealtimeClientEvent{_unknown=$_json}"
580553
else -> throw IllegalStateException("Invalid RealtimeClientEvent")
581554
}
@@ -736,11 +709,6 @@ private constructor(
736709
@JvmStatic
737710
fun ofSessionUpdate(sessionUpdate: SessionUpdateEvent) =
738711
RealtimeClientEvent(sessionUpdate = sessionUpdate)
739-
740-
/** Send this event to update a transcription session. */
741-
@JvmStatic
742-
fun ofTranscriptionSessionUpdate(transcriptionSessionUpdate: TranscriptionSessionUpdate) =
743-
RealtimeClientEvent(transcriptionSessionUpdate = transcriptionSessionUpdate)
744712
}
745713

746714
/**
@@ -886,11 +854,6 @@ private constructor(
886854
*/
887855
fun visitSessionUpdate(sessionUpdate: SessionUpdateEvent): T
888856

889-
/** Send this event to update a transcription session. */
890-
fun visitTranscriptionSessionUpdate(
891-
transcriptionSessionUpdate: TranscriptionSessionUpdate
892-
): T
893-
894857
/**
895858
* Maps an unknown variant of [RealtimeClientEvent] to a value of type [T].
896859
*
@@ -969,11 +932,6 @@ private constructor(
969932
RealtimeClientEvent(sessionUpdate = it, _json = json)
970933
} ?: RealtimeClientEvent(_json = json)
971934
}
972-
"transcription_session.update" -> {
973-
return tryDeserialize(node, jacksonTypeRef<TranscriptionSessionUpdate>())?.let {
974-
RealtimeClientEvent(transcriptionSessionUpdate = it, _json = json)
975-
} ?: RealtimeClientEvent(_json = json)
976-
}
977935
}
978936

979937
return RealtimeClientEvent(_json = json)
@@ -1007,8 +965,6 @@ private constructor(
1007965
value.responseCancel != null -> generator.writeObject(value.responseCancel)
1008966
value.responseCreate != null -> generator.writeObject(value.responseCreate)
1009967
value.sessionUpdate != null -> generator.writeObject(value.sessionUpdate)
1010-
value.transcriptionSessionUpdate != null ->
1011-
generator.writeObject(value.transcriptionSessionUpdate)
1012968
value._json != null -> generator.writeObject(value._json)
1013969
else -> throw IllegalStateException("Invalid RealtimeClientEvent")
1014970
}

openai-java-core/src/main/kotlin/com/openai/models/realtime/Models.kt renamed to openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeFunctionTool.kt

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import java.util.Objects
1717
import java.util.Optional
1818
import kotlin.jvm.optionals.getOrNull
1919

20-
class Models
20+
class RealtimeFunctionTool
2121
private constructor(
2222
private val description: JsonField<String>,
2323
private val name: JsonField<String>,
@@ -99,11 +99,11 @@ private constructor(
9999

100100
companion object {
101101

102-
/** Returns a mutable builder for constructing an instance of [Models]. */
102+
/** Returns a mutable builder for constructing an instance of [RealtimeFunctionTool]. */
103103
@JvmStatic fun builder() = Builder()
104104
}
105105

106-
/** A builder for [Models]. */
106+
/** A builder for [RealtimeFunctionTool]. */
107107
class Builder internal constructor() {
108108

109109
private var description: JsonField<String> = JsonMissing.of()
@@ -113,12 +113,12 @@ private constructor(
113113
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
114114

115115
@JvmSynthetic
116-
internal fun from(models: Models) = apply {
117-
description = models.description
118-
name = models.name
119-
parameters = models.parameters
120-
type = models.type
121-
additionalProperties = models.additionalProperties.toMutableMap()
116+
internal fun from(realtimeFunctionTool: RealtimeFunctionTool) = apply {
117+
description = realtimeFunctionTool.description
118+
name = realtimeFunctionTool.name
119+
parameters = realtimeFunctionTool.parameters
120+
type = realtimeFunctionTool.type
121+
additionalProperties = realtimeFunctionTool.additionalProperties.toMutableMap()
122122
}
123123

124124
/**
@@ -181,17 +181,23 @@ private constructor(
181181
}
182182

183183
/**
184-
* Returns an immutable instance of [Models].
184+
* Returns an immutable instance of [RealtimeFunctionTool].
185185
*
186186
* Further updates to this [Builder] will not mutate the returned instance.
187187
*/
188-
fun build(): Models =
189-
Models(description, name, parameters, type, additionalProperties.toMutableMap())
188+
fun build(): RealtimeFunctionTool =
189+
RealtimeFunctionTool(
190+
description,
191+
name,
192+
parameters,
193+
type,
194+
additionalProperties.toMutableMap(),
195+
)
190196
}
191197

192198
private var validated: Boolean = false
193199

194-
fun validate(): Models = apply {
200+
fun validate(): RealtimeFunctionTool = apply {
195201
if (validated) {
196202
return@apply
197203
}
@@ -346,7 +352,7 @@ private constructor(
346352
return true
347353
}
348354

349-
return other is Models &&
355+
return other is RealtimeFunctionTool &&
350356
description == other.description &&
351357
name == other.name &&
352358
parameters == other.parameters &&
@@ -361,5 +367,5 @@ private constructor(
361367
override fun hashCode(): Int = hashCode
362368

363369
override fun toString() =
364-
"Models{description=$description, name=$name, parameters=$parameters, type=$type, additionalProperties=$additionalProperties}"
370+
"RealtimeFunctionTool{description=$description, name=$name, parameters=$parameters, type=$type, additionalProperties=$additionalProperties}"
365371
}

openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseCreateParams.kt

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,9 @@ private constructor(
677677
(tools ?: JsonField.of(mutableListOf())).also { checkKnown("tools", it).add(tool) }
678678
}
679679

680-
/** Alias for calling [addTool] with `Tool.ofModels(models)`. */
681-
fun addTool(models: Models) = addTool(Tool.ofModels(models))
680+
/** Alias for calling [addTool] with `Tool.ofRealtimeFunction(realtimeFunction)`. */
681+
fun addTool(realtimeFunction: RealtimeFunctionTool) =
682+
addTool(Tool.ofRealtimeFunction(realtimeFunction))
682683

683684
/**
684685
* Alias for calling [addTool] with
@@ -1589,12 +1590,13 @@ private constructor(
15891590
@JsonSerialize(using = Tool.Serializer::class)
15901591
class Tool
15911592
private constructor(
1592-
private val models: Models? = null,
1593+
private val realtimeFunction: RealtimeFunctionTool? = null,
15931594
private val realtimeResponseCreateMcp: RealtimeResponseCreateMcpTool? = null,
15941595
private val _json: JsonValue? = null,
15951596
) {
15961597

1597-
fun models(): Optional<Models> = Optional.ofNullable(models)
1598+
fun realtimeFunction(): Optional<RealtimeFunctionTool> =
1599+
Optional.ofNullable(realtimeFunction)
15981600

15991601
/**
16001602
* Give the model access to additional tools via remote Model Context Protocol (MCP)
@@ -1604,11 +1606,12 @@ private constructor(
16041606
fun realtimeResponseCreateMcp(): Optional<RealtimeResponseCreateMcpTool> =
16051607
Optional.ofNullable(realtimeResponseCreateMcp)
16061608

1607-
fun isModels(): Boolean = models != null
1609+
fun isRealtimeFunction(): Boolean = realtimeFunction != null
16081610

16091611
fun isRealtimeResponseCreateMcp(): Boolean = realtimeResponseCreateMcp != null
16101612

1611-
fun asModels(): Models = models.getOrThrow("models")
1613+
fun asRealtimeFunction(): RealtimeFunctionTool =
1614+
realtimeFunction.getOrThrow("realtimeFunction")
16121615

16131616
/**
16141617
* Give the model access to additional tools via remote Model Context Protocol (MCP)
@@ -1622,7 +1625,7 @@ private constructor(
16221625

16231626
fun <T> accept(visitor: Visitor<T>): T =
16241627
when {
1625-
models != null -> visitor.visitModels(models)
1628+
realtimeFunction != null -> visitor.visitRealtimeFunction(realtimeFunction)
16261629
realtimeResponseCreateMcp != null ->
16271630
visitor.visitRealtimeResponseCreateMcp(realtimeResponseCreateMcp)
16281631
else -> visitor.unknown(_json)
@@ -1637,8 +1640,8 @@ private constructor(
16371640

16381641
accept(
16391642
object : Visitor<Unit> {
1640-
override fun visitModels(models: Models) {
1641-
models.validate()
1643+
override fun visitRealtimeFunction(realtimeFunction: RealtimeFunctionTool) {
1644+
realtimeFunction.validate()
16421645
}
16431646

16441647
override fun visitRealtimeResponseCreateMcp(
@@ -1669,7 +1672,8 @@ private constructor(
16691672
internal fun validity(): Int =
16701673
accept(
16711674
object : Visitor<Int> {
1672-
override fun visitModels(models: Models) = models.validity()
1675+
override fun visitRealtimeFunction(realtimeFunction: RealtimeFunctionTool) =
1676+
realtimeFunction.validity()
16731677

16741678
override fun visitRealtimeResponseCreateMcp(
16751679
realtimeResponseCreateMcp: RealtimeResponseCreateMcpTool
@@ -1685,15 +1689,15 @@ private constructor(
16851689
}
16861690

16871691
return other is Tool &&
1688-
models == other.models &&
1692+
realtimeFunction == other.realtimeFunction &&
16891693
realtimeResponseCreateMcp == other.realtimeResponseCreateMcp
16901694
}
16911695

1692-
override fun hashCode(): Int = Objects.hash(models, realtimeResponseCreateMcp)
1696+
override fun hashCode(): Int = Objects.hash(realtimeFunction, realtimeResponseCreateMcp)
16931697

16941698
override fun toString(): String =
16951699
when {
1696-
models != null -> "Tool{models=$models}"
1700+
realtimeFunction != null -> "Tool{realtimeFunction=$realtimeFunction}"
16971701
realtimeResponseCreateMcp != null ->
16981702
"Tool{realtimeResponseCreateMcp=$realtimeResponseCreateMcp}"
16991703
_json != null -> "Tool{_unknown=$_json}"
@@ -1702,7 +1706,9 @@ private constructor(
17021706

17031707
companion object {
17041708

1705-
@JvmStatic fun ofModels(models: Models) = Tool(models = models)
1709+
@JvmStatic
1710+
fun ofRealtimeFunction(realtimeFunction: RealtimeFunctionTool) =
1711+
Tool(realtimeFunction = realtimeFunction)
17061712

17071713
/**
17081714
* Give the model access to additional tools via remote Model Context Protocol (MCP)
@@ -1718,7 +1724,7 @@ private constructor(
17181724
/** An interface that defines how to map each variant of [Tool] to a value of type [T]. */
17191725
interface Visitor<out T> {
17201726

1721-
fun visitModels(models: Models): T
1727+
fun visitRealtimeFunction(realtimeFunction: RealtimeFunctionTool): T
17221728

17231729
/**
17241730
* Give the model access to additional tools via remote Model Context Protocol (MCP)
@@ -1750,8 +1756,8 @@ private constructor(
17501756

17511757
val bestMatches =
17521758
sequenceOf(
1753-
tryDeserialize(node, jacksonTypeRef<Models>())?.let {
1754-
Tool(models = it, _json = json)
1759+
tryDeserialize(node, jacksonTypeRef<RealtimeFunctionTool>())?.let {
1760+
Tool(realtimeFunction = it, _json = json)
17551761
},
17561762
tryDeserialize(node, jacksonTypeRef<RealtimeResponseCreateMcpTool>())
17571763
?.let { Tool(realtimeResponseCreateMcp = it, _json = json) },
@@ -1780,7 +1786,7 @@ private constructor(
17801786
provider: SerializerProvider,
17811787
) {
17821788
when {
1783-
value.models != null -> generator.writeObject(value.models)
1789+
value.realtimeFunction != null -> generator.writeObject(value.realtimeFunction)
17841790
value.realtimeResponseCreateMcp != null ->
17851791
generator.writeObject(value.realtimeResponseCreateMcp)
17861792
value._json != null -> generator.writeObject(value._json)

0 commit comments

Comments
 (0)