From 9202c695d939def7c9598e9ee75999b8ebd87e32 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Nov 2025 21:19:45 +0000 Subject: [PATCH 1/6] fix(api): align types of input items / output items for typescript --- .stats.yml | 4 +- .../responses/ResponseApplyPatchToolCall.kt | 386 +++++++++--------- .../ResponseApplyPatchToolCallOutput.kt | 84 ++-- .../models/responses/ResponseInputItem.kt | 5 +- .../items/ConversationItemTest.kt | 12 +- .../ResponseApplyPatchToolCallOutputTest.kt | 6 +- .../ResponseApplyPatchToolCallTest.kt | 16 +- .../models/responses/ResponseItemTest.kt | 12 +- .../responses/ResponseOutputItemTest.kt | 12 +- 9 files changed, 270 insertions(+), 267 deletions(-) diff --git a/.stats.yml b/.stats.yml index 38f260dd..d15659c7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 135 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-ca24bc4d8125b5153514ce643c4e3220f25971b7d67ca384d56d493c72c0d977.yml -openapi_spec_hash: c6f048c7b3d29f4de48fde0e845ba33f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-a7e92d12ebe89ca019a7ac5b29759064eefa2c38fe08d03516f2620e66abb32b.yml +openapi_spec_hash: acbc703b2739447abc6312b2d753631c config_hash: b876221dfb213df9f0a999e75d38a65e diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseApplyPatchToolCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseApplyPatchToolCall.kt index bf3e8167..b406fb42 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseApplyPatchToolCall.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseApplyPatchToolCall.kt @@ -34,10 +34,10 @@ class ResponseApplyPatchToolCall private constructor( private val id: JsonField, private val callId: JsonField, + private val operation: JsonField, private val status: JsonField, private val type: JsonValue, private val createdBy: JsonField, - private val operation: JsonField, private val additionalProperties: MutableMap, ) { @@ -45,13 +45,13 @@ private constructor( private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("call_id") @ExcludeMissing callId: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - @JsonProperty("created_by") @ExcludeMissing createdBy: JsonField = JsonMissing.of(), @JsonProperty("operation") @ExcludeMissing operation: JsonField = JsonMissing.of(), - ) : this(id, callId, status, type, createdBy, operation, mutableMapOf()) + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("created_by") @ExcludeMissing createdBy: JsonField = JsonMissing.of(), + ) : this(id, callId, operation, status, type, createdBy, mutableMapOf()) /** * The unique ID of the apply patch tool call. Populated when this item is returned via API. @@ -69,6 +69,14 @@ private constructor( */ fun callId(): String = callId.getRequired("call_id") + /** + * One of the create_file, delete_file, or update_file operations applied via apply_patch. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operation(): Operation = operation.getRequired("operation") + /** * The status of the apply patch tool call. One of `in_progress` or `completed`. * @@ -98,14 +106,6 @@ private constructor( */ fun createdBy(): Optional = createdBy.getOptional("created_by") - /** - * One of the create_file, delete_file, or update_file operations applied via apply_patch. - * - * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun operation(): Optional = operation.getOptional("operation") - /** * Returns the raw JSON value of [id]. * @@ -120,6 +120,13 @@ private constructor( */ @JsonProperty("call_id") @ExcludeMissing fun _callId(): JsonField = callId + /** + * Returns the raw JSON value of [operation]. + * + * Unlike [operation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operation") @ExcludeMissing fun _operation(): JsonField = operation + /** * Returns the raw JSON value of [status]. * @@ -134,13 +141,6 @@ private constructor( */ @JsonProperty("created_by") @ExcludeMissing fun _createdBy(): JsonField = createdBy - /** - * Returns the raw JSON value of [operation]. - * - * Unlike [operation], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("operation") @ExcludeMissing fun _operation(): JsonField = operation - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -162,6 +162,7 @@ private constructor( * ```java * .id() * .callId() + * .operation() * .status() * ``` */ @@ -173,20 +174,20 @@ private constructor( private var id: JsonField? = null private var callId: JsonField? = null + private var operation: JsonField? = null private var status: JsonField? = null private var type: JsonValue = JsonValue.from("apply_patch_call") private var createdBy: JsonField = JsonMissing.of() - private var operation: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(responseApplyPatchToolCall: ResponseApplyPatchToolCall) = apply { id = responseApplyPatchToolCall.id callId = responseApplyPatchToolCall.callId + operation = responseApplyPatchToolCall.operation status = responseApplyPatchToolCall.status type = responseApplyPatchToolCall.type createdBy = responseApplyPatchToolCall.createdBy - operation = responseApplyPatchToolCall.operation additionalProperties = responseApplyPatchToolCall.additionalProperties.toMutableMap() } @@ -214,43 +215,6 @@ private constructor( */ fun callId(callId: JsonField) = apply { this.callId = callId } - /** The status of the apply patch tool call. One of `in_progress` or `completed`. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("apply_patch_call") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** The ID of the entity that created this tool call. */ - fun createdBy(createdBy: String) = createdBy(JsonField.of(createdBy)) - - /** - * Sets [Builder.createdBy] to an arbitrary JSON value. - * - * You should usually call [Builder.createdBy] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun createdBy(createdBy: JsonField) = apply { this.createdBy = createdBy } - /** * One of the create_file, delete_file, or update_file operations applied via apply_patch. */ @@ -288,6 +252,43 @@ private constructor( fun operation(updateFile: Operation.UpdateFile) = operation(Operation.ofUpdateFile(updateFile)) + /** The status of the apply patch tool call. One of `in_progress` or `completed`. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("apply_patch_call") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** The ID of the entity that created this tool call. */ + fun createdBy(createdBy: String) = createdBy(JsonField.of(createdBy)) + + /** + * Sets [Builder.createdBy] to an arbitrary JSON value. + * + * You should usually call [Builder.createdBy] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun createdBy(createdBy: JsonField) = apply { this.createdBy = createdBy } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -316,6 +317,7 @@ private constructor( * ```java * .id() * .callId() + * .operation() * .status() * ``` * @@ -325,10 +327,10 @@ private constructor( ResponseApplyPatchToolCall( checkRequired("id", id), checkRequired("callId", callId), + checkRequired("operation", operation), checkRequired("status", status), type, createdBy, - operation, additionalProperties.toMutableMap(), ) } @@ -342,6 +344,7 @@ private constructor( id() callId() + operation().validate() status().validate() _type().let { if (it != JsonValue.from("apply_patch_call")) { @@ -349,7 +352,6 @@ private constructor( } } createdBy() - operation().ifPresent { it.validate() } validated = true } @@ -370,136 +372,10 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (callId.asKnown().isPresent) 1 else 0) + + (operation.asKnown().getOrNull()?.validity() ?: 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + type.let { if (it == JsonValue.from("apply_patch_call")) 1 else 0 } + - (if (createdBy.asKnown().isPresent) 1 else 0) + - (operation.asKnown().getOrNull()?.validity() ?: 0) - - /** The status of the apply patch tool call. One of `in_progress` or `completed`. */ - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val IN_PROGRESS = of("in_progress") - - @JvmField val COMPLETED = of("completed") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - IN_PROGRESS, - COMPLETED, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - IN_PROGRESS, - COMPLETED, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - IN_PROGRESS -> Value.IN_PROGRESS - COMPLETED -> Value.COMPLETED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OpenAIInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - IN_PROGRESS -> Known.IN_PROGRESS - COMPLETED -> Known.COMPLETED - else -> throw OpenAIInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OpenAIInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OpenAIInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + (if (createdBy.asKnown().isPresent) 1 else 0) /** One of the create_file, delete_file, or update_file operations applied via apply_patch. */ @JsonDeserialize(using = Operation.Deserializer::class) @@ -1403,6 +1279,132 @@ private constructor( } } + /** The status of the apply patch tool call. One of `in_progress` or `completed`. */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val IN_PROGRESS = of("in_progress") + + @JvmField val COMPLETED = of("completed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + IN_PROGRESS, + COMPLETED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_PROGRESS, + COMPLETED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_PROGRESS -> Value.IN_PROGRESS + COMPLETED -> Value.COMPLETED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OpenAIInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_PROGRESS -> Known.IN_PROGRESS + COMPLETED -> Known.COMPLETED + else -> throw OpenAIInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OpenAIInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OpenAIInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1411,19 +1413,19 @@ private constructor( return other is ResponseApplyPatchToolCall && id == other.id && callId == other.callId && + operation == other.operation && status == other.status && type == other.type && createdBy == other.createdBy && - operation == other.operation && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, callId, status, type, createdBy, operation, additionalProperties) + Objects.hash(id, callId, operation, status, type, createdBy, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ResponseApplyPatchToolCall{id=$id, callId=$callId, status=$status, type=$type, createdBy=$createdBy, operation=$operation, additionalProperties=$additionalProperties}" + "ResponseApplyPatchToolCall{id=$id, callId=$callId, operation=$operation, status=$status, type=$type, createdBy=$createdBy, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseApplyPatchToolCallOutput.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseApplyPatchToolCallOutput.kt index 0956f691..86d82ee4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseApplyPatchToolCallOutput.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseApplyPatchToolCallOutput.kt @@ -24,10 +24,10 @@ class ResponseApplyPatchToolCallOutput private constructor( private val id: JsonField, private val callId: JsonField, - private val output: JsonField, private val status: JsonField, private val type: JsonValue, private val createdBy: JsonField, + private val output: JsonField, private val additionalProperties: MutableMap, ) { @@ -35,11 +35,11 @@ private constructor( private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("call_id") @ExcludeMissing callId: JsonField = JsonMissing.of(), - @JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("created_by") @ExcludeMissing createdBy: JsonField = JsonMissing.of(), - ) : this(id, callId, output, status, type, createdBy, mutableMapOf()) + @JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(), + ) : this(id, callId, status, type, createdBy, output, mutableMapOf()) /** * The unique ID of the apply patch tool call output. Populated when this item is returned via @@ -58,14 +58,6 @@ private constructor( */ fun callId(): String = callId.getRequired("call_id") - /** - * Optional textual output returned by the apply patch tool. - * - * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun output(): Optional = output.getOptional("output") - /** * The status of the apply patch tool call output. One of `completed` or `failed`. * @@ -95,6 +87,14 @@ private constructor( */ fun createdBy(): Optional = createdBy.getOptional("created_by") + /** + * Optional textual output returned by the apply patch tool. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun output(): Optional = output.getOptional("output") + /** * Returns the raw JSON value of [id]. * @@ -109,13 +109,6 @@ private constructor( */ @JsonProperty("call_id") @ExcludeMissing fun _callId(): JsonField = callId - /** - * Returns the raw JSON value of [output]. - * - * Unlike [output], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("output") @ExcludeMissing fun _output(): JsonField = output - /** * Returns the raw JSON value of [status]. * @@ -130,6 +123,13 @@ private constructor( */ @JsonProperty("created_by") @ExcludeMissing fun _createdBy(): JsonField = createdBy + /** + * Returns the raw JSON value of [output]. + * + * Unlike [output], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("output") @ExcludeMissing fun _output(): JsonField = output + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -152,7 +152,6 @@ private constructor( * ```java * .id() * .callId() - * .output() * .status() * ``` */ @@ -164,10 +163,10 @@ private constructor( private var id: JsonField? = null private var callId: JsonField? = null - private var output: JsonField? = null private var status: JsonField? = null private var type: JsonValue = JsonValue.from("apply_patch_call_output") private var createdBy: JsonField = JsonMissing.of() + private var output: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -175,10 +174,10 @@ private constructor( apply { id = responseApplyPatchToolCallOutput.id callId = responseApplyPatchToolCallOutput.callId - output = responseApplyPatchToolCallOutput.output status = responseApplyPatchToolCallOutput.status type = responseApplyPatchToolCallOutput.type createdBy = responseApplyPatchToolCallOutput.createdBy + output = responseApplyPatchToolCallOutput.output additionalProperties = responseApplyPatchToolCallOutput.additionalProperties.toMutableMap() } @@ -208,20 +207,6 @@ private constructor( */ fun callId(callId: JsonField) = apply { this.callId = callId } - /** Optional textual output returned by the apply patch tool. */ - fun output(output: String?) = output(JsonField.ofNullable(output)) - - /** Alias for calling [Builder.output] with `output.orElse(null)`. */ - fun output(output: Optional) = output(output.getOrNull()) - - /** - * Sets [Builder.output] to an arbitrary JSON value. - * - * You should usually call [Builder.output] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun output(output: JsonField) = apply { this.output = output } - /** The status of the apply patch tool call output. One of `completed` or `failed`. */ fun status(status: Status) = status(JsonField.of(status)) @@ -259,6 +244,20 @@ private constructor( */ fun createdBy(createdBy: JsonField) = apply { this.createdBy = createdBy } + /** Optional textual output returned by the apply patch tool. */ + fun output(output: String?) = output(JsonField.ofNullable(output)) + + /** Alias for calling [Builder.output] with `output.orElse(null)`. */ + fun output(output: Optional) = output(output.getOrNull()) + + /** + * Sets [Builder.output] to an arbitrary JSON value. + * + * You should usually call [Builder.output] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun output(output: JsonField) = apply { this.output = output } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -287,7 +286,6 @@ private constructor( * ```java * .id() * .callId() - * .output() * .status() * ``` * @@ -297,10 +295,10 @@ private constructor( ResponseApplyPatchToolCallOutput( checkRequired("id", id), checkRequired("callId", callId), - checkRequired("output", output), checkRequired("status", status), type, createdBy, + output, additionalProperties.toMutableMap(), ) } @@ -314,7 +312,6 @@ private constructor( id() callId() - output() status().validate() _type().let { if (it != JsonValue.from("apply_patch_call_output")) { @@ -322,6 +319,7 @@ private constructor( } } createdBy() + output() validated = true } @@ -342,10 +340,10 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (callId.asKnown().isPresent) 1 else 0) + - (if (output.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + type.let { if (it == JsonValue.from("apply_patch_call_output")) 1 else 0 } + - (if (createdBy.asKnown().isPresent) 1 else 0) + (if (createdBy.asKnown().isPresent) 1 else 0) + + (if (output.asKnown().isPresent) 1 else 0) /** The status of the apply patch tool call output. One of `completed` or `failed`. */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -481,19 +479,19 @@ private constructor( return other is ResponseApplyPatchToolCallOutput && id == other.id && callId == other.callId && - output == other.output && status == other.status && type == other.type && createdBy == other.createdBy && + output == other.output && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, callId, output, status, type, createdBy, additionalProperties) + Objects.hash(id, callId, status, type, createdBy, output, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ResponseApplyPatchToolCallOutput{id=$id, callId=$callId, output=$output, status=$status, type=$type, createdBy=$createdBy, additionalProperties=$additionalProperties}" + "ResponseApplyPatchToolCallOutput{id=$id, callId=$callId, status=$status, type=$type, createdBy=$createdBy, output=$output, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt index aed22f62..f389252a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt @@ -7908,7 +7908,10 @@ private constructor( * Optional human-readable log text from the apply patch tool (e.g., patch results or * errors). */ - fun output(output: String) = output(JsonField.of(output)) + fun output(output: String?) = output(JsonField.ofNullable(output)) + + /** Alias for calling [Builder.output] with `output.orElse(null)`. */ + fun output(output: Optional) = output(output.getOrNull()) /** * Sets [Builder.output] to an arbitrary JSON value. diff --git a/openai-java-core/src/test/kotlin/com/openai/models/conversations/items/ConversationItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/conversations/items/ConversationItemTest.kt index eb907c49..8e4bc785 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/conversations/items/ConversationItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/conversations/items/ConversationItemTest.kt @@ -997,14 +997,14 @@ internal class ConversationItemTest { ResponseApplyPatchToolCall.builder() .id("id") .callId("call_id") - .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) - .createdBy("created_by") .operation( ResponseApplyPatchToolCall.Operation.CreateFile.builder() .diff("diff") .path("path") .build() ) + .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) + .createdBy("created_by") .build() val conversationItem = ConversationItem.ofApplyPatchCall(applyPatchCall) @@ -1041,14 +1041,14 @@ internal class ConversationItemTest { ResponseApplyPatchToolCall.builder() .id("id") .callId("call_id") - .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) - .createdBy("created_by") .operation( ResponseApplyPatchToolCall.Operation.CreateFile.builder() .diff("diff") .path("path") .build() ) + .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) + .createdBy("created_by") .build() ) @@ -1067,9 +1067,9 @@ internal class ConversationItemTest { ResponseApplyPatchToolCallOutput.builder() .id("id") .callId("call_id") - .output("output") .status(ResponseApplyPatchToolCallOutput.Status.COMPLETED) .createdBy("created_by") + .output("output") .build() val conversationItem = ConversationItem.ofApplyPatchCallOutput(applyPatchCallOutput) @@ -1106,9 +1106,9 @@ internal class ConversationItemTest { ResponseApplyPatchToolCallOutput.builder() .id("id") .callId("call_id") - .output("output") .status(ResponseApplyPatchToolCallOutput.Status.COMPLETED) .createdBy("created_by") + .output("output") .build() ) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseApplyPatchToolCallOutputTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseApplyPatchToolCallOutputTest.kt index 55e4a9f6..069e965f 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseApplyPatchToolCallOutputTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseApplyPatchToolCallOutputTest.kt @@ -15,17 +15,17 @@ internal class ResponseApplyPatchToolCallOutputTest { ResponseApplyPatchToolCallOutput.builder() .id("id") .callId("call_id") - .output("output") .status(ResponseApplyPatchToolCallOutput.Status.COMPLETED) .createdBy("created_by") + .output("output") .build() assertThat(responseApplyPatchToolCallOutput.id()).isEqualTo("id") assertThat(responseApplyPatchToolCallOutput.callId()).isEqualTo("call_id") - assertThat(responseApplyPatchToolCallOutput.output()).contains("output") assertThat(responseApplyPatchToolCallOutput.status()) .isEqualTo(ResponseApplyPatchToolCallOutput.Status.COMPLETED) assertThat(responseApplyPatchToolCallOutput.createdBy()).contains("created_by") + assertThat(responseApplyPatchToolCallOutput.output()).contains("output") } @Test @@ -35,9 +35,9 @@ internal class ResponseApplyPatchToolCallOutputTest { ResponseApplyPatchToolCallOutput.builder() .id("id") .callId("call_id") - .output("output") .status(ResponseApplyPatchToolCallOutput.Status.COMPLETED) .createdBy("created_by") + .output("output") .build() val roundtrippedResponseApplyPatchToolCallOutput = diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseApplyPatchToolCallTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseApplyPatchToolCallTest.kt index c75d3504..22de5069 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseApplyPatchToolCallTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseApplyPatchToolCallTest.kt @@ -15,23 +15,20 @@ internal class ResponseApplyPatchToolCallTest { ResponseApplyPatchToolCall.builder() .id("id") .callId("call_id") - .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) - .createdBy("created_by") .operation( ResponseApplyPatchToolCall.Operation.CreateFile.builder() .diff("diff") .path("path") .build() ) + .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) + .createdBy("created_by") .build() assertThat(responseApplyPatchToolCall.id()).isEqualTo("id") assertThat(responseApplyPatchToolCall.callId()).isEqualTo("call_id") - assertThat(responseApplyPatchToolCall.status()) - .isEqualTo(ResponseApplyPatchToolCall.Status.IN_PROGRESS) - assertThat(responseApplyPatchToolCall.createdBy()).contains("created_by") assertThat(responseApplyPatchToolCall.operation()) - .contains( + .isEqualTo( ResponseApplyPatchToolCall.Operation.ofCreateFile( ResponseApplyPatchToolCall.Operation.CreateFile.builder() .diff("diff") @@ -39,6 +36,9 @@ internal class ResponseApplyPatchToolCallTest { .build() ) ) + assertThat(responseApplyPatchToolCall.status()) + .isEqualTo(ResponseApplyPatchToolCall.Status.IN_PROGRESS) + assertThat(responseApplyPatchToolCall.createdBy()).contains("created_by") } @Test @@ -48,14 +48,14 @@ internal class ResponseApplyPatchToolCallTest { ResponseApplyPatchToolCall.builder() .id("id") .callId("call_id") - .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) - .createdBy("created_by") .operation( ResponseApplyPatchToolCall.Operation.CreateFile.builder() .diff("diff") .path("path") .build() ) + .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) + .createdBy("created_by") .build() val roundtrippedResponseApplyPatchToolCall = diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseItemTest.kt index 552a8d0e..71a984b9 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseItemTest.kt @@ -1000,14 +1000,14 @@ internal class ResponseItemTest { ResponseApplyPatchToolCall.builder() .id("id") .callId("call_id") - .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) - .createdBy("created_by") .operation( ResponseApplyPatchToolCall.Operation.CreateFile.builder() .diff("diff") .path("path") .build() ) + .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) + .createdBy("created_by") .build() val responseItem = ResponseItem.ofApplyPatchCall(applyPatchCall) @@ -1042,14 +1042,14 @@ internal class ResponseItemTest { ResponseApplyPatchToolCall.builder() .id("id") .callId("call_id") - .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) - .createdBy("created_by") .operation( ResponseApplyPatchToolCall.Operation.CreateFile.builder() .diff("diff") .path("path") .build() ) + .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) + .createdBy("created_by") .build() ) @@ -1068,9 +1068,9 @@ internal class ResponseItemTest { ResponseApplyPatchToolCallOutput.builder() .id("id") .callId("call_id") - .output("output") .status(ResponseApplyPatchToolCallOutput.Status.COMPLETED) .createdBy("created_by") + .output("output") .build() val responseItem = ResponseItem.ofApplyPatchCallOutput(applyPatchCallOutput) @@ -1105,9 +1105,9 @@ internal class ResponseItemTest { ResponseApplyPatchToolCallOutput.builder() .id("id") .callId("call_id") - .output("output") .status(ResponseApplyPatchToolCallOutput.Status.COMPLETED) .createdBy("created_by") + .output("output") .build() ) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt index 275bf369..2348ad9f 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt @@ -777,14 +777,14 @@ internal class ResponseOutputItemTest { ResponseApplyPatchToolCall.builder() .id("id") .callId("call_id") - .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) - .createdBy("created_by") .operation( ResponseApplyPatchToolCall.Operation.CreateFile.builder() .diff("diff") .path("path") .build() ) + .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) + .createdBy("created_by") .build() val responseOutputItem = ResponseOutputItem.ofApplyPatchCall(applyPatchCall) @@ -816,14 +816,14 @@ internal class ResponseOutputItemTest { ResponseApplyPatchToolCall.builder() .id("id") .callId("call_id") - .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) - .createdBy("created_by") .operation( ResponseApplyPatchToolCall.Operation.CreateFile.builder() .diff("diff") .path("path") .build() ) + .status(ResponseApplyPatchToolCall.Status.IN_PROGRESS) + .createdBy("created_by") .build() ) @@ -842,9 +842,9 @@ internal class ResponseOutputItemTest { ResponseApplyPatchToolCallOutput.builder() .id("id") .callId("call_id") - .output("output") .status(ResponseApplyPatchToolCallOutput.Status.COMPLETED) .createdBy("created_by") + .output("output") .build() val responseOutputItem = ResponseOutputItem.ofApplyPatchCallOutput(applyPatchCallOutput) @@ -876,9 +876,9 @@ internal class ResponseOutputItemTest { ResponseApplyPatchToolCallOutput.builder() .id("id") .callId("call_id") - .output("output") .status(ResponseApplyPatchToolCallOutput.Status.COMPLETED) .createdBy("created_by") + .output("output") .build() ) From b6ae6984f637437864bd2410acee0418bfb58736 Mon Sep 17 00:00:00 2001 From: Alex Chang Date: Mon, 17 Nov 2025 17:48:15 -0500 Subject: [PATCH 2/6] fix tests --- .../models/responses/StructuredResponseOutputItemTest.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseOutputItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseOutputItemTest.kt index 66826bd1..809dc306 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseOutputItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseOutputItemTest.kt @@ -119,6 +119,12 @@ internal class StructuredResponseOutputItemTest { ResponseApplyPatchToolCall.builder() .id(STRING) .callId(STRING) + .operation( + ResponseApplyPatchToolCall.Operation.CreateFile.builder() + .diff(STRING) + .path(STRING) + .build() + ) .status(ResponseApplyPatchToolCall.Status.COMPLETED) .build() private val APPLY_PATCH_TOOL_CALL_OUTPUT = From c665e21c83123931baed5b21b9bbaa96a4d77495 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 26 Nov 2025 19:59:42 +0000 Subject: [PATCH 3/6] fix(client): cancel okhttp call when future cancelled --- openai-java-client-okhttp/build.gradle.kts | 1 + .../com/openai/client/okhttp/OkHttpClient.kt | 34 ++++++++------ .../openai/client/okhttp/OkHttpClientTest.kt | 44 +++++++++++++++++++ 3 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 openai-java-client-okhttp/src/test/kotlin/com/openai/client/okhttp/OkHttpClientTest.kt diff --git a/openai-java-client-okhttp/build.gradle.kts b/openai-java-client-okhttp/build.gradle.kts index 4f14e269..272eaba2 100644 --- a/openai-java-client-okhttp/build.gradle.kts +++ b/openai-java-client-okhttp/build.gradle.kts @@ -11,4 +11,5 @@ dependencies { testImplementation(kotlin("test")) testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") } diff --git a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt index d99c47cb..f036cbd2 100644 --- a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt +++ b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt @@ -13,6 +13,7 @@ import java.io.IOException import java.io.InputStream import java.net.Proxy import java.time.Duration +import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory @@ -29,8 +30,8 @@ import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink -class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : - HttpClient { +class OkHttpClient +private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { val call = newCall(request, requestOptions) @@ -50,20 +51,25 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC ): CompletableFuture { val future = CompletableFuture() - request.body?.run { future.whenComplete { _, _ -> close() } } - - newCall(request, requestOptions) - .enqueue( - object : Callback { - override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) - } + val call = newCall(request, requestOptions) + call.enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } - override fun onFailure(call: Call, e: IOException) { - future.completeExceptionally(OpenAIIoException("Request failed", e)) - } + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(OpenAIIoException("Request failed", e)) } - ) + } + ) + + future.whenComplete { _, e -> + if (e is CancellationException) { + call.cancel() + } + request.body?.close() + } return future } diff --git a/openai-java-client-okhttp/src/test/kotlin/com/openai/client/okhttp/OkHttpClientTest.kt b/openai-java-client-okhttp/src/test/kotlin/com/openai/client/okhttp/OkHttpClientTest.kt new file mode 100644 index 00000000..b202c83c --- /dev/null +++ b/openai-java-client-okhttp/src/test/kotlin/com/openai/client/okhttp/OkHttpClientTest.kt @@ -0,0 +1,44 @@ +package com.openai.client.okhttp + +import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.openai.core.http.HttpMethod +import com.openai.core.http.HttpRequest +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class OkHttpClientTest { + + private lateinit var baseUrl: String + private lateinit var httpClient: OkHttpClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + baseUrl = wmRuntimeInfo.httpBaseUrl + httpClient = OkHttpClient.builder().build() + } + + @Test + fun executeAsync_whenFutureCancelled_cancelsUnderlyingCall() { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + val responseFuture = + httpClient.executeAsync( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build() + ) + val call = httpClient.okHttpClient.dispatcher.runningCalls().single() + + responseFuture.cancel(false) + + // Should have cancelled the underlying call + assertThat(call.isCanceled()).isTrue() + } +} From 66f7a4b3d2b88fc3e80c1552d0a0df86cd45c1ff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Dec 2025 08:47:38 +0000 Subject: [PATCH 4/6] docs: remove `$` for better copy-pasteabality --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e8a28b7d..a9285832 100644 --- a/README.md +++ b/README.md @@ -1310,13 +1310,13 @@ The SDK uses the standard [OkHttp logging interceptor](https://github.com/square Enable logging by setting the `OPENAI_LOG` environment variable to `info`: ```sh -$ export OPENAI_LOG=info +export OPENAI_LOG=info ``` Or to `debug` for more verbose logging: ```sh -$ export OPENAI_LOG=debug +export OPENAI_LOG=debug ``` ## ProGuard and R8 From 651c44f570ba07784d715a382d94b255fd3afa60 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Dec 2025 17:50:56 +0000 Subject: [PATCH 5/6] feat(api): gpt-5.1-codex-max and responses/compact --- .stats.yml | 8 +- gradle.properties | 3 + .../kotlin/com/openai/models/AllModels.kt | 6 + .../kotlin/com/openai/models/Reasoning.kt | 11 +- .../com/openai/models/ReasoningEffort.kt | 11 +- .../com/openai/models/ResponsesModel.kt | 6 + .../beta/assistants/AssistantCreateParams.kt | 24 +- .../beta/assistants/AssistantUpdateParams.kt | 24 +- .../beta/threads/runs/RunCreateParams.kt | 24 +- .../completions/ChatCompletionCreateParams.kt | 24 +- .../containers/ContainerCreateParams.kt | 220 ++- .../containers/ContainerCreateResponse.kt | 249 ++- .../containers/ContainerListResponse.kt | 249 ++- .../containers/ContainerRetrieveResponse.kt | 249 ++- .../conversations/ConversationCreateParams.kt | 33 + .../conversations/items/ItemCreateParams.kt | 33 + .../CreateEvalCompletionsRunDataSource.kt | 13 +- .../models/evals/runs/RunCancelResponse.kt | 26 +- .../models/evals/runs/RunCreateParams.kt | 26 +- .../models/evals/runs/RunCreateResponse.kt | 26 +- .../models/evals/runs/RunListResponse.kt | 26 +- .../models/evals/runs/RunRetrieveResponse.kt | 26 +- .../graders/gradermodels/ScoreModelGrader.kt | 13 +- .../InputAudioBufferDtmfEventReceivedEvent.kt | 263 +++ .../realtime/OutputAudioBufferClearEvent.kt | 6 +- .../RealtimeAudioInputTurnDetection.kt | 33 +- .../models/realtime/RealtimeClientEvent.kt | 24 +- .../models/realtime/RealtimeServerEvent.kt | 157 +- .../openai/models/realtime/RealtimeSession.kt | 31 +- .../realtime/RealtimeSessionCreateRequest.kt | 37 +- ...scriptionSessionAudioInputTurnDetection.kt | 33 +- .../models/realtime/RealtimeTruncation.kt | 14 +- .../RealtimeSessionCreateResponse.kt | 71 +- .../models/responses/CompactedResponse.kt | 450 +++++ .../com/openai/models/responses/Response.kt | 12 +- .../models/responses/ResponseCompactParams.kt | 1526 +++++++++++++++++ .../responses/ResponseCompactionItem.kt | 295 ++++ .../responses/ResponseCompactionItemParam.kt | 265 +++ .../models/responses/ResponseCreateParams.kt | 8 +- .../ResponseFunctionShellCallOutputContent.kt | 24 +- .../ResponseFunctionShellToolCall.kt | 11 +- .../ResponseFunctionShellToolCallOutput.kt | 8 +- .../models/responses/ResponseInputItem.kt | 82 +- .../models/responses/ResponseOutputItem.kt | 46 + .../responses/ResponseOutputItemAddedEvent.kt | 4 + .../responses/ResponseOutputItemDoneEvent.kt | 4 + .../responses/StructuredResponseOutputItem.kt | 17 + .../com/openai/models/responses/Tool.kt | 9 +- .../models/responses/ToolChoiceShell.kt | 2 +- .../inputtokens/InputTokenCountParams.kt | 8 +- .../openai/models/videos/VideoCreateParams.kt | 39 +- .../services/async/ResponseServiceAsync.kt | 45 + .../async/ResponseServiceAsyncImpl.kt | 40 + .../services/blocking/ResponseService.kt | 44 + .../services/blocking/ResponseServiceImpl.kt | 37 + .../containers/ContainerCreateParamsTest.kt | 3 + .../containers/ContainerCreateResponseTest.kt | 7 + .../ContainerListPageResponseTest.kt | 6 + .../containers/ContainerListResponseTest.kt | 7 + .../ContainerRetrieveResponseTest.kt | 7 + ...utAudioBufferDtmfEventReceivedEventTest.kt | 36 + .../realtime/RealtimeServerEventTest.kt | 124 ++ .../models/responses/CompactedResponseTest.kt | 180 ++ .../responses/ResponseCompactParamsTest.kt | 44 + .../ResponseCompactionItemParamTest.kt | 41 + .../responses/ResponseCompactionItemTest.kt | 44 + .../responses/ResponseCompletedEventTest.kt | 6 +- .../responses/ResponseCreateParamsTest.kt | 6 +- .../responses/ResponseCreatedEventTest.kt | 6 +- .../responses/ResponseFailedEventTest.kt | 6 +- .../responses/ResponseInProgressEventTest.kt | 6 +- .../responses/ResponseIncompleteEventTest.kt | 6 +- .../models/responses/ResponseInputItemTest.kt | 83 + .../responses/ResponseOutputItemTest.kt | 69 + .../responses/ResponseQueuedEventTest.kt | 6 +- .../responses/ResponseStreamEventTest.kt | 24 +- .../openai/models/responses/ResponseTest.kt | 6 +- .../StructuredResponseOutputItemTest.kt | 7 + .../async/ContainerServiceAsyncTest.kt | 1 + .../async/ResponseServiceAsyncTest.kt | 28 +- .../services/blocking/ContainerServiceTest.kt | 1 + .../services/blocking/ResponseServiceTest.kt | 27 +- scripts/build | 3 +- scripts/test | 7 +- 84 files changed, 5411 insertions(+), 361 deletions(-) create mode 100644 openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferDtmfEventReceivedEvent.kt create mode 100644 openai-java-core/src/main/kotlin/com/openai/models/responses/CompactedResponse.kt create mode 100644 openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactParams.kt create mode 100644 openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactionItem.kt create mode 100644 openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactionItemParam.kt create mode 100644 openai-java-core/src/test/kotlin/com/openai/models/realtime/InputAudioBufferDtmfEventReceivedEventTest.kt create mode 100644 openai-java-core/src/test/kotlin/com/openai/models/responses/CompactedResponseTest.kt create mode 100644 openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompactParamsTest.kt create mode 100644 openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompactionItemParamTest.kt create mode 100644 openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompactionItemTest.kt diff --git a/.stats.yml b/.stats.yml index d15659c7..b4550c39 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 135 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-a7e92d12ebe89ca019a7ac5b29759064eefa2c38fe08d03516f2620e66abb32b.yml -openapi_spec_hash: acbc703b2739447abc6312b2d753631c -config_hash: b876221dfb213df9f0a999e75d38a65e +configured_endpoints: 136 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-fe8a79e6fd407e6c9afec60971f03076b65f711ccd6ea16457933b0e24fb1f6d.yml +openapi_spec_hash: 38c0a73f4e08843732c5f8002a809104 +config_hash: 2c350086d87a4b4532077363087840e7 diff --git a/gradle.properties b/gradle.properties index 6680f9ce..5d1dabd2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,9 @@ org.gradle.caching=true org.gradle.configuration-cache=true org.gradle.parallel=true org.gradle.daemon=false +kotlin.daemon.enabled=false +kotlin.compiler.execution.strategy=in-process +kotlin.incremental=false # These options improve our compilation and test performance. They are inherited by the Kotlin daemon. org.gradle.jvmargs=\ -Xms2g \ diff --git a/openai-java-core/src/main/kotlin/com/openai/models/AllModels.kt b/openai-java-core/src/main/kotlin/com/openai/models/AllModels.kt index 8862a6c6..891771e2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/AllModels.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/AllModels.kt @@ -258,6 +258,8 @@ private constructor( @JvmField val GPT_5_PRO_2025_10_06 = of("gpt-5-pro-2025-10-06") + @JvmField val GPT_5_1_CODEX_MAX = of("gpt-5.1-codex-max") + @JvmStatic fun of(value: String) = ResponsesOnlyModel(JsonField.of(value)) } @@ -276,6 +278,7 @@ private constructor( GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, + GPT_5_1_CODEX_MAX, } /** @@ -301,6 +304,7 @@ private constructor( GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, + GPT_5_1_CODEX_MAX, /** * An enum member indicating that [ResponsesOnlyModel] was instantiated with an unknown * value. @@ -330,6 +334,7 @@ private constructor( GPT_5_CODEX -> Value.GPT_5_CODEX GPT_5_PRO -> Value.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Value.GPT_5_PRO_2025_10_06 + GPT_5_1_CODEX_MAX -> Value.GPT_5_1_CODEX_MAX else -> Value._UNKNOWN } @@ -357,6 +362,7 @@ private constructor( GPT_5_CODEX -> Known.GPT_5_CODEX GPT_5_PRO -> Known.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Known.GPT_5_PRO_2025_10_06 + GPT_5_1_CODEX_MAX -> Known.GPT_5_1_CODEX_MAX else -> throw OpenAIInvalidDataException("Unknown ResponsesOnlyModel: $value") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/Reasoning.kt b/openai-java-core/src/main/kotlin/com/openai/models/Reasoning.kt index bd2d4558..b102ab22 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/Reasoning.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/Reasoning.kt @@ -45,14 +45,15 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported - * values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning effort can - * result in faster responses and fewer tokens used on reasoning in a response. + * values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing reasoning effort + * can result in faster responses and fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for * all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -144,14 +145,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning - * effort can result in faster responses and fewer tokens used on reasoning in a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing + * reasoning effort can result in faster responses and fewer tokens used on reasoning in a + * response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported * for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun effort(effort: ReasoningEffort?) = effort(JsonField.ofNullable(effort)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ReasoningEffort.kt b/openai-java-core/src/main/kotlin/com/openai/models/ReasoningEffort.kt index 00fce409..5519cce6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ReasoningEffort.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ReasoningEffort.kt @@ -10,13 +10,14 @@ import com.openai.errors.OpenAIInvalidDataException /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported values - * are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning effort can result in - * faster responses and fewer tokens used on reasoning in a response. + * are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing reasoning effort can result + * in faster responses and fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning values * for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for all * reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ class ReasoningEffort @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -42,6 +43,8 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi @JvmField val HIGH = of("high") + @JvmField val XHIGH = of("xhigh") + @JvmStatic fun of(value: String) = ReasoningEffort(JsonField.of(value)) } @@ -52,6 +55,7 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi LOW, MEDIUM, HIGH, + XHIGH, } /** @@ -69,6 +73,7 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi LOW, MEDIUM, HIGH, + XHIGH, /** * An enum member indicating that [ReasoningEffort] was instantiated with an unknown value. */ @@ -89,6 +94,7 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi LOW -> Value.LOW MEDIUM -> Value.MEDIUM HIGH -> Value.HIGH + XHIGH -> Value.XHIGH else -> Value._UNKNOWN } @@ -107,6 +113,7 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi LOW -> Known.LOW MEDIUM -> Known.MEDIUM HIGH -> Known.HIGH + XHIGH -> Known.XHIGH else -> throw OpenAIInvalidDataException("Unknown ReasoningEffort: $value") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ResponsesModel.kt b/openai-java-core/src/main/kotlin/com/openai/models/ResponsesModel.kt index bbf0eee4..e64aa924 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ResponsesModel.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ResponsesModel.kt @@ -257,6 +257,8 @@ private constructor( @JvmField val GPT_5_PRO_2025_10_06 = of("gpt-5-pro-2025-10-06") + @JvmField val GPT_5_1_CODEX_MAX = of("gpt-5.1-codex-max") + @JvmStatic fun of(value: String) = ResponsesOnlyModel(JsonField.of(value)) } @@ -275,6 +277,7 @@ private constructor( GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, + GPT_5_1_CODEX_MAX, } /** @@ -300,6 +303,7 @@ private constructor( GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, + GPT_5_1_CODEX_MAX, /** * An enum member indicating that [ResponsesOnlyModel] was instantiated with an unknown * value. @@ -329,6 +333,7 @@ private constructor( GPT_5_CODEX -> Value.GPT_5_CODEX GPT_5_PRO -> Value.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Value.GPT_5_PRO_2025_10_06 + GPT_5_1_CODEX_MAX -> Value.GPT_5_1_CODEX_MAX else -> Value._UNKNOWN } @@ -356,6 +361,7 @@ private constructor( GPT_5_CODEX -> Known.GPT_5_CODEX GPT_5_PRO -> Known.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Known.GPT_5_PRO_2025_10_06 + GPT_5_1_CODEX_MAX -> Known.GPT_5_1_CODEX_MAX else -> throw OpenAIInvalidDataException("Unknown ResponsesOnlyModel: $value") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt index 9403087e..3c5939db 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt @@ -98,14 +98,15 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported - * values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning effort can - * result in faster responses and fewer tokens used on reasoning in a response. + * values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing reasoning effort + * can result in faster responses and fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for * all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -403,14 +404,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning - * effort can result in faster responses and fewer tokens used on reasoning in a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing + * reasoning effort can result in faster responses and fewer tokens used on reasoning in a + * response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported * for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = apply { body.reasoningEffort(reasoningEffort) @@ -871,14 +874,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning - * effort can result in faster responses and fewer tokens used on reasoning in a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing + * reasoning effort can result in faster responses and fewer tokens used on reasoning in a + * response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported * for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1208,15 +1213,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing - * reasoning effort can result in faster responses and fewer tokens used on reasoning in - * a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. + * Reducing reasoning effort can result in faster responses and fewer tokens used on + * reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported * reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls * are supported for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not * support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt index f5088a30..9fca0bf2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt @@ -90,14 +90,15 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported - * values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning effort can - * result in faster responses and fewer tokens used on reasoning in a response. + * values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing reasoning effort + * can result in faster responses and fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for * all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -397,14 +398,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning - * effort can result in faster responses and fewer tokens used on reasoning in a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing + * reasoning effort can result in faster responses and fewer tokens used on reasoning in a + * response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported * for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = apply { body.reasoningEffort(reasoningEffort) @@ -865,14 +868,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning - * effort can result in faster responses and fewer tokens used on reasoning in a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing + * reasoning effort can result in faster responses and fewer tokens used on reasoning in a + * response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported * for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1195,15 +1200,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing - * reasoning effort can result in faster responses and fewer tokens used on reasoning in - * a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. + * Reducing reasoning effort can result in faster responses and fewer tokens used on + * reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported * reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls * are supported for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not * support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCreateParams.kt index f36832b1..71e92717 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCreateParams.kt @@ -167,14 +167,15 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported - * values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning effort can - * result in faster responses and fewer tokens used on reasoning in a response. + * values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing reasoning effort + * can result in faster responses and fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for * all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -692,14 +693,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning - * effort can result in faster responses and fewer tokens used on reasoning in a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing + * reasoning effort can result in faster responses and fewer tokens used on reasoning in a + * response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported * for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = apply { body.reasoningEffort(reasoningEffort) @@ -1290,14 +1293,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning - * effort can result in faster responses and fewer tokens used on reasoning in a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing + * reasoning effort can result in faster responses and fewer tokens used on reasoning in a + * response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported * for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1838,15 +1843,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing - * reasoning effort can result in faster responses and fewer tokens used on reasoning in - * a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. + * Reducing reasoning effort can result in faster responses and fewer tokens used on + * reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported * reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls * are supported for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not * support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt index 8d4586e2..c42eff41 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt @@ -278,14 +278,15 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported - * values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning effort can - * result in faster responses and fewer tokens used on reasoning in a response. + * values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing reasoning effort + * can result in faster responses and fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for * all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1397,14 +1398,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning - * effort can result in faster responses and fewer tokens used on reasoning in a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing + * reasoning effort can result in faster responses and fewer tokens used on reasoning in a + * response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported * for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = apply { body.reasoningEffort(reasoningEffort) @@ -2434,14 +2437,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning - * effort can result in faster responses and fewer tokens used on reasoning in a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing + * reasoning effort can result in faster responses and fewer tokens used on reasoning in a + * response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported * for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -3729,15 +3734,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing - * reasoning effort can result in faster responses and fewer tokens used on reasoning in - * a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. + * Reducing reasoning effort can result in faster responses and fewer tokens used on + * reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported * reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls * are supported for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not * support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateParams.kt index b2df2416..49dfcf01 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateParams.kt @@ -55,6 +55,14 @@ private constructor( */ fun fileIds(): Optional> = body.fileIds() + /** + * Optional memory limit for the container. Defaults to "1g". + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun memoryLimit(): Optional = body.memoryLimit() + /** * Returns the raw JSON value of [name]. * @@ -76,6 +84,13 @@ private constructor( */ fun _fileIds(): JsonField> = body._fileIds() + /** + * Returns the raw JSON value of [memoryLimit]. + * + * Unlike [memoryLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _memoryLimit(): JsonField = body._memoryLimit() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -121,6 +136,7 @@ private constructor( * - [name] * - [expiresAfter] * - [fileIds] + * - [memoryLimit] */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -168,6 +184,20 @@ private constructor( */ fun addFileId(fileId: String) = apply { body.addFileId(fileId) } + /** Optional memory limit for the container. Defaults to "1g". */ + fun memoryLimit(memoryLimit: MemoryLimit) = apply { body.memoryLimit(memoryLimit) } + + /** + * Sets [Builder.memoryLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.memoryLimit] with a well-typed [MemoryLimit] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun memoryLimit(memoryLimit: JsonField) = apply { + body.memoryLimit(memoryLimit) + } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -317,6 +347,7 @@ private constructor( private val name: JsonField, private val expiresAfter: JsonField, private val fileIds: JsonField>, + private val memoryLimit: JsonField, private val additionalProperties: MutableMap, ) { @@ -329,7 +360,10 @@ private constructor( @JsonProperty("file_ids") @ExcludeMissing fileIds: JsonField> = JsonMissing.of(), - ) : this(name, expiresAfter, fileIds, mutableMapOf()) + @JsonProperty("memory_limit") + @ExcludeMissing + memoryLimit: JsonField = JsonMissing.of(), + ) : this(name, expiresAfter, fileIds, memoryLimit, mutableMapOf()) /** * Name of the container to create. @@ -355,6 +389,14 @@ private constructor( */ fun fileIds(): Optional> = fileIds.getOptional("file_ids") + /** + * Optional memory limit for the container. Defaults to "1g". + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun memoryLimit(): Optional = memoryLimit.getOptional("memory_limit") + /** * Returns the raw JSON value of [name]. * @@ -379,6 +421,15 @@ private constructor( */ @JsonProperty("file_ids") @ExcludeMissing fun _fileIds(): JsonField> = fileIds + /** + * Returns the raw JSON value of [memoryLimit]. + * + * Unlike [memoryLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memory_limit") + @ExcludeMissing + fun _memoryLimit(): JsonField = memoryLimit + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -410,6 +461,7 @@ private constructor( private var name: JsonField? = null private var expiresAfter: JsonField = JsonMissing.of() private var fileIds: JsonField>? = null + private var memoryLimit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -417,6 +469,7 @@ private constructor( name = body.name expiresAfter = body.expiresAfter fileIds = body.fileIds.map { it.toMutableList() } + memoryLimit = body.memoryLimit additionalProperties = body.additionalProperties.toMutableMap() } @@ -472,6 +525,20 @@ private constructor( } } + /** Optional memory limit for the container. Defaults to "1g". */ + fun memoryLimit(memoryLimit: MemoryLimit) = memoryLimit(JsonField.of(memoryLimit)) + + /** + * Sets [Builder.memoryLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.memoryLimit] with a well-typed [MemoryLimit] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun memoryLimit(memoryLimit: JsonField) = apply { + this.memoryLimit = memoryLimit + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -508,6 +575,7 @@ private constructor( checkRequired("name", name), expiresAfter, (fileIds ?: JsonMissing.of()).map { it.toImmutable() }, + memoryLimit, additionalProperties.toMutableMap(), ) } @@ -522,6 +590,7 @@ private constructor( name() expiresAfter().ifPresent { it.validate() } fileIds() + memoryLimit().ifPresent { it.validate() } validated = true } @@ -543,7 +612,8 @@ private constructor( internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + (expiresAfter.asKnown().getOrNull()?.validity() ?: 0) + - (fileIds.asKnown().getOrNull()?.size ?: 0) + (fileIds.asKnown().getOrNull()?.size ?: 0) + + (memoryLimit.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -554,17 +624,18 @@ private constructor( name == other.name && expiresAfter == other.expiresAfter && fileIds == other.fileIds && + memoryLimit == other.memoryLimit && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(name, expiresAfter, fileIds, additionalProperties) + Objects.hash(name, expiresAfter, fileIds, memoryLimit, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{name=$name, expiresAfter=$expiresAfter, fileIds=$fileIds, additionalProperties=$additionalProperties}" + "Body{name=$name, expiresAfter=$expiresAfter, fileIds=$fileIds, memoryLimit=$memoryLimit, additionalProperties=$additionalProperties}" } /** Container expiration time in seconds relative to the 'anchor' time. */ @@ -889,6 +960,147 @@ private constructor( "ExpiresAfter{anchor=$anchor, minutes=$minutes, additionalProperties=$additionalProperties}" } + /** Optional memory limit for the container. Defaults to "1g". */ + class MemoryLimit @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _1G = of("1g") + + @JvmField val _4G = of("4g") + + @JvmField val _16G = of("16g") + + @JvmField val _64G = of("64g") + + @JvmStatic fun of(value: String) = MemoryLimit(JsonField.of(value)) + } + + /** An enum containing [MemoryLimit]'s known values. */ + enum class Known { + _1G, + _4G, + _16G, + _64G, + } + + /** + * An enum containing [MemoryLimit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [MemoryLimit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _1G, + _4G, + _16G, + _64G, + /** + * An enum member indicating that [MemoryLimit] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _1G -> Value._1G + _4G -> Value._4G + _16G -> Value._16G + _64G -> Value._64G + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OpenAIInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + _1G -> Known._1G + _4G -> Known._4G + _16G -> Known._16G + _64G -> Known._64G + else -> throw OpenAIInvalidDataException("Unknown MemoryLimit: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OpenAIInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OpenAIInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): MemoryLimit = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemoryLimit && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateResponse.kt index e7991d9c..803ee160 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateResponse.kt @@ -27,6 +27,8 @@ private constructor( private val object_: JsonField, private val status: JsonField, private val expiresAfter: JsonField, + private val lastActiveAt: JsonField, + private val memoryLimit: JsonField, private val additionalProperties: MutableMap, ) { @@ -40,7 +42,23 @@ private constructor( @JsonProperty("expires_after") @ExcludeMissing expiresAfter: JsonField = JsonMissing.of(), - ) : this(id, createdAt, name, object_, status, expiresAfter, mutableMapOf()) + @JsonProperty("last_active_at") + @ExcludeMissing + lastActiveAt: JsonField = JsonMissing.of(), + @JsonProperty("memory_limit") + @ExcludeMissing + memoryLimit: JsonField = JsonMissing.of(), + ) : this( + id, + createdAt, + name, + object_, + status, + expiresAfter, + lastActiveAt, + memoryLimit, + mutableMapOf(), + ) /** * Unique identifier for the container. @@ -92,6 +110,22 @@ private constructor( */ fun expiresAfter(): Optional = expiresAfter.getOptional("expires_after") + /** + * Unix timestamp (in seconds) when the container was last active. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastActiveAt(): Optional = lastActiveAt.getOptional("last_active_at") + + /** + * The memory limit configured for the container. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun memoryLimit(): Optional = memoryLimit.getOptional("memory_limit") + /** * Returns the raw JSON value of [id]. * @@ -136,6 +170,24 @@ private constructor( @ExcludeMissing fun _expiresAfter(): JsonField = expiresAfter + /** + * Returns the raw JSON value of [lastActiveAt]. + * + * Unlike [lastActiveAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_active_at") + @ExcludeMissing + fun _lastActiveAt(): JsonField = lastActiveAt + + /** + * Returns the raw JSON value of [memoryLimit]. + * + * Unlike [memoryLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memory_limit") + @ExcludeMissing + fun _memoryLimit(): JsonField = memoryLimit + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -174,6 +226,8 @@ private constructor( private var object_: JsonField? = null private var status: JsonField? = null private var expiresAfter: JsonField = JsonMissing.of() + private var lastActiveAt: JsonField = JsonMissing.of() + private var memoryLimit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -184,6 +238,8 @@ private constructor( object_ = containerCreateResponse.object_ status = containerCreateResponse.status expiresAfter = containerCreateResponse.expiresAfter + lastActiveAt = containerCreateResponse.lastActiveAt + memoryLimit = containerCreateResponse.memoryLimit additionalProperties = containerCreateResponse.additionalProperties.toMutableMap() } @@ -260,6 +316,32 @@ private constructor( this.expiresAfter = expiresAfter } + /** Unix timestamp (in seconds) when the container was last active. */ + fun lastActiveAt(lastActiveAt: Long) = lastActiveAt(JsonField.of(lastActiveAt)) + + /** + * Sets [Builder.lastActiveAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastActiveAt] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun lastActiveAt(lastActiveAt: JsonField) = apply { this.lastActiveAt = lastActiveAt } + + /** The memory limit configured for the container. */ + fun memoryLimit(memoryLimit: MemoryLimit) = memoryLimit(JsonField.of(memoryLimit)) + + /** + * Sets [Builder.memoryLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.memoryLimit] with a well-typed [MemoryLimit] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun memoryLimit(memoryLimit: JsonField) = apply { + this.memoryLimit = memoryLimit + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -303,6 +385,8 @@ private constructor( checkRequired("object_", object_), checkRequired("status", status), expiresAfter, + lastActiveAt, + memoryLimit, additionalProperties.toMutableMap(), ) } @@ -320,6 +404,8 @@ private constructor( object_() status() expiresAfter().ifPresent { it.validate() } + lastActiveAt() + memoryLimit().ifPresent { it.validate() } validated = true } @@ -343,7 +429,9 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (object_.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + - (expiresAfter.asKnown().getOrNull()?.validity() ?: 0) + (expiresAfter.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastActiveAt.asKnown().isPresent) 1 else 0) + + (memoryLimit.asKnown().getOrNull()?.validity() ?: 0) /** * The container will expire after this time period. The anchor is the reference point for the @@ -652,6 +740,147 @@ private constructor( "ExpiresAfter{anchor=$anchor, minutes=$minutes, additionalProperties=$additionalProperties}" } + /** The memory limit configured for the container. */ + class MemoryLimit @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _1G = of("1g") + + @JvmField val _4G = of("4g") + + @JvmField val _16G = of("16g") + + @JvmField val _64G = of("64g") + + @JvmStatic fun of(value: String) = MemoryLimit(JsonField.of(value)) + } + + /** An enum containing [MemoryLimit]'s known values. */ + enum class Known { + _1G, + _4G, + _16G, + _64G, + } + + /** + * An enum containing [MemoryLimit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [MemoryLimit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _1G, + _4G, + _16G, + _64G, + /** + * An enum member indicating that [MemoryLimit] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _1G -> Value._1G + _4G -> Value._4G + _16G -> Value._16G + _64G -> Value._64G + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OpenAIInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + _1G -> Known._1G + _4G -> Known._4G + _16G -> Known._16G + _64G -> Known._64G + else -> throw OpenAIInvalidDataException("Unknown MemoryLimit: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OpenAIInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OpenAIInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): MemoryLimit = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemoryLimit && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -664,15 +893,27 @@ private constructor( object_ == other.object_ && status == other.status && expiresAfter == other.expiresAfter && + lastActiveAt == other.lastActiveAt && + memoryLimit == other.memoryLimit && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, name, object_, status, expiresAfter, additionalProperties) + Objects.hash( + id, + createdAt, + name, + object_, + status, + expiresAfter, + lastActiveAt, + memoryLimit, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ContainerCreateResponse{id=$id, createdAt=$createdAt, name=$name, object_=$object_, status=$status, expiresAfter=$expiresAfter, additionalProperties=$additionalProperties}" + "ContainerCreateResponse{id=$id, createdAt=$createdAt, name=$name, object_=$object_, status=$status, expiresAfter=$expiresAfter, lastActiveAt=$lastActiveAt, memoryLimit=$memoryLimit, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListResponse.kt index d344a1c6..d8f8b9bf 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListResponse.kt @@ -27,6 +27,8 @@ private constructor( private val object_: JsonField, private val status: JsonField, private val expiresAfter: JsonField, + private val lastActiveAt: JsonField, + private val memoryLimit: JsonField, private val additionalProperties: MutableMap, ) { @@ -40,7 +42,23 @@ private constructor( @JsonProperty("expires_after") @ExcludeMissing expiresAfter: JsonField = JsonMissing.of(), - ) : this(id, createdAt, name, object_, status, expiresAfter, mutableMapOf()) + @JsonProperty("last_active_at") + @ExcludeMissing + lastActiveAt: JsonField = JsonMissing.of(), + @JsonProperty("memory_limit") + @ExcludeMissing + memoryLimit: JsonField = JsonMissing.of(), + ) : this( + id, + createdAt, + name, + object_, + status, + expiresAfter, + lastActiveAt, + memoryLimit, + mutableMapOf(), + ) /** * Unique identifier for the container. @@ -92,6 +110,22 @@ private constructor( */ fun expiresAfter(): Optional = expiresAfter.getOptional("expires_after") + /** + * Unix timestamp (in seconds) when the container was last active. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastActiveAt(): Optional = lastActiveAt.getOptional("last_active_at") + + /** + * The memory limit configured for the container. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun memoryLimit(): Optional = memoryLimit.getOptional("memory_limit") + /** * Returns the raw JSON value of [id]. * @@ -136,6 +170,24 @@ private constructor( @ExcludeMissing fun _expiresAfter(): JsonField = expiresAfter + /** + * Returns the raw JSON value of [lastActiveAt]. + * + * Unlike [lastActiveAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_active_at") + @ExcludeMissing + fun _lastActiveAt(): JsonField = lastActiveAt + + /** + * Returns the raw JSON value of [memoryLimit]. + * + * Unlike [memoryLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memory_limit") + @ExcludeMissing + fun _memoryLimit(): JsonField = memoryLimit + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -174,6 +226,8 @@ private constructor( private var object_: JsonField? = null private var status: JsonField? = null private var expiresAfter: JsonField = JsonMissing.of() + private var lastActiveAt: JsonField = JsonMissing.of() + private var memoryLimit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -184,6 +238,8 @@ private constructor( object_ = containerListResponse.object_ status = containerListResponse.status expiresAfter = containerListResponse.expiresAfter + lastActiveAt = containerListResponse.lastActiveAt + memoryLimit = containerListResponse.memoryLimit additionalProperties = containerListResponse.additionalProperties.toMutableMap() } @@ -260,6 +316,32 @@ private constructor( this.expiresAfter = expiresAfter } + /** Unix timestamp (in seconds) when the container was last active. */ + fun lastActiveAt(lastActiveAt: Long) = lastActiveAt(JsonField.of(lastActiveAt)) + + /** + * Sets [Builder.lastActiveAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastActiveAt] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun lastActiveAt(lastActiveAt: JsonField) = apply { this.lastActiveAt = lastActiveAt } + + /** The memory limit configured for the container. */ + fun memoryLimit(memoryLimit: MemoryLimit) = memoryLimit(JsonField.of(memoryLimit)) + + /** + * Sets [Builder.memoryLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.memoryLimit] with a well-typed [MemoryLimit] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun memoryLimit(memoryLimit: JsonField) = apply { + this.memoryLimit = memoryLimit + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -303,6 +385,8 @@ private constructor( checkRequired("object_", object_), checkRequired("status", status), expiresAfter, + lastActiveAt, + memoryLimit, additionalProperties.toMutableMap(), ) } @@ -320,6 +404,8 @@ private constructor( object_() status() expiresAfter().ifPresent { it.validate() } + lastActiveAt() + memoryLimit().ifPresent { it.validate() } validated = true } @@ -343,7 +429,9 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (object_.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + - (expiresAfter.asKnown().getOrNull()?.validity() ?: 0) + (expiresAfter.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastActiveAt.asKnown().isPresent) 1 else 0) + + (memoryLimit.asKnown().getOrNull()?.validity() ?: 0) /** * The container will expire after this time period. The anchor is the reference point for the @@ -652,6 +740,147 @@ private constructor( "ExpiresAfter{anchor=$anchor, minutes=$minutes, additionalProperties=$additionalProperties}" } + /** The memory limit configured for the container. */ + class MemoryLimit @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _1G = of("1g") + + @JvmField val _4G = of("4g") + + @JvmField val _16G = of("16g") + + @JvmField val _64G = of("64g") + + @JvmStatic fun of(value: String) = MemoryLimit(JsonField.of(value)) + } + + /** An enum containing [MemoryLimit]'s known values. */ + enum class Known { + _1G, + _4G, + _16G, + _64G, + } + + /** + * An enum containing [MemoryLimit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [MemoryLimit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _1G, + _4G, + _16G, + _64G, + /** + * An enum member indicating that [MemoryLimit] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _1G -> Value._1G + _4G -> Value._4G + _16G -> Value._16G + _64G -> Value._64G + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OpenAIInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + _1G -> Known._1G + _4G -> Known._4G + _16G -> Known._16G + _64G -> Known._64G + else -> throw OpenAIInvalidDataException("Unknown MemoryLimit: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OpenAIInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OpenAIInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): MemoryLimit = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemoryLimit && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -664,15 +893,27 @@ private constructor( object_ == other.object_ && status == other.status && expiresAfter == other.expiresAfter && + lastActiveAt == other.lastActiveAt && + memoryLimit == other.memoryLimit && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, name, object_, status, expiresAfter, additionalProperties) + Objects.hash( + id, + createdAt, + name, + object_, + status, + expiresAfter, + lastActiveAt, + memoryLimit, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ContainerListResponse{id=$id, createdAt=$createdAt, name=$name, object_=$object_, status=$status, expiresAfter=$expiresAfter, additionalProperties=$additionalProperties}" + "ContainerListResponse{id=$id, createdAt=$createdAt, name=$name, object_=$object_, status=$status, expiresAfter=$expiresAfter, lastActiveAt=$lastActiveAt, memoryLimit=$memoryLimit, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerRetrieveResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerRetrieveResponse.kt index 383d268e..59ab1ad1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerRetrieveResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerRetrieveResponse.kt @@ -27,6 +27,8 @@ private constructor( private val object_: JsonField, private val status: JsonField, private val expiresAfter: JsonField, + private val lastActiveAt: JsonField, + private val memoryLimit: JsonField, private val additionalProperties: MutableMap, ) { @@ -40,7 +42,23 @@ private constructor( @JsonProperty("expires_after") @ExcludeMissing expiresAfter: JsonField = JsonMissing.of(), - ) : this(id, createdAt, name, object_, status, expiresAfter, mutableMapOf()) + @JsonProperty("last_active_at") + @ExcludeMissing + lastActiveAt: JsonField = JsonMissing.of(), + @JsonProperty("memory_limit") + @ExcludeMissing + memoryLimit: JsonField = JsonMissing.of(), + ) : this( + id, + createdAt, + name, + object_, + status, + expiresAfter, + lastActiveAt, + memoryLimit, + mutableMapOf(), + ) /** * Unique identifier for the container. @@ -92,6 +110,22 @@ private constructor( */ fun expiresAfter(): Optional = expiresAfter.getOptional("expires_after") + /** + * Unix timestamp (in seconds) when the container was last active. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastActiveAt(): Optional = lastActiveAt.getOptional("last_active_at") + + /** + * The memory limit configured for the container. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun memoryLimit(): Optional = memoryLimit.getOptional("memory_limit") + /** * Returns the raw JSON value of [id]. * @@ -136,6 +170,24 @@ private constructor( @ExcludeMissing fun _expiresAfter(): JsonField = expiresAfter + /** + * Returns the raw JSON value of [lastActiveAt]. + * + * Unlike [lastActiveAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_active_at") + @ExcludeMissing + fun _lastActiveAt(): JsonField = lastActiveAt + + /** + * Returns the raw JSON value of [memoryLimit]. + * + * Unlike [memoryLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memory_limit") + @ExcludeMissing + fun _memoryLimit(): JsonField = memoryLimit + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -174,6 +226,8 @@ private constructor( private var object_: JsonField? = null private var status: JsonField? = null private var expiresAfter: JsonField = JsonMissing.of() + private var lastActiveAt: JsonField = JsonMissing.of() + private var memoryLimit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -184,6 +238,8 @@ private constructor( object_ = containerRetrieveResponse.object_ status = containerRetrieveResponse.status expiresAfter = containerRetrieveResponse.expiresAfter + lastActiveAt = containerRetrieveResponse.lastActiveAt + memoryLimit = containerRetrieveResponse.memoryLimit additionalProperties = containerRetrieveResponse.additionalProperties.toMutableMap() } @@ -260,6 +316,32 @@ private constructor( this.expiresAfter = expiresAfter } + /** Unix timestamp (in seconds) when the container was last active. */ + fun lastActiveAt(lastActiveAt: Long) = lastActiveAt(JsonField.of(lastActiveAt)) + + /** + * Sets [Builder.lastActiveAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastActiveAt] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun lastActiveAt(lastActiveAt: JsonField) = apply { this.lastActiveAt = lastActiveAt } + + /** The memory limit configured for the container. */ + fun memoryLimit(memoryLimit: MemoryLimit) = memoryLimit(JsonField.of(memoryLimit)) + + /** + * Sets [Builder.memoryLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.memoryLimit] with a well-typed [MemoryLimit] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun memoryLimit(memoryLimit: JsonField) = apply { + this.memoryLimit = memoryLimit + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -303,6 +385,8 @@ private constructor( checkRequired("object_", object_), checkRequired("status", status), expiresAfter, + lastActiveAt, + memoryLimit, additionalProperties.toMutableMap(), ) } @@ -320,6 +404,8 @@ private constructor( object_() status() expiresAfter().ifPresent { it.validate() } + lastActiveAt() + memoryLimit().ifPresent { it.validate() } validated = true } @@ -343,7 +429,9 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (object_.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + - (expiresAfter.asKnown().getOrNull()?.validity() ?: 0) + (expiresAfter.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastActiveAt.asKnown().isPresent) 1 else 0) + + (memoryLimit.asKnown().getOrNull()?.validity() ?: 0) /** * The container will expire after this time period. The anchor is the reference point for the @@ -652,6 +740,147 @@ private constructor( "ExpiresAfter{anchor=$anchor, minutes=$minutes, additionalProperties=$additionalProperties}" } + /** The memory limit configured for the container. */ + class MemoryLimit @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _1G = of("1g") + + @JvmField val _4G = of("4g") + + @JvmField val _16G = of("16g") + + @JvmField val _64G = of("64g") + + @JvmStatic fun of(value: String) = MemoryLimit(JsonField.of(value)) + } + + /** An enum containing [MemoryLimit]'s known values. */ + enum class Known { + _1G, + _4G, + _16G, + _64G, + } + + /** + * An enum containing [MemoryLimit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [MemoryLimit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _1G, + _4G, + _16G, + _64G, + /** + * An enum member indicating that [MemoryLimit] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _1G -> Value._1G + _4G -> Value._4G + _16G -> Value._16G + _64G -> Value._64G + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OpenAIInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + _1G -> Known._1G + _4G -> Known._4G + _16G -> Known._16G + _64G -> Known._64G + else -> throw OpenAIInvalidDataException("Unknown MemoryLimit: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OpenAIInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OpenAIInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): MemoryLimit = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemoryLimit && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -664,15 +893,27 @@ private constructor( object_ == other.object_ && status == other.status && expiresAfter == other.expiresAfter && + lastActiveAt == other.lastActiveAt && + memoryLimit == other.memoryLimit && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, name, object_, status, expiresAfter, additionalProperties) + Objects.hash( + id, + createdAt, + name, + object_, + status, + expiresAfter, + lastActiveAt, + memoryLimit, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ContainerRetrieveResponse{id=$id, createdAt=$createdAt, name=$name, object_=$object_, status=$status, expiresAfter=$expiresAfter, additionalProperties=$additionalProperties}" + "ContainerRetrieveResponse{id=$id, createdAt=$createdAt, name=$name, object_=$object_, status=$status, expiresAfter=$expiresAfter, lastActiveAt=$lastActiveAt, memoryLimit=$memoryLimit, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationCreateParams.kt index 6cba6d50..b886b09c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationCreateParams.kt @@ -18,6 +18,7 @@ import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException import com.openai.models.responses.EasyInputMessage import com.openai.models.responses.ResponseCodeInterpreterToolCall +import com.openai.models.responses.ResponseCompactionItemParam import com.openai.models.responses.ResponseComputerToolCall import com.openai.models.responses.ResponseCustomToolCall import com.openai.models.responses.ResponseCustomToolCallOutput @@ -196,6 +197,21 @@ private constructor( /** Alias for calling [addItem] with `ResponseInputItem.ofReasoning(reasoning)`. */ fun addItem(reasoning: ResponseReasoningItem) = apply { body.addItem(reasoning) } + /** Alias for calling [addItem] with `ResponseInputItem.ofCompaction(compaction)`. */ + fun addItem(compaction: ResponseCompactionItemParam) = apply { body.addItem(compaction) } + + /** + * Alias for calling [addItem] with the following: + * ```java + * ResponseCompactionItemParam.builder() + * .encryptedContent(encryptedContent) + * .build() + * ``` + */ + fun addCompactionItem(encryptedContent: String) = apply { + body.addCompactionItem(encryptedContent) + } + /** * Alias for calling [addItem] with * `ResponseInputItem.ofImageGenerationCall(imageGenerationCall)`. @@ -644,6 +660,23 @@ private constructor( fun addItem(reasoning: ResponseReasoningItem) = addItem(ResponseInputItem.ofReasoning(reasoning)) + /** Alias for calling [addItem] with `ResponseInputItem.ofCompaction(compaction)`. */ + fun addItem(compaction: ResponseCompactionItemParam) = + addItem(ResponseInputItem.ofCompaction(compaction)) + + /** + * Alias for calling [addItem] with the following: + * ```java + * ResponseCompactionItemParam.builder() + * .encryptedContent(encryptedContent) + * .build() + * ``` + */ + fun addCompactionItem(encryptedContent: String) = + addItem( + ResponseCompactionItemParam.builder().encryptedContent(encryptedContent).build() + ) + /** * Alias for calling [addItem] with * `ResponseInputItem.ofImageGenerationCall(imageGenerationCall)`. diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ItemCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ItemCreateParams.kt index 3ee3db14..f629d720 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ItemCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ItemCreateParams.kt @@ -19,6 +19,7 @@ import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException import com.openai.models.responses.EasyInputMessage import com.openai.models.responses.ResponseCodeInterpreterToolCall +import com.openai.models.responses.ResponseCompactionItemParam import com.openai.models.responses.ResponseComputerToolCall import com.openai.models.responses.ResponseCustomToolCall import com.openai.models.responses.ResponseCustomToolCallOutput @@ -218,6 +219,21 @@ private constructor( /** Alias for calling [addItem] with `ResponseInputItem.ofReasoning(reasoning)`. */ fun addItem(reasoning: ResponseReasoningItem) = apply { body.addItem(reasoning) } + /** Alias for calling [addItem] with `ResponseInputItem.ofCompaction(compaction)`. */ + fun addItem(compaction: ResponseCompactionItemParam) = apply { body.addItem(compaction) } + + /** + * Alias for calling [addItem] with the following: + * ```java + * ResponseCompactionItemParam.builder() + * .encryptedContent(encryptedContent) + * .build() + * ``` + */ + fun addCompactionItem(encryptedContent: String) = apply { + body.addCompactionItem(encryptedContent) + } + /** * Alias for calling [addItem] with * `ResponseInputItem.ofImageGenerationCall(imageGenerationCall)`. @@ -639,6 +655,23 @@ private constructor( fun addItem(reasoning: ResponseReasoningItem) = addItem(ResponseInputItem.ofReasoning(reasoning)) + /** Alias for calling [addItem] with `ResponseInputItem.ofCompaction(compaction)`. */ + fun addItem(compaction: ResponseCompactionItemParam) = + addItem(ResponseInputItem.ofCompaction(compaction)) + + /** + * Alias for calling [addItem] with the following: + * ```java + * ResponseCompactionItemParam.builder() + * .encryptedContent(encryptedContent) + * .build() + * ``` + */ + fun addCompactionItem(encryptedContent: String) = + addItem( + ResponseCompactionItemParam.builder().encryptedContent(encryptedContent).build() + ) + /** * Alias for calling [addItem] with * `ResponseInputItem.ofImageGenerationCall(imageGenerationCall)`. diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt index 64c30b68..6e50e10a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt @@ -4474,14 +4474,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning - * effort can result in faster responses and fewer tokens used on reasoning in a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing + * reasoning effort can result in faster responses and fewer tokens used on reasoning in a + * response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported * for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -4662,15 +4664,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing - * reasoning effort can result in faster responses and fewer tokens used on reasoning in - * a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. + * Reducing reasoning effort can result in faster responses and fewer tokens used on + * reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported * reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls * are supported for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not * support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt index 9f9dc382..43eeef52 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt @@ -2735,9 +2735,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and fewer - * tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, + * and `xhigh`. Reducing reasoning effort can result in faster responses and + * fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and * `high`. Tool calls are supported for all reasoning values in gpt-5.1. @@ -2745,6 +2745,7 @@ private constructor( * not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -3057,9 +3058,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and - * fewer tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, + * `high`, and `xhigh`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, * and `high`. Tool calls are supported for all reasoning values in @@ -3068,6 +3069,7 @@ private constructor( * do not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) @@ -6060,8 +6062,8 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing - * reasoning effort can result in faster responses and fewer tokens used on + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. + * Reducing reasoning effort can result in faster responses and fewer tokens used on * reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported * reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool @@ -6069,6 +6071,7 @@ private constructor( * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not * support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -6255,9 +6258,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and fewer - * tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, + * and `xhigh`. Reducing reasoning effort can result in faster responses and + * fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and * `high`. Tool calls are supported for all reasoning values in gpt-5.1. @@ -6265,6 +6268,7 @@ private constructor( * not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt index 862eddee..4f48b185 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt @@ -2497,9 +2497,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and fewer - * tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, + * and `xhigh`. Reducing reasoning effort can result in faster responses and + * fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and * `high`. Tool calls are supported for all reasoning values in gpt-5.1. @@ -2507,6 +2507,7 @@ private constructor( * not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -2817,9 +2818,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and - * fewer tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, + * `high`, and `xhigh`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, * and `high`. Tool calls are supported for all reasoning values in @@ -2828,6 +2829,7 @@ private constructor( * do not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) @@ -5945,8 +5947,8 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing - * reasoning effort can result in faster responses and fewer tokens used on + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. + * Reducing reasoning effort can result in faster responses and fewer tokens used on * reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported * reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool @@ -5954,6 +5956,7 @@ private constructor( * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not * support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -6140,9 +6143,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and fewer - * tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, + * and `xhigh`. Reducing reasoning effort can result in faster responses and + * fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and * `high`. Tool calls are supported for all reasoning values in gpt-5.1. @@ -6150,6 +6153,7 @@ private constructor( * not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt index bed308e3..31809894 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt @@ -2735,9 +2735,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and fewer - * tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, + * and `xhigh`. Reducing reasoning effort can result in faster responses and + * fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and * `high`. Tool calls are supported for all reasoning values in gpt-5.1. @@ -2745,6 +2745,7 @@ private constructor( * not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -3057,9 +3058,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and - * fewer tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, + * `high`, and `xhigh`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, * and `high`. Tool calls are supported for all reasoning values in @@ -3068,6 +3069,7 @@ private constructor( * do not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) @@ -6060,8 +6062,8 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing - * reasoning effort can result in faster responses and fewer tokens used on + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. + * Reducing reasoning effort can result in faster responses and fewer tokens used on * reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported * reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool @@ -6069,6 +6071,7 @@ private constructor( * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not * support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -6255,9 +6258,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and fewer - * tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, + * and `xhigh`. Reducing reasoning effort can result in faster responses and + * fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and * `high`. Tool calls are supported for all reasoning values in gpt-5.1. @@ -6265,6 +6268,7 @@ private constructor( * not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt index 0241c34c..6383fc57 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt @@ -2735,9 +2735,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and fewer - * tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, + * and `xhigh`. Reducing reasoning effort can result in faster responses and + * fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and * `high`. Tool calls are supported for all reasoning values in gpt-5.1. @@ -2745,6 +2745,7 @@ private constructor( * not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -3057,9 +3058,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and - * fewer tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, + * `high`, and `xhigh`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, * and `high`. Tool calls are supported for all reasoning values in @@ -3068,6 +3069,7 @@ private constructor( * do not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) @@ -6060,8 +6062,8 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing - * reasoning effort can result in faster responses and fewer tokens used on + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. + * Reducing reasoning effort can result in faster responses and fewer tokens used on * reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported * reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool @@ -6069,6 +6071,7 @@ private constructor( * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not * support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -6255,9 +6258,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and fewer - * tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, + * and `xhigh`. Reducing reasoning effort can result in faster responses and + * fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and * `high`. Tool calls are supported for all reasoning values in gpt-5.1. @@ -6265,6 +6268,7 @@ private constructor( * not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt index 74e92339..9957806c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt @@ -2735,9 +2735,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and fewer - * tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, + * and `xhigh`. Reducing reasoning effort can result in faster responses and + * fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and * `high`. Tool calls are supported for all reasoning values in gpt-5.1. @@ -2745,6 +2745,7 @@ private constructor( * not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -3057,9 +3058,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and - * fewer tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, + * `high`, and `xhigh`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, * and `high`. Tool calls are supported for all reasoning values in @@ -3068,6 +3069,7 @@ private constructor( * do not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) @@ -6060,8 +6062,8 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing - * reasoning effort can result in faster responses and fewer tokens used on + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. + * Reducing reasoning effort can result in faster responses and fewer tokens used on * reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported * reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool @@ -6069,6 +6071,7 @@ private constructor( * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not * support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -6255,9 +6258,9 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). - * Currently supported values are `none`, `minimal`, `low`, `medium`, and - * `high`. Reducing reasoning effort can result in faster responses and fewer - * tokens used on reasoning in a response. + * Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, + * and `xhigh`. Reducing reasoning effort can result in faster responses and + * fewer tokens used on reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The * supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and * `high`. Tool calls are supported for all reasoning values in gpt-5.1. @@ -6265,6 +6268,7 @@ private constructor( * not support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning * effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt index 34b14865..c62e4d9e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt @@ -1786,14 +1786,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing reasoning - * effort can result in faster responses and fewer tokens used on reasoning in a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing + * reasoning effort can result in faster responses and fewer tokens used on reasoning in a + * response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning * values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported * for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support * `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1939,15 +1941,16 @@ private constructor( /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently - * supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing - * reasoning effort can result in faster responses and fewer tokens used on reasoning in - * a response. + * supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. + * Reducing reasoning effort can result in faster responses and fewer tokens used on + * reasoning in a response. * - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported * reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls * are supported for all reasoning values in gpt-5.1. * - All models before `gpt-5.1` default to `medium` reasoning effort, and do not * support `none`. * - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. + * - `xhigh` is currently only supported for `gpt-5.1-codex-max`. */ fun reasoningEffort(reasoningEffort: ReasoningEffort?) = reasoningEffort(JsonField.ofNullable(reasoningEffort)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferDtmfEventReceivedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferDtmfEventReceivedEvent.kt new file mode 100644 index 00000000..01f67ebf --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferDtmfEventReceivedEvent.kt @@ -0,0 +1,263 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.realtime + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * **SIP Only:** Returned when an DTMF event is received. A DTMF event is a message that represents + * a telephone keypad press (0–9, *, #, A–D). The `event` property is the keypad that the user + * press. The `received_at` is the UTC Unix Timestamp that the server received the event. + */ +class InputAudioBufferDtmfEventReceivedEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val event: JsonField, + private val receivedAt: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("event") @ExcludeMissing event: JsonField = JsonMissing.of(), + @JsonProperty("received_at") @ExcludeMissing receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(event, receivedAt, type, mutableMapOf()) + + /** + * The telephone keypad that was pressed by the user. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun event(): String = event.getRequired("event") + + /** + * UTC Unix Timestamp when DTMF Event was received by server. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun receivedAt(): Long = receivedAt.getRequired("received_at") + + /** + * The event type, must be `input_audio_buffer.dtmf_event_received`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("input_audio_buffer.dtmf_event_received") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [event]. + * + * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("received_at") @ExcludeMissing fun _receivedAt(): JsonField = receivedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InputAudioBufferDtmfEventReceivedEvent]. + * + * The following fields are required: + * ```java + * .event() + * .receivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputAudioBufferDtmfEventReceivedEvent]. */ + class Builder internal constructor() { + + private var event: JsonField? = null + private var receivedAt: JsonField? = null + private var type: JsonValue = JsonValue.from("input_audio_buffer.dtmf_event_received") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + inputAudioBufferDtmfEventReceivedEvent: InputAudioBufferDtmfEventReceivedEvent + ) = apply { + event = inputAudioBufferDtmfEventReceivedEvent.event + receivedAt = inputAudioBufferDtmfEventReceivedEvent.receivedAt + type = inputAudioBufferDtmfEventReceivedEvent.type + additionalProperties = + inputAudioBufferDtmfEventReceivedEvent.additionalProperties.toMutableMap() + } + + /** The telephone keypad that was pressed by the user. */ + fun event(event: String) = event(JsonField.of(event)) + + /** + * Sets [Builder.event] to an arbitrary JSON value. + * + * You should usually call [Builder.event] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun event(event: JsonField) = apply { this.event = event } + + /** UTC Unix Timestamp when DTMF Event was received by server. */ + fun receivedAt(receivedAt: Long) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { this.receivedAt = receivedAt } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("input_audio_buffer.dtmf_event_received") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InputAudioBufferDtmfEventReceivedEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .event() + * .receivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InputAudioBufferDtmfEventReceivedEvent = + InputAudioBufferDtmfEventReceivedEvent( + checkRequired("event", event), + checkRequired("receivedAt", receivedAt), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InputAudioBufferDtmfEventReceivedEvent = apply { + if (validated) { + return@apply + } + + event() + receivedAt() + _type().let { + if (it != JsonValue.from("input_audio_buffer.dtmf_event_received")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (event.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("input_audio_buffer.dtmf_event_received")) 1 else 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputAudioBufferDtmfEventReceivedEvent && + event == other.event && + receivedAt == other.receivedAt && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(event, receivedAt, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InputAudioBufferDtmfEventReceivedEvent{event=$event, receivedAt=$receivedAt, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/OutputAudioBufferClearEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/OutputAudioBufferClearEvent.kt index 4a21ca93..f07856af 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/OutputAudioBufferClearEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/OutputAudioBufferClearEvent.kt @@ -16,9 +16,9 @@ import java.util.Objects import java.util.Optional /** - * **WebRTC Only:** Emit to cut off the current audio response. This will trigger the server to stop - * generating audio and emit a `output_audio_buffer.cleared` event. This event should be preceded by - * a `response.cancel` client event to stop the generation of the current response. + * **WebRTC/SIP Only:** Emit to cut off the current audio response. This will trigger the server to + * stop generating audio and emit a `output_audio_buffer.cleared` event. This event should be + * preceded by a `response.cancel` client event to stop the generation of the current response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ class OutputAudioBufferClearEvent diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioInputTurnDetection.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioInputTurnDetection.kt index b99f1923..198924a6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioInputTurnDetection.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioInputTurnDetection.kt @@ -308,7 +308,12 @@ private constructor( @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** - * Whether or not to automatically generate a response when a VAD stop event occurs. + * Whether or not to automatically generate a response when a VAD stop event occurs. If + * `interrupt_response` is set to `false` this may fail to create a response if the model is + * already responding. + * + * If both `create_response` and `interrupt_response` are set to `false`, the model will + * never respond automatically but VAD events will still be emitted. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -334,8 +339,12 @@ private constructor( fun idleTimeoutMs(): Optional = idleTimeoutMs.getOptional("idle_timeout_ms") /** - * Whether or not to automatically interrupt any ongoing response with output to the default - * conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. + * Whether or not to automatically interrupt (cancel) any ongoing response with output to + * the default conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. + * If `true` then the response will be cancelled, otherwise it will continue until complete. + * + * If both `create_response` and `interrupt_response` are set to `false`, the model will + * never respond automatically but VAD events will still be emitted. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -486,7 +495,14 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - /** Whether or not to automatically generate a response when a VAD stop event occurs. */ + /** + * Whether or not to automatically generate a response when a VAD stop event occurs. If + * `interrupt_response` is set to `false` this may fail to create a response if the + * model is already responding. + * + * If both `create_response` and `interrupt_response` are set to `false`, the model will + * never respond automatically but VAD events will still be emitted. + */ fun createResponse(createResponse: Boolean) = createResponse(JsonField.of(createResponse)) @@ -540,8 +556,13 @@ private constructor( } /** - * Whether or not to automatically interrupt any ongoing response with output to the - * default conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. + * Whether or not to automatically interrupt (cancel) any ongoing response with output + * to the default conversation (i.e. `conversation` of `auto`) when a VAD start event + * occurs. If `true` then the response will be cancelled, otherwise it will continue + * until complete. + * + * If both `create_response` and `interrupt_response` are set to `false`, the model will + * never respond automatically but VAD events will still be emitted. */ fun interruptResponse(interruptResponse: Boolean) = interruptResponse(JsonField.of(interruptResponse)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeClientEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeClientEvent.kt index 5a0300e3..897150aa 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeClientEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeClientEvent.kt @@ -107,8 +107,8 @@ private constructor( Optional.ofNullable(inputAudioBufferClear) /** - * **WebRTC Only:** Emit to cut off the current audio response. This will trigger the server to - * stop generating audio and emit a `output_audio_buffer.cleared` event. This event should be + * **WebRTC/SIP Only:** Emit to cut off the current audio response. This will trigger the server + * to stop generating audio and emit a `output_audio_buffer.cleared` event. This event should be * preceded by a `response.cancel` client event to stop the generation of the current response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ @@ -266,8 +266,8 @@ private constructor( inputAudioBufferClear.getOrThrow("inputAudioBufferClear") /** - * **WebRTC Only:** Emit to cut off the current audio response. This will trigger the server to - * stop generating audio and emit a `output_audio_buffer.cleared` event. This event should be + * **WebRTC/SIP Only:** Emit to cut off the current audio response. This will trigger the server + * to stop generating audio and emit a `output_audio_buffer.cleared` event. This event should be * preceded by a `response.cancel` client event to stop the generation of the current response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ @@ -631,10 +631,10 @@ private constructor( RealtimeClientEvent(inputAudioBufferClear = inputAudioBufferClear) /** - * **WebRTC Only:** Emit to cut off the current audio response. This will trigger the server - * to stop generating audio and emit a `output_audio_buffer.cleared` event. This event - * should be preceded by a `response.cancel` client event to stop the generation of the - * current response. + * **WebRTC/SIP Only:** Emit to cut off the current audio response. This will trigger the + * server to stop generating audio and emit a `output_audio_buffer.cleared` event. This + * event should be preceded by a `response.cancel` client event to stop the generation of + * the current response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ @JvmStatic @@ -785,10 +785,10 @@ private constructor( fun visitInputAudioBufferClear(inputAudioBufferClear: InputAudioBufferClearEvent): T /** - * **WebRTC Only:** Emit to cut off the current audio response. This will trigger the server - * to stop generating audio and emit a `output_audio_buffer.cleared` event. This event - * should be preceded by a `response.cancel` client event to stop the generation of the - * current response. + * **WebRTC/SIP Only:** Emit to cut off the current audio response. This will trigger the + * server to stop generating audio and emit a `output_audio_buffer.cleared` event. This + * event should be preceded by a `response.cancel` client event to stop the generation of + * the current response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ fun visitOutputAudioBufferClear(outputAudioBufferClear: OutputAudioBufferClearEvent): T diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeServerEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeServerEvent.kt index 517884ca..9f5c943d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeServerEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeServerEvent.kt @@ -49,6 +49,7 @@ private constructor( private val error: RealtimeErrorEvent? = null, private val inputAudioBufferCleared: InputAudioBufferClearedEvent? = null, private val inputAudioBufferCommitted: InputAudioBufferCommittedEvent? = null, + private val inputAudioBufferDtmfEventReceived: InputAudioBufferDtmfEventReceivedEvent? = null, private val inputAudioBufferSpeechStarted: InputAudioBufferSpeechStartedEvent? = null, private val inputAudioBufferSpeechStopped: InputAudioBufferSpeechStoppedEvent? = null, private val rateLimitsUpdated: RateLimitsUpdatedEvent? = null, @@ -187,6 +188,15 @@ private constructor( fun inputAudioBufferCommitted(): Optional = Optional.ofNullable(inputAudioBufferCommitted) + /** + * **SIP Only:** Returned when an DTMF event is received. A DTMF event is a message that + * represents a telephone keypad press (0–9, *, #, A–D). The `event` property is the keypad that + * the user press. The `received_at` is the UTC Unix Timestamp that the server received the + * event. + */ + fun inputAudioBufferDtmfEventReceived(): Optional = + Optional.ofNullable(inputAudioBufferDtmfEventReceived) + /** * Sent by the server when in `server_vad` mode to indicate that speech has been detected in the * audio buffer. This can happen any time audio is added to the buffer (unless speech is already @@ -318,8 +328,8 @@ private constructor( fun sessionUpdated(): Optional = Optional.ofNullable(sessionUpdated) /** - * **WebRTC Only:** Emitted when the server begins streaming audio to the client. This event is - * emitted after an audio content part has been added (`response.content_part.added`) to the + * **WebRTC/SIP Only:** Emitted when the server begins streaming audio to the client. This event + * is emitted after an audio content part has been added (`response.content_part.added`) to the * response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ @@ -327,7 +337,7 @@ private constructor( Optional.ofNullable(outputAudioBufferStarted) /** - * **WebRTC Only:** Emitted when the output audio buffer has been completely drained on the + * **WebRTC/SIP Only:** Emitted when the output audio buffer has been completely drained on the * server, and no more audio is forthcoming. This event is emitted after the full response data * has been sent to the client (`response.done`). * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). @@ -336,10 +346,10 @@ private constructor( Optional.ofNullable(outputAudioBufferStopped) /** - * **WebRTC Only:** Emitted when the output audio buffer is cleared. This happens either in VAD - * mode when the user has interrupted (`input_audio_buffer.speech_started`), or when the client - * has emitted the `output_audio_buffer.clear` event to manually cut off the current audio - * response. + * **WebRTC/SIP Only:** Emitted when the output audio buffer is cleared. This happens either in + * VAD mode when the user has interrupted (`input_audio_buffer.speech_started`), or when the + * client has emitted the `output_audio_buffer.clear` event to manually cut off the current + * audio response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ fun outputAudioBufferCleared(): Optional = @@ -450,6 +460,8 @@ private constructor( fun isInputAudioBufferCommitted(): Boolean = inputAudioBufferCommitted != null + fun isInputAudioBufferDtmfEventReceived(): Boolean = inputAudioBufferDtmfEventReceived != null + fun isInputAudioBufferSpeechStarted(): Boolean = inputAudioBufferSpeechStarted != null fun isInputAudioBufferSpeechStopped(): Boolean = inputAudioBufferSpeechStopped != null @@ -624,6 +636,15 @@ private constructor( fun asInputAudioBufferCommitted(): InputAudioBufferCommittedEvent = inputAudioBufferCommitted.getOrThrow("inputAudioBufferCommitted") + /** + * **SIP Only:** Returned when an DTMF event is received. A DTMF event is a message that + * represents a telephone keypad press (0–9, *, #, A–D). The `event` property is the keypad that + * the user press. The `received_at` is the UTC Unix Timestamp that the server received the + * event. + */ + fun asInputAudioBufferDtmfEventReceived(): InputAudioBufferDtmfEventReceivedEvent = + inputAudioBufferDtmfEventReceived.getOrThrow("inputAudioBufferDtmfEventReceived") + /** * Sent by the server when in `server_vad` mode to indicate that speech has been detected in the * audio buffer. This can happen any time audio is added to the buffer (unless speech is already @@ -755,8 +776,8 @@ private constructor( fun asSessionUpdated(): SessionUpdatedEvent = sessionUpdated.getOrThrow("sessionUpdated") /** - * **WebRTC Only:** Emitted when the server begins streaming audio to the client. This event is - * emitted after an audio content part has been added (`response.content_part.added`) to the + * **WebRTC/SIP Only:** Emitted when the server begins streaming audio to the client. This event + * is emitted after an audio content part has been added (`response.content_part.added`) to the * response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ @@ -764,7 +785,7 @@ private constructor( outputAudioBufferStarted.getOrThrow("outputAudioBufferStarted") /** - * **WebRTC Only:** Emitted when the output audio buffer has been completely drained on the + * **WebRTC/SIP Only:** Emitted when the output audio buffer has been completely drained on the * server, and no more audio is forthcoming. This event is emitted after the full response data * has been sent to the client (`response.done`). * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). @@ -773,10 +794,10 @@ private constructor( outputAudioBufferStopped.getOrThrow("outputAudioBufferStopped") /** - * **WebRTC Only:** Emitted when the output audio buffer is cleared. This happens either in VAD - * mode when the user has interrupted (`input_audio_buffer.speech_started`), or when the client - * has emitted the `output_audio_buffer.clear` event to manually cut off the current audio - * response. + * **WebRTC/SIP Only:** Emitted when the output audio buffer is cleared. This happens either in + * VAD mode when the user has interrupted (`input_audio_buffer.speech_started`), or when the + * client has emitted the `output_audio_buffer.clear` event to manually cut off the current + * audio response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ fun asOutputAudioBufferCleared(): OutputAudioBufferCleared = @@ -895,6 +916,8 @@ private constructor( visitor.visitInputAudioBufferCleared(inputAudioBufferCleared) inputAudioBufferCommitted != null -> visitor.visitInputAudioBufferCommitted(inputAudioBufferCommitted) + inputAudioBufferDtmfEventReceived != null -> + visitor.visitInputAudioBufferDtmfEventReceived(inputAudioBufferDtmfEventReceived) inputAudioBufferSpeechStarted != null -> visitor.visitInputAudioBufferSpeechStarted(inputAudioBufferSpeechStarted) inputAudioBufferSpeechStopped != null -> @@ -1037,6 +1060,12 @@ private constructor( inputAudioBufferCommitted.validate() } + override fun visitInputAudioBufferDtmfEventReceived( + inputAudioBufferDtmfEventReceived: InputAudioBufferDtmfEventReceivedEvent + ) { + inputAudioBufferDtmfEventReceived.validate() + } + override fun visitInputAudioBufferSpeechStarted( inputAudioBufferSpeechStarted: InputAudioBufferSpeechStartedEvent ) { @@ -1294,6 +1323,10 @@ private constructor( inputAudioBufferCommitted: InputAudioBufferCommittedEvent ) = inputAudioBufferCommitted.validity() + override fun visitInputAudioBufferDtmfEventReceived( + inputAudioBufferDtmfEventReceived: InputAudioBufferDtmfEventReceivedEvent + ) = inputAudioBufferDtmfEventReceived.validity() + override fun visitInputAudioBufferSpeechStarted( inputAudioBufferSpeechStarted: InputAudioBufferSpeechStartedEvent ) = inputAudioBufferSpeechStarted.validity() @@ -1448,6 +1481,7 @@ private constructor( error == other.error && inputAudioBufferCleared == other.inputAudioBufferCleared && inputAudioBufferCommitted == other.inputAudioBufferCommitted && + inputAudioBufferDtmfEventReceived == other.inputAudioBufferDtmfEventReceived && inputAudioBufferSpeechStarted == other.inputAudioBufferSpeechStarted && inputAudioBufferSpeechStopped == other.inputAudioBufferSpeechStopped && rateLimitsUpdated == other.rateLimitsUpdated && @@ -1498,6 +1532,7 @@ private constructor( error, inputAudioBufferCleared, inputAudioBufferCommitted, + inputAudioBufferDtmfEventReceived, inputAudioBufferSpeechStarted, inputAudioBufferSpeechStopped, rateLimitsUpdated, @@ -1557,6 +1592,8 @@ private constructor( "RealtimeServerEvent{inputAudioBufferCleared=$inputAudioBufferCleared}" inputAudioBufferCommitted != null -> "RealtimeServerEvent{inputAudioBufferCommitted=$inputAudioBufferCommitted}" + inputAudioBufferDtmfEventReceived != null -> + "RealtimeServerEvent{inputAudioBufferDtmfEventReceived=$inputAudioBufferDtmfEventReceived}" inputAudioBufferSpeechStarted != null -> "RealtimeServerEvent{inputAudioBufferSpeechStarted=$inputAudioBufferSpeechStarted}" inputAudioBufferSpeechStopped != null -> @@ -1750,6 +1787,20 @@ private constructor( fun ofInputAudioBufferCommitted(inputAudioBufferCommitted: InputAudioBufferCommittedEvent) = RealtimeServerEvent(inputAudioBufferCommitted = inputAudioBufferCommitted) + /** + * **SIP Only:** Returned when an DTMF event is received. A DTMF event is a message that + * represents a telephone keypad press (0–9, *, #, A–D). The `event` property is the keypad + * that the user press. The `received_at` is the UTC Unix Timestamp that the server received + * the event. + */ + @JvmStatic + fun ofInputAudioBufferDtmfEventReceived( + inputAudioBufferDtmfEventReceived: InputAudioBufferDtmfEventReceivedEvent + ) = + RealtimeServerEvent( + inputAudioBufferDtmfEventReceived = inputAudioBufferDtmfEventReceived + ) + /** * Sent by the server when in `server_vad` mode to indicate that speech has been detected in * the audio buffer. This can happen any time audio is added to the buffer (unless speech is @@ -1925,9 +1976,9 @@ private constructor( RealtimeServerEvent(sessionUpdated = sessionUpdated) /** - * **WebRTC Only:** Emitted when the server begins streaming audio to the client. This event - * is emitted after an audio content part has been added (`response.content_part.added`) to - * the response. + * **WebRTC/SIP Only:** Emitted when the server begins streaming audio to the client. This + * event is emitted after an audio content part has been added + * (`response.content_part.added`) to the response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ @JvmStatic @@ -1935,9 +1986,9 @@ private constructor( RealtimeServerEvent(outputAudioBufferStarted = outputAudioBufferStarted) /** - * **WebRTC Only:** Emitted when the output audio buffer has been completely drained on the - * server, and no more audio is forthcoming. This event is emitted after the full response - * data has been sent to the client (`response.done`). + * **WebRTC/SIP Only:** Emitted when the output audio buffer has been completely drained on + * the server, and no more audio is forthcoming. This event is emitted after the full + * response data has been sent to the client (`response.done`). * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ @JvmStatic @@ -1945,10 +1996,10 @@ private constructor( RealtimeServerEvent(outputAudioBufferStopped = outputAudioBufferStopped) /** - * **WebRTC Only:** Emitted when the output audio buffer is cleared. This happens either in - * VAD mode when the user has interrupted (`input_audio_buffer.speech_started`), or when the - * client has emitted the `output_audio_buffer.clear` event to manually cut off the current - * audio response. + * **WebRTC/SIP Only:** Emitted when the output audio buffer is cleared. This happens either + * in VAD mode when the user has interrupted (`input_audio_buffer.speech_started`), or when + * the client has emitted the `output_audio_buffer.clear` event to manually cut off the + * current audio response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ @JvmStatic @@ -2164,6 +2215,16 @@ private constructor( inputAudioBufferCommitted: InputAudioBufferCommittedEvent ): T + /** + * **SIP Only:** Returned when an DTMF event is received. A DTMF event is a message that + * represents a telephone keypad press (0–9, *, #, A–D). The `event` property is the keypad + * that the user press. The `received_at` is the UTC Unix Timestamp that the server received + * the event. + */ + fun visitInputAudioBufferDtmfEventReceived( + inputAudioBufferDtmfEventReceived: InputAudioBufferDtmfEventReceivedEvent + ): T + /** * Sent by the server when in `server_vad` mode to indicate that speech has been detected in * the audio buffer. This can happen any time audio is added to the buffer (unless speech is @@ -2297,26 +2358,26 @@ private constructor( fun visitSessionUpdated(sessionUpdated: SessionUpdatedEvent): T /** - * **WebRTC Only:** Emitted when the server begins streaming audio to the client. This event - * is emitted after an audio content part has been added (`response.content_part.added`) to - * the response. + * **WebRTC/SIP Only:** Emitted when the server begins streaming audio to the client. This + * event is emitted after an audio content part has been added + * (`response.content_part.added`) to the response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ fun visitOutputAudioBufferStarted(outputAudioBufferStarted: OutputAudioBufferStarted): T /** - * **WebRTC Only:** Emitted when the output audio buffer has been completely drained on the - * server, and no more audio is forthcoming. This event is emitted after the full response - * data has been sent to the client (`response.done`). + * **WebRTC/SIP Only:** Emitted when the output audio buffer has been completely drained on + * the server, and no more audio is forthcoming. This event is emitted after the full + * response data has been sent to the client (`response.done`). * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ fun visitOutputAudioBufferStopped(outputAudioBufferStopped: OutputAudioBufferStopped): T /** - * **WebRTC Only:** Emitted when the output audio buffer is cleared. This happens either in - * VAD mode when the user has interrupted (`input_audio_buffer.speech_started`), or when the - * client has emitted the `output_audio_buffer.clear` event to manually cut off the current - * audio response. + * **WebRTC/SIP Only:** Emitted when the output audio buffer is cleared. This happens either + * in VAD mode when the user has interrupted (`input_audio_buffer.speech_started`), or when + * the client has emitted the `output_audio_buffer.clear` event to manually cut off the + * current audio response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ fun visitOutputAudioBufferCleared(outputAudioBufferCleared: OutputAudioBufferCleared): T @@ -2499,6 +2560,18 @@ private constructor( ?.let { RealtimeServerEvent(inputAudioBufferCommitted = it, _json = json) } ?: RealtimeServerEvent(_json = json) } + "input_audio_buffer.dtmf_event_received" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + RealtimeServerEvent( + inputAudioBufferDtmfEventReceived = it, + _json = json, + ) + } ?: RealtimeServerEvent(_json = json) + } "input_audio_buffer.speech_started" -> { return tryDeserialize( node, @@ -2744,6 +2817,8 @@ private constructor( generator.writeObject(value.inputAudioBufferCleared) value.inputAudioBufferCommitted != null -> generator.writeObject(value.inputAudioBufferCommitted) + value.inputAudioBufferDtmfEventReceived != null -> + generator.writeObject(value.inputAudioBufferDtmfEventReceived) value.inputAudioBufferSpeechStarted != null -> generator.writeObject(value.inputAudioBufferSpeechStarted) value.inputAudioBufferSpeechStopped != null -> @@ -3164,8 +3239,8 @@ private constructor( } /** - * **WebRTC Only:** Emitted when the server begins streaming audio to the client. This event is - * emitted after an audio content part has been added (`response.content_part.added`) to the + * **WebRTC/SIP Only:** Emitted when the server begins streaming audio to the client. This event + * is emitted after an audio content part has been added (`response.content_part.added`) to the * response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ @@ -3413,7 +3488,7 @@ private constructor( } /** - * **WebRTC Only:** Emitted when the output audio buffer has been completely drained on the + * **WebRTC/SIP Only:** Emitted when the output audio buffer has been completely drained on the * server, and no more audio is forthcoming. This event is emitted after the full response data * has been sent to the client (`response.done`). * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). @@ -3662,10 +3737,10 @@ private constructor( } /** - * **WebRTC Only:** Emitted when the output audio buffer is cleared. This happens either in VAD - * mode when the user has interrupted (`input_audio_buffer.speech_started`), or when the client - * has emitted the `output_audio_buffer.clear` event to manually cut off the current audio - * response. + * **WebRTC/SIP Only:** Emitted when the output audio buffer is cleared. This happens either in + * VAD mode when the user has interrupted (`input_audio_buffer.speech_started`), or when the + * client has emitted the `output_audio_buffer.clear` event to manually cut off the current + * audio response. * [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc). */ class OutputAudioBufferCleared diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSession.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSession.kt index 877d611e..88bc0c56 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSession.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSession.kt @@ -2990,7 +2990,12 @@ private constructor( @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** - * Whether or not to automatically generate a response when a VAD stop event occurs. + * Whether or not to automatically generate a response when a VAD stop event occurs. If + * `interrupt_response` is set to `false` this may fail to create a response if the + * model is already responding. + * + * If both `create_response` and `interrupt_response` are set to `false`, the model will + * never respond automatically but VAD events will still be emitted. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -3016,8 +3021,13 @@ private constructor( fun idleTimeoutMs(): Optional = idleTimeoutMs.getOptional("idle_timeout_ms") /** - * Whether or not to automatically interrupt any ongoing response with output to the - * default conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. + * Whether or not to automatically interrupt (cancel) any ongoing response with output + * to the default conversation (i.e. `conversation` of `auto`) when a VAD start event + * occurs. If `true` then the response will be cancelled, otherwise it will continue + * until complete. + * + * If both `create_response` and `interrupt_response` are set to `false`, the model will + * never respond automatically but VAD events will still be emitted. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -3173,6 +3183,11 @@ private constructor( /** * Whether or not to automatically generate a response when a VAD stop event occurs. + * If `interrupt_response` is set to `false` this may fail to create a response if + * the model is already responding. + * + * If both `create_response` and `interrupt_response` are set to `false`, the model + * will never respond automatically but VAD events will still be emitted. */ fun createResponse(createResponse: Boolean) = createResponse(JsonField.of(createResponse)) @@ -3228,9 +3243,13 @@ private constructor( } /** - * Whether or not to automatically interrupt any ongoing response with output to the - * default conversation (i.e. `conversation` of `auto`) when a VAD start event - * occurs. + * Whether or not to automatically interrupt (cancel) any ongoing response with + * output to the default conversation (i.e. `conversation` of `auto`) when a VAD + * start event occurs. If `true` then the response will be cancelled, otherwise it + * will continue until complete. + * + * If both `create_response` and `interrupt_response` are set to `false`, the model + * will never respond automatically but VAD events will still be emitted. */ fun interruptResponse(interruptResponse: Boolean) = interruptResponse(JsonField.of(interruptResponse)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSessionCreateRequest.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSessionCreateRequest.kt index 8ce46c57..b6b530d8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSessionCreateRequest.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSessionCreateRequest.kt @@ -224,12 +224,16 @@ private constructor( * When the number of tokens in a conversation exceeds the model's input token limit, the * conversation be truncated, meaning messages (starting from the oldest) will not be included * in the model's context. A 32k context model with 4,096 max output tokens can only include - * 28,224 tokens in the context before truncation occurs. Clients can configure truncation - * behavior to truncate with a lower max token limit, which is an effective way to control token - * usage and cost. Truncation will reduce the number of cached tokens on the next turn (busting - * the cache), since messages are dropped from the beginning of the context. However, clients - * can also configure truncation to retain messages up to a fraction of the maximum context - * size, which will reduce the need for future truncations and thus improve the cache rate. + * 28,224 tokens in the context before truncation occurs. + * + * Clients can configure truncation behavior to truncate with a lower max token limit, which is + * an effective way to control token usage and cost. + * + * Truncation will reduce the number of cached tokens on the next turn (busting the cache), + * since messages are dropped from the beginning of the context. However, clients can also + * configure truncation to retain messages up to a fraction of the maximum context size, which + * will reduce the need for future truncations and thus improve the cache rate. + * * Truncation can be disabled entirely, which means the server will never truncate but would * instead return an error if the conversation exceeds the model's input token limit. * @@ -678,15 +682,18 @@ private constructor( * When the number of tokens in a conversation exceeds the model's input token limit, the * conversation be truncated, meaning messages (starting from the oldest) will not be * included in the model's context. A 32k context model with 4,096 max output tokens can - * only include 28,224 tokens in the context before truncation occurs. Clients can configure - * truncation behavior to truncate with a lower max token limit, which is an effective way - * to control token usage and cost. Truncation will reduce the number of cached tokens on - * the next turn (busting the cache), since messages are dropped from the beginning of the - * context. However, clients can also configure truncation to retain messages up to a - * fraction of the maximum context size, which will reduce the need for future truncations - * and thus improve the cache rate. Truncation can be disabled entirely, which means the - * server will never truncate but would instead return an error if the conversation exceeds - * the model's input token limit. + * only include 28,224 tokens in the context before truncation occurs. + * + * Clients can configure truncation behavior to truncate with a lower max token limit, which + * is an effective way to control token usage and cost. + * + * Truncation will reduce the number of cached tokens on the next turn (busting the cache), + * since messages are dropped from the beginning of the context. However, clients can also + * configure truncation to retain messages up to a fraction of the maximum context size, + * which will reduce the need for future truncations and thus improve the cache rate. + * + * Truncation can be disabled entirely, which means the server will never truncate but would + * instead return an error if the conversation exceeds the model's input token limit. */ fun truncation(truncation: RealtimeTruncation) = truncation(JsonField.of(truncation)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudioInputTurnDetection.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudioInputTurnDetection.kt index 218e0007..8969e7ea 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudioInputTurnDetection.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudioInputTurnDetection.kt @@ -331,7 +331,12 @@ private constructor( @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** - * Whether or not to automatically generate a response when a VAD stop event occurs. + * Whether or not to automatically generate a response when a VAD stop event occurs. If + * `interrupt_response` is set to `false` this may fail to create a response if the model is + * already responding. + * + * If both `create_response` and `interrupt_response` are set to `false`, the model will + * never respond automatically but VAD events will still be emitted. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -357,8 +362,12 @@ private constructor( fun idleTimeoutMs(): Optional = idleTimeoutMs.getOptional("idle_timeout_ms") /** - * Whether or not to automatically interrupt any ongoing response with output to the default - * conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. + * Whether or not to automatically interrupt (cancel) any ongoing response with output to + * the default conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. + * If `true` then the response will be cancelled, otherwise it will continue until complete. + * + * If both `create_response` and `interrupt_response` are set to `false`, the model will + * never respond automatically but VAD events will still be emitted. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -509,7 +518,14 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - /** Whether or not to automatically generate a response when a VAD stop event occurs. */ + /** + * Whether or not to automatically generate a response when a VAD stop event occurs. If + * `interrupt_response` is set to `false` this may fail to create a response if the + * model is already responding. + * + * If both `create_response` and `interrupt_response` are set to `false`, the model will + * never respond automatically but VAD events will still be emitted. + */ fun createResponse(createResponse: Boolean) = createResponse(JsonField.of(createResponse)) @@ -563,8 +579,13 @@ private constructor( } /** - * Whether or not to automatically interrupt any ongoing response with output to the - * default conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. + * Whether or not to automatically interrupt (cancel) any ongoing response with output + * to the default conversation (i.e. `conversation` of `auto`) when a VAD start event + * occurs. If `true` then the response will be cancelled, otherwise it will continue + * until complete. + * + * If both `create_response` and `interrupt_response` are set to `false`, the model will + * never respond automatically but VAD events will still be emitted. */ fun interruptResponse(interruptResponse: Boolean) = interruptResponse(JsonField.of(interruptResponse)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTruncation.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTruncation.kt index 42acf274..fb192b3e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTruncation.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTruncation.kt @@ -25,14 +25,18 @@ import java.util.Optional * When the number of tokens in a conversation exceeds the model's input token limit, the * conversation be truncated, meaning messages (starting from the oldest) will not be included in * the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 - * tokens in the context before truncation occurs. Clients can configure truncation behavior to - * truncate with a lower max token limit, which is an effective way to control token usage and cost. + * tokens in the context before truncation occurs. + * + * Clients can configure truncation behavior to truncate with a lower max token limit, which is an + * effective way to control token usage and cost. + * * Truncation will reduce the number of cached tokens on the next turn (busting the cache), since * messages are dropped from the beginning of the context. However, clients can also configure * truncation to retain messages up to a fraction of the maximum context size, which will reduce the - * need for future truncations and thus improve the cache rate. Truncation can be disabled entirely, - * which means the server will never truncate but would instead return an error if the conversation - * exceeds the model's input token limit. + * need for future truncations and thus improve the cache rate. + * + * Truncation can be disabled entirely, which means the server will never truncate but would instead + * return an error if the conversation exceeds the model's input token limit. */ @JsonDeserialize(using = RealtimeTruncation.Deserializer::class) @JsonSerialize(using = RealtimeTruncation.Serializer::class) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/clientsecrets/RealtimeSessionCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/clientsecrets/RealtimeSessionCreateResponse.kt index 01e4d2c4..181b2f86 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/clientsecrets/RealtimeSessionCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/clientsecrets/RealtimeSessionCreateResponse.kt @@ -240,12 +240,16 @@ private constructor( * When the number of tokens in a conversation exceeds the model's input token limit, the * conversation be truncated, meaning messages (starting from the oldest) will not be included * in the model's context. A 32k context model with 4,096 max output tokens can only include - * 28,224 tokens in the context before truncation occurs. Clients can configure truncation - * behavior to truncate with a lower max token limit, which is an effective way to control token - * usage and cost. Truncation will reduce the number of cached tokens on the next turn (busting - * the cache), since messages are dropped from the beginning of the context. However, clients - * can also configure truncation to retain messages up to a fraction of the maximum context - * size, which will reduce the need for future truncations and thus improve the cache rate. + * 28,224 tokens in the context before truncation occurs. + * + * Clients can configure truncation behavior to truncate with a lower max token limit, which is + * an effective way to control token usage and cost. + * + * Truncation will reduce the number of cached tokens on the next turn (busting the cache), + * since messages are dropped from the beginning of the context. However, clients can also + * configure truncation to retain messages up to a fraction of the maximum context size, which + * will reduce the need for future truncations and thus improve the cache rate. + * * Truncation can be disabled entirely, which means the server will never truncate but would * instead return an error if the conversation exceeds the model's input token limit. * @@ -691,15 +695,18 @@ private constructor( * When the number of tokens in a conversation exceeds the model's input token limit, the * conversation be truncated, meaning messages (starting from the oldest) will not be * included in the model's context. A 32k context model with 4,096 max output tokens can - * only include 28,224 tokens in the context before truncation occurs. Clients can configure - * truncation behavior to truncate with a lower max token limit, which is an effective way - * to control token usage and cost. Truncation will reduce the number of cached tokens on - * the next turn (busting the cache), since messages are dropped from the beginning of the - * context. However, clients can also configure truncation to retain messages up to a - * fraction of the maximum context size, which will reduce the need for future truncations - * and thus improve the cache rate. Truncation can be disabled entirely, which means the - * server will never truncate but would instead return an error if the conversation exceeds - * the model's input token limit. + * only include 28,224 tokens in the context before truncation occurs. + * + * Clients can configure truncation behavior to truncate with a lower max token limit, which + * is an effective way to control token usage and cost. + * + * Truncation will reduce the number of cached tokens on the next turn (busting the cache), + * since messages are dropped from the beginning of the context. However, clients can also + * configure truncation to retain messages up to a fraction of the maximum context size, + * which will reduce the need for future truncations and thus improve the cache rate. + * + * Truncation can be disabled entirely, which means the server will never truncate but would + * instead return an error if the conversation exceeds the model's input token limit. */ fun truncation(truncation: RealtimeTruncation) = truncation(JsonField.of(truncation)) @@ -1781,7 +1788,11 @@ private constructor( /** * Whether or not to automatically generate a response when a VAD stop event - * occurs. + * occurs. If `interrupt_response` is set to `false` this may fail to create a + * response if the model is already responding. + * + * If both `create_response` and `interrupt_response` are set to `false`, the + * model will never respond automatically but VAD events will still be emitted. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -1810,9 +1821,13 @@ private constructor( idleTimeoutMs.getOptional("idle_timeout_ms") /** - * Whether or not to automatically interrupt any ongoing response with output to - * the default conversation (i.e. `conversation` of `auto`) when a VAD start - * event occurs. + * Whether or not to automatically interrupt (cancel) any ongoing response with + * output to the default conversation (i.e. `conversation` of `auto`) when a VAD + * start event occurs. If `true` then the response will be cancelled, otherwise + * it will continue until complete. + * + * If both `create_response` and `interrupt_response` are set to `false`, the + * model will never respond automatically but VAD events will still be emitted. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -1972,7 +1987,12 @@ private constructor( /** * Whether or not to automatically generate a response when a VAD stop event - * occurs. + * occurs. If `interrupt_response` is set to `false` this may fail to create + * a response if the model is already responding. + * + * If both `create_response` and `interrupt_response` are set to `false`, + * the model will never respond automatically but VAD events will still be + * emitted. */ fun createResponse(createResponse: Boolean) = createResponse(JsonField.of(createResponse)) @@ -2033,9 +2053,14 @@ private constructor( } /** - * Whether or not to automatically interrupt any ongoing response with - * output to the default conversation (i.e. `conversation` of `auto`) when a - * VAD start event occurs. + * Whether or not to automatically interrupt (cancel) any ongoing response + * with output to the default conversation (i.e. `conversation` of `auto`) + * when a VAD start event occurs. If `true` then the response will be + * cancelled, otherwise it will continue until complete. + * + * If both `create_response` and `interrupt_response` are set to `false`, + * the model will never respond automatically but VAD events will still be + * emitted. */ fun interruptResponse(interruptResponse: Boolean) = interruptResponse(JsonField.of(interruptResponse)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/CompactedResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/CompactedResponse.kt new file mode 100644 index 00000000..fae2bd3b --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/CompactedResponse.kt @@ -0,0 +1,450 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.responses + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.checkKnown +import com.openai.core.checkRequired +import com.openai.core.toImmutable +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class CompactedResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val object_: JsonValue, + private val output: JsonField>, + private val usage: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("object") @ExcludeMissing object_: JsonValue = JsonMissing.of(), + @JsonProperty("output") + @ExcludeMissing + output: JsonField> = JsonMissing.of(), + @JsonProperty("usage") @ExcludeMissing usage: JsonField = JsonMissing.of(), + ) : this(id, createdAt, object_, output, usage, mutableMapOf()) + + /** + * The unique identifier for the compacted response. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Unix timestamp (in seconds) when the compacted conversation was created. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): Long = createdAt.getRequired("created_at") + + /** + * The object type. Always `response.compaction`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("response.compaction") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("object") @ExcludeMissing fun _object_(): JsonValue = object_ + + /** + * The compacted list of output items. This is a list of all user messages, followed by a single + * compaction item. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun output(): List = output.getRequired("output") + + /** + * Token accounting for the compaction pass, including cached, reasoning, and total tokens. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun usage(): ResponseUsage = usage.getRequired("usage") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [output]. + * + * Unlike [output], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("output") + @ExcludeMissing + fun _output(): JsonField> = output + + /** + * Returns the raw JSON value of [usage]. + * + * Unlike [usage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompactedResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .output() + * .usage() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompactedResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var object_: JsonValue = JsonValue.from("response.compaction") + private var output: JsonField>? = null + private var usage: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(compactedResponse: CompactedResponse) = apply { + id = compactedResponse.id + createdAt = compactedResponse.createdAt + object_ = compactedResponse.object_ + output = compactedResponse.output.map { it.toMutableList() } + usage = compactedResponse.usage + additionalProperties = compactedResponse.additionalProperties.toMutableMap() + } + + /** The unique identifier for the compacted response. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Unix timestamp (in seconds) when the compacted conversation was created. */ + fun createdAt(createdAt: Long) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("response.compaction") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun object_(object_: JsonValue) = apply { this.object_ = object_ } + + /** + * The compacted list of output items. This is a list of all user messages, followed by a + * single compaction item. + */ + fun output(output: List) = output(JsonField.of(output)) + + /** + * Sets [Builder.output] to an arbitrary JSON value. + * + * You should usually call [Builder.output] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun output(output: JsonField>) = apply { + this.output = output.map { it.toMutableList() } + } + + /** + * Adds a single [ResponseOutputItem] to [Builder.output]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOutput(output: ResponseOutputItem) = apply { + this.output = + (this.output ?: JsonField.of(mutableListOf())).also { + checkKnown("output", it).add(output) + } + } + + /** Alias for calling [addOutput] with `ResponseOutputItem.ofMessage(message)`. */ + fun addOutput(message: ResponseOutputMessage) = + addOutput(ResponseOutputItem.ofMessage(message)) + + /** + * Alias for calling [addOutput] with `ResponseOutputItem.ofFileSearchCall(fileSearchCall)`. + */ + fun addOutput(fileSearchCall: ResponseFileSearchToolCall) = + addOutput(ResponseOutputItem.ofFileSearchCall(fileSearchCall)) + + /** Alias for calling [addOutput] with `ResponseOutputItem.ofFunctionCall(functionCall)`. */ + fun addOutput(functionCall: ResponseFunctionToolCall) = + addOutput(ResponseOutputItem.ofFunctionCall(functionCall)) + + /** + * Alias for calling [addOutput] with `ResponseOutputItem.ofWebSearchCall(webSearchCall)`. + */ + fun addOutput(webSearchCall: ResponseFunctionWebSearch) = + addOutput(ResponseOutputItem.ofWebSearchCall(webSearchCall)) + + /** Alias for calling [addOutput] with `ResponseOutputItem.ofComputerCall(computerCall)`. */ + fun addOutput(computerCall: ResponseComputerToolCall) = + addOutput(ResponseOutputItem.ofComputerCall(computerCall)) + + /** Alias for calling [addOutput] with `ResponseOutputItem.ofReasoning(reasoning)`. */ + fun addOutput(reasoning: ResponseReasoningItem) = + addOutput(ResponseOutputItem.ofReasoning(reasoning)) + + /** Alias for calling [addOutput] with `ResponseOutputItem.ofCompaction(compaction)`. */ + fun addOutput(compaction: ResponseCompactionItem) = + addOutput(ResponseOutputItem.ofCompaction(compaction)) + + /** + * Alias for calling [addOutput] with + * `ResponseOutputItem.ofImageGenerationCall(imageGenerationCall)`. + */ + fun addOutput(imageGenerationCall: ResponseOutputItem.ImageGenerationCall) = + addOutput(ResponseOutputItem.ofImageGenerationCall(imageGenerationCall)) + + /** + * Alias for calling [addOutput] with + * `ResponseOutputItem.ofCodeInterpreterCall(codeInterpreterCall)`. + */ + fun addOutput(codeInterpreterCall: ResponseCodeInterpreterToolCall) = + addOutput(ResponseOutputItem.ofCodeInterpreterCall(codeInterpreterCall)) + + /** + * Alias for calling [addOutput] with `ResponseOutputItem.ofLocalShellCall(localShellCall)`. + */ + fun addOutput(localShellCall: ResponseOutputItem.LocalShellCall) = + addOutput(ResponseOutputItem.ofLocalShellCall(localShellCall)) + + /** Alias for calling [addOutput] with `ResponseOutputItem.ofShellCall(shellCall)`. */ + fun addOutput(shellCall: ResponseFunctionShellToolCall) = + addOutput(ResponseOutputItem.ofShellCall(shellCall)) + + /** + * Alias for calling [addOutput] with + * `ResponseOutputItem.ofShellCallOutput(shellCallOutput)`. + */ + fun addOutput(shellCallOutput: ResponseFunctionShellToolCallOutput) = + addOutput(ResponseOutputItem.ofShellCallOutput(shellCallOutput)) + + /** + * Alias for calling [addOutput] with `ResponseOutputItem.ofApplyPatchCall(applyPatchCall)`. + */ + fun addOutput(applyPatchCall: ResponseApplyPatchToolCall) = + addOutput(ResponseOutputItem.ofApplyPatchCall(applyPatchCall)) + + /** + * Alias for calling [addOutput] with + * `ResponseOutputItem.ofApplyPatchCallOutput(applyPatchCallOutput)`. + */ + fun addOutput(applyPatchCallOutput: ResponseApplyPatchToolCallOutput) = + addOutput(ResponseOutputItem.ofApplyPatchCallOutput(applyPatchCallOutput)) + + /** Alias for calling [addOutput] with `ResponseOutputItem.ofMcpCall(mcpCall)`. */ + fun addOutput(mcpCall: ResponseOutputItem.McpCall) = + addOutput(ResponseOutputItem.ofMcpCall(mcpCall)) + + /** Alias for calling [addOutput] with `ResponseOutputItem.ofMcpListTools(mcpListTools)`. */ + fun addOutput(mcpListTools: ResponseOutputItem.McpListTools) = + addOutput(ResponseOutputItem.ofMcpListTools(mcpListTools)) + + /** + * Alias for calling [addOutput] with + * `ResponseOutputItem.ofMcpApprovalRequest(mcpApprovalRequest)`. + */ + fun addOutput(mcpApprovalRequest: ResponseOutputItem.McpApprovalRequest) = + addOutput(ResponseOutputItem.ofMcpApprovalRequest(mcpApprovalRequest)) + + /** + * Alias for calling [addOutput] with `ResponseOutputItem.ofCustomToolCall(customToolCall)`. + */ + fun addOutput(customToolCall: ResponseCustomToolCall) = + addOutput(ResponseOutputItem.ofCustomToolCall(customToolCall)) + + /** + * Token accounting for the compaction pass, including cached, reasoning, and total tokens. + */ + fun usage(usage: ResponseUsage) = usage(JsonField.of(usage)) + + /** + * Sets [Builder.usage] to an arbitrary JSON value. + * + * You should usually call [Builder.usage] with a well-typed [ResponseUsage] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun usage(usage: JsonField) = apply { this.usage = usage } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompactedResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .output() + * .usage() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompactedResponse = + CompactedResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + object_, + checkRequired("output", output).map { it.toImmutable() }, + checkRequired("usage", usage), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompactedResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + _object_().let { + if (it != JsonValue.from("response.compaction")) { + throw OpenAIInvalidDataException("'object_' is invalid, received $it") + } + } + output().forEach { it.validate() } + usage().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + object_.let { if (it == JsonValue.from("response.compaction")) 1 else 0 } + + (output.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (usage.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompactedResponse && + id == other.id && + createdAt == other.createdAt && + object_ == other.object_ && + output == other.output && + usage == other.usage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, object_, output, usage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompactedResponse{id=$id, createdAt=$createdAt, object_=$object_, output=$output, usage=$usage, additionalProperties=$additionalProperties}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt index b4d19f09..aa63a0fa 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt @@ -1089,6 +1089,10 @@ private constructor( fun addOutput(reasoning: ResponseReasoningItem) = addOutput(ResponseOutputItem.ofReasoning(reasoning)) + /** Alias for calling [addOutput] with `ResponseOutputItem.ofCompaction(compaction)`. */ + fun addOutput(compaction: ResponseCompactionItem) = + addOutput(ResponseOutputItem.ofCompaction(compaction)) + /** * Alias for calling [addOutput] with * `ResponseOutputItem.ofImageGenerationCall(imageGenerationCall)`. @@ -2578,7 +2582,7 @@ private constructor( /** Forces the model to call the apply_patch tool when executing a tool call. */ fun applyPatch(): Optional = Optional.ofNullable(applyPatch) - /** Forces the model to call the function shell tool when a tool call is required. */ + /** Forces the model to call the shell tool when a tool call is required. */ fun shell(): Optional = Optional.ofNullable(shell) fun isOptions(): Boolean = options != null @@ -2630,7 +2634,7 @@ private constructor( /** Forces the model to call the apply_patch tool when executing a tool call. */ fun asApplyPatch(): ToolChoiceApplyPatch = applyPatch.getOrThrow("applyPatch") - /** Forces the model to call the function shell tool when a tool call is required. */ + /** Forces the model to call the shell tool when a tool call is required. */ fun asShell(): ToolChoiceShell = shell.getOrThrow("shell") fun _json(): Optional = Optional.ofNullable(_json) @@ -2804,7 +2808,7 @@ private constructor( @JvmStatic fun ofApplyPatch(applyPatch: ToolChoiceApplyPatch) = ToolChoice(applyPatch = applyPatch) - /** Forces the model to call the function shell tool when a tool call is required. */ + /** Forces the model to call the shell tool when a tool call is required. */ @JvmStatic fun ofShell(shell: ToolChoiceShell) = ToolChoice(shell = shell) } @@ -2848,7 +2852,7 @@ private constructor( /** Forces the model to call the apply_patch tool when executing a tool call. */ fun visitApplyPatch(applyPatch: ToolChoiceApplyPatch): T - /** Forces the model to call the function shell tool when a tool call is required. */ + /** Forces the model to call the shell tool when a tool call is required. */ fun visitShell(shell: ToolChoiceShell): T /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactParams.kt new file mode 100644 index 00000000..f042314c --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactParams.kt @@ -0,0 +1,1526 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.responses + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.BaseDeserializer +import com.openai.core.BaseSerializer +import com.openai.core.Enum +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.Params +import com.openai.core.allMaxBy +import com.openai.core.getOrThrow +import com.openai.core.http.Headers +import com.openai.core.http.QueryParams +import com.openai.core.toImmutable +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Compact conversation */ +class ResponseCompactParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Text, image, or file inputs to the model, used to generate a response + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun input(): Optional = body.input() + + /** + * A system (or developer) message inserted into the model's context. When used along with + * `previous_response_id`, the instructions from a previous response will not be carried over to + * the next response. This makes it simple to swap out system (or developer) messages in new + * responses. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun instructions(): Optional = body.instructions() + + /** + * Model ID used to generate the response, like `gpt-5` or `o3`. OpenAI offers a wide range of + * models with different capabilities, performance characteristics, and price points. Refer to + * the [model guide](https://platform.openai.com/docs/models) to browse and compare available + * models. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun model(): Optional = body.model() + + /** + * The unique ID of the previous response to the model. Use this to create multi-turn + * conversations. Learn more about + * [conversation state](https://platform.openai.com/docs/guides/conversation-state). Cannot be + * used in conjunction with `conversation`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun previousResponseId(): Optional = body.previousResponseId() + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _input(): JsonField = body._input() + + /** + * Returns the raw JSON value of [instructions]. + * + * Unlike [instructions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _instructions(): JsonField = body._instructions() + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _model(): JsonField = body._model() + + /** + * Returns the raw JSON value of [previousResponseId]. + * + * Unlike [previousResponseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _previousResponseId(): JsonField = body._previousResponseId() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ResponseCompactParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ResponseCompactParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResponseCompactParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(responseCompactParams: ResponseCompactParams) = apply { + body = responseCompactParams.body.toBuilder() + additionalHeaders = responseCompactParams.additionalHeaders.toBuilder() + additionalQueryParams = responseCompactParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [input] + * - [instructions] + * - [model] + * - [previousResponseId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Text, image, or file inputs to the model, used to generate a response */ + fun input(input: Input?) = apply { body.input(input) } + + /** Alias for calling [Builder.input] with `input.orElse(null)`. */ + fun input(input: Optional) = input(input.getOrNull()) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [Input] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun input(input: JsonField) = apply { body.input(input) } + + /** Alias for calling [input] with `Input.ofString(string)`. */ + fun input(string: String) = apply { body.input(string) } + + /** Alias for calling [input] with `Input.ofResponseInputItems(responseInputItems)`. */ + fun inputOfResponseInputItems(responseInputItems: List) = apply { + body.inputOfResponseInputItems(responseInputItems) + } + + /** + * A system (or developer) message inserted into the model's context. When used along with + * `previous_response_id`, the instructions from a previous response will not be carried + * over to the next response. This makes it simple to swap out system (or developer) + * messages in new responses. + */ + fun instructions(instructions: String?) = apply { body.instructions(instructions) } + + /** Alias for calling [Builder.instructions] with `instructions.orElse(null)`. */ + fun instructions(instructions: Optional) = instructions(instructions.getOrNull()) + + /** + * Sets [Builder.instructions] to an arbitrary JSON value. + * + * You should usually call [Builder.instructions] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun instructions(instructions: JsonField) = apply { + body.instructions(instructions) + } + + /** + * Model ID used to generate the response, like `gpt-5` or `o3`. OpenAI offers a wide range + * of models with different capabilities, performance characteristics, and price points. + * Refer to the [model guide](https://platform.openai.com/docs/models) to browse and compare + * available models. + */ + fun model(model: Model?) = apply { body.model(model) } + + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ + fun model(model: Optional) = model(model.getOrNull()) + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [Model] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun model(model: JsonField) = apply { body.model(model) } + + /** + * Sets [model] to an arbitrary [String]. + * + * You should usually call [model] with a well-typed [Model] constant instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun model(value: String) = apply { body.model(value) } + + /** + * The unique ID of the previous response to the model. Use this to create multi-turn + * conversations. Learn more about + * [conversation state](https://platform.openai.com/docs/guides/conversation-state). Cannot + * be used in conjunction with `conversation`. + */ + fun previousResponseId(previousResponseId: String?) = apply { + body.previousResponseId(previousResponseId) + } + + /** + * Alias for calling [Builder.previousResponseId] with `previousResponseId.orElse(null)`. + */ + fun previousResponseId(previousResponseId: Optional) = + previousResponseId(previousResponseId.getOrNull()) + + /** + * Sets [Builder.previousResponseId] to an arbitrary JSON value. + * + * You should usually call [Builder.previousResponseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun previousResponseId(previousResponseId: JsonField) = apply { + body.previousResponseId(previousResponseId) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ResponseCompactParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ResponseCompactParams = + ResponseCompactParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val input: JsonField, + private val instructions: JsonField, + private val model: JsonField, + private val previousResponseId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("input") @ExcludeMissing input: JsonField = JsonMissing.of(), + @JsonProperty("instructions") + @ExcludeMissing + instructions: JsonField = JsonMissing.of(), + @JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(), + @JsonProperty("previous_response_id") + @ExcludeMissing + previousResponseId: JsonField = JsonMissing.of(), + ) : this(input, instructions, model, previousResponseId, mutableMapOf()) + + /** + * Text, image, or file inputs to the model, used to generate a response + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun input(): Optional = input.getOptional("input") + + /** + * A system (or developer) message inserted into the model's context. When used along with + * `previous_response_id`, the instructions from a previous response will not be carried + * over to the next response. This makes it simple to swap out system (or developer) + * messages in new responses. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun instructions(): Optional = instructions.getOptional("instructions") + + /** + * Model ID used to generate the response, like `gpt-5` or `o3`. OpenAI offers a wide range + * of models with different capabilities, performance characteristics, and price points. + * Refer to the [model guide](https://platform.openai.com/docs/models) to browse and compare + * available models. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun model(): Optional = model.getOptional("model") + + /** + * The unique ID of the previous response to the model. Use this to create multi-turn + * conversations. Learn more about + * [conversation state](https://platform.openai.com/docs/guides/conversation-state). Cannot + * be used in conjunction with `conversation`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun previousResponseId(): Optional = + previousResponseId.getOptional("previous_response_id") + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [instructions]. + * + * Unlike [instructions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("instructions") + @ExcludeMissing + fun _instructions(): JsonField = instructions + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + + /** + * Returns the raw JSON value of [previousResponseId]. + * + * Unlike [previousResponseId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previous_response_id") + @ExcludeMissing + fun _previousResponseId(): JsonField = previousResponseId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var input: JsonField = JsonMissing.of() + private var instructions: JsonField = JsonMissing.of() + private var model: JsonField = JsonMissing.of() + private var previousResponseId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + input = body.input + instructions = body.instructions + model = body.model + previousResponseId = body.previousResponseId + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Text, image, or file inputs to the model, used to generate a response */ + fun input(input: Input?) = input(JsonField.ofNullable(input)) + + /** Alias for calling [Builder.input] with `input.orElse(null)`. */ + fun input(input: Optional) = input(input.getOrNull()) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [Input] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** Alias for calling [input] with `Input.ofString(string)`. */ + fun input(string: String) = input(Input.ofString(string)) + + /** Alias for calling [input] with `Input.ofResponseInputItems(responseInputItems)`. */ + fun inputOfResponseInputItems(responseInputItems: List) = + input(Input.ofResponseInputItems(responseInputItems)) + + /** + * A system (or developer) message inserted into the model's context. When used along + * with `previous_response_id`, the instructions from a previous response will not be + * carried over to the next response. This makes it simple to swap out system (or + * developer) messages in new responses. + */ + fun instructions(instructions: String?) = + instructions(JsonField.ofNullable(instructions)) + + /** Alias for calling [Builder.instructions] with `instructions.orElse(null)`. */ + fun instructions(instructions: Optional) = + instructions(instructions.getOrNull()) + + /** + * Sets [Builder.instructions] to an arbitrary JSON value. + * + * You should usually call [Builder.instructions] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun instructions(instructions: JsonField) = apply { + this.instructions = instructions + } + + /** + * Model ID used to generate the response, like `gpt-5` or `o3`. OpenAI offers a wide + * range of models with different capabilities, performance characteristics, and price + * points. Refer to the [model guide](https://platform.openai.com/docs/models) to browse + * and compare available models. + */ + fun model(model: Model?) = model(JsonField.ofNullable(model)) + + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ + fun model(model: Optional) = model(model.getOrNull()) + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [Model] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun model(model: JsonField) = apply { this.model = model } + + /** + * Sets [model] to an arbitrary [String]. + * + * You should usually call [model] with a well-typed [Model] constant instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun model(value: String) = model(Model.of(value)) + + /** + * The unique ID of the previous response to the model. Use this to create multi-turn + * conversations. Learn more about + * [conversation state](https://platform.openai.com/docs/guides/conversation-state). + * Cannot be used in conjunction with `conversation`. + */ + fun previousResponseId(previousResponseId: String?) = + previousResponseId(JsonField.ofNullable(previousResponseId)) + + /** + * Alias for calling [Builder.previousResponseId] with + * `previousResponseId.orElse(null)`. + */ + fun previousResponseId(previousResponseId: Optional) = + previousResponseId(previousResponseId.getOrNull()) + + /** + * Sets [Builder.previousResponseId] to an arbitrary JSON value. + * + * You should usually call [Builder.previousResponseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun previousResponseId(previousResponseId: JsonField) = apply { + this.previousResponseId = previousResponseId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + input, + instructions, + model, + previousResponseId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + input().ifPresent { it.validate() } + instructions() + model() + previousResponseId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (input.asKnown().getOrNull()?.validity() ?: 0) + + (if (instructions.asKnown().isPresent) 1 else 0) + + (if (model.asKnown().isPresent) 1 else 0) + + (if (previousResponseId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + input == other.input && + instructions == other.instructions && + model == other.model && + previousResponseId == other.previousResponseId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(input, instructions, model, previousResponseId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{input=$input, instructions=$instructions, model=$model, previousResponseId=$previousResponseId, additionalProperties=$additionalProperties}" + } + + /** Text, image, or file inputs to the model, used to generate a response */ + @JsonDeserialize(using = Input.Deserializer::class) + @JsonSerialize(using = Input.Serializer::class) + class Input + private constructor( + private val string: String? = null, + private val responseInputItems: List? = null, + private val _json: JsonValue? = null, + ) { + + /** A text input to the model, equivalent to a text input with the `user` role. */ + fun string(): Optional = Optional.ofNullable(string) + + fun responseInputItems(): Optional> = + Optional.ofNullable(responseInputItems) + + fun isString(): Boolean = string != null + + fun isResponseInputItems(): Boolean = responseInputItems != null + + /** A text input to the model, equivalent to a text input with the `user` role. */ + fun asString(): String = string.getOrThrow("string") + + fun asResponseInputItems(): List = + responseInputItems.getOrThrow("responseInputItems") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + responseInputItems != null -> visitor.visitResponseInputItems(responseInputItems) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Input = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitResponseInputItems( + responseInputItems: List + ) { + responseInputItems.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitResponseInputItems( + responseInputItems: List + ) = responseInputItems.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Input && + string == other.string && + responseInputItems == other.responseInputItems + } + + override fun hashCode(): Int = Objects.hash(string, responseInputItems) + + override fun toString(): String = + when { + string != null -> "Input{string=$string}" + responseInputItems != null -> "Input{responseInputItems=$responseInputItems}" + _json != null -> "Input{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Input") + } + + companion object { + + /** A text input to the model, equivalent to a text input with the `user` role. */ + @JvmStatic fun ofString(string: String) = Input(string = string) + + @JvmStatic + fun ofResponseInputItems(responseInputItems: List) = + Input(responseInputItems = responseInputItems.toImmutable()) + } + + /** An interface that defines how to map each variant of [Input] to a value of type [T]. */ + interface Visitor { + + /** A text input to the model, equivalent to a text input with the `user` role. */ + fun visitString(string: String): T + + fun visitResponseInputItems(responseInputItems: List): T + + /** + * Maps an unknown variant of [Input] to a value of type [T]. + * + * An instance of [Input] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException("Unknown Input: $json") + } + } + + internal class Deserializer : BaseDeserializer(Input::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Input { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Input(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Input(responseInputItems = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Input(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Input::class) { + + override fun serialize( + value: Input, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.responseInputItems != null -> + generator.writeObject(value.responseInputItems) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Input") + } + } + } + } + + /** + * Model ID used to generate the response, like `gpt-5` or `o3`. OpenAI offers a wide range of + * models with different capabilities, performance characteristics, and price points. Refer to + * the [model guide](https://platform.openai.com/docs/models) to browse and compare available + * models. + */ + class Model @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GPT_5_1 = of("gpt-5.1") + + @JvmField val GPT_5_1_2025_11_13 = of("gpt-5.1-2025-11-13") + + @JvmField val GPT_5_1_CODEX = of("gpt-5.1-codex") + + @JvmField val GPT_5_1_MINI = of("gpt-5.1-mini") + + @JvmField val GPT_5_1_CHAT_LATEST = of("gpt-5.1-chat-latest") + + @JvmField val GPT_5 = of("gpt-5") + + @JvmField val GPT_5_MINI = of("gpt-5-mini") + + @JvmField val GPT_5_NANO = of("gpt-5-nano") + + @JvmField val GPT_5_2025_08_07 = of("gpt-5-2025-08-07") + + @JvmField val GPT_5_MINI_2025_08_07 = of("gpt-5-mini-2025-08-07") + + @JvmField val GPT_5_NANO_2025_08_07 = of("gpt-5-nano-2025-08-07") + + @JvmField val GPT_5_CHAT_LATEST = of("gpt-5-chat-latest") + + @JvmField val GPT_4_1 = of("gpt-4.1") + + @JvmField val GPT_4_1_MINI = of("gpt-4.1-mini") + + @JvmField val GPT_4_1_NANO = of("gpt-4.1-nano") + + @JvmField val GPT_4_1_2025_04_14 = of("gpt-4.1-2025-04-14") + + @JvmField val GPT_4_1_MINI_2025_04_14 = of("gpt-4.1-mini-2025-04-14") + + @JvmField val GPT_4_1_NANO_2025_04_14 = of("gpt-4.1-nano-2025-04-14") + + @JvmField val O4_MINI = of("o4-mini") + + @JvmField val O4_MINI_2025_04_16 = of("o4-mini-2025-04-16") + + @JvmField val O3 = of("o3") + + @JvmField val O3_2025_04_16 = of("o3-2025-04-16") + + @JvmField val O3_MINI = of("o3-mini") + + @JvmField val O3_MINI_2025_01_31 = of("o3-mini-2025-01-31") + + @JvmField val O1 = of("o1") + + @JvmField val O1_2024_12_17 = of("o1-2024-12-17") + + @JvmField val O1_PREVIEW = of("o1-preview") + + @JvmField val O1_PREVIEW_2024_09_12 = of("o1-preview-2024-09-12") + + @JvmField val O1_MINI = of("o1-mini") + + @JvmField val O1_MINI_2024_09_12 = of("o1-mini-2024-09-12") + + @JvmField val GPT_4O = of("gpt-4o") + + @JvmField val GPT_4O_2024_11_20 = of("gpt-4o-2024-11-20") + + @JvmField val GPT_4O_2024_08_06 = of("gpt-4o-2024-08-06") + + @JvmField val GPT_4O_2024_05_13 = of("gpt-4o-2024-05-13") + + @JvmField val GPT_4O_AUDIO_PREVIEW = of("gpt-4o-audio-preview") + + @JvmField val GPT_4O_AUDIO_PREVIEW_2024_10_01 = of("gpt-4o-audio-preview-2024-10-01") + + @JvmField val GPT_4O_AUDIO_PREVIEW_2024_12_17 = of("gpt-4o-audio-preview-2024-12-17") + + @JvmField val GPT_4O_AUDIO_PREVIEW_2025_06_03 = of("gpt-4o-audio-preview-2025-06-03") + + @JvmField val GPT_4O_MINI_AUDIO_PREVIEW = of("gpt-4o-mini-audio-preview") + + @JvmField + val GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17 = of("gpt-4o-mini-audio-preview-2024-12-17") + + @JvmField val GPT_4O_SEARCH_PREVIEW = of("gpt-4o-search-preview") + + @JvmField val GPT_4O_MINI_SEARCH_PREVIEW = of("gpt-4o-mini-search-preview") + + @JvmField val GPT_4O_SEARCH_PREVIEW_2025_03_11 = of("gpt-4o-search-preview-2025-03-11") + + @JvmField + val GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11 = of("gpt-4o-mini-search-preview-2025-03-11") + + @JvmField val CHATGPT_4O_LATEST = of("chatgpt-4o-latest") + + @JvmField val CODEX_MINI_LATEST = of("codex-mini-latest") + + @JvmField val GPT_4O_MINI = of("gpt-4o-mini") + + @JvmField val GPT_4O_MINI_2024_07_18 = of("gpt-4o-mini-2024-07-18") + + @JvmField val GPT_4_TURBO = of("gpt-4-turbo") + + @JvmField val GPT_4_TURBO_2024_04_09 = of("gpt-4-turbo-2024-04-09") + + @JvmField val GPT_4_0125_PREVIEW = of("gpt-4-0125-preview") + + @JvmField val GPT_4_TURBO_PREVIEW = of("gpt-4-turbo-preview") + + @JvmField val GPT_4_1106_PREVIEW = of("gpt-4-1106-preview") + + @JvmField val GPT_4_VISION_PREVIEW = of("gpt-4-vision-preview") + + @JvmField val GPT_4 = of("gpt-4") + + @JvmField val GPT_4_0314 = of("gpt-4-0314") + + @JvmField val GPT_4_0613 = of("gpt-4-0613") + + @JvmField val GPT_4_32K = of("gpt-4-32k") + + @JvmField val GPT_4_32K_0314 = of("gpt-4-32k-0314") + + @JvmField val GPT_4_32K_0613 = of("gpt-4-32k-0613") + + @JvmField val GPT_3_5_TURBO = of("gpt-3.5-turbo") + + @JvmField val GPT_3_5_TURBO_16K = of("gpt-3.5-turbo-16k") + + @JvmField val GPT_3_5_TURBO_0301 = of("gpt-3.5-turbo-0301") + + @JvmField val GPT_3_5_TURBO_0613 = of("gpt-3.5-turbo-0613") + + @JvmField val GPT_3_5_TURBO_1106 = of("gpt-3.5-turbo-1106") + + @JvmField val GPT_3_5_TURBO_0125 = of("gpt-3.5-turbo-0125") + + @JvmField val GPT_3_5_TURBO_16K_0613 = of("gpt-3.5-turbo-16k-0613") + + @JvmField val O1_PRO = of("o1-pro") + + @JvmField val O1_PRO_2025_03_19 = of("o1-pro-2025-03-19") + + @JvmField val O3_PRO = of("o3-pro") + + @JvmField val O3_PRO_2025_06_10 = of("o3-pro-2025-06-10") + + @JvmField val O3_DEEP_RESEARCH = of("o3-deep-research") + + @JvmField val O3_DEEP_RESEARCH_2025_06_26 = of("o3-deep-research-2025-06-26") + + @JvmField val O4_MINI_DEEP_RESEARCH = of("o4-mini-deep-research") + + @JvmField val O4_MINI_DEEP_RESEARCH_2025_06_26 = of("o4-mini-deep-research-2025-06-26") + + @JvmField val COMPUTER_USE_PREVIEW = of("computer-use-preview") + + @JvmField val COMPUTER_USE_PREVIEW_2025_03_11 = of("computer-use-preview-2025-03-11") + + @JvmField val GPT_5_CODEX = of("gpt-5-codex") + + @JvmField val GPT_5_PRO = of("gpt-5-pro") + + @JvmField val GPT_5_PRO_2025_10_06 = of("gpt-5-pro-2025-10-06") + + @JvmField val GPT_5_1_CODEX_MAX = of("gpt-5.1-codex-max") + + @JvmStatic fun of(value: String) = Model(JsonField.of(value)) + } + + /** An enum containing [Model]'s known values. */ + enum class Known { + GPT_5_1, + GPT_5_1_2025_11_13, + GPT_5_1_CODEX, + GPT_5_1_MINI, + GPT_5_1_CHAT_LATEST, + GPT_5, + GPT_5_MINI, + GPT_5_NANO, + GPT_5_2025_08_07, + GPT_5_MINI_2025_08_07, + GPT_5_NANO_2025_08_07, + GPT_5_CHAT_LATEST, + GPT_4_1, + GPT_4_1_MINI, + GPT_4_1_NANO, + GPT_4_1_2025_04_14, + GPT_4_1_MINI_2025_04_14, + GPT_4_1_NANO_2025_04_14, + O4_MINI, + O4_MINI_2025_04_16, + O3, + O3_2025_04_16, + O3_MINI, + O3_MINI_2025_01_31, + O1, + O1_2024_12_17, + O1_PREVIEW, + O1_PREVIEW_2024_09_12, + O1_MINI, + O1_MINI_2024_09_12, + GPT_4O, + GPT_4O_2024_11_20, + GPT_4O_2024_08_06, + GPT_4O_2024_05_13, + GPT_4O_AUDIO_PREVIEW, + GPT_4O_AUDIO_PREVIEW_2024_10_01, + GPT_4O_AUDIO_PREVIEW_2024_12_17, + GPT_4O_AUDIO_PREVIEW_2025_06_03, + GPT_4O_MINI_AUDIO_PREVIEW, + GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17, + GPT_4O_SEARCH_PREVIEW, + GPT_4O_MINI_SEARCH_PREVIEW, + GPT_4O_SEARCH_PREVIEW_2025_03_11, + GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11, + CHATGPT_4O_LATEST, + CODEX_MINI_LATEST, + GPT_4O_MINI, + GPT_4O_MINI_2024_07_18, + GPT_4_TURBO, + GPT_4_TURBO_2024_04_09, + GPT_4_0125_PREVIEW, + GPT_4_TURBO_PREVIEW, + GPT_4_1106_PREVIEW, + GPT_4_VISION_PREVIEW, + GPT_4, + GPT_4_0314, + GPT_4_0613, + GPT_4_32K, + GPT_4_32K_0314, + GPT_4_32K_0613, + GPT_3_5_TURBO, + GPT_3_5_TURBO_16K, + GPT_3_5_TURBO_0301, + GPT_3_5_TURBO_0613, + GPT_3_5_TURBO_1106, + GPT_3_5_TURBO_0125, + GPT_3_5_TURBO_16K_0613, + O1_PRO, + O1_PRO_2025_03_19, + O3_PRO, + O3_PRO_2025_06_10, + O3_DEEP_RESEARCH, + O3_DEEP_RESEARCH_2025_06_26, + O4_MINI_DEEP_RESEARCH, + O4_MINI_DEEP_RESEARCH_2025_06_26, + COMPUTER_USE_PREVIEW, + COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_CODEX, + GPT_5_PRO, + GPT_5_PRO_2025_10_06, + GPT_5_1_CODEX_MAX, + } + + /** + * An enum containing [Model]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Model] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GPT_5_1, + GPT_5_1_2025_11_13, + GPT_5_1_CODEX, + GPT_5_1_MINI, + GPT_5_1_CHAT_LATEST, + GPT_5, + GPT_5_MINI, + GPT_5_NANO, + GPT_5_2025_08_07, + GPT_5_MINI_2025_08_07, + GPT_5_NANO_2025_08_07, + GPT_5_CHAT_LATEST, + GPT_4_1, + GPT_4_1_MINI, + GPT_4_1_NANO, + GPT_4_1_2025_04_14, + GPT_4_1_MINI_2025_04_14, + GPT_4_1_NANO_2025_04_14, + O4_MINI, + O4_MINI_2025_04_16, + O3, + O3_2025_04_16, + O3_MINI, + O3_MINI_2025_01_31, + O1, + O1_2024_12_17, + O1_PREVIEW, + O1_PREVIEW_2024_09_12, + O1_MINI, + O1_MINI_2024_09_12, + GPT_4O, + GPT_4O_2024_11_20, + GPT_4O_2024_08_06, + GPT_4O_2024_05_13, + GPT_4O_AUDIO_PREVIEW, + GPT_4O_AUDIO_PREVIEW_2024_10_01, + GPT_4O_AUDIO_PREVIEW_2024_12_17, + GPT_4O_AUDIO_PREVIEW_2025_06_03, + GPT_4O_MINI_AUDIO_PREVIEW, + GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17, + GPT_4O_SEARCH_PREVIEW, + GPT_4O_MINI_SEARCH_PREVIEW, + GPT_4O_SEARCH_PREVIEW_2025_03_11, + GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11, + CHATGPT_4O_LATEST, + CODEX_MINI_LATEST, + GPT_4O_MINI, + GPT_4O_MINI_2024_07_18, + GPT_4_TURBO, + GPT_4_TURBO_2024_04_09, + GPT_4_0125_PREVIEW, + GPT_4_TURBO_PREVIEW, + GPT_4_1106_PREVIEW, + GPT_4_VISION_PREVIEW, + GPT_4, + GPT_4_0314, + GPT_4_0613, + GPT_4_32K, + GPT_4_32K_0314, + GPT_4_32K_0613, + GPT_3_5_TURBO, + GPT_3_5_TURBO_16K, + GPT_3_5_TURBO_0301, + GPT_3_5_TURBO_0613, + GPT_3_5_TURBO_1106, + GPT_3_5_TURBO_0125, + GPT_3_5_TURBO_16K_0613, + O1_PRO, + O1_PRO_2025_03_19, + O3_PRO, + O3_PRO_2025_06_10, + O3_DEEP_RESEARCH, + O3_DEEP_RESEARCH_2025_06_26, + O4_MINI_DEEP_RESEARCH, + O4_MINI_DEEP_RESEARCH_2025_06_26, + COMPUTER_USE_PREVIEW, + COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_CODEX, + GPT_5_PRO, + GPT_5_PRO_2025_10_06, + GPT_5_1_CODEX_MAX, + /** An enum member indicating that [Model] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GPT_5_1 -> Value.GPT_5_1 + GPT_5_1_2025_11_13 -> Value.GPT_5_1_2025_11_13 + GPT_5_1_CODEX -> Value.GPT_5_1_CODEX + GPT_5_1_MINI -> Value.GPT_5_1_MINI + GPT_5_1_CHAT_LATEST -> Value.GPT_5_1_CHAT_LATEST + GPT_5 -> Value.GPT_5 + GPT_5_MINI -> Value.GPT_5_MINI + GPT_5_NANO -> Value.GPT_5_NANO + GPT_5_2025_08_07 -> Value.GPT_5_2025_08_07 + GPT_5_MINI_2025_08_07 -> Value.GPT_5_MINI_2025_08_07 + GPT_5_NANO_2025_08_07 -> Value.GPT_5_NANO_2025_08_07 + GPT_5_CHAT_LATEST -> Value.GPT_5_CHAT_LATEST + GPT_4_1 -> Value.GPT_4_1 + GPT_4_1_MINI -> Value.GPT_4_1_MINI + GPT_4_1_NANO -> Value.GPT_4_1_NANO + GPT_4_1_2025_04_14 -> Value.GPT_4_1_2025_04_14 + GPT_4_1_MINI_2025_04_14 -> Value.GPT_4_1_MINI_2025_04_14 + GPT_4_1_NANO_2025_04_14 -> Value.GPT_4_1_NANO_2025_04_14 + O4_MINI -> Value.O4_MINI + O4_MINI_2025_04_16 -> Value.O4_MINI_2025_04_16 + O3 -> Value.O3 + O3_2025_04_16 -> Value.O3_2025_04_16 + O3_MINI -> Value.O3_MINI + O3_MINI_2025_01_31 -> Value.O3_MINI_2025_01_31 + O1 -> Value.O1 + O1_2024_12_17 -> Value.O1_2024_12_17 + O1_PREVIEW -> Value.O1_PREVIEW + O1_PREVIEW_2024_09_12 -> Value.O1_PREVIEW_2024_09_12 + O1_MINI -> Value.O1_MINI + O1_MINI_2024_09_12 -> Value.O1_MINI_2024_09_12 + GPT_4O -> Value.GPT_4O + GPT_4O_2024_11_20 -> Value.GPT_4O_2024_11_20 + GPT_4O_2024_08_06 -> Value.GPT_4O_2024_08_06 + GPT_4O_2024_05_13 -> Value.GPT_4O_2024_05_13 + GPT_4O_AUDIO_PREVIEW -> Value.GPT_4O_AUDIO_PREVIEW + GPT_4O_AUDIO_PREVIEW_2024_10_01 -> Value.GPT_4O_AUDIO_PREVIEW_2024_10_01 + GPT_4O_AUDIO_PREVIEW_2024_12_17 -> Value.GPT_4O_AUDIO_PREVIEW_2024_12_17 + GPT_4O_AUDIO_PREVIEW_2025_06_03 -> Value.GPT_4O_AUDIO_PREVIEW_2025_06_03 + GPT_4O_MINI_AUDIO_PREVIEW -> Value.GPT_4O_MINI_AUDIO_PREVIEW + GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17 -> Value.GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17 + GPT_4O_SEARCH_PREVIEW -> Value.GPT_4O_SEARCH_PREVIEW + GPT_4O_MINI_SEARCH_PREVIEW -> Value.GPT_4O_MINI_SEARCH_PREVIEW + GPT_4O_SEARCH_PREVIEW_2025_03_11 -> Value.GPT_4O_SEARCH_PREVIEW_2025_03_11 + GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11 -> Value.GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11 + CHATGPT_4O_LATEST -> Value.CHATGPT_4O_LATEST + CODEX_MINI_LATEST -> Value.CODEX_MINI_LATEST + GPT_4O_MINI -> Value.GPT_4O_MINI + GPT_4O_MINI_2024_07_18 -> Value.GPT_4O_MINI_2024_07_18 + GPT_4_TURBO -> Value.GPT_4_TURBO + GPT_4_TURBO_2024_04_09 -> Value.GPT_4_TURBO_2024_04_09 + GPT_4_0125_PREVIEW -> Value.GPT_4_0125_PREVIEW + GPT_4_TURBO_PREVIEW -> Value.GPT_4_TURBO_PREVIEW + GPT_4_1106_PREVIEW -> Value.GPT_4_1106_PREVIEW + GPT_4_VISION_PREVIEW -> Value.GPT_4_VISION_PREVIEW + GPT_4 -> Value.GPT_4 + GPT_4_0314 -> Value.GPT_4_0314 + GPT_4_0613 -> Value.GPT_4_0613 + GPT_4_32K -> Value.GPT_4_32K + GPT_4_32K_0314 -> Value.GPT_4_32K_0314 + GPT_4_32K_0613 -> Value.GPT_4_32K_0613 + GPT_3_5_TURBO -> Value.GPT_3_5_TURBO + GPT_3_5_TURBO_16K -> Value.GPT_3_5_TURBO_16K + GPT_3_5_TURBO_0301 -> Value.GPT_3_5_TURBO_0301 + GPT_3_5_TURBO_0613 -> Value.GPT_3_5_TURBO_0613 + GPT_3_5_TURBO_1106 -> Value.GPT_3_5_TURBO_1106 + GPT_3_5_TURBO_0125 -> Value.GPT_3_5_TURBO_0125 + GPT_3_5_TURBO_16K_0613 -> Value.GPT_3_5_TURBO_16K_0613 + O1_PRO -> Value.O1_PRO + O1_PRO_2025_03_19 -> Value.O1_PRO_2025_03_19 + O3_PRO -> Value.O3_PRO + O3_PRO_2025_06_10 -> Value.O3_PRO_2025_06_10 + O3_DEEP_RESEARCH -> Value.O3_DEEP_RESEARCH + O3_DEEP_RESEARCH_2025_06_26 -> Value.O3_DEEP_RESEARCH_2025_06_26 + O4_MINI_DEEP_RESEARCH -> Value.O4_MINI_DEEP_RESEARCH + O4_MINI_DEEP_RESEARCH_2025_06_26 -> Value.O4_MINI_DEEP_RESEARCH_2025_06_26 + COMPUTER_USE_PREVIEW -> Value.COMPUTER_USE_PREVIEW + COMPUTER_USE_PREVIEW_2025_03_11 -> Value.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_CODEX -> Value.GPT_5_CODEX + GPT_5_PRO -> Value.GPT_5_PRO + GPT_5_PRO_2025_10_06 -> Value.GPT_5_PRO_2025_10_06 + GPT_5_1_CODEX_MAX -> Value.GPT_5_1_CODEX_MAX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OpenAIInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GPT_5_1 -> Known.GPT_5_1 + GPT_5_1_2025_11_13 -> Known.GPT_5_1_2025_11_13 + GPT_5_1_CODEX -> Known.GPT_5_1_CODEX + GPT_5_1_MINI -> Known.GPT_5_1_MINI + GPT_5_1_CHAT_LATEST -> Known.GPT_5_1_CHAT_LATEST + GPT_5 -> Known.GPT_5 + GPT_5_MINI -> Known.GPT_5_MINI + GPT_5_NANO -> Known.GPT_5_NANO + GPT_5_2025_08_07 -> Known.GPT_5_2025_08_07 + GPT_5_MINI_2025_08_07 -> Known.GPT_5_MINI_2025_08_07 + GPT_5_NANO_2025_08_07 -> Known.GPT_5_NANO_2025_08_07 + GPT_5_CHAT_LATEST -> Known.GPT_5_CHAT_LATEST + GPT_4_1 -> Known.GPT_4_1 + GPT_4_1_MINI -> Known.GPT_4_1_MINI + GPT_4_1_NANO -> Known.GPT_4_1_NANO + GPT_4_1_2025_04_14 -> Known.GPT_4_1_2025_04_14 + GPT_4_1_MINI_2025_04_14 -> Known.GPT_4_1_MINI_2025_04_14 + GPT_4_1_NANO_2025_04_14 -> Known.GPT_4_1_NANO_2025_04_14 + O4_MINI -> Known.O4_MINI + O4_MINI_2025_04_16 -> Known.O4_MINI_2025_04_16 + O3 -> Known.O3 + O3_2025_04_16 -> Known.O3_2025_04_16 + O3_MINI -> Known.O3_MINI + O3_MINI_2025_01_31 -> Known.O3_MINI_2025_01_31 + O1 -> Known.O1 + O1_2024_12_17 -> Known.O1_2024_12_17 + O1_PREVIEW -> Known.O1_PREVIEW + O1_PREVIEW_2024_09_12 -> Known.O1_PREVIEW_2024_09_12 + O1_MINI -> Known.O1_MINI + O1_MINI_2024_09_12 -> Known.O1_MINI_2024_09_12 + GPT_4O -> Known.GPT_4O + GPT_4O_2024_11_20 -> Known.GPT_4O_2024_11_20 + GPT_4O_2024_08_06 -> Known.GPT_4O_2024_08_06 + GPT_4O_2024_05_13 -> Known.GPT_4O_2024_05_13 + GPT_4O_AUDIO_PREVIEW -> Known.GPT_4O_AUDIO_PREVIEW + GPT_4O_AUDIO_PREVIEW_2024_10_01 -> Known.GPT_4O_AUDIO_PREVIEW_2024_10_01 + GPT_4O_AUDIO_PREVIEW_2024_12_17 -> Known.GPT_4O_AUDIO_PREVIEW_2024_12_17 + GPT_4O_AUDIO_PREVIEW_2025_06_03 -> Known.GPT_4O_AUDIO_PREVIEW_2025_06_03 + GPT_4O_MINI_AUDIO_PREVIEW -> Known.GPT_4O_MINI_AUDIO_PREVIEW + GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17 -> Known.GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17 + GPT_4O_SEARCH_PREVIEW -> Known.GPT_4O_SEARCH_PREVIEW + GPT_4O_MINI_SEARCH_PREVIEW -> Known.GPT_4O_MINI_SEARCH_PREVIEW + GPT_4O_SEARCH_PREVIEW_2025_03_11 -> Known.GPT_4O_SEARCH_PREVIEW_2025_03_11 + GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11 -> Known.GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11 + CHATGPT_4O_LATEST -> Known.CHATGPT_4O_LATEST + CODEX_MINI_LATEST -> Known.CODEX_MINI_LATEST + GPT_4O_MINI -> Known.GPT_4O_MINI + GPT_4O_MINI_2024_07_18 -> Known.GPT_4O_MINI_2024_07_18 + GPT_4_TURBO -> Known.GPT_4_TURBO + GPT_4_TURBO_2024_04_09 -> Known.GPT_4_TURBO_2024_04_09 + GPT_4_0125_PREVIEW -> Known.GPT_4_0125_PREVIEW + GPT_4_TURBO_PREVIEW -> Known.GPT_4_TURBO_PREVIEW + GPT_4_1106_PREVIEW -> Known.GPT_4_1106_PREVIEW + GPT_4_VISION_PREVIEW -> Known.GPT_4_VISION_PREVIEW + GPT_4 -> Known.GPT_4 + GPT_4_0314 -> Known.GPT_4_0314 + GPT_4_0613 -> Known.GPT_4_0613 + GPT_4_32K -> Known.GPT_4_32K + GPT_4_32K_0314 -> Known.GPT_4_32K_0314 + GPT_4_32K_0613 -> Known.GPT_4_32K_0613 + GPT_3_5_TURBO -> Known.GPT_3_5_TURBO + GPT_3_5_TURBO_16K -> Known.GPT_3_5_TURBO_16K + GPT_3_5_TURBO_0301 -> Known.GPT_3_5_TURBO_0301 + GPT_3_5_TURBO_0613 -> Known.GPT_3_5_TURBO_0613 + GPT_3_5_TURBO_1106 -> Known.GPT_3_5_TURBO_1106 + GPT_3_5_TURBO_0125 -> Known.GPT_3_5_TURBO_0125 + GPT_3_5_TURBO_16K_0613 -> Known.GPT_3_5_TURBO_16K_0613 + O1_PRO -> Known.O1_PRO + O1_PRO_2025_03_19 -> Known.O1_PRO_2025_03_19 + O3_PRO -> Known.O3_PRO + O3_PRO_2025_06_10 -> Known.O3_PRO_2025_06_10 + O3_DEEP_RESEARCH -> Known.O3_DEEP_RESEARCH + O3_DEEP_RESEARCH_2025_06_26 -> Known.O3_DEEP_RESEARCH_2025_06_26 + O4_MINI_DEEP_RESEARCH -> Known.O4_MINI_DEEP_RESEARCH + O4_MINI_DEEP_RESEARCH_2025_06_26 -> Known.O4_MINI_DEEP_RESEARCH_2025_06_26 + COMPUTER_USE_PREVIEW -> Known.COMPUTER_USE_PREVIEW + COMPUTER_USE_PREVIEW_2025_03_11 -> Known.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_CODEX -> Known.GPT_5_CODEX + GPT_5_PRO -> Known.GPT_5_PRO + GPT_5_PRO_2025_10_06 -> Known.GPT_5_PRO_2025_10_06 + GPT_5_1_CODEX_MAX -> Known.GPT_5_1_CODEX_MAX + else -> throw OpenAIInvalidDataException("Unknown Model: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OpenAIInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OpenAIInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Model = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Model && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResponseCompactParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ResponseCompactParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactionItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactionItem.kt new file mode 100644 index 00000000..e7db40bc --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactionItem.kt @@ -0,0 +1,295 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.responses + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * A compaction item generated by the + * [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact). + */ +class ResponseCompactionItem +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val encryptedContent: JsonField, + private val type: JsonValue, + private val createdBy: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("encrypted_content") + @ExcludeMissing + encryptedContent: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("created_by") @ExcludeMissing createdBy: JsonField = JsonMissing.of(), + ) : this(id, encryptedContent, type, createdBy, mutableMapOf()) + + /** + * The unique ID of the compaction item. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun encryptedContent(): String = encryptedContent.getRequired("encrypted_content") + + /** + * The type of the item. Always `compaction`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("compaction") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdBy(): Optional = createdBy.getOptional("created_by") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [encryptedContent]. + * + * Unlike [encryptedContent], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("encrypted_content") + @ExcludeMissing + fun _encryptedContent(): JsonField = encryptedContent + + /** + * Returns the raw JSON value of [createdBy]. + * + * Unlike [createdBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_by") @ExcludeMissing fun _createdBy(): JsonField = createdBy + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ResponseCompactionItem]. + * + * The following fields are required: + * ```java + * .id() + * .encryptedContent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResponseCompactionItem]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var encryptedContent: JsonField? = null + private var type: JsonValue = JsonValue.from("compaction") + private var createdBy: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(responseCompactionItem: ResponseCompactionItem) = apply { + id = responseCompactionItem.id + encryptedContent = responseCompactionItem.encryptedContent + type = responseCompactionItem.type + createdBy = responseCompactionItem.createdBy + additionalProperties = responseCompactionItem.additionalProperties.toMutableMap() + } + + /** The unique ID of the compaction item. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun encryptedContent(encryptedContent: String) = + encryptedContent(JsonField.of(encryptedContent)) + + /** + * Sets [Builder.encryptedContent] to an arbitrary JSON value. + * + * You should usually call [Builder.encryptedContent] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun encryptedContent(encryptedContent: JsonField) = apply { + this.encryptedContent = encryptedContent + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("compaction") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun createdBy(createdBy: String) = createdBy(JsonField.of(createdBy)) + + /** + * Sets [Builder.createdBy] to an arbitrary JSON value. + * + * You should usually call [Builder.createdBy] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun createdBy(createdBy: JsonField) = apply { this.createdBy = createdBy } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ResponseCompactionItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .encryptedContent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ResponseCompactionItem = + ResponseCompactionItem( + checkRequired("id", id), + checkRequired("encryptedContent", encryptedContent), + type, + createdBy, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ResponseCompactionItem = apply { + if (validated) { + return@apply + } + + id() + encryptedContent() + _type().let { + if (it != JsonValue.from("compaction")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + createdBy() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (encryptedContent.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("compaction")) 1 else 0 } + + (if (createdBy.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResponseCompactionItem && + id == other.id && + encryptedContent == other.encryptedContent && + type == other.type && + createdBy == other.createdBy && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, encryptedContent, type, createdBy, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ResponseCompactionItem{id=$id, encryptedContent=$encryptedContent, type=$type, createdBy=$createdBy, additionalProperties=$additionalProperties}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactionItemParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactionItemParam.kt new file mode 100644 index 00000000..6df326db --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactionItemParam.kt @@ -0,0 +1,265 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.responses + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A compaction item generated by the + * [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact). + */ +class ResponseCompactionItemParam +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val encryptedContent: JsonField, + private val type: JsonValue, + private val id: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("encrypted_content") + @ExcludeMissing + encryptedContent: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + ) : this(encryptedContent, type, id, mutableMapOf()) + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun encryptedContent(): String = encryptedContent.getRequired("encrypted_content") + + /** + * The type of the item. Always `compaction`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("compaction") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * The ID of the compaction item. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Returns the raw JSON value of [encryptedContent]. + * + * Unlike [encryptedContent], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("encrypted_content") + @ExcludeMissing + fun _encryptedContent(): JsonField = encryptedContent + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ResponseCompactionItemParam]. + * + * The following fields are required: + * ```java + * .encryptedContent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResponseCompactionItemParam]. */ + class Builder internal constructor() { + + private var encryptedContent: JsonField? = null + private var type: JsonValue = JsonValue.from("compaction") + private var id: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(responseCompactionItemParam: ResponseCompactionItemParam) = apply { + encryptedContent = responseCompactionItemParam.encryptedContent + type = responseCompactionItemParam.type + id = responseCompactionItemParam.id + additionalProperties = responseCompactionItemParam.additionalProperties.toMutableMap() + } + + fun encryptedContent(encryptedContent: String) = + encryptedContent(JsonField.of(encryptedContent)) + + /** + * Sets [Builder.encryptedContent] to an arbitrary JSON value. + * + * You should usually call [Builder.encryptedContent] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun encryptedContent(encryptedContent: JsonField) = apply { + this.encryptedContent = encryptedContent + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("compaction") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** The ID of the compaction item. */ + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ResponseCompactionItemParam]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .encryptedContent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ResponseCompactionItemParam = + ResponseCompactionItemParam( + checkRequired("encryptedContent", encryptedContent), + type, + id, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ResponseCompactionItemParam = apply { + if (validated) { + return@apply + } + + encryptedContent() + _type().let { + if (it != JsonValue.from("compaction")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (encryptedContent.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("compaction")) 1 else 0 } + + (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResponseCompactionItemParam && + encryptedContent == other.encryptedContent && + type == other.type && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(encryptedContent, type, id, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ResponseCompactionItemParam{encryptedContent=$encryptedContent, type=$type, id=$id, additionalProperties=$additionalProperties}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt index 8df88d78..76580d2a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt @@ -4426,7 +4426,7 @@ private constructor( /** Forces the model to call the apply_patch tool when executing a tool call. */ fun applyPatch(): Optional = Optional.ofNullable(applyPatch) - /** Forces the model to call the function shell tool when a tool call is required. */ + /** Forces the model to call the shell tool when a tool call is required. */ fun shell(): Optional = Optional.ofNullable(shell) fun isOptions(): Boolean = options != null @@ -4478,7 +4478,7 @@ private constructor( /** Forces the model to call the apply_patch tool when executing a tool call. */ fun asApplyPatch(): ToolChoiceApplyPatch = applyPatch.getOrThrow("applyPatch") - /** Forces the model to call the function shell tool when a tool call is required. */ + /** Forces the model to call the shell tool when a tool call is required. */ fun asShell(): ToolChoiceShell = shell.getOrThrow("shell") fun _json(): Optional = Optional.ofNullable(_json) @@ -4652,7 +4652,7 @@ private constructor( @JvmStatic fun ofApplyPatch(applyPatch: ToolChoiceApplyPatch) = ToolChoice(applyPatch = applyPatch) - /** Forces the model to call the function shell tool when a tool call is required. */ + /** Forces the model to call the shell tool when a tool call is required. */ @JvmStatic fun ofShell(shell: ToolChoiceShell) = ToolChoice(shell = shell) } @@ -4696,7 +4696,7 @@ private constructor( /** Forces the model to call the apply_patch tool when executing a tool call. */ fun visitApplyPatch(applyPatch: ToolChoiceApplyPatch): T - /** Forces the model to call the function shell tool when a tool call is required. */ + /** Forces the model to call the shell tool when a tool call is required. */ fun visitShell(shell: ToolChoiceShell): T /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionShellCallOutputContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionShellCallOutputContent.kt index 38c0872c..869c8142 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionShellCallOutputContent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionShellCallOutputContent.kt @@ -27,7 +27,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Captured stdout and stderr for a portion of a function shell tool call output. */ +/** Captured stdout and stderr for a portion of a shell tool call output. */ class ResponseFunctionShellCallOutputContent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -45,7 +45,7 @@ private constructor( ) : this(outcome, stderr, stdout, mutableMapOf()) /** - * The exit or timeout outcome associated with this chunk. + * The exit or timeout outcome associated with this shell call. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -53,7 +53,7 @@ private constructor( fun outcome(): Outcome = outcome.getRequired("outcome") /** - * Captured stderr output for this chunk of the shell call. + * Captured stderr output for the shell call. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -61,7 +61,7 @@ private constructor( fun stderr(): String = stderr.getRequired("stderr") /** - * Captured stdout output for this chunk of the shell call. + * Captured stdout output for the shell call. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -136,7 +136,7 @@ private constructor( responseFunctionShellCallOutputContent.additionalProperties.toMutableMap() } - /** The exit or timeout outcome associated with this chunk. */ + /** The exit or timeout outcome associated with this shell call. */ fun outcome(outcome: Outcome) = outcome(JsonField.of(outcome)) /** @@ -163,7 +163,7 @@ private constructor( */ fun exitOutcome(exitCode: Long) = outcome(Outcome.Exit.builder().exitCode(exitCode).build()) - /** Captured stderr output for this chunk of the shell call. */ + /** Captured stderr output for the shell call. */ fun stderr(stderr: String) = stderr(JsonField.of(stderr)) /** @@ -174,7 +174,7 @@ private constructor( */ fun stderr(stderr: JsonField) = apply { this.stderr = stderr } - /** Captured stdout output for this chunk of the shell call. */ + /** Captured stdout output for the shell call. */ fun stdout(stdout: String) = stdout(JsonField.of(stdout)) /** @@ -259,7 +259,7 @@ private constructor( (if (stderr.asKnown().isPresent) 1 else 0) + (if (stdout.asKnown().isPresent) 1 else 0) - /** The exit or timeout outcome associated with this chunk. */ + /** The exit or timeout outcome associated with this shell call. */ @JsonDeserialize(using = Outcome.Deserializer::class) @JsonSerialize(using = Outcome.Serializer::class) class Outcome @@ -269,7 +269,7 @@ private constructor( private val _json: JsonValue? = null, ) { - /** Indicates that the function shell call exceeded its configured time limit. */ + /** Indicates that the shell call exceeded its configured time limit. */ fun timeout(): Optional = Optional.ofNullable(timeout) /** Indicates that the shell commands finished and returned an exit code. */ @@ -279,7 +279,7 @@ private constructor( fun isExit(): Boolean = exit != null - /** Indicates that the function shell call exceeded its configured time limit. */ + /** Indicates that the shell call exceeded its configured time limit. */ fun asTimeout(): JsonValue = timeout.getOrThrow("timeout") /** Indicates that the shell commands finished and returned an exit code. */ @@ -370,7 +370,7 @@ private constructor( companion object { - /** Indicates that the function shell call exceeded its configured time limit. */ + /** Indicates that the shell call exceeded its configured time limit. */ @JvmStatic fun ofTimeout() = Outcome(timeout = JsonValue.from(mapOf("type" to "timeout"))) @@ -383,7 +383,7 @@ private constructor( */ interface Visitor { - /** Indicates that the function shell call exceeded its configured time limit. */ + /** Indicates that the shell call exceeded its configured time limit. */ fun visitTimeout(timeout: JsonValue): T /** Indicates that the shell commands finished and returned an exit code. */ diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionShellToolCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionShellToolCall.kt index 344c0c02..9111064a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionShellToolCall.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionShellToolCall.kt @@ -44,7 +44,7 @@ private constructor( ) : this(id, action, callId, status, type, createdBy, mutableMapOf()) /** - * The unique ID of the function shell tool call. Populated when this item is returned via API. + * The unique ID of the shell tool call. Populated when this item is returned via API. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -60,7 +60,7 @@ private constructor( fun action(): Action = action.getRequired("action") /** - * The unique ID of the function shell tool call generated by the model. + * The unique ID of the shell tool call generated by the model. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -182,10 +182,7 @@ private constructor( additionalProperties = responseFunctionShellToolCall.additionalProperties.toMutableMap() } - /** - * The unique ID of the function shell tool call. Populated when this item is returned via - * API. - */ + /** The unique ID of the shell tool call. Populated when this item is returned via API. */ fun id(id: String) = id(JsonField.of(id)) /** @@ -207,7 +204,7 @@ private constructor( */ fun action(action: JsonField) = apply { this.action = action } - /** The unique ID of the function shell tool call generated by the model. */ + /** The unique ID of the shell tool call generated by the model. */ fun callId(callId: String) = callId(JsonField.of(callId)) /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionShellToolCallOutput.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionShellToolCallOutput.kt index f35c13a7..fa41f3b0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionShellToolCallOutput.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionShellToolCallOutput.kt @@ -664,7 +664,7 @@ private constructor( private val _json: JsonValue? = null, ) { - /** Indicates that the function shell call exceeded its configured time limit. */ + /** Indicates that the shell call exceeded its configured time limit. */ fun timeout(): Optional = Optional.ofNullable(timeout) /** Indicates that the shell commands finished and returned an exit code. */ @@ -674,7 +674,7 @@ private constructor( fun isExit(): Boolean = exit != null - /** Indicates that the function shell call exceeded its configured time limit. */ + /** Indicates that the shell call exceeded its configured time limit. */ fun asTimeout(): JsonValue = timeout.getOrThrow("timeout") /** Indicates that the shell commands finished and returned an exit code. */ @@ -765,7 +765,7 @@ private constructor( companion object { - /** Indicates that the function shell call exceeded its configured time limit. */ + /** Indicates that the shell call exceeded its configured time limit. */ @JvmStatic fun ofTimeout() = Outcome(timeout = JsonValue.from(mapOf("type" to "timeout"))) @@ -779,7 +779,7 @@ private constructor( */ interface Visitor { - /** Indicates that the function shell call exceeded its configured time limit. */ + /** Indicates that the shell call exceeded its configured time limit. */ fun visitTimeout(timeout: JsonValue): T /** Indicates that the shell commands finished and returned an exit code. */ diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt index f389252a..bb24811e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt @@ -52,6 +52,7 @@ private constructor( private val functionCall: ResponseFunctionToolCall? = null, private val functionCallOutput: FunctionCallOutput? = null, private val reasoning: ResponseReasoningItem? = null, + private val compaction: ResponseCompactionItemParam? = null, private val imageGenerationCall: ImageGenerationCall? = null, private val codeInterpreterCall: ResponseCodeInterpreterToolCall? = null, private val localShellCall: LocalShellCall? = null, @@ -131,6 +132,12 @@ private constructor( */ fun reasoning(): Optional = Optional.ofNullable(reasoning) + /** + * A compaction item generated by the + * [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact). + */ + fun compaction(): Optional = Optional.ofNullable(compaction) + /** An image generation request made by the model. */ fun imageGenerationCall(): Optional = Optional.ofNullable(imageGenerationCall) @@ -149,7 +156,7 @@ private constructor( /** A tool representing a request to execute one or more shell commands. */ fun shellCall(): Optional = Optional.ofNullable(shellCall) - /** The streamed output items emitted by a function shell tool call. */ + /** The streamed output items emitted by a shell tool call. */ fun shellCallOutput(): Optional = Optional.ofNullable(shellCallOutput) /** A tool call representing a request to create, delete, or update files using diff patches. */ @@ -202,6 +209,8 @@ private constructor( fun isReasoning(): Boolean = reasoning != null + fun isCompaction(): Boolean = compaction != null + fun isImageGenerationCall(): Boolean = imageGenerationCall != null fun isCodeInterpreterCall(): Boolean = codeInterpreterCall != null @@ -295,6 +304,12 @@ private constructor( */ fun asReasoning(): ResponseReasoningItem = reasoning.getOrThrow("reasoning") + /** + * A compaction item generated by the + * [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact). + */ + fun asCompaction(): ResponseCompactionItemParam = compaction.getOrThrow("compaction") + /** An image generation request made by the model. */ fun asImageGenerationCall(): ImageGenerationCall = imageGenerationCall.getOrThrow("imageGenerationCall") @@ -313,7 +328,7 @@ private constructor( /** A tool representing a request to execute one or more shell commands. */ fun asShellCall(): ShellCall = shellCall.getOrThrow("shellCall") - /** The streamed output items emitted by a function shell tool call. */ + /** The streamed output items emitted by a shell tool call. */ fun asShellCallOutput(): ShellCallOutput = shellCallOutput.getOrThrow("shellCallOutput") /** A tool call representing a request to create, delete, or update files using diff patches. */ @@ -362,6 +377,7 @@ private constructor( functionCall != null -> visitor.visitFunctionCall(functionCall) functionCallOutput != null -> visitor.visitFunctionCallOutput(functionCallOutput) reasoning != null -> visitor.visitReasoning(reasoning) + compaction != null -> visitor.visitCompaction(compaction) imageGenerationCall != null -> visitor.visitImageGenerationCall(imageGenerationCall) codeInterpreterCall != null -> visitor.visitCodeInterpreterCall(codeInterpreterCall) localShellCall != null -> visitor.visitLocalShellCall(localShellCall) @@ -431,6 +447,10 @@ private constructor( reasoning.validate() } + override fun visitCompaction(compaction: ResponseCompactionItemParam) { + compaction.validate() + } + override fun visitImageGenerationCall(imageGenerationCall: ImageGenerationCall) { imageGenerationCall.validate() } @@ -545,6 +565,9 @@ private constructor( override fun visitReasoning(reasoning: ResponseReasoningItem) = reasoning.validity() + override fun visitCompaction(compaction: ResponseCompactionItemParam) = + compaction.validity() + override fun visitImageGenerationCall(imageGenerationCall: ImageGenerationCall) = imageGenerationCall.validity() @@ -609,6 +632,7 @@ private constructor( functionCall == other.functionCall && functionCallOutput == other.functionCallOutput && reasoning == other.reasoning && + compaction == other.compaction && imageGenerationCall == other.imageGenerationCall && codeInterpreterCall == other.codeInterpreterCall && localShellCall == other.localShellCall && @@ -638,6 +662,7 @@ private constructor( functionCall, functionCallOutput, reasoning, + compaction, imageGenerationCall, codeInterpreterCall, localShellCall, @@ -670,6 +695,7 @@ private constructor( functionCallOutput != null -> "ResponseInputItem{functionCallOutput=$functionCallOutput}" reasoning != null -> "ResponseInputItem{reasoning=$reasoning}" + compaction != null -> "ResponseInputItem{compaction=$compaction}" imageGenerationCall != null -> "ResponseInputItem{imageGenerationCall=$imageGenerationCall}" codeInterpreterCall != null -> @@ -775,6 +801,14 @@ private constructor( @JvmStatic fun ofReasoning(reasoning: ResponseReasoningItem) = ResponseInputItem(reasoning = reasoning) + /** + * A compaction item generated by the + * [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact). + */ + @JvmStatic + fun ofCompaction(compaction: ResponseCompactionItemParam) = + ResponseInputItem(compaction = compaction) + /** An image generation request made by the model. */ @JvmStatic fun ofImageGenerationCall(imageGenerationCall: ImageGenerationCall) = @@ -798,7 +832,7 @@ private constructor( /** A tool representing a request to execute one or more shell commands. */ @JvmStatic fun ofShellCall(shellCall: ShellCall) = ResponseInputItem(shellCall = shellCall) - /** The streamed output items emitted by a function shell tool call. */ + /** The streamed output items emitted by a shell tool call. */ @JvmStatic fun ofShellCallOutput(shellCallOutput: ShellCallOutput) = ResponseInputItem(shellCallOutput = shellCallOutput) @@ -915,6 +949,12 @@ private constructor( */ fun visitReasoning(reasoning: ResponseReasoningItem): T + /** + * A compaction item generated by the + * [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact). + */ + fun visitCompaction(compaction: ResponseCompactionItemParam): T + /** An image generation request made by the model. */ fun visitImageGenerationCall(imageGenerationCall: ImageGenerationCall): T @@ -930,7 +970,7 @@ private constructor( /** A tool representing a request to execute one or more shell commands. */ fun visitShellCall(shellCall: ShellCall): T - /** The streamed output items emitted by a function shell tool call. */ + /** The streamed output items emitted by a shell tool call. */ fun visitShellCallOutput(shellCallOutput: ShellCallOutput): T /** @@ -1046,6 +1086,11 @@ private constructor( ResponseInputItem(reasoning = it, _json = json) } ?: ResponseInputItem(_json = json) } + "compaction" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ResponseInputItem(compaction = it, _json = json) } + ?: ResponseInputItem(_json = json) + } "image_generation_call" -> { return tryDeserialize(node, jacksonTypeRef())?.let { ResponseInputItem(imageGenerationCall = it, _json = json) @@ -1146,6 +1191,7 @@ private constructor( value.functionCall != null -> generator.writeObject(value.functionCall) value.functionCallOutput != null -> generator.writeObject(value.functionCallOutput) value.reasoning != null -> generator.writeObject(value.reasoning) + value.compaction != null -> generator.writeObject(value.compaction) value.imageGenerationCall != null -> generator.writeObject(value.imageGenerationCall) value.codeInterpreterCall != null -> @@ -5226,7 +5272,7 @@ private constructor( fun action(): Action = action.getRequired("action") /** - * The unique ID of the function shell tool call generated by the model. + * The unique ID of the shell tool call generated by the model. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -5234,7 +5280,7 @@ private constructor( fun callId(): String = callId.getRequired("call_id") /** - * The type of the item. Always `function_shell_call`. + * The type of the item. Always `shell_call`. * * Expected to always return the following: * ```java @@ -5247,8 +5293,7 @@ private constructor( @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** - * The unique ID of the function shell tool call. Populated when this item is returned via - * API. + * The unique ID of the shell tool call. Populated when this item is returned via API. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -5349,7 +5394,7 @@ private constructor( */ fun action(action: JsonField) = apply { this.action = action } - /** The unique ID of the function shell tool call generated by the model. */ + /** The unique ID of the shell tool call generated by the model. */ fun callId(callId: String) = callId(JsonField.of(callId)) /** @@ -5376,8 +5421,7 @@ private constructor( fun type(type: JsonValue) = apply { this.type = type } /** - * The unique ID of the function shell tool call. Populated when this item is returned - * via API. + * The unique ID of the shell tool call. Populated when this item is returned via API. */ fun id(id: String?) = id(JsonField.ofNullable(id)) @@ -5949,7 +5993,7 @@ private constructor( "ShellCall{action=$action, callId=$callId, type=$type, id=$id, status=$status, additionalProperties=$additionalProperties}" } - /** The streamed output items emitted by a function shell tool call. */ + /** The streamed output items emitted by a shell tool call. */ class ShellCallOutput @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -5975,7 +6019,7 @@ private constructor( ) : this(callId, output, type, id, maxOutputLength, mutableMapOf()) /** - * The unique ID of the function shell tool call generated by the model. + * The unique ID of the shell tool call generated by the model. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -5991,7 +6035,7 @@ private constructor( fun output(): List = output.getRequired("output") /** - * The type of the item. Always `function_shell_call_output`. + * The type of the item. Always `shell_call_output`. * * Expected to always return the following: * ```java @@ -6004,8 +6048,8 @@ private constructor( @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** - * The unique ID of the function shell tool call output. Populated when this item is - * returned via API. + * The unique ID of the shell tool call output. Populated when this item is returned via + * API. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -6100,7 +6144,7 @@ private constructor( additionalProperties = shellCallOutput.additionalProperties.toMutableMap() } - /** The unique ID of the function shell tool call generated by the model. */ + /** The unique ID of the shell tool call generated by the model. */ fun callId(callId: String) = callId(JsonField.of(callId)) /** @@ -6156,8 +6200,8 @@ private constructor( fun type(type: JsonValue) = apply { this.type = type } /** - * The unique ID of the function shell tool call output. Populated when this item is - * returned via API. + * The unique ID of the shell tool call output. Populated when this item is returned via + * API. */ fun id(id: String?) = id(JsonField.ofNullable(id)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItem.kt index 2819e2e9..7db13676 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItem.kt @@ -41,6 +41,7 @@ private constructor( private val webSearchCall: ResponseFunctionWebSearch? = null, private val computerCall: ResponseComputerToolCall? = null, private val reasoning: ResponseReasoningItem? = null, + private val compaction: ResponseCompactionItem? = null, private val imageGenerationCall: ImageGenerationCall? = null, private val codeInterpreterCall: ResponseCodeInterpreterToolCall? = null, private val localShellCall: LocalShellCall? = null, @@ -94,6 +95,12 @@ private constructor( */ fun reasoning(): Optional = Optional.ofNullable(reasoning) + /** + * A compaction item generated by the + * [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact). + */ + fun compaction(): Optional = Optional.ofNullable(compaction) + /** An image generation request made by the model. */ fun imageGenerationCall(): Optional = Optional.ofNullable(imageGenerationCall) @@ -143,6 +150,8 @@ private constructor( fun isReasoning(): Boolean = reasoning != null + fun isCompaction(): Boolean = compaction != null + fun isImageGenerationCall(): Boolean = imageGenerationCall != null fun isCodeInterpreterCall(): Boolean = codeInterpreterCall != null @@ -204,6 +213,12 @@ private constructor( */ fun asReasoning(): ResponseReasoningItem = reasoning.getOrThrow("reasoning") + /** + * A compaction item generated by the + * [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact). + */ + fun asCompaction(): ResponseCompactionItem = compaction.getOrThrow("compaction") + /** An image generation request made by the model. */ fun asImageGenerationCall(): ImageGenerationCall = imageGenerationCall.getOrThrow("imageGenerationCall") @@ -252,6 +267,7 @@ private constructor( webSearchCall != null -> visitor.visitWebSearchCall(webSearchCall) computerCall != null -> visitor.visitComputerCall(computerCall) reasoning != null -> visitor.visitReasoning(reasoning) + compaction != null -> visitor.visitCompaction(compaction) imageGenerationCall != null -> visitor.visitImageGenerationCall(imageGenerationCall) codeInterpreterCall != null -> visitor.visitCodeInterpreterCall(codeInterpreterCall) localShellCall != null -> visitor.visitLocalShellCall(localShellCall) @@ -299,6 +315,10 @@ private constructor( reasoning.validate() } + override fun visitCompaction(compaction: ResponseCompactionItem) { + compaction.validate() + } + override fun visitImageGenerationCall(imageGenerationCall: ImageGenerationCall) { imageGenerationCall.validate() } @@ -386,6 +406,9 @@ private constructor( override fun visitReasoning(reasoning: ResponseReasoningItem) = reasoning.validity() + override fun visitCompaction(compaction: ResponseCompactionItem) = + compaction.validity() + override fun visitImageGenerationCall(imageGenerationCall: ImageGenerationCall) = imageGenerationCall.validity() @@ -436,6 +459,7 @@ private constructor( webSearchCall == other.webSearchCall && computerCall == other.computerCall && reasoning == other.reasoning && + compaction == other.compaction && imageGenerationCall == other.imageGenerationCall && codeInterpreterCall == other.codeInterpreterCall && localShellCall == other.localShellCall && @@ -457,6 +481,7 @@ private constructor( webSearchCall, computerCall, reasoning, + compaction, imageGenerationCall, codeInterpreterCall, localShellCall, @@ -478,6 +503,7 @@ private constructor( webSearchCall != null -> "ResponseOutputItem{webSearchCall=$webSearchCall}" computerCall != null -> "ResponseOutputItem{computerCall=$computerCall}" reasoning != null -> "ResponseOutputItem{reasoning=$reasoning}" + compaction != null -> "ResponseOutputItem{compaction=$compaction}" imageGenerationCall != null -> "ResponseOutputItem{imageGenerationCall=$imageGenerationCall}" codeInterpreterCall != null -> @@ -549,6 +575,14 @@ private constructor( fun ofReasoning(reasoning: ResponseReasoningItem) = ResponseOutputItem(reasoning = reasoning) + /** + * A compaction item generated by the + * [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact). + */ + @JvmStatic + fun ofCompaction(compaction: ResponseCompactionItem) = + ResponseOutputItem(compaction = compaction) + /** An image generation request made by the model. */ @JvmStatic fun ofImageGenerationCall(imageGenerationCall: ImageGenerationCall) = @@ -648,6 +682,12 @@ private constructor( */ fun visitReasoning(reasoning: ResponseReasoningItem): T + /** + * A compaction item generated by the + * [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact). + */ + fun visitCompaction(compaction: ResponseCompactionItem): T + /** An image generation request made by the model. */ fun visitImageGenerationCall(imageGenerationCall: ImageGenerationCall): T @@ -733,6 +773,11 @@ private constructor( ResponseOutputItem(reasoning = it, _json = json) } ?: ResponseOutputItem(_json = json) } + "compaction" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ResponseOutputItem(compaction = it, _json = json) + } ?: ResponseOutputItem(_json = json) + } "image_generation_call" -> { return tryDeserialize(node, jacksonTypeRef())?.let { ResponseOutputItem(imageGenerationCall = it, _json = json) @@ -811,6 +856,7 @@ private constructor( value.webSearchCall != null -> generator.writeObject(value.webSearchCall) value.computerCall != null -> generator.writeObject(value.computerCall) value.reasoning != null -> generator.writeObject(value.reasoning) + value.compaction != null -> generator.writeObject(value.compaction) value.imageGenerationCall != null -> generator.writeObject(value.imageGenerationCall) value.codeInterpreterCall != null -> diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItemAddedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItemAddedEvent.kt index 3b2c0b0e..f572b8be 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItemAddedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItemAddedEvent.kt @@ -180,6 +180,10 @@ private constructor( /** Alias for calling [item] with `ResponseOutputItem.ofReasoning(reasoning)`. */ fun item(reasoning: ResponseReasoningItem) = item(ResponseOutputItem.ofReasoning(reasoning)) + /** Alias for calling [item] with `ResponseOutputItem.ofCompaction(compaction)`. */ + fun item(compaction: ResponseCompactionItem) = + item(ResponseOutputItem.ofCompaction(compaction)) + /** * Alias for calling [item] with * `ResponseOutputItem.ofImageGenerationCall(imageGenerationCall)`. diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItemDoneEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItemDoneEvent.kt index 2d1a67f5..d1fe199f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItemDoneEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItemDoneEvent.kt @@ -180,6 +180,10 @@ private constructor( /** Alias for calling [item] with `ResponseOutputItem.ofReasoning(reasoning)`. */ fun item(reasoning: ResponseReasoningItem) = item(ResponseOutputItem.ofReasoning(reasoning)) + /** Alias for calling [item] with `ResponseOutputItem.ofCompaction(compaction)`. */ + fun item(compaction: ResponseCompactionItem) = + item(ResponseOutputItem.ofCompaction(compaction)) + /** * Alias for calling [item] with * `ResponseOutputItem.ofImageGenerationCall(imageGenerationCall)`. diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/StructuredResponseOutputItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/StructuredResponseOutputItem.kt index d56ff6ec..d3ffcc6d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/StructuredResponseOutputItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/StructuredResponseOutputItem.kt @@ -41,6 +41,9 @@ class StructuredResponseOutputItem( /** @see ResponseOutputItem.reasoning */ fun reasoning(): Optional = rawOutputItem.reasoning() + /** @see ResponseOutputItem.compaction */ + fun compaction(): Optional = rawOutputItem.compaction() + /** @see ResponseOutputItem.codeInterpreterCall */ fun codeInterpreterCall(): Optional = rawOutputItem.codeInterpreterCall() @@ -98,6 +101,9 @@ class StructuredResponseOutputItem( /** @see ResponseOutputItem.isReasoning */ fun isReasoning(): Boolean = rawOutputItem.isReasoning() + /** @see ResponseOutputItem.isCompaction */ + fun isCompaction(): Boolean = rawOutputItem.isCompaction() + /** @see ResponseOutputItem.isCodeInterpreterCall */ fun isCodeInterpreterCall(): Boolean = rawOutputItem.isCodeInterpreterCall() @@ -153,6 +159,9 @@ class StructuredResponseOutputItem( /** @see ResponseOutputItem.asReasoning */ fun asReasoning(): ResponseReasoningItem = rawOutputItem.asReasoning() + /** @see ResponseOutputItem.asCompaction */ + fun asCompaction(): ResponseCompactionItem = rawOutputItem.asCompaction() + /** @see ResponseOutputItem.asCodeInterpreterCall */ fun asCodeInterpreterCall(): ResponseCodeInterpreterToolCall = rawOutputItem.asCodeInterpreterCall() @@ -202,6 +211,7 @@ class StructuredResponseOutputItem( isWebSearchCall() -> visitor.visitWebSearchCall(asWebSearchCall()) isComputerCall() -> visitor.visitComputerCall(asComputerCall()) isReasoning() -> visitor.visitReasoning(asReasoning()) + isCompaction() -> visitor.visitCompaction(asCompaction()) isCodeInterpreterCall() -> visitor.visitCodeInterpreterCall(asCodeInterpreterCall()) isImageGenerationCall() -> visitor.visitImageGenerationCall(asImageGenerationCall()) isLocalShellCall() -> visitor.visitLocalShellCall(asLocalShellCall()) @@ -249,6 +259,10 @@ class StructuredResponseOutputItem( reasoning.validate() } + override fun visitCompaction(compaction: ResponseCompactionItem) { + compaction.validate() + } + override fun visitCodeInterpreterCall( codeInterpreterCall: ResponseCodeInterpreterToolCall ) { @@ -352,6 +366,9 @@ class StructuredResponseOutputItem( /** @see ResponseOutputItem.Visitor.visitReasoning */ fun visitReasoning(reasoning: ResponseReasoningItem): T + /** @see ResponseOutputItem.Visitor.visitCompaction */ + fun visitCompaction(compaction: ResponseCompactionItem): T + /** @see ResponseOutputItem.Visitor.visitCodeInterpreterCall */ fun visitCodeInterpreterCall(codeInterpreterCall: ResponseCodeInterpreterToolCall): T diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/Tool.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/Tool.kt index 6eec1d2c..b43d5333 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/Tool.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/Tool.kt @@ -2967,7 +2967,8 @@ private constructor( /** * The code interpreter container. Can be a container ID or an object that specifies - * uploaded file IDs to make available to your code. + * uploaded file IDs to make available to your code, along with an optional `memory_limit` + * setting. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -3037,7 +3038,8 @@ private constructor( /** * The code interpreter container. Can be a container ID or an object that specifies - * uploaded file IDs to make available to your code. + * uploaded file IDs to make available to your code, along with an optional + * `memory_limit` setting. */ fun container(container: Container) = container(JsonField.of(container)) @@ -3150,7 +3152,8 @@ private constructor( /** * The code interpreter container. Can be a container ID or an object that specifies - * uploaded file IDs to make available to your code. + * uploaded file IDs to make available to your code, along with an optional `memory_limit` + * setting. */ @JsonDeserialize(using = Container.Deserializer::class) @JsonSerialize(using = Container.Serializer::class) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ToolChoiceShell.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ToolChoiceShell.kt index 3381f505..3c22e8ee 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ToolChoiceShell.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ToolChoiceShell.kt @@ -13,7 +13,7 @@ import com.openai.errors.OpenAIInvalidDataException import java.util.Collections import java.util.Objects -/** Forces the model to call the function shell tool when a tool call is required. */ +/** Forces the model to call the shell tool when a tool call is required. */ class ToolChoiceShell @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParams.kt index 38e81b99..8fa7ff5c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParams.kt @@ -2467,7 +2467,7 @@ private constructor( /** Forces the model to call the apply_patch tool when executing a tool call. */ fun applyPatch(): Optional = Optional.ofNullable(applyPatch) - /** Forces the model to call the function shell tool when a tool call is required. */ + /** Forces the model to call the shell tool when a tool call is required. */ fun shell(): Optional = Optional.ofNullable(shell) fun isOptions(): Boolean = options != null @@ -2519,7 +2519,7 @@ private constructor( /** Forces the model to call the apply_patch tool when executing a tool call. */ fun asApplyPatch(): ToolChoiceApplyPatch = applyPatch.getOrThrow("applyPatch") - /** Forces the model to call the function shell tool when a tool call is required. */ + /** Forces the model to call the shell tool when a tool call is required. */ fun asShell(): ToolChoiceShell = shell.getOrThrow("shell") fun _json(): Optional = Optional.ofNullable(_json) @@ -2693,7 +2693,7 @@ private constructor( @JvmStatic fun ofApplyPatch(applyPatch: ToolChoiceApplyPatch) = ToolChoice(applyPatch = applyPatch) - /** Forces the model to call the function shell tool when a tool call is required. */ + /** Forces the model to call the shell tool when a tool call is required. */ @JvmStatic fun ofShell(shell: ToolChoiceShell) = ToolChoice(shell = shell) } @@ -2737,7 +2737,7 @@ private constructor( /** Forces the model to call the apply_patch tool when executing a tool call. */ fun visitApplyPatch(applyPatch: ToolChoiceApplyPatch): T - /** Forces the model to call the function shell tool when a tool call is required. */ + /** Forces the model to call the shell tool when a tool call is required. */ fun visitShell(shell: ToolChoiceShell): T /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/videos/VideoCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/videos/VideoCreateParams.kt index 418db36e..761924a0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/videos/VideoCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/videos/VideoCreateParams.kt @@ -47,7 +47,7 @@ private constructor( fun inputReference(): Optional = body.inputReference() /** - * The video generation model to use. Defaults to `sora-2`. + * The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to `sora-2`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -55,7 +55,7 @@ private constructor( fun model(): Optional = body.model() /** - * Clip duration in seconds. Defaults to 4 seconds. + * Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -63,7 +63,8 @@ private constructor( fun seconds(): Optional = body.seconds() /** - * Output resolution formatted as width x height. Defaults to 720x1280. + * Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, + * 1792x1024). Defaults to 720x1280. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -192,7 +193,10 @@ private constructor( /** Optional image reference that guides generation. */ fun inputReference(path: Path) = apply { body.inputReference(path) } - /** The video generation model to use. Defaults to `sora-2`. */ + /** + * The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to + * `sora-2`. + */ fun model(model: VideoModel) = apply { body.model(model) } /** @@ -204,7 +208,7 @@ private constructor( */ fun model(model: MultipartField) = apply { body.model(model) } - /** Clip duration in seconds. Defaults to 4 seconds. */ + /** Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds. */ fun seconds(seconds: VideoSeconds) = apply { body.seconds(seconds) } /** @@ -216,7 +220,10 @@ private constructor( */ fun seconds(seconds: MultipartField) = apply { body.seconds(seconds) } - /** Output resolution formatted as width x height. Defaults to 720x1280. */ + /** + * Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, + * 1024x1792, 1792x1024). Defaults to 720x1280. + */ fun size(size: VideoSize) = apply { body.size(size) } /** @@ -407,7 +414,8 @@ private constructor( inputReference.value.getOptional("input_reference") /** - * The video generation model to use. Defaults to `sora-2`. + * The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to + * `sora-2`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -415,7 +423,7 @@ private constructor( fun model(): Optional = model.value.getOptional("model") /** - * Clip duration in seconds. Defaults to 4 seconds. + * Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -423,7 +431,8 @@ private constructor( fun seconds(): Optional = seconds.value.getOptional("seconds") /** - * Output resolution formatted as width x height. Defaults to 720x1280. + * Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, + * 1024x1792, 1792x1024). Defaults to 720x1280. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -556,7 +565,10 @@ private constructor( .build() ) - /** The video generation model to use. Defaults to `sora-2`. */ + /** + * The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to + * `sora-2`. + */ fun model(model: VideoModel) = model(MultipartField.of(model)) /** @@ -568,7 +580,7 @@ private constructor( */ fun model(model: MultipartField) = apply { this.model = model } - /** Clip duration in seconds. Defaults to 4 seconds. */ + /** Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds. */ fun seconds(seconds: VideoSeconds) = seconds(MultipartField.of(seconds)) /** @@ -580,7 +592,10 @@ private constructor( */ fun seconds(seconds: MultipartField) = apply { this.seconds = seconds } - /** Output resolution formatted as width x height. Defaults to 720x1280. */ + /** + * Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, + * 1024x1792, 1792x1024). Defaults to 720x1280. + */ fun size(size: VideoSize) = size(MultipartField.of(size)) /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt index e50006e8..1d1a5456 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt @@ -9,8 +9,10 @@ import com.openai.core.http.AsyncStreamResponse import com.openai.core.http.HttpResponse import com.openai.core.http.HttpResponseFor import com.openai.core.http.StreamResponse +import com.openai.models.responses.CompactedResponse import com.openai.models.responses.Response import com.openai.models.responses.ResponseCancelParams +import com.openai.models.responses.ResponseCompactParams import com.openai.models.responses.ResponseCreateParams import com.openai.models.responses.ResponseDeleteParams import com.openai.models.responses.ResponseRetrieveParams @@ -278,6 +280,24 @@ interface ResponseServiceAsync { fun cancel(responseId: String, requestOptions: RequestOptions): CompletableFuture = cancel(responseId, ResponseCancelParams.none(), requestOptions) + /** Compact conversation */ + fun compact(): CompletableFuture = compact(ResponseCompactParams.none()) + + /** @see compact */ + fun compact( + params: ResponseCompactParams = ResponseCompactParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see compact */ + fun compact( + params: ResponseCompactParams = ResponseCompactParams.none() + ): CompletableFuture = compact(params, RequestOptions.none()) + + /** @see compact */ + fun compact(requestOptions: RequestOptions): CompletableFuture = + compact(ResponseCompactParams.none(), requestOptions) + /** * A view of [ResponseServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -512,5 +532,30 @@ interface ResponseServiceAsync { requestOptions: RequestOptions, ): CompletableFuture> = cancel(responseId, ResponseCancelParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /responses/compact`, but is otherwise the same as + * [ResponseServiceAsync.compact]. + */ + fun compact(): CompletableFuture> = + compact(ResponseCompactParams.none()) + + /** @see compact */ + fun compact( + params: ResponseCompactParams = ResponseCompactParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see compact */ + fun compact( + params: ResponseCompactParams = ResponseCompactParams.none() + ): CompletableFuture> = + compact(params, RequestOptions.none()) + + /** @see compact */ + fun compact( + requestOptions: RequestOptions + ): CompletableFuture> = + compact(ResponseCompactParams.none(), requestOptions) } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt index feb85710..92f70109 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt @@ -24,8 +24,10 @@ import com.openai.core.http.map import com.openai.core.http.parseable import com.openai.core.http.toAsync import com.openai.core.prepareAsync +import com.openai.models.responses.CompactedResponse import com.openai.models.responses.Response import com.openai.models.responses.ResponseCancelParams +import com.openai.models.responses.ResponseCompactParams import com.openai.models.responses.ResponseCreateParams import com.openai.models.responses.ResponseDeleteParams import com.openai.models.responses.ResponseRetrieveParams @@ -110,6 +112,13 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C // post /responses/{response_id}/cancel withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } + override fun compact( + params: ResponseCompactParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /responses/compact + withRawResponse().compact(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ResponseServiceAsync.WithRawResponse { @@ -337,5 +346,36 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C } } } + + private val compactHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun compact( + params: ResponseCompactParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("responses", "compact") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { compactHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseService.kt index 959abb86..a30ac14c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseService.kt @@ -8,8 +8,10 @@ import com.openai.core.RequestOptions import com.openai.core.http.HttpResponse import com.openai.core.http.HttpResponseFor import com.openai.core.http.StreamResponse +import com.openai.models.responses.CompactedResponse import com.openai.models.responses.Response import com.openai.models.responses.ResponseCancelParams +import com.openai.models.responses.ResponseCompactParams import com.openai.models.responses.ResponseCreateParams import com.openai.models.responses.ResponseDeleteParams import com.openai.models.responses.ResponseRetrieveParams @@ -269,6 +271,23 @@ interface ResponseService { fun cancel(responseId: String, requestOptions: RequestOptions): Response = cancel(responseId, ResponseCancelParams.none(), requestOptions) + /** Compact conversation */ + fun compact(): CompactedResponse = compact(ResponseCompactParams.none()) + + /** @see compact */ + fun compact( + params: ResponseCompactParams = ResponseCompactParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompactedResponse + + /** @see compact */ + fun compact(params: ResponseCompactParams = ResponseCompactParams.none()): CompactedResponse = + compact(params, RequestOptions.none()) + + /** @see compact */ + fun compact(requestOptions: RequestOptions): CompactedResponse = + compact(ResponseCompactParams.none(), requestOptions) + /** A view of [ResponseService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -509,5 +528,30 @@ interface ResponseService { @MustBeClosed fun cancel(responseId: String, requestOptions: RequestOptions): HttpResponseFor = cancel(responseId, ResponseCancelParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /responses/compact`, but is otherwise the same as + * [ResponseService.compact]. + */ + @MustBeClosed + fun compact(): HttpResponseFor = compact(ResponseCompactParams.none()) + + /** @see compact */ + @MustBeClosed + fun compact( + params: ResponseCompactParams = ResponseCompactParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see compact */ + @MustBeClosed + fun compact( + params: ResponseCompactParams = ResponseCompactParams.none() + ): HttpResponseFor = compact(params, RequestOptions.none()) + + /** @see compact */ + @MustBeClosed + fun compact(requestOptions: RequestOptions): HttpResponseFor = + compact(ResponseCompactParams.none(), requestOptions) } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt index 4ffdd147..3951d570 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt @@ -22,8 +22,10 @@ import com.openai.core.http.json import com.openai.core.http.map import com.openai.core.http.parseable import com.openai.core.prepare +import com.openai.models.responses.CompactedResponse import com.openai.models.responses.Response import com.openai.models.responses.ResponseCancelParams +import com.openai.models.responses.ResponseCompactParams import com.openai.models.responses.ResponseCreateParams import com.openai.models.responses.ResponseDeleteParams import com.openai.models.responses.ResponseRetrieveParams @@ -89,6 +91,13 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client // post /responses/{response_id}/cancel withRawResponse().cancel(params, requestOptions).parse() + override fun compact( + params: ResponseCompactParams, + requestOptions: RequestOptions, + ): CompactedResponse = + // post /responses/compact + withRawResponse().compact(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ResponseService.WithRawResponse { @@ -298,5 +307,33 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client } } } + + private val compactHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun compact( + params: ResponseCompactParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("responses", "compact") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { compactHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateParamsTest.kt index 3e98dd1d..d0231163 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateParamsTest.kt @@ -19,6 +19,7 @@ internal class ContainerCreateParamsTest { .build() ) .addFileId("string") + .memoryLimit(ContainerCreateParams.MemoryLimit._1G) .build() } @@ -34,6 +35,7 @@ internal class ContainerCreateParamsTest { .build() ) .addFileId("string") + .memoryLimit(ContainerCreateParams.MemoryLimit._1G) .build() val body = params._body() @@ -47,6 +49,7 @@ internal class ContainerCreateParamsTest { .build() ) assertThat(body.fileIds().getOrNull()).containsExactly("string") + assertThat(body.memoryLimit()).contains(ContainerCreateParams.MemoryLimit._1G) } @Test diff --git a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateResponseTest.kt index 6c8c22a6..4088c082 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateResponseTest.kt @@ -24,6 +24,8 @@ internal class ContainerCreateResponseTest { .minutes(0L) .build() ) + .lastActiveAt(0L) + .memoryLimit(ContainerCreateResponse.MemoryLimit._1G) .build() assertThat(containerCreateResponse.id()).isEqualTo("id") @@ -38,6 +40,9 @@ internal class ContainerCreateResponseTest { .minutes(0L) .build() ) + assertThat(containerCreateResponse.lastActiveAt()).contains(0L) + assertThat(containerCreateResponse.memoryLimit()) + .contains(ContainerCreateResponse.MemoryLimit._1G) } @Test @@ -56,6 +61,8 @@ internal class ContainerCreateResponseTest { .minutes(0L) .build() ) + .lastActiveAt(0L) + .memoryLimit(ContainerCreateResponse.MemoryLimit._1G) .build() val roundtrippedContainerCreateResponse = diff --git a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListPageResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListPageResponseTest.kt index d3c9bced..4c545bbf 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListPageResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListPageResponseTest.kt @@ -26,6 +26,8 @@ internal class ContainerListPageResponseTest { .minutes(0L) .build() ) + .lastActiveAt(0L) + .memoryLimit(ContainerListResponse.MemoryLimit._1G) .build() ) .firstId("first_id") @@ -47,6 +49,8 @@ internal class ContainerListPageResponseTest { .minutes(0L) .build() ) + .lastActiveAt(0L) + .memoryLimit(ContainerListResponse.MemoryLimit._1G) .build() ) assertThat(containerListPageResponse.firstId()).isEqualTo("first_id") @@ -72,6 +76,8 @@ internal class ContainerListPageResponseTest { .minutes(0L) .build() ) + .lastActiveAt(0L) + .memoryLimit(ContainerListResponse.MemoryLimit._1G) .build() ) .firstId("first_id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListResponseTest.kt index b48fc105..63d28719 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListResponseTest.kt @@ -24,6 +24,8 @@ internal class ContainerListResponseTest { .minutes(0L) .build() ) + .lastActiveAt(0L) + .memoryLimit(ContainerListResponse.MemoryLimit._1G) .build() assertThat(containerListResponse.id()).isEqualTo("id") @@ -38,6 +40,9 @@ internal class ContainerListResponseTest { .minutes(0L) .build() ) + assertThat(containerListResponse.lastActiveAt()).contains(0L) + assertThat(containerListResponse.memoryLimit()) + .contains(ContainerListResponse.MemoryLimit._1G) } @Test @@ -56,6 +61,8 @@ internal class ContainerListResponseTest { .minutes(0L) .build() ) + .lastActiveAt(0L) + .memoryLimit(ContainerListResponse.MemoryLimit._1G) .build() val roundtrippedContainerListResponse = diff --git a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerRetrieveResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerRetrieveResponseTest.kt index 74852e64..30b03278 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerRetrieveResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerRetrieveResponseTest.kt @@ -24,6 +24,8 @@ internal class ContainerRetrieveResponseTest { .minutes(0L) .build() ) + .lastActiveAt(0L) + .memoryLimit(ContainerRetrieveResponse.MemoryLimit._1G) .build() assertThat(containerRetrieveResponse.id()).isEqualTo("id") @@ -38,6 +40,9 @@ internal class ContainerRetrieveResponseTest { .minutes(0L) .build() ) + assertThat(containerRetrieveResponse.lastActiveAt()).contains(0L) + assertThat(containerRetrieveResponse.memoryLimit()) + .contains(ContainerRetrieveResponse.MemoryLimit._1G) } @Test @@ -56,6 +61,8 @@ internal class ContainerRetrieveResponseTest { .minutes(0L) .build() ) + .lastActiveAt(0L) + .memoryLimit(ContainerRetrieveResponse.MemoryLimit._1G) .build() val roundtrippedContainerRetrieveResponse = diff --git a/openai-java-core/src/test/kotlin/com/openai/models/realtime/InputAudioBufferDtmfEventReceivedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/realtime/InputAudioBufferDtmfEventReceivedEventTest.kt new file mode 100644 index 00000000..5782d968 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/realtime/InputAudioBufferDtmfEventReceivedEventTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.realtime + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InputAudioBufferDtmfEventReceivedEventTest { + + @Test + fun create() { + val inputAudioBufferDtmfEventReceivedEvent = + InputAudioBufferDtmfEventReceivedEvent.builder().event("event").receivedAt(0L).build() + + assertThat(inputAudioBufferDtmfEventReceivedEvent.event()).isEqualTo("event") + assertThat(inputAudioBufferDtmfEventReceivedEvent.receivedAt()).isEqualTo(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inputAudioBufferDtmfEventReceivedEvent = + InputAudioBufferDtmfEventReceivedEvent.builder().event("event").receivedAt(0L).build() + + val roundtrippedInputAudioBufferDtmfEventReceivedEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inputAudioBufferDtmfEventReceivedEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInputAudioBufferDtmfEventReceivedEvent) + .isEqualTo(inputAudioBufferDtmfEventReceivedEvent) + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/realtime/RealtimeServerEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/realtime/RealtimeServerEventTest.kt index 3424a1e7..7e80f94c 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/realtime/RealtimeServerEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/realtime/RealtimeServerEventTest.kt @@ -42,6 +42,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -140,6 +141,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -231,6 +233,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -332,6 +335,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -441,6 +445,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -536,6 +541,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -636,6 +642,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -732,6 +739,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -819,6 +827,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).contains(error) assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -902,6 +911,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).contains(inputAudioBufferCleared) assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -979,6 +989,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()) .contains(inputAudioBufferCommitted) + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -1036,6 +1047,85 @@ internal class RealtimeServerEventTest { assertThat(roundtrippedRealtimeServerEvent).isEqualTo(realtimeServerEvent) } + @Test + fun ofInputAudioBufferDtmfEventReceived() { + val inputAudioBufferDtmfEventReceived = + InputAudioBufferDtmfEventReceivedEvent.builder().event("event").receivedAt(0L).build() + + val realtimeServerEvent = + RealtimeServerEvent.ofInputAudioBufferDtmfEventReceived( + inputAudioBufferDtmfEventReceived + ) + + assertThat(realtimeServerEvent.conversationCreated()).isEmpty + assertThat(realtimeServerEvent.conversationItemCreated()).isEmpty + assertThat(realtimeServerEvent.conversationItemDeleted()).isEmpty + assertThat(realtimeServerEvent.conversationItemInputAudioTranscriptionCompleted()).isEmpty + assertThat(realtimeServerEvent.conversationItemInputAudioTranscriptionDelta()).isEmpty + assertThat(realtimeServerEvent.conversationItemInputAudioTranscriptionFailed()).isEmpty + assertThat(realtimeServerEvent.conversationItemRetrieved()).isEmpty + assertThat(realtimeServerEvent.conversationItemTruncated()).isEmpty + assertThat(realtimeServerEvent.error()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()) + .contains(inputAudioBufferDtmfEventReceived) + assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty + assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty + assertThat(realtimeServerEvent.responseOutputAudioDelta()).isEmpty + assertThat(realtimeServerEvent.responseOutputAudioDone()).isEmpty + assertThat(realtimeServerEvent.responseOutputAudioTranscriptDelta()).isEmpty + assertThat(realtimeServerEvent.responseOutputAudioTranscriptDone()).isEmpty + assertThat(realtimeServerEvent.responseContentPartAdded()).isEmpty + assertThat(realtimeServerEvent.responseContentPartDone()).isEmpty + assertThat(realtimeServerEvent.responseCreated()).isEmpty + assertThat(realtimeServerEvent.responseDone()).isEmpty + assertThat(realtimeServerEvent.responseFunctionCallArgumentsDelta()).isEmpty + assertThat(realtimeServerEvent.responseFunctionCallArgumentsDone()).isEmpty + assertThat(realtimeServerEvent.responseOutputItemAdded()).isEmpty + assertThat(realtimeServerEvent.responseOutputItemDone()).isEmpty + assertThat(realtimeServerEvent.responseOutputTextDelta()).isEmpty + assertThat(realtimeServerEvent.responseOutputTextDone()).isEmpty + assertThat(realtimeServerEvent.sessionCreated()).isEmpty + assertThat(realtimeServerEvent.sessionUpdated()).isEmpty + assertThat(realtimeServerEvent.outputAudioBufferStarted()).isEmpty + assertThat(realtimeServerEvent.outputAudioBufferStopped()).isEmpty + assertThat(realtimeServerEvent.outputAudioBufferCleared()).isEmpty + assertThat(realtimeServerEvent.conversationItemAdded()).isEmpty + assertThat(realtimeServerEvent.conversationItemDone()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferTimeoutTriggered()).isEmpty + assertThat(realtimeServerEvent.conversationItemInputAudioTranscriptionSegment()).isEmpty + assertThat(realtimeServerEvent.mcpListToolsInProgress()).isEmpty + assertThat(realtimeServerEvent.mcpListToolsCompleted()).isEmpty + assertThat(realtimeServerEvent.mcpListToolsFailed()).isEmpty + assertThat(realtimeServerEvent.responseMcpCallArgumentsDelta()).isEmpty + assertThat(realtimeServerEvent.responseMcpCallArgumentsDone()).isEmpty + assertThat(realtimeServerEvent.responseMcpCallInProgress()).isEmpty + assertThat(realtimeServerEvent.responseMcpCallCompleted()).isEmpty + assertThat(realtimeServerEvent.responseMcpCallFailed()).isEmpty + } + + @Test + fun ofInputAudioBufferDtmfEventReceivedRoundtrip() { + val jsonMapper = jsonMapper() + val realtimeServerEvent = + RealtimeServerEvent.ofInputAudioBufferDtmfEventReceived( + InputAudioBufferDtmfEventReceivedEvent.builder() + .event("event") + .receivedAt(0L) + .build() + ) + + val roundtrippedRealtimeServerEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(realtimeServerEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRealtimeServerEvent).isEqualTo(realtimeServerEvent) + } + @Test fun ofInputAudioBufferSpeechStarted() { val inputAudioBufferSpeechStarted = @@ -1059,6 +1149,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()) .contains(inputAudioBufferSpeechStarted) assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty @@ -1140,6 +1231,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()) .contains(inputAudioBufferSpeechStopped) @@ -1226,6 +1318,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).contains(rateLimitsUpdated) @@ -1315,6 +1408,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -1401,6 +1495,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -1488,6 +1583,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -1577,6 +1673,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -1671,6 +1768,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -1772,6 +1870,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -1947,6 +2046,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -2202,6 +2302,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -2377,6 +2478,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -2466,6 +2568,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -2563,6 +2666,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -2672,6 +2776,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -2771,6 +2876,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -2857,6 +2963,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -3019,6 +3126,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -3262,6 +3370,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -3425,6 +3534,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -3504,6 +3614,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -3583,6 +3694,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -3674,6 +3786,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -3780,6 +3893,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -3876,6 +3990,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -3965,6 +4080,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -4047,6 +4163,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -4118,6 +4235,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -4189,6 +4307,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -4268,6 +4387,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -4354,6 +4474,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -4437,6 +4558,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -4518,6 +4640,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty @@ -4598,6 +4721,7 @@ internal class RealtimeServerEventTest { assertThat(realtimeServerEvent.error()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCleared()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferCommitted()).isEmpty + assertThat(realtimeServerEvent.inputAudioBufferDtmfEventReceived()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStarted()).isEmpty assertThat(realtimeServerEvent.inputAudioBufferSpeechStopped()).isEmpty assertThat(realtimeServerEvent.rateLimitsUpdated()).isEmpty diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/CompactedResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/CompactedResponseTest.kt new file mode 100644 index 00000000..2e25f937 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/CompactedResponseTest.kt @@ -0,0 +1,180 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.responses + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CompactedResponseTest { + + @Test + fun create() { + val compactedResponse = + CompactedResponse.builder() + .id("id") + .createdAt(0L) + .addOutput( + ResponseOutputMessage.builder() + .id("id") + .addContent( + ResponseOutputText.builder() + .addAnnotation( + ResponseOutputText.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) + .text("text") + .addLogprob( + ResponseOutputText.Logprob.builder() + .token("token") + .addByte(0L) + .logprob(0.0) + .addTopLogprob( + ResponseOutputText.Logprob.TopLogprob.builder() + .token("token") + .addByte(0L) + .logprob(0.0) + .build() + ) + .build() + ) + .build() + ) + .status(ResponseOutputMessage.Status.IN_PROGRESS) + .build() + ) + .usage( + ResponseUsage.builder() + .inputTokens(0L) + .inputTokensDetails( + ResponseUsage.InputTokensDetails.builder().cachedTokens(0L).build() + ) + .outputTokens(0L) + .outputTokensDetails( + ResponseUsage.OutputTokensDetails.builder().reasoningTokens(0L).build() + ) + .totalTokens(0L) + .build() + ) + .build() + + assertThat(compactedResponse.id()).isEqualTo("id") + assertThat(compactedResponse.createdAt()).isEqualTo(0L) + assertThat(compactedResponse.output()) + .containsExactly( + ResponseOutputItem.ofMessage( + ResponseOutputMessage.builder() + .id("id") + .addContent( + ResponseOutputText.builder() + .addAnnotation( + ResponseOutputText.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) + .text("text") + .addLogprob( + ResponseOutputText.Logprob.builder() + .token("token") + .addByte(0L) + .logprob(0.0) + .addTopLogprob( + ResponseOutputText.Logprob.TopLogprob.builder() + .token("token") + .addByte(0L) + .logprob(0.0) + .build() + ) + .build() + ) + .build() + ) + .status(ResponseOutputMessage.Status.IN_PROGRESS) + .build() + ) + ) + assertThat(compactedResponse.usage()) + .isEqualTo( + ResponseUsage.builder() + .inputTokens(0L) + .inputTokensDetails( + ResponseUsage.InputTokensDetails.builder().cachedTokens(0L).build() + ) + .outputTokens(0L) + .outputTokensDetails( + ResponseUsage.OutputTokensDetails.builder().reasoningTokens(0L).build() + ) + .totalTokens(0L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val compactedResponse = + CompactedResponse.builder() + .id("id") + .createdAt(0L) + .addOutput( + ResponseOutputMessage.builder() + .id("id") + .addContent( + ResponseOutputText.builder() + .addAnnotation( + ResponseOutputText.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) + .text("text") + .addLogprob( + ResponseOutputText.Logprob.builder() + .token("token") + .addByte(0L) + .logprob(0.0) + .addTopLogprob( + ResponseOutputText.Logprob.TopLogprob.builder() + .token("token") + .addByte(0L) + .logprob(0.0) + .build() + ) + .build() + ) + .build() + ) + .status(ResponseOutputMessage.Status.IN_PROGRESS) + .build() + ) + .usage( + ResponseUsage.builder() + .inputTokens(0L) + .inputTokensDetails( + ResponseUsage.InputTokensDetails.builder().cachedTokens(0L).build() + ) + .outputTokens(0L) + .outputTokensDetails( + ResponseUsage.OutputTokensDetails.builder().reasoningTokens(0L).build() + ) + .totalTokens(0L) + .build() + ) + .build() + + val roundtrippedCompactedResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(compactedResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCompactedResponse).isEqualTo(compactedResponse) + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompactParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompactParamsTest.kt new file mode 100644 index 00000000..378643e9 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompactParamsTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.responses + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ResponseCompactParamsTest { + + @Test + fun create() { + ResponseCompactParams.builder() + .input("string") + .instructions("instructions") + .model(ResponseCompactParams.Model.GPT_5_1) + .previousResponseId("resp_123") + .build() + } + + @Test + fun body() { + val params = + ResponseCompactParams.builder() + .input("string") + .instructions("instructions") + .model(ResponseCompactParams.Model.GPT_5_1) + .previousResponseId("resp_123") + .build() + + val body = params._body() + + assertThat(body.input()).contains(ResponseCompactParams.Input.ofString("string")) + assertThat(body.instructions()).contains("instructions") + assertThat(body.model()).contains(ResponseCompactParams.Model.GPT_5_1) + assertThat(body.previousResponseId()).contains("resp_123") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = ResponseCompactParams.builder().build() + + val body = params._body() + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompactionItemParamTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompactionItemParamTest.kt new file mode 100644 index 00000000..8d4f68d7 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompactionItemParamTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.responses + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ResponseCompactionItemParamTest { + + @Test + fun create() { + val responseCompactionItemParam = + ResponseCompactionItemParam.builder() + .encryptedContent("encrypted_content") + .id("cmp_123") + .build() + + assertThat(responseCompactionItemParam.encryptedContent()).isEqualTo("encrypted_content") + assertThat(responseCompactionItemParam.id()).contains("cmp_123") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val responseCompactionItemParam = + ResponseCompactionItemParam.builder() + .encryptedContent("encrypted_content") + .id("cmp_123") + .build() + + val roundtrippedResponseCompactionItemParam = + jsonMapper.readValue( + jsonMapper.writeValueAsString(responseCompactionItemParam), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResponseCompactionItemParam).isEqualTo(responseCompactionItemParam) + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompactionItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompactionItemTest.kt new file mode 100644 index 00000000..51bf4cd9 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompactionItemTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.responses + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ResponseCompactionItemTest { + + @Test + fun create() { + val responseCompactionItem = + ResponseCompactionItem.builder() + .id("id") + .encryptedContent("encrypted_content") + .createdBy("created_by") + .build() + + assertThat(responseCompactionItem.id()).isEqualTo("id") + assertThat(responseCompactionItem.encryptedContent()).isEqualTo("encrypted_content") + assertThat(responseCompactionItem.createdBy()).contains("created_by") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val responseCompactionItem = + ResponseCompactionItem.builder() + .id("id") + .encryptedContent("encrypted_content") + .createdBy("created_by") + .build() + + val roundtrippedResponseCompactionItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(responseCompactionItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResponseCompactionItem).isEqualTo(responseCompactionItem) + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompletedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompletedEventTest.kt index 83964f48..83f11a94 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompletedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompletedEventTest.kt @@ -39,7 +39,7 @@ internal class ResponseCompletedEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -169,7 +169,7 @@ internal class ResponseCompletedEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -301,7 +301,7 @@ internal class ResponseCompletedEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreateParamsTest.kt index 81d01bae..da33364d 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreateParamsTest.kt @@ -29,7 +29,7 @@ internal class ResponseCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .parallelToolCalls(true) .previousResponseId("previous_response_id") .prompt( @@ -101,7 +101,7 @@ internal class ResponseCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .parallelToolCalls(true) .previousResponseId("previous_response_id") .prompt( @@ -172,7 +172,7 @@ internal class ResponseCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - assertThat(body.model()).contains(ResponsesModel.ofChat(ChatModel.GPT_4O)) + assertThat(body.model()).contains(ResponsesModel.ofChat(ChatModel.GPT_5_1)) assertThat(body.parallelToolCalls()).contains(true) assertThat(body.previousResponseId()).contains("previous_response_id") assertThat(body.prompt()) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreatedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreatedEventTest.kt index 40ace6df..1db2bb3c 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreatedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreatedEventTest.kt @@ -39,7 +39,7 @@ internal class ResponseCreatedEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -169,7 +169,7 @@ internal class ResponseCreatedEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -301,7 +301,7 @@ internal class ResponseCreatedEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseFailedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseFailedEventTest.kt index 8cef5294..40d6e6dd 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseFailedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseFailedEventTest.kt @@ -39,7 +39,7 @@ internal class ResponseFailedEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -169,7 +169,7 @@ internal class ResponseFailedEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -301,7 +301,7 @@ internal class ResponseFailedEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInProgressEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInProgressEventTest.kt index ca751646..a528a1f9 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInProgressEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInProgressEventTest.kt @@ -39,7 +39,7 @@ internal class ResponseInProgressEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -169,7 +169,7 @@ internal class ResponseInProgressEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -301,7 +301,7 @@ internal class ResponseInProgressEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseIncompleteEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseIncompleteEventTest.kt index a3ff7882..26daee42 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseIncompleteEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseIncompleteEventTest.kt @@ -39,7 +39,7 @@ internal class ResponseIncompleteEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -169,7 +169,7 @@ internal class ResponseIncompleteEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -301,7 +301,7 @@ internal class ResponseIncompleteEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInputItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInputItemTest.kt index 32f8a64b..8849298d 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInputItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInputItemTest.kt @@ -35,6 +35,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -95,6 +96,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -180,6 +182,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -277,6 +280,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -364,6 +368,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -451,6 +456,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -532,6 +538,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -602,6 +609,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).contains(functionCall) assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -664,6 +672,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).contains(functionCallOutput) assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -726,6 +735,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).contains(reasoning) + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -766,6 +776,64 @@ internal class ResponseInputItemTest { assertThat(roundtrippedResponseInputItem).isEqualTo(responseInputItem) } + @Test + fun ofCompaction() { + val compaction = + ResponseCompactionItemParam.builder() + .encryptedContent("encrypted_content") + .id("cmp_123") + .build() + + val responseInputItem = ResponseInputItem.ofCompaction(compaction) + + assertThat(responseInputItem.easyInputMessage()).isEmpty + assertThat(responseInputItem.message()).isEmpty + assertThat(responseInputItem.responseOutputMessage()).isEmpty + assertThat(responseInputItem.fileSearchCall()).isEmpty + assertThat(responseInputItem.computerCall()).isEmpty + assertThat(responseInputItem.computerCallOutput()).isEmpty + assertThat(responseInputItem.webSearchCall()).isEmpty + assertThat(responseInputItem.functionCall()).isEmpty + assertThat(responseInputItem.functionCallOutput()).isEmpty + assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).contains(compaction) + assertThat(responseInputItem.imageGenerationCall()).isEmpty + assertThat(responseInputItem.codeInterpreterCall()).isEmpty + assertThat(responseInputItem.localShellCall()).isEmpty + assertThat(responseInputItem.localShellCallOutput()).isEmpty + assertThat(responseInputItem.shellCall()).isEmpty + assertThat(responseInputItem.shellCallOutput()).isEmpty + assertThat(responseInputItem.applyPatchCall()).isEmpty + assertThat(responseInputItem.applyPatchCallOutput()).isEmpty + assertThat(responseInputItem.mcpListTools()).isEmpty + assertThat(responseInputItem.mcpApprovalRequest()).isEmpty + assertThat(responseInputItem.mcpApprovalResponse()).isEmpty + assertThat(responseInputItem.mcpCall()).isEmpty + assertThat(responseInputItem.customToolCallOutput()).isEmpty + assertThat(responseInputItem.customToolCall()).isEmpty + assertThat(responseInputItem.itemReference()).isEmpty + } + + @Test + fun ofCompactionRoundtrip() { + val jsonMapper = jsonMapper() + val responseInputItem = + ResponseInputItem.ofCompaction( + ResponseCompactionItemParam.builder() + .encryptedContent("encrypted_content") + .id("cmp_123") + .build() + ) + + val roundtrippedResponseInputItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(responseInputItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResponseInputItem).isEqualTo(responseInputItem) + } + @Test fun ofImageGenerationCall() { val imageGenerationCall = @@ -787,6 +855,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).contains(imageGenerationCall) assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -848,6 +917,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).contains(codeInterpreterCall) assertThat(responseInputItem.localShellCall()).isEmpty @@ -922,6 +992,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).contains(localShellCall) @@ -994,6 +1065,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -1060,6 +1132,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -1133,6 +1206,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -1205,6 +1279,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -1271,6 +1346,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -1339,6 +1415,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -1407,6 +1484,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -1468,6 +1546,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -1533,6 +1612,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -1597,6 +1677,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -1657,6 +1738,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty @@ -1716,6 +1798,7 @@ internal class ResponseInputItemTest { assertThat(responseInputItem.functionCall()).isEmpty assertThat(responseInputItem.functionCallOutput()).isEmpty assertThat(responseInputItem.reasoning()).isEmpty + assertThat(responseInputItem.compaction()).isEmpty assertThat(responseInputItem.imageGenerationCall()).isEmpty assertThat(responseInputItem.codeInterpreterCall()).isEmpty assertThat(responseInputItem.localShellCall()).isEmpty diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt index 2348ad9f..b6ef85d8 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt @@ -56,6 +56,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -145,6 +146,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -211,6 +213,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -273,6 +276,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).contains(webSearchCall) assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -348,6 +352,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).contains(computerCall) assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -416,6 +421,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).contains(reasoning) + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -452,6 +458,58 @@ internal class ResponseOutputItemTest { assertThat(roundtrippedResponseOutputItem).isEqualTo(responseOutputItem) } + @Test + fun ofCompaction() { + val compaction = + ResponseCompactionItem.builder() + .id("id") + .encryptedContent("encrypted_content") + .createdBy("created_by") + .build() + + val responseOutputItem = ResponseOutputItem.ofCompaction(compaction) + + assertThat(responseOutputItem.message()).isEmpty + assertThat(responseOutputItem.fileSearchCall()).isEmpty + assertThat(responseOutputItem.functionCall()).isEmpty + assertThat(responseOutputItem.webSearchCall()).isEmpty + assertThat(responseOutputItem.computerCall()).isEmpty + assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).contains(compaction) + assertThat(responseOutputItem.imageGenerationCall()).isEmpty + assertThat(responseOutputItem.codeInterpreterCall()).isEmpty + assertThat(responseOutputItem.localShellCall()).isEmpty + assertThat(responseOutputItem.shellCall()).isEmpty + assertThat(responseOutputItem.shellCallOutput()).isEmpty + assertThat(responseOutputItem.applyPatchCall()).isEmpty + assertThat(responseOutputItem.applyPatchCallOutput()).isEmpty + assertThat(responseOutputItem.mcpCall()).isEmpty + assertThat(responseOutputItem.mcpListTools()).isEmpty + assertThat(responseOutputItem.mcpApprovalRequest()).isEmpty + assertThat(responseOutputItem.customToolCall()).isEmpty + } + + @Test + fun ofCompactionRoundtrip() { + val jsonMapper = jsonMapper() + val responseOutputItem = + ResponseOutputItem.ofCompaction( + ResponseCompactionItem.builder() + .id("id") + .encryptedContent("encrypted_content") + .createdBy("created_by") + .build() + ) + + val roundtrippedResponseOutputItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(responseOutputItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResponseOutputItem).isEqualTo(responseOutputItem) + } + @Test fun ofImageGenerationCall() { val imageGenerationCall = @@ -469,6 +527,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).contains(imageGenerationCall) assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -522,6 +581,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).contains(codeInterpreterCall) assertThat(responseOutputItem.localShellCall()).isEmpty @@ -588,6 +648,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).contains(localShellCall) @@ -660,6 +721,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -728,6 +790,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -795,6 +858,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -855,6 +919,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -913,6 +978,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -977,6 +1043,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -1037,6 +1104,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty @@ -1090,6 +1158,7 @@ internal class ResponseOutputItemTest { assertThat(responseOutputItem.webSearchCall()).isEmpty assertThat(responseOutputItem.computerCall()).isEmpty assertThat(responseOutputItem.reasoning()).isEmpty + assertThat(responseOutputItem.compaction()).isEmpty assertThat(responseOutputItem.imageGenerationCall()).isEmpty assertThat(responseOutputItem.codeInterpreterCall()).isEmpty assertThat(responseOutputItem.localShellCall()).isEmpty diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseQueuedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseQueuedEventTest.kt index 988a51f6..c7f1118d 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseQueuedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseQueuedEventTest.kt @@ -39,7 +39,7 @@ internal class ResponseQueuedEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -169,7 +169,7 @@ internal class ResponseQueuedEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -301,7 +301,7 @@ internal class ResponseQueuedEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt index 5c4f0635..a0b2cf62 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt @@ -809,7 +809,7 @@ internal class ResponseStreamEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -1001,7 +1001,7 @@ internal class ResponseStreamEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -1427,7 +1427,7 @@ internal class ResponseStreamEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -1619,7 +1619,7 @@ internal class ResponseStreamEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -2301,7 +2301,7 @@ internal class ResponseStreamEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -2493,7 +2493,7 @@ internal class ResponseStreamEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -2637,7 +2637,7 @@ internal class ResponseStreamEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -2829,7 +2829,7 @@ internal class ResponseStreamEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -2973,7 +2973,7 @@ internal class ResponseStreamEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -3165,7 +3165,7 @@ internal class ResponseStreamEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -5995,7 +5995,7 @@ internal class ResponseStreamEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -6187,7 +6187,7 @@ internal class ResponseStreamEventTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTest.kt index 640b2210..291dfd2b 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTest.kt @@ -38,7 +38,7 @@ internal class ResponseTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") @@ -161,7 +161,7 @@ internal class ResponseTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - assertThat(response.model()).isEqualTo(ResponsesModel.ofChat(ChatModel.GPT_4O)) + assertThat(response.model()).isEqualTo(ResponsesModel.ofChat(ChatModel.GPT_5_1)) assertThat(response.output()) .containsExactly( ResponseOutputItem.ofMessage( @@ -299,7 +299,7 @@ internal class ResponseTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .addOutput( ResponseOutputMessage.builder() .id("id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseOutputItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseOutputItemTest.kt index 809dc306..9e26e4b5 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseOutputItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseOutputItemTest.kt @@ -61,6 +61,8 @@ internal class StructuredResponseOutputItemTest { .build() private val REASONING_ITEM = ResponseReasoningItem.builder().id(STRING).summary(listOf()).build() + private val COMPACTION_ITEM = + ResponseCompactionItem.builder().id(STRING).encryptedContent(STRING).build() private val CODE_INTERPRETER_CALL = ResponseCodeInterpreterToolCall.builder() .id(STRING) @@ -175,6 +177,7 @@ internal class StructuredResponseOutputItemTest { DelegationReadTestCase("webSearchCall", OPTIONAL), DelegationReadTestCase("computerCall", OPTIONAL), DelegationReadTestCase("reasoning", OPTIONAL), + DelegationReadTestCase("compaction", OPTIONAL), DelegationReadTestCase("localShellCall", OPTIONAL), DelegationReadTestCase("shellCall", OPTIONAL), DelegationReadTestCase("shellCallOutput", OPTIONAL), @@ -193,6 +196,8 @@ internal class StructuredResponseOutputItemTest { DelegationReadTestCase("isComputerCall", false), DelegationReadTestCase("isReasoning", true), DelegationReadTestCase("isReasoning", false), + DelegationReadTestCase("isCompaction", true), + DelegationReadTestCase("isCompaction", false), DelegationReadTestCase("isLocalShellCall", true), DelegationReadTestCase("isLocalShellCall", false), DelegationReadTestCase("isShellCall", true), @@ -209,6 +214,7 @@ internal class StructuredResponseOutputItemTest { DelegationReadTestCase("asWebSearchCall", FUNCTION_WEB_SEARCH), DelegationReadTestCase("asComputerCall", COMPUTER_TOOL_CALL), DelegationReadTestCase("asReasoning", REASONING_ITEM), + DelegationReadTestCase("asCompaction", COMPACTION_ITEM), DelegationReadTestCase("asCodeInterpreterCall", CODE_INTERPRETER_CALL), DelegationReadTestCase("asImageGenerationCall", IMAGE_GENERATION_CALL), DelegationReadTestCase("asLocalShellCall", LOCAL_SHELL_CALL), @@ -287,6 +293,7 @@ internal class StructuredResponseOutputItemTest { "accept", "visitCodeInterpreterCall", "visitImageGenerationCall", + "visitCompaction", "visitMcpApprovalRequest", "visitMcpCall", "visitMcpListTools", diff --git a/openai-java-core/src/test/kotlin/com/openai/services/async/ContainerServiceAsyncTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/async/ContainerServiceAsyncTest.kt index 03ff3b7a..c969f669 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/async/ContainerServiceAsyncTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/async/ContainerServiceAsyncTest.kt @@ -31,6 +31,7 @@ internal class ContainerServiceAsyncTest { .build() ) .addFileId("string") + .memoryLimit(ContainerCreateParams.MemoryLimit._1G) .build() ) diff --git a/openai-java-core/src/test/kotlin/com/openai/services/async/ResponseServiceAsyncTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/async/ResponseServiceAsyncTest.kt index e8726d3f..4c67800b 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/async/ResponseServiceAsyncTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/async/ResponseServiceAsyncTest.kt @@ -10,6 +10,7 @@ import com.openai.models.Reasoning import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatText import com.openai.models.responses.FunctionTool +import com.openai.models.responses.ResponseCompactParams import com.openai.models.responses.ResponseCreateParams import com.openai.models.responses.ResponseIncludable import com.openai.models.responses.ResponsePrompt @@ -46,7 +47,7 @@ internal class ResponseServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .parallelToolCalls(true) .previousResponseId("previous_response_id") .prompt( @@ -132,7 +133,7 @@ internal class ResponseServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .parallelToolCalls(true) .previousResponseId("previous_response_id") .prompt( @@ -270,4 +271,27 @@ internal class ResponseServiceAsyncTest { val response = responseFuture.get() response.validate() } + + @Test + fun compact() { + val client = + OpenAIOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val responseServiceAsync = client.responses() + + val compactedResponseFuture = + responseServiceAsync.compact( + ResponseCompactParams.builder() + .input("string") + .instructions("instructions") + .model(ResponseCompactParams.Model.GPT_5_1) + .previousResponseId("resp_123") + .build() + ) + + val compactedResponse = compactedResponseFuture.get() + compactedResponse.validate() + } } diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/ContainerServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/ContainerServiceTest.kt index 97e30ca8..1bbd9926 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/ContainerServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/ContainerServiceTest.kt @@ -31,6 +31,7 @@ internal class ContainerServiceTest { .build() ) .addFileId("string") + .memoryLimit(ContainerCreateParams.MemoryLimit._1G) .build() ) diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/ResponseServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/ResponseServiceTest.kt index 9e009da9..e88ccad5 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/ResponseServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/ResponseServiceTest.kt @@ -10,6 +10,7 @@ import com.openai.models.Reasoning import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatText import com.openai.models.responses.FunctionTool +import com.openai.models.responses.ResponseCompactParams import com.openai.models.responses.ResponseCreateParams import com.openai.models.responses.ResponseIncludable import com.openai.models.responses.ResponsePrompt @@ -46,7 +47,7 @@ internal class ResponseServiceTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .parallelToolCalls(true) .previousResponseId("previous_response_id") .prompt( @@ -131,7 +132,7 @@ internal class ResponseServiceTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model(ChatModel.GPT_4O) + .model(ChatModel.GPT_5_1) .parallelToolCalls(true) .previousResponseId("previous_response_id") .prompt( @@ -265,4 +266,26 @@ internal class ResponseServiceTest { response.validate() } + + @Test + fun compact() { + val client = + OpenAIOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val responseService = client.responses() + + val compactedResponse = + responseService.compact( + ResponseCompactParams.builder() + .input("string") + .instructions("instructions") + .model(ResponseCompactParams.Model.GPT_5_1) + .previousResponseId("resp_123") + .build() + ) + + compactedResponse.validate() + } } diff --git a/scripts/build b/scripts/build index f4063482..32d2e4ea 100755 --- a/scripts/build +++ b/scripts/build @@ -5,4 +5,5 @@ set -e cd "$(dirname "$0")/.." echo "==> Building classes" -./gradlew build testClasses -x test + +./gradlew build testClasses -x test \ No newline at end of file diff --git a/scripts/test b/scripts/test index abf365dc..c6276344 100755 --- a/scripts/test +++ b/scripts/test @@ -54,9 +54,4 @@ fi echo "==> Running tests" -./gradlew \ - --no-daemon \ - -Dkotlin.daemon.enabled=false \ - -Dkotlin.compiler.execution.strategy=in-process \ - -Dkotlin.incremental=false \ - test "$@" +./gradlew test "$@" From babb353b4590229ca1b2164dcc737ecb07f7a354 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Dec 2025 17:51:55 +0000 Subject: [PATCH 6/6] release: 4.9.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 19 +++++++++++++++++++ README.md | 14 +++++++------- build.gradle.kts | 2 +- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 90eeef65..6b467676 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.8.0" + ".": "4.9.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 4203879a..09229e41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## 4.9.0 (2025-12-04) + +Full Changelog: [v4.8.0...v4.9.0](https://github.com/openai/openai-java/compare/v4.8.0...v4.9.0) + +### Features + +* **api:** gpt-5.1-codex-max and responses/compact ([651c44f](https://github.com/openai/openai-java/commit/651c44f570ba07784d715a382d94b255fd3afa60)) + + +### Bug Fixes + +* **api:** align types of input items / output items for typescript ([9202c69](https://github.com/openai/openai-java/commit/9202c695d939def7c9598e9ee75999b8ebd87e32)) +* **client:** cancel okhttp call when future cancelled ([c665e21](https://github.com/openai/openai-java/commit/c665e21c83123931baed5b21b9bbaa96a4d77495)) + + +### Documentation + +* remove `$` for better copy-pasteabality ([66f7a4b](https://github.com/openai/openai-java/commit/66f7a4b3d2b88fc3e80c1552d0a0df86cd45c1ff)) + ## 4.8.0 (2025-11-13) Full Changelog: [v4.7.2...v4.8.0](https://github.com/openai/openai-java/compare/v4.7.2...v4.8.0) diff --git a/README.md b/README.md index a9285832..30f01cdc 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/4.8.0) -[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/4.8.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/4.8.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/4.9.0) +[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/4.9.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/4.9.0) @@ -11,7 +11,7 @@ The OpenAI Java SDK provides convenient access to the [OpenAI REST API](https:// -The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/4.8.0). +The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/4.9.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor ### Gradle ```kotlin -implementation("com.openai:openai-java:4.8.0") +implementation("com.openai:openai-java:4.9.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.openai:openai-java:4.8.0") com.openai openai-java - 4.8.0 + 4.9.0 ``` @@ -1342,7 +1342,7 @@ If you're using Spring Boot, then you can use the SDK's [Spring Boot starter](ht #### Gradle ```kotlin -implementation("com.openai:openai-java-spring-boot-starter:4.8.0") +implementation("com.openai:openai-java-spring-boot-starter:4.9.0") ``` #### Maven @@ -1351,7 +1351,7 @@ implementation("com.openai:openai-java-spring-boot-starter:4.8.0") com.openai openai-java-spring-boot-starter - 4.8.0 + 4.9.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 6ec56e42..6347a8c0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openai" - version = "4.8.0" // x-release-please-version + version = "4.9.0" // x-release-please-version } subprojects {