diff --git a/.stats.yml b/.stats.yml index 58a71565e..873d2c179 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 61 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-fc5dbc19505b0035f9e7f88868619f4fb519b048bde011f6154f3132d4be71fb.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-7c699d4503077d06a4a44f52c0c1f902d19a87c766b8be75b97c8dfd484ad4aa.yml diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantCreateParams.kt index 27f6d24be..51a377724 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantCreateParams.kt @@ -6,6 +6,7 @@ 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.Enum import com.openai.core.ExcludeMissing import com.openai.core.JsonField import com.openai.core.JsonMissing @@ -17,6 +18,7 @@ import com.openai.core.http.Headers import com.openai.core.http.QueryParams import com.openai.core.immutableEmptyMap import com.openai.core.toImmutable +import com.openai.errors.OpenAIInvalidDataException import java.util.Objects import java.util.Optional @@ -57,6 +59,16 @@ private constructor( /** The name of the assistant. The maximum length is 256 characters. */ fun name(): Optional = body.name() + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported + * values are `low`, `medium`, and `high`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(): Optional = body.reasoningEffort() + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -136,6 +148,16 @@ private constructor( /** The name of the assistant. The maximum length is 256 characters. */ fun _name(): JsonField = body._name() + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported + * values are `low`, `medium`, and `high`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. + */ + fun _reasoningEffort(): JsonField = body._reasoningEffort() + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -217,6 +239,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("reasoning_effort") + @ExcludeMissing + private val reasoningEffort: JsonField = JsonMissing.of(), @JsonProperty("response_format") @ExcludeMissing private val responseFormat: JsonField = JsonMissing.of(), @@ -268,6 +293,17 @@ private constructor( /** The name of the assistant. The maximum length is 256 characters. */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(): Optional = + Optional.ofNullable(reasoningEffort.getNullable("reasoning_effort")) + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -356,6 +392,18 @@ private constructor( /** The name of the assistant. The maximum length is 256 characters. */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + @JsonProperty("reasoning_effort") + @ExcludeMissing + fun _reasoningEffort(): JsonField = reasoningEffort + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -429,6 +477,7 @@ private constructor( instructions() metadata().ifPresent { it.validate() } name() + reasoningEffort() responseFormat().ifPresent { it.validate() } temperature() toolResources().ifPresent { it.validate() } @@ -452,6 +501,7 @@ private constructor( private var instructions: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() + private var reasoningEffort: JsonField = JsonMissing.of() private var responseFormat: JsonField = JsonMissing.of() private var temperature: JsonField = JsonMissing.of() private var toolResources: JsonField = JsonMissing.of() @@ -466,6 +516,7 @@ private constructor( instructions = betaAssistantCreateBody.instructions metadata = betaAssistantCreateBody.metadata name = betaAssistantCreateBody.name + reasoningEffort = betaAssistantCreateBody.reasoningEffort responseFormat = betaAssistantCreateBody.responseFormat temperature = betaAssistantCreateBody.temperature toolResources = betaAssistantCreateBody.toolResources @@ -570,6 +621,40 @@ private constructor( /** The name of the assistant. The maximum length is 256 characters. */ fun name(name: JsonField) = apply { this.name = name } + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can + * result in faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: ReasoningEffort?) = + reasoningEffort(JsonField.ofNullable(reasoningEffort)) + + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can + * result in faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: Optional) = + reasoningEffort(reasoningEffort.orElse(null)) + + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can + * result in faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: JsonField) = apply { + this.reasoningEffort = reasoningEffort + } + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -906,6 +991,7 @@ private constructor( instructions, metadata, name, + reasoningEffort, responseFormat, temperature, toolResources, @@ -920,17 +1006,17 @@ private constructor( return true } - return /* spotless:off */ other is BetaAssistantCreateBody && model == other.model && description == other.description && instructions == other.instructions && metadata == other.metadata && name == other.name && responseFormat == other.responseFormat && temperature == other.temperature && toolResources == other.toolResources && tools == other.tools && topP == other.topP && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BetaAssistantCreateBody && model == other.model && description == other.description && instructions == other.instructions && metadata == other.metadata && name == other.name && reasoningEffort == other.reasoningEffort && responseFormat == other.responseFormat && temperature == other.temperature && toolResources == other.toolResources && tools == other.tools && topP == other.topP && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(model, description, instructions, metadata, name, responseFormat, temperature, toolResources, tools, topP, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(model, description, instructions, metadata, name, reasoningEffort, responseFormat, temperature, toolResources, tools, topP, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "BetaAssistantCreateBody{model=$model, description=$description, instructions=$instructions, metadata=$metadata, name=$name, responseFormat=$responseFormat, temperature=$temperature, toolResources=$toolResources, tools=$tools, topP=$topP, additionalProperties=$additionalProperties}" + "BetaAssistantCreateBody{model=$model, description=$description, instructions=$instructions, metadata=$metadata, name=$name, reasoningEffort=$reasoningEffort, responseFormat=$responseFormat, temperature=$temperature, toolResources=$toolResources, tools=$tools, topP=$topP, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -1047,6 +1133,41 @@ private constructor( /** The name of the assistant. The maximum length is 256 characters. */ fun name(name: JsonField) = apply { body.name(name) } + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: ReasoningEffort?) = apply { + body.reasoningEffort(reasoningEffort) + } + + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: Optional) = + reasoningEffort(reasoningEffort.orElse(null)) + + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: JsonField) = apply { + body.reasoningEffort(reasoningEffort) + } + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -1453,6 +1574,115 @@ private constructor( ) } + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported + * values are `low`, `medium`, and `high`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. + */ + class ReasoningEffort + @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 LOW = of("low") + + @JvmField val MEDIUM = of("medium") + + @JvmField val HIGH = of("high") + + @JvmStatic fun of(value: String) = ReasoningEffort(JsonField.of(value)) + } + + /** An enum containing [ReasoningEffort]'s known values. */ + enum class Known { + LOW, + MEDIUM, + HIGH, + } + + /** + * An enum containing [ReasoningEffort]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasoningEffort] 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 { + LOW, + MEDIUM, + HIGH, + /** + * An enum member indicating that [ReasoningEffort] 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) { + LOW -> Value.LOW + MEDIUM -> Value.MEDIUM + HIGH -> Value.HIGH + 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) { + LOW -> Known.LOW + MEDIUM -> Known.MEDIUM + HIGH -> Known.HIGH + else -> throw OpenAIInvalidDataException("Unknown ReasoningEffort: $value") + } + + fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ReasoningEffort && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * A set of resources that are used by the assistant's tools. The resources are specific to the * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantUpdateParams.kt index 4890dd0e2..18bae55b8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantUpdateParams.kt @@ -6,6 +6,7 @@ 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.Enum import com.openai.core.ExcludeMissing import com.openai.core.JsonField import com.openai.core.JsonMissing @@ -17,6 +18,7 @@ import com.openai.core.http.Headers import com.openai.core.http.QueryParams import com.openai.core.immutableEmptyMap import com.openai.core.toImmutable +import com.openai.errors.OpenAIInvalidDataException import java.util.Objects import java.util.Optional @@ -55,11 +57,21 @@ private constructor( * your available models, or see our [Model overview](https://platform.openai.com/docs/models) * for descriptions of them. */ - fun model(): Optional = body.model() + fun model(): Optional = body.model() /** The name of the assistant. The maximum length is 256 characters. */ fun name(): Optional = body.name() + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported + * values are `low`, `medium`, and `high`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(): Optional = body.reasoningEffort() + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -134,11 +146,21 @@ private constructor( * your available models, or see our [Model overview](https://platform.openai.com/docs/models) * for descriptions of them. */ - fun _model(): JsonField = body._model() + fun _model(): JsonField = body._model() /** The name of the assistant. The maximum length is 256 characters. */ fun _name(): JsonField = body._name() + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported + * values are `low`, `medium`, and `high`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. + */ + fun _reasoningEffort(): JsonField = body._reasoningEffort() + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -223,10 +245,13 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("model") @ExcludeMissing - private val model: JsonField = JsonMissing.of(), + private val model: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("reasoning_effort") + @ExcludeMissing + private val reasoningEffort: JsonField = JsonMissing.of(), @JsonProperty("response_format") @ExcludeMissing private val responseFormat: JsonField = JsonMissing.of(), @@ -273,11 +298,22 @@ private constructor( * of your available models, or see our * [Model overview](https://platform.openai.com/docs/models) for descriptions of them. */ - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) /** The name of the assistant. The maximum length is 256 characters. */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(): Optional = + Optional.ofNullable(reasoningEffort.getNullable("reasoning_effort")) + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -361,11 +397,23 @@ private constructor( * of your available models, or see our * [Model overview](https://platform.openai.com/docs/models) for descriptions of them. */ - @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model /** The name of the assistant. The maximum length is 256 characters. */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + @JsonProperty("reasoning_effort") + @ExcludeMissing + fun _reasoningEffort(): JsonField = reasoningEffort + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -439,6 +487,7 @@ private constructor( metadata().ifPresent { it.validate() } model() name() + reasoningEffort() responseFormat().ifPresent { it.validate() } temperature() toolResources().ifPresent { it.validate() } @@ -460,8 +509,9 @@ private constructor( private var description: JsonField = JsonMissing.of() private var instructions: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() - private var model: JsonField = JsonMissing.of() + private var model: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() + private var reasoningEffort: JsonField = JsonMissing.of() private var responseFormat: JsonField = JsonMissing.of() private var temperature: JsonField = JsonMissing.of() private var toolResources: JsonField = JsonMissing.of() @@ -476,6 +526,7 @@ private constructor( metadata = betaAssistantUpdateBody.metadata model = betaAssistantUpdateBody.model name = betaAssistantUpdateBody.name + reasoningEffort = betaAssistantUpdateBody.reasoningEffort responseFormat = betaAssistantUpdateBody.responseFormat temperature = betaAssistantUpdateBody.temperature toolResources = betaAssistantUpdateBody.toolResources @@ -553,7 +604,15 @@ private constructor( * all of your available models, or see our * [Model overview](https://platform.openai.com/docs/models) for descriptions of them. */ - fun model(model: String) = model(JsonField.of(model)) + fun model(model: Model) = model(JsonField.of(model)) + + /** + * ID of the model to use. You can use the + * [List models](https://platform.openai.com/docs/api-reference/models/list) API to see + * all of your available models, or see our + * [Model overview](https://platform.openai.com/docs/models) for descriptions of them. + */ + fun model(model: JsonField) = apply { this.model = model } /** * ID of the model to use. You can use the @@ -561,7 +620,7 @@ private constructor( * all of your available models, or see our * [Model overview](https://platform.openai.com/docs/models) for descriptions of them. */ - fun model(model: JsonField) = apply { this.model = model } + fun model(value: String) = model(Model.of(value)) /** The name of the assistant. The maximum length is 256 characters. */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -572,6 +631,40 @@ private constructor( /** The name of the assistant. The maximum length is 256 characters. */ fun name(name: JsonField) = apply { this.name = name } + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can + * result in faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: ReasoningEffort?) = + reasoningEffort(JsonField.ofNullable(reasoningEffort)) + + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can + * result in faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: Optional) = + reasoningEffort(reasoningEffort.orElse(null)) + + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can + * result in faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: JsonField) = apply { + this.reasoningEffort = reasoningEffort + } + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -908,6 +1001,7 @@ private constructor( metadata, model, name, + reasoningEffort, responseFormat, temperature, toolResources, @@ -922,17 +1016,17 @@ private constructor( return true } - return /* spotless:off */ other is BetaAssistantUpdateBody && description == other.description && instructions == other.instructions && metadata == other.metadata && model == other.model && name == other.name && responseFormat == other.responseFormat && temperature == other.temperature && toolResources == other.toolResources && tools == other.tools && topP == other.topP && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BetaAssistantUpdateBody && description == other.description && instructions == other.instructions && metadata == other.metadata && model == other.model && name == other.name && reasoningEffort == other.reasoningEffort && responseFormat == other.responseFormat && temperature == other.temperature && toolResources == other.toolResources && tools == other.tools && topP == other.topP && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(description, instructions, metadata, model, name, responseFormat, temperature, toolResources, tools, topP, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(description, instructions, metadata, model, name, reasoningEffort, responseFormat, temperature, toolResources, tools, topP, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "BetaAssistantUpdateBody{description=$description, instructions=$instructions, metadata=$metadata, model=$model, name=$name, responseFormat=$responseFormat, temperature=$temperature, toolResources=$toolResources, tools=$tools, topP=$topP, additionalProperties=$additionalProperties}" + "BetaAssistantUpdateBody{description=$description, instructions=$instructions, metadata=$metadata, model=$model, name=$name, reasoningEffort=$reasoningEffort, responseFormat=$responseFormat, temperature=$temperature, toolResources=$toolResources, tools=$tools, topP=$topP, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -1026,7 +1120,7 @@ private constructor( * of your available models, or see our * [Model overview](https://platform.openai.com/docs/models) for descriptions of them. */ - fun model(model: String) = apply { body.model(model) } + fun model(model: Model) = apply { body.model(model) } /** * ID of the model to use. You can use the @@ -1034,7 +1128,15 @@ private constructor( * of your available models, or see our * [Model overview](https://platform.openai.com/docs/models) for descriptions of them. */ - fun model(model: JsonField) = apply { body.model(model) } + fun model(model: JsonField) = apply { body.model(model) } + + /** + * ID of the model to use. You can use the + * [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all + * of your available models, or see our + * [Model overview](https://platform.openai.com/docs/models) for descriptions of them. + */ + fun model(value: String) = apply { body.model(value) } /** The name of the assistant. The maximum length is 256 characters. */ fun name(name: String?) = apply { body.name(name) } @@ -1045,6 +1147,41 @@ private constructor( /** The name of the assistant. The maximum length is 256 characters. */ fun name(name: JsonField) = apply { body.name(name) } + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: ReasoningEffort?) = apply { + body.reasoningEffort(reasoningEffort) + } + + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: Optional) = + reasoningEffort(reasoningEffort.orElse(null)) + + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: JsonField) = apply { + body.reasoningEffort(reasoningEffort) + } + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -1452,6 +1589,369 @@ private constructor( ) } + /** + * ID of the model to use. You can use the + * [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of + * your available models, or see our [Model overview](https://platform.openai.com/docs/models) + * for descriptions of them. + */ + 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 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 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_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_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") + + @JvmStatic fun of(value: String) = Model(JsonField.of(value)) + } + + /** An enum containing [Model]'s known values. */ + enum class Known { + O3_MINI, + O3_MINI_2025_01_31, + O1, + O1_2024_12_17, + GPT_4O, + GPT_4O_2024_11_20, + GPT_4O_2024_08_06, + GPT_4O_2024_05_13, + 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_0613, + GPT_3_5_TURBO_1106, + GPT_3_5_TURBO_0125, + GPT_3_5_TURBO_16K_0613, + } + + /** + * 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 { + O3_MINI, + O3_MINI_2025_01_31, + O1, + O1_2024_12_17, + GPT_4O, + GPT_4O_2024_11_20, + GPT_4O_2024_08_06, + GPT_4O_2024_05_13, + 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_0613, + GPT_3_5_TURBO_1106, + GPT_3_5_TURBO_0125, + GPT_3_5_TURBO_16K_0613, + /** 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) { + 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 + 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_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_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 + 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) { + 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 + 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_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_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 + else -> throw OpenAIInvalidDataException("Unknown Model: $value") + } + + fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Model && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported + * values are `low`, `medium`, and `high`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. + */ + class ReasoningEffort + @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 LOW = of("low") + + @JvmField val MEDIUM = of("medium") + + @JvmField val HIGH = of("high") + + @JvmStatic fun of(value: String) = ReasoningEffort(JsonField.of(value)) + } + + /** An enum containing [ReasoningEffort]'s known values. */ + enum class Known { + LOW, + MEDIUM, + HIGH, + } + + /** + * An enum containing [ReasoningEffort]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasoningEffort] 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 { + LOW, + MEDIUM, + HIGH, + /** + * An enum member indicating that [ReasoningEffort] 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) { + LOW -> Value.LOW + MEDIUM -> Value.MEDIUM + HIGH -> Value.HIGH + 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) { + LOW -> Known.LOW + MEDIUM -> Known.MEDIUM + HIGH -> Known.HIGH + else -> throw OpenAIInvalidDataException("Unknown ReasoningEffort: $value") + } + + fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ReasoningEffort && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * A set of resources that are used by the assistant's tools. The resources are specific to the * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadRunCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadRunCreateParams.kt index 2dbc4ffcb..b40856189 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadRunCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadRunCreateParams.kt @@ -118,6 +118,16 @@ private constructor( */ fun parallelToolCalls(): Optional = body.parallelToolCalls() + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported + * values are `low`, `medium`, and `high`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(): Optional = body.reasoningEffort() + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -239,6 +249,16 @@ private constructor( */ fun _parallelToolCalls(): JsonField = body._parallelToolCalls() + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported + * values are `low`, `medium`, and `high`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. + */ + fun _reasoningEffort(): JsonField = body._reasoningEffort() + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -353,6 +373,9 @@ private constructor( @JsonProperty("parallel_tool_calls") @ExcludeMissing private val parallelToolCalls: JsonField = JsonMissing.of(), + @JsonProperty("reasoning_effort") + @ExcludeMissing + private val reasoningEffort: JsonField = JsonMissing.of(), @JsonProperty("response_format") @ExcludeMissing private val responseFormat: JsonField = JsonMissing.of(), @@ -444,6 +467,17 @@ private constructor( fun parallelToolCalls(): Optional = Optional.ofNullable(parallelToolCalls.getNullable("parallel_tool_calls")) + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(): Optional = + Optional.ofNullable(reasoningEffort.getNullable("reasoning_effort")) + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -585,6 +619,18 @@ private constructor( @ExcludeMissing fun _parallelToolCalls(): JsonField = parallelToolCalls + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + @JsonProperty("reasoning_effort") + @ExcludeMissing + fun _reasoningEffort(): JsonField = reasoningEffort + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -673,6 +719,7 @@ private constructor( metadata().ifPresent { it.validate() } model() parallelToolCalls() + reasoningEffort() responseFormat().ifPresent { it.validate() } temperature() toolChoice().ifPresent { it.validate() } @@ -701,6 +748,7 @@ private constructor( private var metadata: JsonField = JsonMissing.of() private var model: JsonField = JsonMissing.of() private var parallelToolCalls: JsonField = JsonMissing.of() + private var reasoningEffort: JsonField = JsonMissing.of() private var responseFormat: JsonField = JsonMissing.of() private var temperature: JsonField = JsonMissing.of() private var toolChoice: JsonField = JsonMissing.of() @@ -721,6 +769,7 @@ private constructor( metadata = betaThreadRunCreateBody.metadata model = betaThreadRunCreateBody.model parallelToolCalls = betaThreadRunCreateBody.parallelToolCalls + reasoningEffort = betaThreadRunCreateBody.reasoningEffort responseFormat = betaThreadRunCreateBody.responseFormat temperature = betaThreadRunCreateBody.temperature toolChoice = betaThreadRunCreateBody.toolChoice @@ -979,6 +1028,40 @@ private constructor( this.parallelToolCalls = parallelToolCalls } + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can + * result in faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: ReasoningEffort?) = + reasoningEffort(JsonField.ofNullable(reasoningEffort)) + + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can + * result in faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: Optional) = + reasoningEffort(reasoningEffort.orElse(null)) + + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can + * result in faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: JsonField) = apply { + this.reasoningEffort = reasoningEffort + } + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -1372,6 +1455,7 @@ private constructor( metadata, model, parallelToolCalls, + reasoningEffort, responseFormat, temperature, toolChoice, @@ -1387,17 +1471,17 @@ private constructor( return true } - return /* spotless:off */ other is BetaThreadRunCreateBody && assistantId == other.assistantId && additionalInstructions == other.additionalInstructions && additionalMessages == other.additionalMessages && instructions == other.instructions && maxCompletionTokens == other.maxCompletionTokens && maxPromptTokens == other.maxPromptTokens && metadata == other.metadata && model == other.model && parallelToolCalls == other.parallelToolCalls && responseFormat == other.responseFormat && temperature == other.temperature && toolChoice == other.toolChoice && tools == other.tools && topP == other.topP && truncationStrategy == other.truncationStrategy && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BetaThreadRunCreateBody && assistantId == other.assistantId && additionalInstructions == other.additionalInstructions && additionalMessages == other.additionalMessages && instructions == other.instructions && maxCompletionTokens == other.maxCompletionTokens && maxPromptTokens == other.maxPromptTokens && metadata == other.metadata && model == other.model && parallelToolCalls == other.parallelToolCalls && reasoningEffort == other.reasoningEffort && responseFormat == other.responseFormat && temperature == other.temperature && toolChoice == other.toolChoice && tools == other.tools && topP == other.topP && truncationStrategy == other.truncationStrategy && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(assistantId, additionalInstructions, additionalMessages, instructions, maxCompletionTokens, maxPromptTokens, metadata, model, parallelToolCalls, responseFormat, temperature, toolChoice, tools, topP, truncationStrategy, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(assistantId, additionalInstructions, additionalMessages, instructions, maxCompletionTokens, maxPromptTokens, metadata, model, parallelToolCalls, reasoningEffort, responseFormat, temperature, toolChoice, tools, topP, truncationStrategy, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "BetaThreadRunCreateBody{assistantId=$assistantId, additionalInstructions=$additionalInstructions, additionalMessages=$additionalMessages, instructions=$instructions, maxCompletionTokens=$maxCompletionTokens, maxPromptTokens=$maxPromptTokens, metadata=$metadata, model=$model, parallelToolCalls=$parallelToolCalls, responseFormat=$responseFormat, temperature=$temperature, toolChoice=$toolChoice, tools=$tools, topP=$topP, truncationStrategy=$truncationStrategy, additionalProperties=$additionalProperties}" + "BetaThreadRunCreateBody{assistantId=$assistantId, additionalInstructions=$additionalInstructions, additionalMessages=$additionalMessages, instructions=$instructions, maxCompletionTokens=$maxCompletionTokens, maxPromptTokens=$maxPromptTokens, metadata=$metadata, model=$model, parallelToolCalls=$parallelToolCalls, reasoningEffort=$reasoningEffort, responseFormat=$responseFormat, temperature=$temperature, toolChoice=$toolChoice, tools=$tools, topP=$topP, truncationStrategy=$truncationStrategy, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -1698,6 +1782,41 @@ private constructor( body.parallelToolCalls(parallelToolCalls) } + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: ReasoningEffort?) = apply { + body.reasoningEffort(reasoningEffort) + } + + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: Optional) = + reasoningEffort(reasoningEffort.orElse(null)) + + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: JsonField) = apply { + body.reasoningEffort(reasoningEffort) + } + /** * Specifies the format that the model must output. Compatible with * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 @@ -2997,6 +3116,115 @@ private constructor( "AdditionalMessage{content=$content, role=$role, attachments=$attachments, metadata=$metadata, additionalProperties=$additionalProperties}" } + /** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported + * values are `low`, `medium`, and `high`. Reducing reasoning effort can result in faster + * responses and fewer tokens used on reasoning in a response. + */ + class ReasoningEffort + @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 LOW = of("low") + + @JvmField val MEDIUM = of("medium") + + @JvmField val HIGH = of("high") + + @JvmStatic fun of(value: String) = ReasoningEffort(JsonField.of(value)) + } + + /** An enum containing [ReasoningEffort]'s known values. */ + enum class Known { + LOW, + MEDIUM, + HIGH, + } + + /** + * An enum containing [ReasoningEffort]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasoningEffort] 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 { + LOW, + MEDIUM, + HIGH, + /** + * An enum member indicating that [ReasoningEffort] 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) { + LOW -> Value.LOW + MEDIUM -> Value.MEDIUM + HIGH -> Value.HIGH + 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) { + LOW -> Known.LOW + MEDIUM -> Known.MEDIUM + HIGH -> Known.HIGH + else -> throw OpenAIInvalidDataException("Unknown ReasoningEffort: $value") + } + + fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ReasoningEffort && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * Controls for how a thread will be truncated prior to the run. Use this to control the intial * context window of the run. diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt index f9f800860..eee050f0a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt @@ -189,7 +189,7 @@ private constructor( fun presencePenalty(): Optional = body.presencePenalty() /** - * **o1 models only** + * **o1 and o3-mini models only** * * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported @@ -438,7 +438,7 @@ private constructor( fun _presencePenalty(): JsonField = body._presencePenalty() /** - * **o1 models only** + * **o1 and o3-mini models only** * * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported @@ -801,7 +801,7 @@ private constructor( Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) /** - * **o1 models only** + * **o1 and o3-mini models only** * * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently @@ -1087,7 +1087,7 @@ private constructor( fun _presencePenalty(): JsonField = presencePenalty /** - * **o1 models only** + * **o1 and o3-mini models only** * * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently @@ -2013,18 +2013,29 @@ private constructor( } /** - * **o1 models only** + * **o1 and o3-mini models only** * * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can * result in faster responses and fewer tokens used on reasoning in a response. */ - fun reasoningEffort(reasoningEffort: ChatCompletionReasoningEffort) = - reasoningEffort(JsonField.of(reasoningEffort)) + fun reasoningEffort(reasoningEffort: ChatCompletionReasoningEffort?) = + reasoningEffort(JsonField.ofNullable(reasoningEffort)) /** - * **o1 models only** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can + * result in faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: Optional) = + reasoningEffort(reasoningEffort.orElse(null)) + + /** + * **o1 and o3-mini models only** * * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently @@ -3175,19 +3186,30 @@ private constructor( } /** - * **o1 models only** + * **o1 and o3-mini models only** * * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in * faster responses and fewer tokens used on reasoning in a response. */ - fun reasoningEffort(reasoningEffort: ChatCompletionReasoningEffort) = apply { + fun reasoningEffort(reasoningEffort: ChatCompletionReasoningEffort?) = apply { body.reasoningEffort(reasoningEffort) } /** - * **o1 models only** + * **o1 and o3-mini models only** + * + * Constrains effort on reasoning for + * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently + * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in + * faster responses and fewer tokens used on reasoning in a response. + */ + fun reasoningEffort(reasoningEffort: Optional) = + reasoningEffort(reasoningEffort.orElse(null)) + + /** + * **o1 and o3-mini models only** * * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionReasoningEffort.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionReasoningEffort.kt index d485fdad0..1b15b0e10 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionReasoningEffort.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionReasoningEffort.kt @@ -8,7 +8,7 @@ import com.openai.core.JsonField import com.openai.errors.OpenAIInvalidDataException /** - * **o1 models only** + * **o1 and o3-mini models only** * * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported values diff --git a/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantCreateParamsTest.kt index cc48f6f80..a02e1470e 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantCreateParamsTest.kt @@ -18,6 +18,7 @@ class BetaAssistantCreateParamsTest { Metadata.builder().putAdditionalProperty("foo", JsonValue.from("string")).build() ) .name("name") + .reasoningEffort(BetaAssistantCreateParams.ReasoningEffort.LOW) .responseFormatAuto() .temperature(1.0) .toolResources( @@ -66,6 +67,7 @@ class BetaAssistantCreateParamsTest { .build() ) .name("name") + .reasoningEffort(BetaAssistantCreateParams.ReasoningEffort.LOW) .responseFormatAuto() .temperature(1.0) .toolResources( @@ -112,6 +114,7 @@ class BetaAssistantCreateParamsTest { Metadata.builder().putAdditionalProperty("foo", JsonValue.from("string")).build() ) assertThat(body.name()).contains("name") + assertThat(body.reasoningEffort()).contains(BetaAssistantCreateParams.ReasoningEffort.LOW) assertThat(body.responseFormat()).contains(AssistantResponseFormatOption.ofAuto()) assertThat(body.temperature()).contains(1.0) assertThat(body.toolResources()) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantUpdateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantUpdateParamsTest.kt index 8cd762eb4..c24672c4c 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantUpdateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantUpdateParamsTest.kt @@ -17,8 +17,9 @@ class BetaAssistantUpdateParamsTest { .metadata( Metadata.builder().putAdditionalProperty("foo", JsonValue.from("string")).build() ) - .model("model") + .model(BetaAssistantUpdateParams.Model.O3_MINI) .name("name") + .reasoningEffort(BetaAssistantUpdateParams.ReasoningEffort.LOW) .responseFormatAuto() .temperature(1.0) .toolResources( @@ -52,8 +53,9 @@ class BetaAssistantUpdateParamsTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model("model") + .model(BetaAssistantUpdateParams.Model.O3_MINI) .name("name") + .reasoningEffort(BetaAssistantUpdateParams.ReasoningEffort.LOW) .responseFormatAuto() .temperature(1.0) .toolResources( @@ -81,8 +83,9 @@ class BetaAssistantUpdateParamsTest { .contains( Metadata.builder().putAdditionalProperty("foo", JsonValue.from("string")).build() ) - assertThat(body.model()).contains("model") + assertThat(body.model()).contains(BetaAssistantUpdateParams.Model.O3_MINI) assertThat(body.name()).contains("name") + assertThat(body.reasoningEffort()).contains(BetaAssistantUpdateParams.ReasoningEffort.LOW) assertThat(body.responseFormat()).contains(AssistantResponseFormatOption.ofAuto()) assertThat(body.temperature()).contains(1.0) assertThat(body.toolResources()) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadRunCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadRunCreateParamsTest.kt index f76d8272f..8e1e0d892 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadRunCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/BetaThreadRunCreateParamsTest.kt @@ -41,6 +41,7 @@ class BetaThreadRunCreateParamsTest { ) .model(ChatModel.O3_MINI) .parallelToolCalls(true) + .reasoningEffort(BetaThreadRunCreateParams.ReasoningEffort.LOW) .responseFormatAuto() .temperature(1.0) .toolChoice(AssistantToolChoiceOption.Auto.NONE) @@ -90,6 +91,7 @@ class BetaThreadRunCreateParamsTest { ) .model(ChatModel.O3_MINI) .parallelToolCalls(true) + .reasoningEffort(BetaThreadRunCreateParams.ReasoningEffort.LOW) .responseFormatAuto() .temperature(1.0) .toolChoice(AssistantToolChoiceOption.Auto.NONE) @@ -156,6 +158,7 @@ class BetaThreadRunCreateParamsTest { ) .model(ChatModel.O3_MINI) .parallelToolCalls(true) + .reasoningEffort(BetaThreadRunCreateParams.ReasoningEffort.LOW) .responseFormatAuto() .temperature(1.0) .toolChoice(AssistantToolChoiceOption.Auto.NONE) @@ -201,6 +204,7 @@ class BetaThreadRunCreateParamsTest { ) assertThat(body.model()).contains(ChatModel.O3_MINI) assertThat(body.parallelToolCalls()).contains(true) + assertThat(body.reasoningEffort()).contains(BetaThreadRunCreateParams.ReasoningEffort.LOW) assertThat(body.responseFormat()).contains(AssistantResponseFormatOption.ofAuto()) assertThat(body.temperature()).contains(1.0) assertThat(body.toolChoice()) diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/AssistantServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/AssistantServiceTest.kt index bbd9f8b37..08a6b6966 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/AssistantServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/AssistantServiceTest.kt @@ -40,6 +40,7 @@ class AssistantServiceTest { .build() ) .name("name") + .reasoningEffort(BetaAssistantCreateParams.ReasoningEffort.LOW) .responseFormatAuto() .temperature(1.0) .toolResources( @@ -117,8 +118,9 @@ class AssistantServiceTest { .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - .model("model") + .model(BetaAssistantUpdateParams.Model.O3_MINI) .name("name") + .reasoningEffort(BetaAssistantUpdateParams.ReasoningEffort.LOW) .responseFormatAuto() .temperature(1.0) .toolResources( diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/threads/RunServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/threads/RunServiceTest.kt index 3d0f31f3f..820b2347c 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/threads/RunServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/threads/RunServiceTest.kt @@ -64,6 +64,7 @@ class RunServiceTest { ) .model(ChatModel.O3_MINI) .parallelToolCalls(true) + .reasoningEffort(BetaThreadRunCreateParams.ReasoningEffort.LOW) .responseFormatAuto() .temperature(1.0) .toolChoice(AssistantToolChoiceOption.Auto.NONE) @@ -124,6 +125,7 @@ class RunServiceTest { ) .model(ChatModel.O3_MINI) .parallelToolCalls(true) + .reasoningEffort(BetaThreadRunCreateParams.ReasoningEffort.LOW) .responseFormatAuto() .temperature(1.0) .toolChoice(AssistantToolChoiceOption.Auto.NONE)