diff --git a/.release-please-manifest.json b/.release-please-manifest.json index a71305534..d52d2b974 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.12.0" + ".": "0.13.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 6e3315239..2e0cee9eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 60 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b5b0e2c794b012919701c3fd43286af10fa25d33ceb8a881bec2636028f446e0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-3904ef6b29a89c98f93a9b7da19879695f3c440564be6384db7af1b734611ede.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index a190bf7e6..18b0707b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.13.0 (2025-01-22) + +Full Changelog: [v0.12.0...v0.13.0](https://github.com/openai/openai-java/compare/v0.12.0...v0.13.0) + +### Features + +* **api:** update enum values, comments, examples, and constants ([#149](https://github.com/openai/openai-java/issues/149)) ([4bfa305](https://github.com/openai/openai-java/commit/4bfa3055d017aa23cc8cc41827012dc773cbf508)) + + +### Bug Fixes + +* **examples:** remove now unneeded role param ([045f141](https://github.com/openai/openai-java/commit/045f141a7956d13a2ac35af30e64c5160252ee6b)) + ## 0.12.0 (2025-01-22) Full Changelog: [v0.11.10...v0.12.0](https://github.com/openai/openai-java/compare/v0.11.10...v0.12.0) diff --git a/README.md b/README.md index c6a6797d4..0a0be5921 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.12.0) -[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.12.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.12.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.13.0) +[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.13.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.13.0) @@ -31,7 +31,7 @@ The REST API documentation can be foundĀ on [platform.openai.com](https://platfo ```kotlin -implementation("com.openai:openai-java:0.12.0") +implementation("com.openai:openai-java:0.13.0") ``` #### Maven @@ -40,7 +40,7 @@ implementation("com.openai:openai-java:0.12.0") com.openai openai-java - 0.12.0 + 0.13.0 ``` @@ -96,7 +96,6 @@ import com.openai.models.ChatModel; ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() .addMessage(ChatCompletionUserMessageParam.builder() - .role(ChatCompletionUserMessageParam.Role.USER) .content("Say this is a test") .build()) .model(ChatModel.O1) @@ -312,7 +311,6 @@ OpenAIClient client = clientBuilder.build(); ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam( ChatCompletionUserMessageParam.builder() - .role(ChatCompletionUserMessageParam.Role.USER) .content(ChatCompletionUserMessageParam.Content.ofTextContent("Who won the world series in 2020?")) .build())) .model("gpt-4o") diff --git a/build.gradle.kts b/build.gradle.kts index 7c362cb38..787da4cab 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openai" - version = "0.12.0" // x-release-please-version + version = "0.13.0" // x-release-please-version } subprojects { diff --git a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExample.java b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExample.java index 1401e77ac..962d69fb6 100644 --- a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExample.java +++ b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExample.java @@ -33,7 +33,6 @@ public static void main(String[] args) { ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam( ChatCompletionUserMessageParam.builder() - .role(ChatCompletionUserMessageParam.Role.USER) .content(ChatCompletionUserMessageParam.Content.ofTextContent("Who won the world series in 2020?")) .build())) .model("gpt-4o") diff --git a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExampleAsync.java b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExampleAsync.java index db8f30fa6..1ab865906 100644 --- a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExampleAsync.java +++ b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureApiKeyExampleAsync.java @@ -34,7 +34,6 @@ public static void main(String[] args) { ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam( ChatCompletionUserMessageParam.builder() - .role(ChatCompletionUserMessageParam.Role.USER) .content(ChatCompletionUserMessageParam.Content.ofTextContent("Who won the world series in 2020?")) .build())) .model("gpt-4o") diff --git a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExample.java b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExample.java index 8f5093ac7..e27ecdd46 100644 --- a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExample.java +++ b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExample.java @@ -39,7 +39,6 @@ public static void main(String[] args) { ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam( ChatCompletionUserMessageParam.builder() - .role(ChatCompletionUserMessageParam.Role.USER) .content(ChatCompletionUserMessageParam.Content.ofTextContent("Who won the world series in 2020?")) .build())) .model("gpt-4o") diff --git a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExampleAsync.java b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExampleAsync.java index 1ad511c46..e526bdc9c 100644 --- a/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExampleAsync.java +++ b/openai-azure-java-example/src/main/java/com.openai.azure.examples/AzureEntraIDExampleAsync.java @@ -39,7 +39,6 @@ public static void main(String[] args) { ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam( ChatCompletionUserMessageParam.builder() - .role(ChatCompletionUserMessageParam.Role.USER) .content(ChatCompletionUserMessageParam.Content.ofTextContent("Who won the world series in 2020?")) .build())) .model("gpt-4o") diff --git a/openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt b/openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt index 887b00b0e..86e9b7bef 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt @@ -6,7 +6,6 @@ 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 @@ -37,9 +36,7 @@ private constructor( @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonValue = JsonMissing.of(), @JsonProperty("model") @ExcludeMissing private val model: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("object") - @ExcludeMissing - private val object_: JsonField = JsonMissing.of(), + @JsonProperty("object") @ExcludeMissing private val object_: JsonValue = JsonMissing.of(), @JsonProperty("tools") @ExcludeMissing private val tools: JsonField> = JsonMissing.of(), @@ -91,7 +88,7 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The object type, which is always `assistant`. */ - fun object_(): Object = object_.getRequired("object") + @JsonProperty("object") @ExcludeMissing fun _object_(): JsonValue = object_ /** * A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. @@ -173,9 +170,6 @@ private constructor( /** The name of the assistant. The maximum length is 256 characters. */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** The object type, which is always `assistant`. */ - @JsonProperty("object") @ExcludeMissing fun _object_(): JsonField = object_ - /** * A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. * Tools can be of types `code_interpreter`, `file_search`, or `function`. @@ -247,7 +241,11 @@ private constructor( instructions() model() name() - object_() + _object_().let { + if (it != JsonValue.from("assistant")) { + throw OpenAIInvalidDataException("'object_' is invalid, received $it") + } + } tools().forEach { it.validate() } responseFormat().ifPresent { it.validate() } temperature() @@ -272,7 +270,7 @@ private constructor( private var metadata: JsonValue? = null private var model: JsonField? = null private var name: JsonField? = null - private var object_: JsonField? = null + private var object_: JsonValue = JsonValue.from("assistant") private var tools: JsonField>? = null private var responseFormat: JsonField = JsonMissing.of() private var temperature: JsonField = JsonMissing.of() @@ -372,10 +370,7 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** The object type, which is always `assistant`. */ - fun object_(object_: Object) = object_(JsonField.of(object_)) - - /** The object type, which is always `assistant`. */ - fun object_(object_: JsonField) = apply { this.object_ = object_ } + fun object_(object_: JsonValue) = apply { this.object_ = object_ } /** * A list of tool enabled on the assistant. There can be a maximum of 128 tools per @@ -500,8 +495,7 @@ private constructor( } /** `auto` is the default value */ - fun responseFormat(behavior: AssistantResponseFormatOption.Behavior) = - responseFormat(AssistantResponseFormatOption.ofBehavior(behavior)) + fun responseFormatAuto() = responseFormat(AssistantResponseFormatOption.ofAuto()) /** * Specifies the format that the model must output. Compatible with @@ -696,7 +690,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("model", model), checkRequired("name", name), - checkRequired("object_", object_), + object_, checkRequired("tools", tools).map { it.toImmutable() }, responseFormat, temperature, @@ -706,58 +700,6 @@ private constructor( ) } - /** The object type, which is always `assistant`. */ - class Object - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ASSISTANT = of("assistant") - - @JvmStatic fun of(value: String) = Object(JsonField.of(value)) - } - - enum class Known { - ASSISTANT, - } - - enum class Value { - ASSISTANT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ASSISTANT -> Value.ASSISTANT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ASSISTANT -> Known.ASSISTANT - else -> throw OpenAIInvalidDataException("Unknown Object: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Object && 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/AssistantDeleted.kt b/openai-java-core/src/main/kotlin/com/openai/models/AssistantDeleted.kt index f736691f4..714653d3e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/AssistantDeleted.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/AssistantDeleted.kt @@ -6,7 +6,6 @@ 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 @@ -26,9 +25,7 @@ private constructor( @JsonProperty("deleted") @ExcludeMissing private val deleted: JsonField = JsonMissing.of(), - @JsonProperty("object") - @ExcludeMissing - private val object_: JsonField = JsonMissing.of(), + @JsonProperty("object") @ExcludeMissing private val object_: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -36,14 +33,12 @@ private constructor( fun deleted(): Boolean = deleted.getRequired("deleted") - fun object_(): Object = object_.getRequired("object") + @JsonProperty("object") @ExcludeMissing fun _object_(): JsonValue = object_ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("deleted") @ExcludeMissing fun _deleted(): JsonField = deleted - @JsonProperty("object") @ExcludeMissing fun _object_(): JsonField = object_ - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -57,7 +52,11 @@ private constructor( id() deleted() - object_() + _object_().let { + if (it != JsonValue.from("assistant.deleted")) { + throw OpenAIInvalidDataException("'object_' is invalid, received $it") + } + } validated = true } @@ -72,7 +71,7 @@ private constructor( private var id: JsonField? = null private var deleted: JsonField? = null - private var object_: JsonField? = null + private var object_: JsonValue = JsonValue.from("assistant.deleted") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -91,9 +90,7 @@ private constructor( fun deleted(deleted: JsonField) = apply { this.deleted = deleted } - fun object_(object_: Object) = object_(JsonField.of(object_)) - - fun object_(object_: JsonField) = apply { this.object_ = object_ } + fun object_(object_: JsonValue) = apply { this.object_ = object_ } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -118,62 +115,11 @@ private constructor( AssistantDeleted( checkRequired("id", id), checkRequired("deleted", deleted), - checkRequired("object_", object_), + object_, additionalProperties.toImmutable(), ) } - class Object - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ASSISTANT_DELETED = of("assistant.deleted") - - @JvmStatic fun of(value: String) = Object(JsonField.of(value)) - } - - enum class Known { - ASSISTANT_DELETED, - } - - enum class Value { - ASSISTANT_DELETED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ASSISTANT_DELETED -> Value.ASSISTANT_DELETED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ASSISTANT_DELETED -> Known.ASSISTANT_DELETED - else -> throw OpenAIInvalidDataException("Unknown Object: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Object && value == other.value /* spotless:on */ - } - - 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/AssistantResponseFormatOption.kt b/openai-java-core/src/main/kotlin/com/openai/models/AssistantResponseFormatOption.kt index d692af323..a956dbb3b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/AssistantResponseFormatOption.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/AssistantResponseFormatOption.kt @@ -2,7 +2,6 @@ package com.openai.models -import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -12,8 +11,6 @@ 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.JsonField import com.openai.core.JsonValue import com.openai.core.getOrThrow import com.openai.errors.OpenAIInvalidDataException @@ -44,7 +41,7 @@ import java.util.Optional @JsonSerialize(using = AssistantResponseFormatOption.Serializer::class) class AssistantResponseFormatOption private constructor( - private val behavior: Behavior? = null, + private val auto: JsonValue? = null, private val responseFormatText: ResponseFormatText? = null, private val responseFormatJsonObject: ResponseFormatJsonObject? = null, private val responseFormatJsonSchema: ResponseFormatJsonSchema? = null, @@ -52,7 +49,7 @@ private constructor( ) { /** `auto` is the default value */ - fun behavior(): Optional = Optional.ofNullable(behavior) + fun auto(): Optional = Optional.ofNullable(auto) fun responseFormatText(): Optional = Optional.ofNullable(responseFormatText) @@ -62,7 +59,7 @@ private constructor( fun responseFormatJsonSchema(): Optional = Optional.ofNullable(responseFormatJsonSchema) - fun isBehavior(): Boolean = behavior != null + fun isAuto(): Boolean = auto != null fun isResponseFormatText(): Boolean = responseFormatText != null @@ -71,7 +68,7 @@ private constructor( fun isResponseFormatJsonSchema(): Boolean = responseFormatJsonSchema != null /** `auto` is the default value */ - fun asBehavior(): Behavior = behavior.getOrThrow("behavior") + fun asAuto(): JsonValue = auto.getOrThrow("auto") fun asResponseFormatText(): ResponseFormatText = responseFormatText.getOrThrow("responseFormatText") @@ -86,7 +83,7 @@ private constructor( fun accept(visitor: Visitor): T { return when { - behavior != null -> visitor.visitBehavior(behavior) + auto != null -> visitor.visitAuto(auto) responseFormatText != null -> visitor.visitResponseFormatText(responseFormatText) responseFormatJsonObject != null -> visitor.visitResponseFormatJsonObject(responseFormatJsonObject) @@ -105,7 +102,13 @@ private constructor( accept( object : Visitor { - override fun visitBehavior(behavior: Behavior) {} + override fun visitAuto(auto: JsonValue) { + auto.let { + if (it != JsonValue.from("auto")) { + throw OpenAIInvalidDataException("'auto' is invalid, received $it") + } + } + } override fun visitResponseFormatText(responseFormatText: ResponseFormatText) { responseFormatText.validate() @@ -132,14 +135,14 @@ private constructor( return true } - return /* spotless:off */ other is AssistantResponseFormatOption && behavior == other.behavior && responseFormatText == other.responseFormatText && responseFormatJsonObject == other.responseFormatJsonObject && responseFormatJsonSchema == other.responseFormatJsonSchema /* spotless:on */ + return /* spotless:off */ other is AssistantResponseFormatOption && auto == other.auto && responseFormatText == other.responseFormatText && responseFormatJsonObject == other.responseFormatJsonObject && responseFormatJsonSchema == other.responseFormatJsonSchema /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(behavior, responseFormatText, responseFormatJsonObject, responseFormatJsonSchema) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(auto, responseFormatText, responseFormatJsonObject, responseFormatJsonSchema) /* spotless:on */ override fun toString(): String = when { - behavior != null -> "AssistantResponseFormatOption{behavior=$behavior}" + auto != null -> "AssistantResponseFormatOption{auto=$auto}" responseFormatText != null -> "AssistantResponseFormatOption{responseFormatText=$responseFormatText}" responseFormatJsonObject != null -> @@ -153,8 +156,7 @@ private constructor( companion object { /** `auto` is the default value */ - @JvmStatic - fun ofBehavior(behavior: Behavior) = AssistantResponseFormatOption(behavior = behavior) + @JvmStatic fun ofAuto() = AssistantResponseFormatOption(auto = JsonValue.from("auto")) @JvmStatic fun ofResponseFormatText(responseFormatText: ResponseFormatText) = @@ -172,7 +174,7 @@ private constructor( interface Visitor { /** `auto` is the default value */ - fun visitBehavior(behavior: Behavior): T + fun visitAuto(auto: JsonValue): T fun visitResponseFormatText(responseFormatText: ResponseFormatText): T @@ -191,9 +193,16 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): AssistantResponseFormatOption { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return AssistantResponseFormatOption(behavior = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.let { + if (it != JsonValue.from("auto")) { + throw OpenAIInvalidDataException("'auto' is invalid, received $it") + } + } + } + ?.let { + return AssistantResponseFormatOption(auto = it, _json = json) + } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return AssistantResponseFormatOption(responseFormatText = it, _json = json) @@ -226,7 +235,7 @@ private constructor( provider: SerializerProvider ) { when { - value.behavior != null -> generator.writeObject(value.behavior) + value.auto != null -> generator.writeObject(value.auto) value.responseFormatText != null -> generator.writeObject(value.responseFormatText) value.responseFormatJsonObject != null -> generator.writeObject(value.responseFormatJsonObject) @@ -237,56 +246,4 @@ private constructor( } } } - - /** `auto` is the default value */ - class Behavior - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AUTO = of("auto") - - @JvmStatic fun of(value: String) = Behavior(JsonField.of(value)) - } - - enum class Known { - AUTO, - } - - enum class Value { - AUTO, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - else -> throw OpenAIInvalidDataException("Unknown Behavior: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Behavior && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/AssistantStreamEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/AssistantStreamEvent.kt index b6e603c0d..914bf70f9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/AssistantStreamEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/AssistantStreamEvent.kt @@ -15,7 +15,6 @@ 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 @@ -1242,9 +1241,7 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonProperty("enabled") @ExcludeMissing private val enabled: JsonField = JsonMissing.of(), @@ -1258,7 +1255,7 @@ private constructor( */ fun data(): Thread = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** Whether to enable input audio transcription. */ fun enabled(): Optional = Optional.ofNullable(enabled.getNullable("enabled")) @@ -1269,8 +1266,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - /** Whether to enable input audio transcription. */ @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled @@ -1286,7 +1281,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.created")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } enabled() validated = true } @@ -1301,7 +1300,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.created") private var enabled: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1325,9 +1324,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } /** Whether to enable input audio transcription. */ fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) @@ -1357,63 +1354,12 @@ private constructor( fun build(): ThreadCreated = ThreadCreated( checkRequired("data", data), - checkRequired("event", event), + event, enabled, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_CREATED = of("thread.created") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_CREATED, - } - - enum class Value { - THREAD_CREATED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_CREATED -> Value.THREAD_CREATED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_CREATED -> Known.THREAD_CREATED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1441,9 +1387,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -1454,7 +1398,7 @@ private constructor( */ fun data(): Run = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents an execution run on a @@ -1462,8 +1406,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1476,7 +1418,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.created")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -1490,7 +1436,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.created") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1512,9 +1458,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1538,62 +1482,11 @@ private constructor( fun build(): ThreadRunCreated = ThreadRunCreated( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_CREATED = of("thread.run.created") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_CREATED, - } - - enum class Value { - THREAD_RUN_CREATED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_CREATED -> Value.THREAD_RUN_CREATED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_CREATED -> Known.THREAD_RUN_CREATED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1621,9 +1514,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -1634,7 +1525,7 @@ private constructor( */ fun data(): Run = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents an execution run on a @@ -1642,8 +1533,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1656,7 +1545,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.queued")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -1670,7 +1563,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.queued") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1692,9 +1585,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1718,62 +1609,11 @@ private constructor( fun build(): ThreadRunQueued = ThreadRunQueued( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_QUEUED = of("thread.run.queued") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_QUEUED, - } - - enum class Value { - THREAD_RUN_QUEUED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_QUEUED -> Value.THREAD_RUN_QUEUED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_QUEUED -> Known.THREAD_RUN_QUEUED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1801,9 +1641,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -1814,7 +1652,7 @@ private constructor( */ fun data(): Run = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents an execution run on a @@ -1822,8 +1660,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1836,7 +1672,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.in_progress")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -1850,7 +1690,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.in_progress") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1872,9 +1712,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1898,62 +1736,11 @@ private constructor( fun build(): ThreadRunInProgress = ThreadRunInProgress( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_IN_PROGRESS = of("thread.run.in_progress") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_IN_PROGRESS, - } - - enum class Value { - THREAD_RUN_IN_PROGRESS, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_IN_PROGRESS -> Value.THREAD_RUN_IN_PROGRESS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_IN_PROGRESS -> Known.THREAD_RUN_IN_PROGRESS - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1981,9 +1768,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -1994,7 +1779,7 @@ private constructor( */ fun data(): Run = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents an execution run on a @@ -2002,8 +1787,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -2016,7 +1799,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.requires_action")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -2030,7 +1817,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.requires_action") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2052,9 +1839,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2078,62 +1863,11 @@ private constructor( fun build(): ThreadRunRequiresAction = ThreadRunRequiresAction( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_REQUIRES_ACTION = of("thread.run.requires_action") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_REQUIRES_ACTION, - } - - enum class Value { - THREAD_RUN_REQUIRES_ACTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_REQUIRES_ACTION -> Value.THREAD_RUN_REQUIRES_ACTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_REQUIRES_ACTION -> Known.THREAD_RUN_REQUIRES_ACTION - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2160,9 +1894,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -2173,7 +1905,7 @@ private constructor( */ fun data(): Run = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents an execution run on a @@ -2181,8 +1913,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -2195,7 +1925,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.completed")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -2209,7 +1943,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.completed") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2231,9 +1965,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2257,62 +1989,11 @@ private constructor( fun build(): ThreadRunCompleted = ThreadRunCompleted( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_COMPLETED = of("thread.run.completed") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_COMPLETED, - } - - enum class Value { - THREAD_RUN_COMPLETED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_COMPLETED -> Value.THREAD_RUN_COMPLETED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_COMPLETED -> Known.THREAD_RUN_COMPLETED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2340,9 +2021,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -2353,7 +2032,7 @@ private constructor( */ fun data(): Run = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents an execution run on a @@ -2361,8 +2040,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -2375,7 +2052,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.incomplete")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -2389,7 +2070,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.incomplete") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2411,9 +2092,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2437,62 +2116,11 @@ private constructor( fun build(): ThreadRunIncomplete = ThreadRunIncomplete( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_INCOMPLETE = of("thread.run.incomplete") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_INCOMPLETE, - } - - enum class Value { - THREAD_RUN_INCOMPLETE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_INCOMPLETE -> Value.THREAD_RUN_INCOMPLETE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_INCOMPLETE -> Known.THREAD_RUN_INCOMPLETE - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2517,9 +2145,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -2530,7 +2156,7 @@ private constructor( */ fun data(): Run = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents an execution run on a @@ -2538,8 +2164,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -2552,7 +2176,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.failed")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -2566,7 +2194,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.failed") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2588,9 +2216,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2614,62 +2240,11 @@ private constructor( fun build(): ThreadRunFailed = ThreadRunFailed( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_FAILED = of("thread.run.failed") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_FAILED, - } - - enum class Value { - THREAD_RUN_FAILED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_FAILED -> Value.THREAD_RUN_FAILED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_FAILED -> Known.THREAD_RUN_FAILED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2697,9 +2272,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -2710,7 +2283,7 @@ private constructor( */ fun data(): Run = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents an execution run on a @@ -2718,8 +2291,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -2732,7 +2303,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.cancelling")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -2746,7 +2321,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.cancelling") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2768,9 +2343,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2794,62 +2367,11 @@ private constructor( fun build(): ThreadRunCancelling = ThreadRunCancelling( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_CANCELLING = of("thread.run.cancelling") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_CANCELLING, - } - - enum class Value { - THREAD_RUN_CANCELLING, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_CANCELLING -> Value.THREAD_RUN_CANCELLING - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_CANCELLING -> Known.THREAD_RUN_CANCELLING - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2876,9 +2398,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -2889,7 +2409,7 @@ private constructor( */ fun data(): Run = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents an execution run on a @@ -2897,8 +2417,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -2911,7 +2429,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.cancelled")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -2925,7 +2447,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.cancelled") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2947,9 +2469,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2973,65 +2493,14 @@ private constructor( fun build(): ThreadRunCancelled = ThreadRunCancelled( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_CANCELLED = of("thread.run.cancelled") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_CANCELLED, - } - - enum class Value { - THREAD_RUN_CANCELLED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_CANCELLED -> Value.THREAD_RUN_CANCELLED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_CANCELLED -> Known.THREAD_RUN_CANCELLED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } return /* spotless:off */ other is ThreadRunCancelled && data == other.data && event == other.event && additionalProperties == other.additionalProperties /* spotless:on */ @@ -3053,9 +2522,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -3066,7 +2533,7 @@ private constructor( */ fun data(): Run = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents an execution run on a @@ -3074,8 +2541,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -3088,7 +2553,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.expired")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -3102,7 +2571,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.expired") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3124,9 +2593,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3150,62 +2617,11 @@ private constructor( fun build(): ThreadRunExpired = ThreadRunExpired( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_EXPIRED = of("thread.run.expired") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_EXPIRED, - } - - enum class Value { - THREAD_RUN_EXPIRED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_EXPIRED -> Value.THREAD_RUN_EXPIRED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_EXPIRED -> Known.THREAD_RUN_EXPIRED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3235,9 +2651,7 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -3245,13 +2659,11 @@ private constructor( /** Represents a step in execution of a run. */ fun data(): RunStep = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** Represents a step in execution of a run. */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -3264,7 +2676,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.step.created")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -3278,7 +2694,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.step.created") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3294,9 +2710,7 @@ private constructor( /** Represents a step in execution of a run. */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3320,62 +2734,11 @@ private constructor( fun build(): ThreadRunStepCreated = ThreadRunStepCreated( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_STEP_CREATED = of("thread.run.step.created") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_STEP_CREATED, - } - - enum class Value { - THREAD_RUN_STEP_CREATED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_STEP_CREATED -> Value.THREAD_RUN_STEP_CREATED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_STEP_CREATED -> Known.THREAD_RUN_STEP_CREATED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3406,9 +2769,7 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -3416,13 +2777,11 @@ private constructor( /** Represents a step in execution of a run. */ fun data(): RunStep = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** Represents a step in execution of a run. */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -3435,7 +2794,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.step.in_progress")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -3449,7 +2812,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.step.in_progress") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3465,9 +2828,7 @@ private constructor( /** Represents a step in execution of a run. */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3491,62 +2852,11 @@ private constructor( fun build(): ThreadRunStepInProgress = ThreadRunStepInProgress( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_STEP_IN_PROGRESS = of("thread.run.step.in_progress") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_STEP_IN_PROGRESS, - } - - enum class Value { - THREAD_RUN_STEP_IN_PROGRESS, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_STEP_IN_PROGRESS -> Value.THREAD_RUN_STEP_IN_PROGRESS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_STEP_IN_PROGRESS -> Known.THREAD_RUN_STEP_IN_PROGRESS - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3577,9 +2887,7 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -3587,13 +2895,11 @@ private constructor( /** Represents a run step delta i.e. any changed fields on a run step during streaming. */ fun data(): RunStepDeltaEvent = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** Represents a run step delta i.e. any changed fields on a run step during streaming. */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -3606,7 +2912,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.step.delta")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -3620,7 +2930,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.step.delta") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3640,9 +2950,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3666,62 +2974,11 @@ private constructor( fun build(): ThreadRunStepDelta = ThreadRunStepDelta( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_STEP_DELTA = of("thread.run.step.delta") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_STEP_DELTA, - } - - enum class Value { - THREAD_RUN_STEP_DELTA, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_STEP_DELTA -> Value.THREAD_RUN_STEP_DELTA - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_STEP_DELTA -> Known.THREAD_RUN_STEP_DELTA - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3752,9 +3009,7 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -3762,13 +3017,11 @@ private constructor( /** Represents a step in execution of a run. */ fun data(): RunStep = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** Represents a step in execution of a run. */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -3781,7 +3034,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.step.completed")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -3795,7 +3052,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.step.completed") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3811,9 +3068,7 @@ private constructor( /** Represents a step in execution of a run. */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3837,62 +3092,11 @@ private constructor( fun build(): ThreadRunStepCompleted = ThreadRunStepCompleted( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_STEP_COMPLETED = of("thread.run.step.completed") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_STEP_COMPLETED, - } - - enum class Value { - THREAD_RUN_STEP_COMPLETED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_STEP_COMPLETED -> Value.THREAD_RUN_STEP_COMPLETED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_STEP_COMPLETED -> Known.THREAD_RUN_STEP_COMPLETED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3922,9 +3126,7 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -3932,13 +3134,11 @@ private constructor( /** Represents a step in execution of a run. */ fun data(): RunStep = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** Represents a step in execution of a run. */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -3951,7 +3151,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.step.failed")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -3965,7 +3169,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.step.failed") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3981,9 +3185,7 @@ private constructor( /** Represents a step in execution of a run. */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4007,62 +3209,11 @@ private constructor( fun build(): ThreadRunStepFailed = ThreadRunStepFailed( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_STEP_FAILED = of("thread.run.step.failed") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_STEP_FAILED, - } - - enum class Value { - THREAD_RUN_STEP_FAILED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_STEP_FAILED -> Value.THREAD_RUN_STEP_FAILED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_STEP_FAILED -> Known.THREAD_RUN_STEP_FAILED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4093,9 +3244,7 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -4103,13 +3252,11 @@ private constructor( /** Represents a step in execution of a run. */ fun data(): RunStep = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** Represents a step in execution of a run. */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -4122,7 +3269,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.step.cancelled")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -4136,7 +3287,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.step.cancelled") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4152,9 +3303,7 @@ private constructor( /** Represents a step in execution of a run. */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4178,62 +3327,11 @@ private constructor( fun build(): ThreadRunStepCancelled = ThreadRunStepCancelled( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_STEP_CANCELLED = of("thread.run.step.cancelled") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_STEP_CANCELLED, - } - - enum class Value { - THREAD_RUN_STEP_CANCELLED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_STEP_CANCELLED -> Value.THREAD_RUN_STEP_CANCELLED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_STEP_CANCELLED -> Known.THREAD_RUN_STEP_CANCELLED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4263,9 +3361,7 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -4273,13 +3369,11 @@ private constructor( /** Represents a step in execution of a run. */ fun data(): RunStep = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** Represents a step in execution of a run. */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -4292,7 +3386,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.run.step.expired")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -4306,7 +3404,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.run.step.expired") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4322,9 +3420,7 @@ private constructor( /** Represents a step in execution of a run. */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4348,62 +3444,11 @@ private constructor( fun build(): ThreadRunStepExpired = ThreadRunStepExpired( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_RUN_STEP_EXPIRED = of("thread.run.step.expired") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_RUN_STEP_EXPIRED, - } - - enum class Value { - THREAD_RUN_STEP_EXPIRED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_RUN_STEP_EXPIRED -> Value.THREAD_RUN_STEP_EXPIRED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_RUN_STEP_EXPIRED -> Known.THREAD_RUN_STEP_EXPIRED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4433,9 +3478,7 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -4446,7 +3489,7 @@ private constructor( */ fun data(): Message = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents a message within a @@ -4454,8 +3497,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -4468,7 +3509,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.message.created")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -4482,7 +3527,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.message.created") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4504,9 +3549,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4530,62 +3573,11 @@ private constructor( fun build(): ThreadMessageCreated = ThreadMessageCreated( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_MESSAGE_CREATED = of("thread.message.created") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_MESSAGE_CREATED, - } - - enum class Value { - THREAD_MESSAGE_CREATED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_MESSAGE_CREATED -> Value.THREAD_MESSAGE_CREATED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_MESSAGE_CREATED -> Known.THREAD_MESSAGE_CREATED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4615,9 +3607,7 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -4628,7 +3618,7 @@ private constructor( */ fun data(): Message = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents a message within a @@ -4636,8 +3626,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -4650,7 +3638,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.message.in_progress")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -4664,7 +3656,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.message.in_progress") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4686,9 +3678,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4712,62 +3702,11 @@ private constructor( fun build(): ThreadMessageInProgress = ThreadMessageInProgress( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_MESSAGE_IN_PROGRESS = of("thread.message.in_progress") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_MESSAGE_IN_PROGRESS, - } - - enum class Value { - THREAD_MESSAGE_IN_PROGRESS, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_MESSAGE_IN_PROGRESS -> Value.THREAD_MESSAGE_IN_PROGRESS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_MESSAGE_IN_PROGRESS -> Known.THREAD_MESSAGE_IN_PROGRESS - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4797,9 +3736,7 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -4807,13 +3744,11 @@ private constructor( /** Represents a message delta i.e. any changed fields on a message during streaming. */ fun data(): MessageDeltaEvent = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** Represents a message delta i.e. any changed fields on a message during streaming. */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -4826,7 +3761,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.message.delta")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -4840,7 +3779,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.message.delta") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4856,9 +3795,7 @@ private constructor( /** Represents a message delta i.e. any changed fields on a message during streaming. */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4882,62 +3819,11 @@ private constructor( fun build(): ThreadMessageDelta = ThreadMessageDelta( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_MESSAGE_DELTA = of("thread.message.delta") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_MESSAGE_DELTA, - } - - enum class Value { - THREAD_MESSAGE_DELTA, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_MESSAGE_DELTA -> Value.THREAD_MESSAGE_DELTA - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_MESSAGE_DELTA -> Known.THREAD_MESSAGE_DELTA - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4967,9 +3853,7 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -4980,7 +3864,7 @@ private constructor( */ fun data(): Message = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents a message within a @@ -4988,8 +3872,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -5002,7 +3884,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.message.completed")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -5016,7 +3902,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.message.completed") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5038,9 +3924,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -5064,62 +3948,11 @@ private constructor( fun build(): ThreadMessageCompleted = ThreadMessageCompleted( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_MESSAGE_COMPLETED = of("thread.message.completed") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_MESSAGE_COMPLETED, - } - - enum class Value { - THREAD_MESSAGE_COMPLETED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_MESSAGE_COMPLETED -> Value.THREAD_MESSAGE_COMPLETED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_MESSAGE_COMPLETED -> Known.THREAD_MESSAGE_COMPLETED - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5149,9 +3982,7 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -5162,7 +3993,7 @@ private constructor( */ fun data(): Message = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event /** * Represents a message within a @@ -5170,8 +4001,6 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -5184,7 +4013,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("thread.message.incomplete")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -5198,7 +4031,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("thread.message.incomplete") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5220,9 +4053,7 @@ private constructor( */ fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -5246,62 +4077,11 @@ private constructor( fun build(): ThreadMessageIncomplete = ThreadMessageIncomplete( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THREAD_MESSAGE_INCOMPLETE = of("thread.message.incomplete") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - THREAD_MESSAGE_INCOMPLETE, - } - - enum class Value { - THREAD_MESSAGE_INCOMPLETE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - THREAD_MESSAGE_INCOMPLETE -> Value.THREAD_MESSAGE_INCOMPLETE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - THREAD_MESSAGE_INCOMPLETE -> Known.THREAD_MESSAGE_INCOMPLETE - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5331,21 +4111,17 @@ private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("event") - @ExcludeMissing - private val event: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing private val event: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { fun data(): ErrorObject = data.getRequired("data") - fun event(): Event = event.getRequired("event") + @JsonProperty("event") @ExcludeMissing fun _event(): JsonValue = event @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -5358,7 +4134,11 @@ private constructor( } data().validate() - event() + _event().let { + if (it != JsonValue.from("error")) { + throw OpenAIInvalidDataException("'event' is invalid, received $it") + } + } validated = true } @@ -5372,7 +4152,7 @@ private constructor( class Builder { private var data: JsonField? = null - private var event: JsonField? = null + private var event: JsonValue = JsonValue.from("error") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5386,9 +4166,7 @@ private constructor( fun data(data: JsonField) = apply { this.data = data } - fun event(event: Event) = event(JsonField.of(event)) - - fun event(event: JsonField) = apply { this.event = event } + fun event(event: JsonValue) = apply { this.event = event } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -5412,62 +4190,11 @@ private constructor( fun build(): ErrorEvent = ErrorEvent( checkRequired("data", data), - checkRequired("event", event), + event, additionalProperties.toImmutable(), ) } - class Event - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ERROR = of("error") - - @JvmStatic fun of(value: String) = Event(JsonField.of(value)) - } - - enum class Known { - ERROR, - } - - enum class Value { - ERROR, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ERROR -> Value.ERROR - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ERROR -> Known.ERROR - else -> throw OpenAIInvalidDataException("Unknown Event: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && value == other.value /* spotless:on */ - } - - 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/AssistantToolChoiceOption.kt b/openai-java-core/src/main/kotlin/com/openai/models/AssistantToolChoiceOption.kt index c23765f4e..287d55fd1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/AssistantToolChoiceOption.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/AssistantToolChoiceOption.kt @@ -32,7 +32,7 @@ import java.util.Optional @JsonSerialize(using = AssistantToolChoiceOption.Serializer::class) class AssistantToolChoiceOption private constructor( - private val behavior: Behavior? = null, + private val auto: Auto? = null, private val assistantToolChoice: AssistantToolChoice? = null, private val _json: JsonValue? = null, ) { @@ -42,13 +42,13 @@ private constructor( * the model can pick between generating a message or calling one or more tools. `required` * means the model must call one or more tools before responding to the user. */ - fun behavior(): Optional = Optional.ofNullable(behavior) + fun auto(): Optional = Optional.ofNullable(auto) /** Specifies a tool the model should use. Use to force the model to call a specific tool. */ fun assistantToolChoice(): Optional = Optional.ofNullable(assistantToolChoice) - fun isBehavior(): Boolean = behavior != null + fun isAuto(): Boolean = auto != null fun isAssistantToolChoice(): Boolean = assistantToolChoice != null @@ -57,7 +57,7 @@ private constructor( * the model can pick between generating a message or calling one or more tools. `required` * means the model must call one or more tools before responding to the user. */ - fun asBehavior(): Behavior = behavior.getOrThrow("behavior") + fun asAuto(): Auto = auto.getOrThrow("auto") /** Specifies a tool the model should use. Use to force the model to call a specific tool. */ fun asAssistantToolChoice(): AssistantToolChoice = @@ -67,7 +67,7 @@ private constructor( fun accept(visitor: Visitor): T { return when { - behavior != null -> visitor.visitBehavior(behavior) + auto != null -> visitor.visitAuto(auto) assistantToolChoice != null -> visitor.visitAssistantToolChoice(assistantToolChoice) else -> visitor.unknown(_json) } @@ -82,7 +82,7 @@ private constructor( accept( object : Visitor { - override fun visitBehavior(behavior: Behavior) {} + override fun visitAuto(auto: Auto) {} override fun visitAssistantToolChoice(assistantToolChoice: AssistantToolChoice) { assistantToolChoice.validate() @@ -97,14 +97,14 @@ private constructor( return true } - return /* spotless:off */ other is AssistantToolChoiceOption && behavior == other.behavior && assistantToolChoice == other.assistantToolChoice /* spotless:on */ + return /* spotless:off */ other is AssistantToolChoiceOption && auto == other.auto && assistantToolChoice == other.assistantToolChoice /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(behavior, assistantToolChoice) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(auto, assistantToolChoice) /* spotless:on */ override fun toString(): String = when { - behavior != null -> "AssistantToolChoiceOption{behavior=$behavior}" + auto != null -> "AssistantToolChoiceOption{auto=$auto}" assistantToolChoice != null -> "AssistantToolChoiceOption{assistantToolChoice=$assistantToolChoice}" _json != null -> "AssistantToolChoiceOption{_unknown=$_json}" @@ -118,8 +118,7 @@ private constructor( * means the model can pick between generating a message or calling one or more tools. * `required` means the model must call one or more tools before responding to the user. */ - @JvmStatic - fun ofBehavior(behavior: Behavior) = AssistantToolChoiceOption(behavior = behavior) + @JvmStatic fun ofAuto(auto: Auto) = AssistantToolChoiceOption(auto = auto) /** * Specifies a tool the model should use. Use to force the model to call a specific tool. @@ -136,7 +135,7 @@ private constructor( * means the model can pick between generating a message or calling one or more tools. * `required` means the model must call one or more tools before responding to the user. */ - fun visitBehavior(behavior: Behavior): T + fun visitAuto(auto: Auto): T /** * Specifies a tool the model should use. Use to force the model to call a specific tool. @@ -154,8 +153,8 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): AssistantToolChoiceOption { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return AssistantToolChoiceOption(behavior = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + return AssistantToolChoiceOption(auto = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { @@ -174,7 +173,7 @@ private constructor( provider: SerializerProvider ) { when { - value.behavior != null -> generator.writeObject(value.behavior) + value.auto != null -> generator.writeObject(value.auto) value.assistantToolChoice != null -> generator.writeObject(value.assistantToolChoice) value._json != null -> generator.writeObject(value._json) @@ -188,7 +187,7 @@ private constructor( * the model can pick between generating a message or calling one or more tools. `required` * means the model must call one or more tools before responding to the user. */ - class Behavior + class Auto @JsonCreator private constructor( private val value: JsonField, @@ -204,7 +203,7 @@ private constructor( @JvmField val REQUIRED = of("required") - @JvmStatic fun of(value: String) = Behavior(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -233,7 +232,7 @@ private constructor( NONE -> Known.NONE AUTO -> Known.AUTO REQUIRED -> Known.REQUIRED - else -> throw OpenAIInvalidDataException("Unknown Behavior: $value") + else -> throw OpenAIInvalidDataException("Unknown Auto: $value") } fun asString(): String = _value().asStringOrThrow() @@ -243,7 +242,7 @@ private constructor( return true } - return /* spotless:off */ other is Behavior && value == other.value /* spotless:on */ + return /* spotless:off */ other is Auto && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/openai-java-core/src/main/kotlin/com/openai/models/AutoFileChunkingStrategyParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/AutoFileChunkingStrategyParam.kt index 407ffc4b0..e736a736a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/AutoFileChunkingStrategyParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/AutoFileChunkingStrategyParam.kt @@ -6,13 +6,10 @@ 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 import com.openai.core.JsonValue import com.openai.core.NoAutoDetect -import com.openai.core.checkRequired import com.openai.core.immutableEmptyMap import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException @@ -26,15 +23,12 @@ import java.util.Objects class AutoFileChunkingStrategyParam @JsonCreator private constructor( - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Always `auto`. */ - fun type(): Type = type.getRequired("type") - - /** Always `auto`. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type @JsonAnyGetter @ExcludeMissing @@ -47,7 +41,11 @@ private constructor( return@apply } - type() + _type().let { + if (it != JsonValue.from("auto")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -60,7 +58,7 @@ private constructor( class Builder { - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("auto") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -70,10 +68,7 @@ private constructor( } /** Always `auto`. */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Always `auto`. */ - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -95,62 +90,7 @@ private constructor( } fun build(): AutoFileChunkingStrategyParam = - AutoFileChunkingStrategyParam( - checkRequired("type", type), - additionalProperties.toImmutable() - ) - } - - /** Always `auto`. */ - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AUTO = of("auto") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - AUTO, - } - - enum class Value { - AUTO, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - else -> throw OpenAIInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + AutoFileChunkingStrategyParam(type, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/Batch.kt b/openai-java-core/src/main/kotlin/com/openai/models/Batch.kt index f592739b6..69dda3f0d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/Batch.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/Batch.kt @@ -36,9 +36,7 @@ private constructor( @JsonProperty("input_file_id") @ExcludeMissing private val inputFileId: JsonField = JsonMissing.of(), - @JsonProperty("object") - @ExcludeMissing - private val object_: JsonField = JsonMissing.of(), + @JsonProperty("object") @ExcludeMissing private val object_: JsonValue = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), @@ -97,7 +95,7 @@ private constructor( fun inputFileId(): String = inputFileId.getRequired("input_file_id") /** The object type, which is always `batch`. */ - fun object_(): Object = object_.getRequired("object") + @JsonProperty("object") @ExcludeMissing fun _object_(): JsonValue = object_ /** The current status of the batch. */ fun status(): Status = status.getRequired("status") @@ -168,9 +166,6 @@ private constructor( @ExcludeMissing fun _inputFileId(): JsonField = inputFileId - /** The object type, which is always `batch`. */ - @JsonProperty("object") @ExcludeMissing fun _object_(): JsonField = object_ - /** The current status of the batch. */ @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @@ -237,7 +232,11 @@ private constructor( createdAt() endpoint() inputFileId() - object_() + _object_().let { + if (it != JsonValue.from("batch")) { + throw OpenAIInvalidDataException("'object_' is invalid, received $it") + } + } status() cancelledAt() cancellingAt() @@ -268,7 +267,7 @@ private constructor( private var createdAt: JsonField? = null private var endpoint: JsonField? = null private var inputFileId: JsonField? = null - private var object_: JsonField? = null + private var object_: JsonValue = JsonValue.from("batch") private var status: JsonField? = null private var cancelledAt: JsonField = JsonMissing.of() private var cancellingAt: JsonField = JsonMissing.of() @@ -342,10 +341,7 @@ private constructor( fun inputFileId(inputFileId: JsonField) = apply { this.inputFileId = inputFileId } /** The object type, which is always `batch`. */ - fun object_(object_: Object) = object_(JsonField.of(object_)) - - /** The object type, which is always `batch`. */ - fun object_(object_: JsonField) = apply { this.object_ = object_ } + fun object_(object_: JsonValue) = apply { this.object_ = object_ } /** The current status of the batch. */ fun status(status: Status) = status(JsonField.of(status)) @@ -461,7 +457,7 @@ private constructor( checkRequired("createdAt", createdAt), checkRequired("endpoint", endpoint), checkRequired("inputFileId", inputFileId), - checkRequired("object_", object_), + object_, checkRequired("status", status), cancelledAt, cancellingAt, @@ -480,58 +476,6 @@ private constructor( ) } - /** The object type, which is always `batch`. */ - class Object - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BATCH = of("batch") - - @JvmStatic fun of(value: String) = Object(JsonField.of(value)) - } - - enum class Known { - BATCH, - } - - enum class Value { - BATCH, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - BATCH -> Value.BATCH - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - BATCH -> Known.BATCH - else -> throw OpenAIInvalidDataException("Unknown Object: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Object && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** The current status of the batch. */ class Status @JsonCreator 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 fa2f64c99..858eb36aa 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 @@ -592,8 +592,7 @@ constructor( } /** `auto` is the default value */ - fun responseFormat(behavior: AssistantResponseFormatOption.Behavior) = - responseFormat(AssistantResponseFormatOption.ofBehavior(behavior)) + fun responseFormatAuto() = responseFormat(AssistantResponseFormatOption.ofAuto()) /** * Specifies the format that the model must output. Compatible with @@ -1038,9 +1037,7 @@ constructor( } /** `auto` is the default value */ - fun responseFormat(behavior: AssistantResponseFormatOption.Behavior) = apply { - body.responseFormat(behavior) - } + fun responseFormatAuto() = apply { body.responseFormatAuto() } /** * Specifies the format that the model must output. Compatible with 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 c5a48b673..d2733429c 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 @@ -594,8 +594,7 @@ constructor( } /** `auto` is the default value */ - fun responseFormat(behavior: AssistantResponseFormatOption.Behavior) = - responseFormat(AssistantResponseFormatOption.ofBehavior(behavior)) + fun responseFormatAuto() = responseFormat(AssistantResponseFormatOption.ofAuto()) /** * Specifies the format that the model must output. Compatible with @@ -1036,9 +1035,7 @@ constructor( } /** `auto` is the default value */ - fun responseFormat(behavior: AssistantResponseFormatOption.Behavior) = apply { - body.responseFormat(behavior) - } + fun responseFormatAuto() = apply { body.responseFormatAuto() } /** * Specifies the format that the model must output. Compatible with diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateAndRunParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateAndRunParams.kt index ad6b25dd7..7d93d8c94 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateAndRunParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateAndRunParams.kt @@ -914,8 +914,7 @@ constructor( } /** `auto` is the default value */ - fun responseFormat(behavior: AssistantResponseFormatOption.Behavior) = - responseFormat(AssistantResponseFormatOption.ofBehavior(behavior)) + fun responseFormatAuto() = responseFormat(AssistantResponseFormatOption.ofAuto()) /** * Specifies the format that the model must output. Compatible with @@ -1077,8 +1076,8 @@ constructor( * tools. `required` means the model must call one or more tools before responding to * the user. */ - fun toolChoice(behavior: AssistantToolChoiceOption.Behavior) = - toolChoice(AssistantToolChoiceOption.ofBehavior(behavior)) + fun toolChoice(auto: AssistantToolChoiceOption.Auto) = + toolChoice(AssistantToolChoiceOption.ofAuto(auto)) /** * Specifies a tool the model should use. Use to force the model to call a specific @@ -1541,9 +1540,7 @@ constructor( } /** `auto` is the default value */ - fun responseFormat(behavior: AssistantResponseFormatOption.Behavior) = apply { - body.responseFormat(behavior) - } + fun responseFormatAuto() = apply { body.responseFormatAuto() } /** * Specifies the format that the model must output. Compatible with @@ -1693,9 +1690,7 @@ constructor( * means the model can pick between generating a message or calling one or more tools. * `required` means the model must call one or more tools before responding to the user. */ - fun toolChoice(behavior: AssistantToolChoiceOption.Behavior) = apply { - body.toolChoice(behavior) - } + fun toolChoice(auto: AssistantToolChoiceOption.Auto) = apply { body.toolChoice(auto) } /** * Specifies a tool the model should use. Use to force the model to call a specific tool. @@ -2681,10 +2676,6 @@ constructor( fun addTool(codeInterpreterTool: CodeInterpreterTool) = addTool(Tool.ofCodeInterpreterTool(codeInterpreterTool)) - /** The tools to add this file to. */ - fun addTool(fileSearch: Tool.FileSearch) = - addTool(Tool.ofFileSearch(fileSearch)) - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2720,14 +2711,14 @@ constructor( class Tool private constructor( private val codeInterpreterTool: CodeInterpreterTool? = null, - private val fileSearch: FileSearch? = null, + private val fileSearch: JsonValue? = null, private val _json: JsonValue? = null, ) { fun codeInterpreterTool(): Optional = Optional.ofNullable(codeInterpreterTool) - fun fileSearch(): Optional = Optional.ofNullable(fileSearch) + fun fileSearch(): Optional = Optional.ofNullable(fileSearch) fun isCodeInterpreterTool(): Boolean = codeInterpreterTool != null @@ -2736,7 +2727,7 @@ constructor( fun asCodeInterpreterTool(): CodeInterpreterTool = codeInterpreterTool.getOrThrow("codeInterpreterTool") - fun asFileSearch(): FileSearch = fileSearch.getOrThrow("fileSearch") + fun asFileSearch(): JsonValue = fileSearch.getOrThrow("fileSearch") fun _json(): Optional = Optional.ofNullable(_json) @@ -2764,8 +2755,14 @@ constructor( codeInterpreterTool.validate() } - override fun visitFileSearch(fileSearch: FileSearch) { - fileSearch.validate() + override fun visitFileSearch(fileSearch: JsonValue) { + fileSearch.let { + if (it != JsonValue.from(mapOf("type" to "file_search"))) { + throw OpenAIInvalidDataException( + "'fileSearch' is invalid, received $it" + ) + } + } } } ) @@ -2798,14 +2795,15 @@ constructor( Tool(codeInterpreterTool = codeInterpreterTool) @JvmStatic - fun ofFileSearch(fileSearch: FileSearch) = Tool(fileSearch = fileSearch) + fun ofFileSearch() = + Tool(fileSearch = JsonValue.from(mapOf("type" to "file_search"))) } interface Visitor { fun visitCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool): T - fun visitFileSearch(fileSearch: FileSearch): T + fun visitFileSearch(fileSearch: JsonValue): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown Tool: $json") @@ -2829,8 +2827,19 @@ constructor( } } "file_search" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() + tryDeserialize(node, jacksonTypeRef()) { + it.let { + if ( + it != + JsonValue.from( + mapOf("type" to "file_search") + ) + ) { + throw OpenAIInvalidDataException( + "'fileSearch' is invalid, received $it" + ) + } + } } ?.let { return Tool(fileSearch = it, _json = json) @@ -2858,165 +2867,6 @@ constructor( } } } - - @NoAutoDetect - class FileSearch - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** The type of tool being defined: `file_search` */ - fun type(): Type = type.getRequired("type") - - /** The type of tool being defined: `file_search` */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FileSearch = apply { - if (validated) { - return@apply - } - - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(fileSearch: FileSearch) = apply { - type = fileSearch.type - additionalProperties = - fileSearch.additionalProperties.toMutableMap() - } - - /** The type of tool being defined: `file_search` */ - fun type(type: Type) = type(JsonField.of(type)) - - /** The type of tool being defined: `file_search` */ - fun type(type: JsonField) = 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) - } - - fun build(): FileSearch = - FileSearch( - checkRequired("type", type), - additionalProperties.toImmutable() - ) - } - - /** The type of tool being defined: `file_search` */ - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val FILE_SEARCH = of("file_search") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FILE_SEARCH, - } - - enum class Value { - FILE_SEARCH, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FILE_SEARCH -> Value.FILE_SEARCH - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FILE_SEARCH -> Known.FILE_SEARCH - else -> throw OpenAIInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FileSearch && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FileSearch{type=$type, additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateParams.kt index 064cbc520..b4e0172a6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateParams.kt @@ -1005,9 +1005,6 @@ constructor( fun addTool(codeInterpreterTool: CodeInterpreterTool) = addTool(Tool.ofCodeInterpreterTool(codeInterpreterTool)) - /** The tools to add this file to. */ - fun addTool(fileSearch: Tool.FileSearch) = addTool(Tool.ofFileSearch(fileSearch)) - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1043,14 +1040,14 @@ constructor( class Tool private constructor( private val codeInterpreterTool: CodeInterpreterTool? = null, - private val fileSearch: FileSearch? = null, + private val fileSearch: JsonValue? = null, private val _json: JsonValue? = null, ) { fun codeInterpreterTool(): Optional = Optional.ofNullable(codeInterpreterTool) - fun fileSearch(): Optional = Optional.ofNullable(fileSearch) + fun fileSearch(): Optional = Optional.ofNullable(fileSearch) fun isCodeInterpreterTool(): Boolean = codeInterpreterTool != null @@ -1059,7 +1056,7 @@ constructor( fun asCodeInterpreterTool(): CodeInterpreterTool = codeInterpreterTool.getOrThrow("codeInterpreterTool") - fun asFileSearch(): FileSearch = fileSearch.getOrThrow("fileSearch") + fun asFileSearch(): JsonValue = fileSearch.getOrThrow("fileSearch") fun _json(): Optional = Optional.ofNullable(_json) @@ -1087,8 +1084,14 @@ constructor( codeInterpreterTool.validate() } - override fun visitFileSearch(fileSearch: FileSearch) { - fileSearch.validate() + override fun visitFileSearch(fileSearch: JsonValue) { + fileSearch.let { + if (it != JsonValue.from(mapOf("type" to "file_search"))) { + throw OpenAIInvalidDataException( + "'fileSearch' is invalid, received $it" + ) + } + } } } ) @@ -1121,14 +1124,15 @@ constructor( Tool(codeInterpreterTool = codeInterpreterTool) @JvmStatic - fun ofFileSearch(fileSearch: FileSearch) = Tool(fileSearch = fileSearch) + fun ofFileSearch() = + Tool(fileSearch = JsonValue.from(mapOf("type" to "file_search"))) } interface Visitor { fun visitCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool): T - fun visitFileSearch(fileSearch: FileSearch): T + fun visitFileSearch(fileSearch: JsonValue): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown Tool: $json") @@ -1151,7 +1155,17 @@ constructor( } } "file_search" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } + tryDeserialize(node, jacksonTypeRef()) { + it.let { + if ( + it != JsonValue.from(mapOf("type" to "file_search")) + ) { + throw OpenAIInvalidDataException( + "'fileSearch' is invalid, received $it" + ) + } + } + } ?.let { return Tool(fileSearch = it, _json = json) } @@ -1178,163 +1192,6 @@ constructor( } } } - - @NoAutoDetect - class FileSearch - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The type of tool being defined: `file_search` */ - fun type(): Type = type.getRequired("type") - - /** The type of tool being defined: `file_search` */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FileSearch = apply { - if (validated) { - return@apply - } - - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(fileSearch: FileSearch) = apply { - type = fileSearch.type - additionalProperties = fileSearch.additionalProperties.toMutableMap() - } - - /** The type of tool being defined: `file_search` */ - fun type(type: Type) = type(JsonField.of(type)) - - /** The type of tool being defined: `file_search` */ - fun type(type: JsonField) = 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) - } - - fun build(): FileSearch = - FileSearch( - checkRequired("type", type), - additionalProperties.toImmutable() - ) - } - - /** The type of tool being defined: `file_search` */ - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val FILE_SEARCH = of("file_search") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FILE_SEARCH, - } - - enum class Value { - FILE_SEARCH, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FILE_SEARCH -> Value.FILE_SEARCH - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FILE_SEARCH -> Known.FILE_SEARCH - else -> throw OpenAIInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FileSearch && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FileSearch{type=$type, additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadMessageCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadMessageCreateParams.kt index 6a7edb67c..635e468c5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadMessageCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadMessageCreateParams.kt @@ -838,9 +838,6 @@ constructor( fun addTool(codeInterpreterTool: CodeInterpreterTool) = addTool(Tool.ofCodeInterpreterTool(codeInterpreterTool)) - /** The tools to add this file to. */ - fun addTool(fileSearch: Tool.FileSearch) = addTool(Tool.ofFileSearch(fileSearch)) - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -873,14 +870,14 @@ constructor( class Tool private constructor( private val codeInterpreterTool: CodeInterpreterTool? = null, - private val fileSearch: FileSearch? = null, + private val fileSearch: JsonValue? = null, private val _json: JsonValue? = null, ) { fun codeInterpreterTool(): Optional = Optional.ofNullable(codeInterpreterTool) - fun fileSearch(): Optional = Optional.ofNullable(fileSearch) + fun fileSearch(): Optional = Optional.ofNullable(fileSearch) fun isCodeInterpreterTool(): Boolean = codeInterpreterTool != null @@ -889,7 +886,7 @@ constructor( fun asCodeInterpreterTool(): CodeInterpreterTool = codeInterpreterTool.getOrThrow("codeInterpreterTool") - fun asFileSearch(): FileSearch = fileSearch.getOrThrow("fileSearch") + fun asFileSearch(): JsonValue = fileSearch.getOrThrow("fileSearch") fun _json(): Optional = Optional.ofNullable(_json) @@ -917,8 +914,14 @@ constructor( codeInterpreterTool.validate() } - override fun visitFileSearch(fileSearch: FileSearch) { - fileSearch.validate() + override fun visitFileSearch(fileSearch: JsonValue) { + fileSearch.let { + if (it != JsonValue.from(mapOf("type" to "file_search"))) { + throw OpenAIInvalidDataException( + "'fileSearch' is invalid, received $it" + ) + } + } } } ) @@ -949,14 +952,16 @@ constructor( fun ofCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool) = Tool(codeInterpreterTool = codeInterpreterTool) - @JvmStatic fun ofFileSearch(fileSearch: FileSearch) = Tool(fileSearch = fileSearch) + @JvmStatic + fun ofFileSearch() = + Tool(fileSearch = JsonValue.from(mapOf("type" to "file_search"))) } interface Visitor { fun visitCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool): T - fun visitFileSearch(fileSearch: FileSearch): T + fun visitFileSearch(fileSearch: JsonValue): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown Tool: $json") @@ -979,7 +984,15 @@ constructor( } } "file_search" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } + tryDeserialize(node, jacksonTypeRef()) { + it.let { + if (it != JsonValue.from(mapOf("type" to "file_search"))) { + throw OpenAIInvalidDataException( + "'fileSearch' is invalid, received $it" + ) + } + } + } ?.let { return Tool(fileSearch = it, _json = json) } @@ -1006,159 +1019,6 @@ constructor( } } } - - @NoAutoDetect - class FileSearch - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The type of tool being defined: `file_search` */ - fun type(): Type = type.getRequired("type") - - /** The type of tool being defined: `file_search` */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FileSearch = apply { - if (validated) { - return@apply - } - - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fileSearch: FileSearch) = apply { - type = fileSearch.type - additionalProperties = fileSearch.additionalProperties.toMutableMap() - } - - /** The type of tool being defined: `file_search` */ - fun type(type: Type) = type(JsonField.of(type)) - - /** The type of tool being defined: `file_search` */ - fun type(type: JsonField) = 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) - } - - fun build(): FileSearch = - FileSearch(checkRequired("type", type), additionalProperties.toImmutable()) - } - - /** The type of tool being defined: `file_search` */ - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val FILE_SEARCH = of("file_search") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FILE_SEARCH, - } - - enum class Value { - FILE_SEARCH, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FILE_SEARCH -> Value.FILE_SEARCH - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FILE_SEARCH -> Known.FILE_SEARCH - else -> throw OpenAIInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FileSearch && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FileSearch{type=$type, additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { 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 d0d607ef0..fd3d928df 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 @@ -1002,8 +1002,7 @@ constructor( } /** `auto` is the default value */ - fun responseFormat(behavior: AssistantResponseFormatOption.Behavior) = - responseFormat(AssistantResponseFormatOption.ofBehavior(behavior)) + fun responseFormatAuto() = responseFormat(AssistantResponseFormatOption.ofAuto()) /** * Specifies the format that the model must output. Compatible with @@ -1159,8 +1158,8 @@ constructor( * tools. `required` means the model must call one or more tools before responding to * the user. */ - fun toolChoice(behavior: AssistantToolChoiceOption.Behavior) = - toolChoice(AssistantToolChoiceOption.ofBehavior(behavior)) + fun toolChoice(auto: AssistantToolChoiceOption.Auto) = + toolChoice(AssistantToolChoiceOption.ofAuto(auto)) /** * Specifies a tool the model should use. Use to force the model to call a specific @@ -1690,9 +1689,7 @@ constructor( } /** `auto` is the default value */ - fun responseFormat(behavior: AssistantResponseFormatOption.Behavior) = apply { - body.responseFormat(behavior) - } + fun responseFormatAuto() = apply { body.responseFormatAuto() } /** * Specifies the format that the model must output. Compatible with @@ -1836,9 +1833,7 @@ constructor( * means the model can pick between generating a message or calling one or more tools. * `required` means the model must call one or more tools before responding to the user. */ - fun toolChoice(behavior: AssistantToolChoiceOption.Behavior) = apply { - body.toolChoice(behavior) - } + fun toolChoice(auto: AssistantToolChoiceOption.Auto) = apply { body.toolChoice(auto) } /** * Specifies a tool the model should use. Use to force the model to call a specific tool. @@ -2590,9 +2585,6 @@ constructor( fun addTool(codeInterpreterTool: CodeInterpreterTool) = addTool(Tool.ofCodeInterpreterTool(codeInterpreterTool)) - /** The tools to add this file to. */ - fun addTool(fileSearch: Tool.FileSearch) = addTool(Tool.ofFileSearch(fileSearch)) - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2628,14 +2620,14 @@ constructor( class Tool private constructor( private val codeInterpreterTool: CodeInterpreterTool? = null, - private val fileSearch: FileSearch? = null, + private val fileSearch: JsonValue? = null, private val _json: JsonValue? = null, ) { fun codeInterpreterTool(): Optional = Optional.ofNullable(codeInterpreterTool) - fun fileSearch(): Optional = Optional.ofNullable(fileSearch) + fun fileSearch(): Optional = Optional.ofNullable(fileSearch) fun isCodeInterpreterTool(): Boolean = codeInterpreterTool != null @@ -2644,7 +2636,7 @@ constructor( fun asCodeInterpreterTool(): CodeInterpreterTool = codeInterpreterTool.getOrThrow("codeInterpreterTool") - fun asFileSearch(): FileSearch = fileSearch.getOrThrow("fileSearch") + fun asFileSearch(): JsonValue = fileSearch.getOrThrow("fileSearch") fun _json(): Optional = Optional.ofNullable(_json) @@ -2672,8 +2664,14 @@ constructor( codeInterpreterTool.validate() } - override fun visitFileSearch(fileSearch: FileSearch) { - fileSearch.validate() + override fun visitFileSearch(fileSearch: JsonValue) { + fileSearch.let { + if (it != JsonValue.from(mapOf("type" to "file_search"))) { + throw OpenAIInvalidDataException( + "'fileSearch' is invalid, received $it" + ) + } + } } } ) @@ -2706,14 +2704,15 @@ constructor( Tool(codeInterpreterTool = codeInterpreterTool) @JvmStatic - fun ofFileSearch(fileSearch: FileSearch) = Tool(fileSearch = fileSearch) + fun ofFileSearch() = + Tool(fileSearch = JsonValue.from(mapOf("type" to "file_search"))) } interface Visitor { fun visitCodeInterpreterTool(codeInterpreterTool: CodeInterpreterTool): T - fun visitFileSearch(fileSearch: FileSearch): T + fun visitFileSearch(fileSearch: JsonValue): T fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException("Unknown Tool: $json") @@ -2736,7 +2735,17 @@ constructor( } } "file_search" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } + tryDeserialize(node, jacksonTypeRef()) { + it.let { + if ( + it != JsonValue.from(mapOf("type" to "file_search")) + ) { + throw OpenAIInvalidDataException( + "'fileSearch' is invalid, received $it" + ) + } + } + } ?.let { return Tool(fileSearch = it, _json = json) } @@ -2763,163 +2772,6 @@ constructor( } } } - - @NoAutoDetect - class FileSearch - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The type of tool being defined: `file_search` */ - fun type(): Type = type.getRequired("type") - - /** The type of tool being defined: `file_search` */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FileSearch = apply { - if (validated) { - return@apply - } - - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(fileSearch: FileSearch) = apply { - type = fileSearch.type - additionalProperties = fileSearch.additionalProperties.toMutableMap() - } - - /** The type of tool being defined: `file_search` */ - fun type(type: Type) = type(JsonField.of(type)) - - /** The type of tool being defined: `file_search` */ - fun type(type: JsonField) = 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) - } - - fun build(): FileSearch = - FileSearch( - checkRequired("type", type), - additionalProperties.toImmutable() - ) - } - - /** The type of tool being defined: `file_search` */ - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val FILE_SEARCH = of("file_search") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FILE_SEARCH, - } - - enum class Value { - FILE_SEARCH, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FILE_SEARCH -> Value.FILE_SEARCH - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FILE_SEARCH -> Known.FILE_SEARCH - else -> throw OpenAIInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FileSearch && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FileSearch{type=$type, additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreCreateParams.kt index b048ee157..dea49f1b1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreCreateParams.kt @@ -6,7 +6,6 @@ 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 @@ -561,9 +560,7 @@ constructor( class ExpiresAfter @JsonCreator private constructor( - @JsonProperty("anchor") - @ExcludeMissing - private val anchor: JsonField = JsonMissing.of(), + @JsonProperty("anchor") @ExcludeMissing private val anchor: JsonValue = JsonMissing.of(), @JsonProperty("days") @ExcludeMissing private val days: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -573,17 +570,11 @@ constructor( * Anchor timestamp after which the expiration policy applies. Supported anchors: * `last_active_at`. */ - fun anchor(): Anchor = anchor.getRequired("anchor") + @JsonProperty("anchor") @ExcludeMissing fun _anchor(): JsonValue = anchor /** The number of days after the anchor time that the vector store will expire. */ fun days(): Long = days.getRequired("days") - /** - * Anchor timestamp after which the expiration policy applies. Supported anchors: - * `last_active_at`. - */ - @JsonProperty("anchor") @ExcludeMissing fun _anchor(): JsonField = anchor - /** The number of days after the anchor time that the vector store will expire. */ @JsonProperty("days") @ExcludeMissing fun _days(): JsonField = days @@ -598,7 +589,11 @@ constructor( return@apply } - anchor() + _anchor().let { + if (it != JsonValue.from("last_active_at")) { + throw OpenAIInvalidDataException("'anchor' is invalid, received $it") + } + } days() validated = true } @@ -612,7 +607,7 @@ constructor( class Builder { - private var anchor: JsonField? = null + private var anchor: JsonValue = JsonValue.from("last_active_at") private var days: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -627,13 +622,7 @@ constructor( * Anchor timestamp after which the expiration policy applies. Supported anchors: * `last_active_at`. */ - fun anchor(anchor: Anchor) = anchor(JsonField.of(anchor)) - - /** - * Anchor timestamp after which the expiration policy applies. Supported anchors: - * `last_active_at`. - */ - fun anchor(anchor: JsonField) = apply { this.anchor = anchor } + fun anchor(anchor: JsonValue) = apply { this.anchor = anchor } /** The number of days after the anchor time that the vector store will expire. */ fun days(days: Long) = days(JsonField.of(days)) @@ -662,67 +651,12 @@ constructor( fun build(): ExpiresAfter = ExpiresAfter( - checkRequired("anchor", anchor), + anchor, checkRequired("days", days), additionalProperties.toImmutable(), ) } - /** - * Anchor timestamp after which the expiration policy applies. Supported anchors: - * `last_active_at`. - */ - class Anchor - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LAST_ACTIVE_AT = of("last_active_at") - - @JvmStatic fun of(value: String) = Anchor(JsonField.of(value)) - } - - enum class Known { - LAST_ACTIVE_AT, - } - - enum class Value { - LAST_ACTIVE_AT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LAST_ACTIVE_AT -> Value.LAST_ACTIVE_AT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LAST_ACTIVE_AT -> Known.LAST_ACTIVE_AT - else -> throw OpenAIInvalidDataException("Unknown Anchor: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Anchor && value == other.value /* spotless:on */ - } - - 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/BetaVectorStoreUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreUpdateParams.kt index f2cd9c16f..1623972cd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaVectorStoreUpdateParams.kt @@ -6,7 +6,6 @@ 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 @@ -406,9 +405,7 @@ constructor( class ExpiresAfter @JsonCreator private constructor( - @JsonProperty("anchor") - @ExcludeMissing - private val anchor: JsonField = JsonMissing.of(), + @JsonProperty("anchor") @ExcludeMissing private val anchor: JsonValue = JsonMissing.of(), @JsonProperty("days") @ExcludeMissing private val days: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -418,17 +415,11 @@ constructor( * Anchor timestamp after which the expiration policy applies. Supported anchors: * `last_active_at`. */ - fun anchor(): Anchor = anchor.getRequired("anchor") + @JsonProperty("anchor") @ExcludeMissing fun _anchor(): JsonValue = anchor /** The number of days after the anchor time that the vector store will expire. */ fun days(): Long = days.getRequired("days") - /** - * Anchor timestamp after which the expiration policy applies. Supported anchors: - * `last_active_at`. - */ - @JsonProperty("anchor") @ExcludeMissing fun _anchor(): JsonField = anchor - /** The number of days after the anchor time that the vector store will expire. */ @JsonProperty("days") @ExcludeMissing fun _days(): JsonField = days @@ -443,7 +434,11 @@ constructor( return@apply } - anchor() + _anchor().let { + if (it != JsonValue.from("last_active_at")) { + throw OpenAIInvalidDataException("'anchor' is invalid, received $it") + } + } days() validated = true } @@ -457,7 +452,7 @@ constructor( class Builder { - private var anchor: JsonField? = null + private var anchor: JsonValue = JsonValue.from("last_active_at") private var days: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -472,13 +467,7 @@ constructor( * Anchor timestamp after which the expiration policy applies. Supported anchors: * `last_active_at`. */ - fun anchor(anchor: Anchor) = anchor(JsonField.of(anchor)) - - /** - * Anchor timestamp after which the expiration policy applies. Supported anchors: - * `last_active_at`. - */ - fun anchor(anchor: JsonField) = apply { this.anchor = anchor } + fun anchor(anchor: JsonValue) = apply { this.anchor = anchor } /** The number of days after the anchor time that the vector store will expire. */ fun days(days: Long) = days(JsonField.of(days)) @@ -507,67 +496,12 @@ constructor( fun build(): ExpiresAfter = ExpiresAfter( - checkRequired("anchor", anchor), + anchor, checkRequired("days", days), additionalProperties.toImmutable(), ) } - /** - * Anchor timestamp after which the expiration policy applies. Supported anchors: - * `last_active_at`. - */ - class Anchor - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LAST_ACTIVE_AT = of("last_active_at") - - @JvmStatic fun of(value: String) = Anchor(JsonField.of(value)) - } - - enum class Known { - LAST_ACTIVE_AT, - } - - enum class Value { - LAST_ACTIVE_AT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LAST_ACTIVE_AT -> Value.LAST_ACTIVE_AT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LAST_ACTIVE_AT -> Known.LAST_ACTIVE_AT - else -> throw OpenAIInvalidDataException("Unknown Anchor: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Anchor && value == other.value /* spotless:on */ - } - - 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/ChatCompletion.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletion.kt index c922018bb..1631a5a48 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletion.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletion.kt @@ -32,9 +32,7 @@ private constructor( @ExcludeMissing private val created: JsonField = JsonMissing.of(), @JsonProperty("model") @ExcludeMissing private val model: JsonField = JsonMissing.of(), - @JsonProperty("object") - @ExcludeMissing - private val object_: JsonField = JsonMissing.of(), + @JsonProperty("object") @ExcludeMissing private val object_: JsonValue = JsonMissing.of(), @JsonProperty("service_tier") @ExcludeMissing private val serviceTier: JsonField = JsonMissing.of(), @@ -60,12 +58,9 @@ private constructor( fun model(): String = model.getRequired("model") /** The object type, which is always `chat.completion`. */ - fun object_(): Object = object_.getRequired("object") + @JsonProperty("object") @ExcludeMissing fun _object_(): JsonValue = object_ - /** - * The service tier used for processing the request. This field is only included if the - * `service_tier` parameter is specified in the request. - */ + /** The service tier used for processing the request. */ fun serviceTier(): Optional = Optional.ofNullable(serviceTier.getNullable("service_tier")) @@ -93,13 +88,7 @@ private constructor( /** The model used for the chat completion. */ @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model - /** The object type, which is always `chat.completion`. */ - @JsonProperty("object") @ExcludeMissing fun _object_(): JsonField = object_ - - /** - * The service tier used for processing the request. This field is only included if the - * `service_tier` parameter is specified in the request. - */ + /** The service tier used for processing the request. */ @JsonProperty("service_tier") @ExcludeMissing fun _serviceTier(): JsonField = serviceTier @@ -132,7 +121,11 @@ private constructor( choices().forEach { it.validate() } created() model() - object_() + _object_().let { + if (it != JsonValue.from("chat.completion")) { + throw OpenAIInvalidDataException("'object_' is invalid, received $it") + } + } serviceTier() systemFingerprint() usage().ifPresent { it.validate() } @@ -152,7 +145,7 @@ private constructor( private var choices: JsonField>? = null private var created: JsonField? = null private var model: JsonField? = null - private var object_: JsonField? = null + private var object_: JsonValue = JsonValue.from("chat.completion") private var serviceTier: JsonField = JsonMissing.of() private var systemFingerprint: JsonField = JsonMissing.of() private var usage: JsonField = JsonMissing.of() @@ -212,27 +205,15 @@ private constructor( fun model(model: JsonField) = apply { this.model = model } /** The object type, which is always `chat.completion`. */ - fun object_(object_: Object) = object_(JsonField.of(object_)) - - /** The object type, which is always `chat.completion`. */ - fun object_(object_: JsonField) = apply { this.object_ = object_ } + fun object_(object_: JsonValue) = apply { this.object_ = object_ } - /** - * The service tier used for processing the request. This field is only included if the - * `service_tier` parameter is specified in the request. - */ + /** The service tier used for processing the request. */ fun serviceTier(serviceTier: ServiceTier?) = serviceTier(JsonField.ofNullable(serviceTier)) - /** - * The service tier used for processing the request. This field is only included if the - * `service_tier` parameter is specified in the request. - */ + /** The service tier used for processing the request. */ fun serviceTier(serviceTier: Optional) = serviceTier(serviceTier.orElse(null)) - /** - * The service tier used for processing the request. This field is only included if the - * `service_tier` parameter is specified in the request. - */ + /** The service tier used for processing the request. */ fun serviceTier(serviceTier: JsonField) = apply { this.serviceTier = serviceTier } @@ -287,7 +268,7 @@ private constructor( checkRequired("choices", choices).map { it.toImmutable() }, checkRequired("created", created), checkRequired("model", model), - checkRequired("object_", object_), + object_, serviceTier, systemFingerprint, usage, @@ -740,62 +721,7 @@ private constructor( "Choice{finishReason=$finishReason, index=$index, logprobs=$logprobs, message=$message, additionalProperties=$additionalProperties}" } - /** The object type, which is always `chat.completion`. */ - class Object - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CHAT_COMPLETION = of("chat.completion") - - @JvmStatic fun of(value: String) = Object(JsonField.of(value)) - } - - enum class Known { - CHAT_COMPLETION, - } - - enum class Value { - CHAT_COMPLETION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - CHAT_COMPLETION -> Value.CHAT_COMPLETION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CHAT_COMPLETION -> Known.CHAT_COMPLETION - else -> throw OpenAIInvalidDataException("Unknown Object: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Object && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * The service tier used for processing the request. This field is only included if the - * `service_tier` parameter is specified in the request. - */ + /** The service tier used for processing the request. */ class ServiceTier @JsonCreator private constructor( diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionAssistantMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionAssistantMessageParam.kt index 3898db162..a826a5268 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionAssistantMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionAssistantMessageParam.kt @@ -15,7 +15,6 @@ 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 @@ -35,7 +34,7 @@ import kotlin.jvm.optionals.getOrNull class ChatCompletionAssistantMessageParam @JsonCreator private constructor( - @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing private val role: JsonValue = JsonMissing.of(), @JsonProperty("audio") @ExcludeMissing private val audio: JsonField