diff --git a/.stats.yml b/.stats.yml index 9501632..2c3f04e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 57 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-kotlin-44b51ad3239a0d86e832a267339339cc1727c967a62b4ac9a419eeba7085a62c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-kotlin-a3cf5e2cde79fce2f8d595cfd5c3b44db6d2a5499e4623e62b5c280646867552.yml diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClient.kt index c283217..2017589 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClient.kt @@ -21,8 +21,6 @@ interface BraintrustClient { fun prompt(): PromptService - fun promptSession(): PromptSessionService - fun role(): RoleService fun group(): GroupService diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClientAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClientAsync.kt index f84da41..52f6add 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClientAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClientAsync.kt @@ -21,8 +21,6 @@ interface BraintrustClientAsync { fun prompt(): PromptServiceAsync - fun promptSession(): PromptSessionServiceAsync - fun role(): RoleServiceAsync fun group(): GroupServiceAsync diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClientAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClientAsyncImpl.kt index eaa61fd..4e38c60 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClientAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClientAsyncImpl.kt @@ -30,10 +30,6 @@ constructor( private val prompt: PromptServiceAsync by lazy { PromptServiceAsyncImpl(clientOptions) } - private val promptSession: PromptSessionServiceAsync by lazy { - PromptSessionServiceAsyncImpl(clientOptions) - } - private val role: RoleServiceAsync by lazy { RoleServiceAsyncImpl(clientOptions) } private val group: GroupServiceAsync by lazy { GroupServiceAsyncImpl(clientOptions) } @@ -54,8 +50,6 @@ constructor( override fun prompt(): PromptServiceAsync = prompt - override fun promptSession(): PromptSessionServiceAsync = promptSession - override fun role(): RoleServiceAsync = role override fun group(): GroupServiceAsync = group diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClientImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClientImpl.kt index e7aeff4..19aec10 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClientImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrust/api/client/BraintrustClientImpl.kt @@ -28,10 +28,6 @@ constructor( private val prompt: PromptService by lazy { PromptServiceImpl(clientOptions) } - private val promptSession: PromptSessionService by lazy { - PromptSessionServiceImpl(clientOptions) - } - private val role: RoleService by lazy { RoleServiceImpl(clientOptions) } private val group: GroupService by lazy { GroupServiceImpl(clientOptions) } @@ -52,8 +48,6 @@ constructor( override fun prompt(): PromptService = prompt - override fun promptSession(): PromptSessionService = promptSession - override fun role(): RoleService = role override fun group(): GroupService = group diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptCreateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/Prompt.kt similarity index 99% rename from braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptCreateResponse.kt rename to braintrust-java-core/src/main/kotlin/com/braintrust/api/models/Prompt.kt index 0775159..2107eca 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptCreateResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/Prompt.kt @@ -28,9 +28,9 @@ import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = PromptCreateResponse.Builder::class) +@JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect -class PromptCreateResponse +class Prompt private constructor( private val id: JsonField, private val _xactId: JsonField, @@ -137,7 +137,7 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): PromptCreateResponse = apply { + fun validate(): Prompt = apply { if (!validated) { id() _xactId() @@ -162,7 +162,7 @@ private constructor( return true } - return other is PromptCreateResponse && + return other is Prompt && this.id == other.id && this._xactId == other._xactId && this.projectId == other.projectId && @@ -201,7 +201,7 @@ private constructor( } override fun toString() = - "PromptCreateResponse{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, additionalProperties=$additionalProperties}" + "Prompt{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, additionalProperties=$additionalProperties}" companion object { @@ -225,20 +225,20 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptCreateResponse: PromptCreateResponse) = apply { - this.id = promptCreateResponse.id - this._xactId = promptCreateResponse._xactId - this.projectId = promptCreateResponse.projectId - this.logId = promptCreateResponse.logId - this.orgId = promptCreateResponse.orgId - this.name = promptCreateResponse.name - this.slug = promptCreateResponse.slug - this.description = promptCreateResponse.description - this.created = promptCreateResponse.created - this.promptData = promptCreateResponse.promptData - this.tags = promptCreateResponse.tags - this.metadata = promptCreateResponse.metadata - additionalProperties(promptCreateResponse.additionalProperties) + internal fun from(prompt: Prompt) = apply { + this.id = prompt.id + this._xactId = prompt._xactId + this.projectId = prompt.projectId + this.logId = prompt.logId + this.orgId = prompt.orgId + this.name = prompt.name + this.slug = prompt.slug + this.description = prompt.description + this.created = prompt.created + this.promptData = prompt.promptData + this.tags = prompt.tags + this.metadata = prompt.metadata + additionalProperties(prompt.additionalProperties) } /** Unique identifier for the prompt */ @@ -357,8 +357,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptCreateResponse = - PromptCreateResponse( + fun build(): Prompt = + Prompt( id, _xactId, projectId, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptDeleteResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptDeleteResponse.kt deleted file mode 100644 index 008eeb5..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptDeleteResponse.kt +++ /dev/null @@ -1,6057 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrust.api.models - -import com.braintrust.api.core.BaseDeserializer -import com.braintrust.api.core.BaseSerializer -import com.braintrust.api.core.Enum -import com.braintrust.api.core.ExcludeMissing -import com.braintrust.api.core.JsonField -import com.braintrust.api.core.JsonMissing -import com.braintrust.api.core.JsonValue -import com.braintrust.api.core.NoAutoDetect -import com.braintrust.api.core.getOrThrow -import com.braintrust.api.core.toUnmodifiable -import com.braintrust.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = PromptDeleteResponse.Builder::class) -@NoAutoDetect -class PromptDeleteResponse -private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val description: JsonField, - private val created: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val metadata: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Unique identifier for the prompt */ - fun id(): String = id.getRequired("id") - - /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) - */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - - /** A literal 'p' which identifies the object as a project prompt */ - fun logId(): LogId = logId.getRequired("log_id") - - /** Unique identifier for the organization */ - fun orgId(): String = orgId.getRequired("org_id") - - /** Name of the prompt */ - fun name(): String = name.getRequired("name") - - /** Unique identifier for the prompt */ - fun slug(): String = slug.getRequired("slug") - - /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** Date of prompt creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - - /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) - - /** A list of tags for the prompt */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** User-controlled metadata about the prompt */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) - */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId - - /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId - - /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** Date of prompt creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData - - /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PromptDeleteResponse = apply { - if (!validated) { - id() - _xactId() - projectId() - logId() - orgId() - name() - slug() - description() - created() - promptData().map { it.validate() } - tags() - metadata().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptDeleteResponse && - this.id == other.id && - this._xactId == other._xactId && - this.projectId == other.projectId && - this.logId == other.logId && - this.orgId == other.orgId && - this.name == other.name && - this.slug == other.slug && - this.description == other.description && - this.created == other.created && - this.promptData == other.promptData && - this.tags == other.tags && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags, - metadata, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptDeleteResponse{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var logId: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var promptData: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptDeleteResponse: PromptDeleteResponse) = apply { - this.id = promptDeleteResponse.id - this._xactId = promptDeleteResponse._xactId - this.projectId = promptDeleteResponse.projectId - this.logId = promptDeleteResponse.logId - this.orgId = promptDeleteResponse.orgId - this.name = promptDeleteResponse.name - this.slug = promptDeleteResponse.slug - this.description = promptDeleteResponse.description - this.created = promptDeleteResponse.created - this.promptData = promptDeleteResponse.promptData - this.tags = promptDeleteResponse.tags - this.metadata = promptDeleteResponse.metadata - additionalProperties(promptDeleteResponse.additionalProperties) - } - - /** Unique identifier for the prompt */ - fun id(id: String) = id(JsonField.of(id)) - - /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) - */ - fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) - */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** A literal 'p' which identifies the object as a project prompt */ - fun logId(logId: LogId) = logId(JsonField.of(logId)) - - /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") - @ExcludeMissing - fun logId(logId: JsonField) = apply { this.logId = logId } - - /** Unique identifier for the organization */ - fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - - /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - - /** Name of the prompt */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Unique identifier for the prompt */ - fun slug(slug: String) = slug(JsonField.of(slug)) - - /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - /** Textual description of the prompt */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** Date of prompt creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** Date of prompt creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - @ExcludeMissing - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } - - /** A list of tags for the prompt */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** User-controlled metadata about the prompt */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PromptDeleteResponse = - PromptDeleteResponse( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags.map { it.toUnmodifiable() }, - metadata, - additionalProperties.toUnmodifiable(), - ) - } - - class LogId - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LogId && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val P = LogId(JsonField.of("p")) - - @JvmStatic fun of(value: String) = LogId(JsonField.of(value)) - } - - enum class Known { - P, - } - - enum class Value { - P, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - P -> Value.P - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - P -> Known.P - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - /** User-controlled metadata about the prompt */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** The prompt, model, and its parameters */ - @JsonDeserialize(builder = PromptData.Builder::class) - @NoAutoDetect - class PromptData - private constructor( - private val prompt: JsonField, - private val options: JsonField, - private val origin: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) - - fun options(): Optional = Optional.ofNullable(options.getNullable("options")) - - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) - - @JsonProperty("prompt") @ExcludeMissing fun _prompt() = prompt - - @JsonProperty("options") @ExcludeMissing fun _options() = options - - @JsonProperty("origin") @ExcludeMissing fun _origin() = origin - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PromptData = apply { - if (!validated) { - prompt() - options().map { it.validate() } - origin().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - prompt, - options, - origin, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var prompt: JsonField = JsonMissing.of() - private var options: JsonField = JsonMissing.of() - private var origin: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptData: PromptData) = apply { - this.prompt = promptData.prompt - this.options = promptData.options - this.origin = promptData.origin - additionalProperties(promptData.additionalProperties) - } - - fun prompt(prompt: Prompt) = prompt(JsonField.of(prompt)) - - @JsonProperty("prompt") - @ExcludeMissing - fun prompt(prompt: JsonField) = apply { this.prompt = prompt } - - fun options(options: Options) = options(JsonField.of(options)) - - @JsonProperty("options") - @ExcludeMissing - fun options(options: JsonField) = apply { this.options = options } - - fun origin(origin: Origin) = origin(JsonField.of(origin)) - - @JsonProperty("origin") - @ExcludeMissing - fun origin(origin: JsonField) = apply { this.origin = origin } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PromptData = - PromptData( - prompt, - options, - origin, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Options.Builder::class) - @NoAutoDetect - class Options - private constructor( - private val model: JsonField, - private val params: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) - - fun params(): Optional = Optional.ofNullable(params.getNullable("params")) - - fun position(): Optional = Optional.ofNullable(position.getNullable("position")) - - @JsonProperty("model") @ExcludeMissing fun _model() = model - - @JsonProperty("params") @ExcludeMissing fun _params() = params - - @JsonProperty("position") @ExcludeMissing fun _position() = position - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Options = apply { - if (!validated) { - model() - params() - position() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var model: JsonField = JsonMissing.of() - private var params: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - this.model = options.model - this.params = options.params - this.position = options.position - additionalProperties(options.additionalProperties) - } - - fun model(model: String) = model(JsonField.of(model)) - - @JsonProperty("model") - @ExcludeMissing - fun model(model: JsonField) = apply { this.model = model } - - fun params(params: Params) = params(JsonField.of(params)) - - @JsonProperty("params") - @ExcludeMissing - fun params(params: JsonField) = apply { this.params = params } - - fun position(position: String) = position(JsonField.of(position)) - - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Options = - Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Params.Deserializer::class) - @JsonSerialize(using = Params.Serializer::class) - class Params - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val useCache: UseCache? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun useCache(): Optional = Optional.ofNullable(useCache) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUseCache(): Boolean = useCache != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUseCache(): UseCache = useCache.getOrThrow("useCache") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - useCache != null -> visitor.visitUseCache(useCache) - else -> visitor.unknown(_json) - } - } - - fun validate(): Params = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null && - useCache == null - ) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - useCache?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.useCache == other.useCache - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - useCache, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Params{unionMember0=$unionMember0}" - unionMember1 != null -> "Params{unionMember1=$unionMember1}" - unionMember2 != null -> "Params{unionMember2=$unionMember2}" - useCache != null -> "Params{useCache=$useCache}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - Params(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - Params(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - Params(unionMember2 = unionMember2) - - @JvmStatic fun ofUseCache(useCache: UseCache) = Params(useCache = useCache) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUseCache(useCache: UseCache): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") - } - } - - class Deserializer : BaseDeserializer(Params::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(useCache = it, _json = json) - } - - return Params(_json = json) - } - } - - class Serializer : BaseSerializer(Params::class) { - - override fun serialize( - value: Params, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.useCache != null -> generator.writeObject(value.useCache) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - - fun maxTokens(): Optional = - Optional.ofNullable(maxTokens.getNullable("max_tokens")) - - fun frequencyPenalty(): Optional = - Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - - fun presencePenalty(): Optional = - Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - - fun responseFormat(): Optional = - Optional.ofNullable(responseFormat.getNullable("response_format")) - - fun toolChoice(): Optional = - Optional.ofNullable(toolChoice.getNullable("tool_choice")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - - fun stop(): Optional> = - Optional.ofNullable(stop.getNullable("stop")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - - @JsonProperty("frequency_penalty") - @ExcludeMissing - fun _frequencyPenalty() = frequencyPenalty - - @JsonProperty("presence_penalty") - @ExcludeMissing - fun _presencePenalty() = presencePenalty - - @JsonProperty("response_format") - @ExcludeMissing - fun _responseFormat() = responseFormat - - @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice - - @JsonProperty("function_call") - @ExcludeMissing - fun _functionCall() = functionCall - - @JsonProperty("n") @ExcludeMissing fun _n() = n - - @JsonProperty("stop") @ExcludeMissing fun _stop() = stop - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat().map { it.validate() } - toolChoice() - functionCall() - n() - stop() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() - private var frequencyPenalty: JsonField = JsonMissing.of() - private var presencePenalty: JsonField = JsonMissing.of() - private var responseFormat: JsonField = JsonMissing.of() - private var toolChoice: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var n: JsonField = JsonMissing.of() - private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.useCache = unionMember0.useCache - this.temperature = unionMember0.temperature - this.topP = unionMember0.topP - this.maxTokens = unionMember0.maxTokens - this.frequencyPenalty = unionMember0.frequencyPenalty - this.presencePenalty = unionMember0.presencePenalty - this.responseFormat = unionMember0.responseFormat - this.toolChoice = unionMember0.toolChoice - this.functionCall = unionMember0.functionCall - this.n = unionMember0.n - this.stop = unionMember0.stop - additionalProperties(unionMember0.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - - @JsonProperty("max_tokens") - @ExcludeMissing - fun maxTokens(maxTokens: JsonField) = apply { - this.maxTokens = maxTokens - } - - fun frequencyPenalty(frequencyPenalty: Double) = - frequencyPenalty(JsonField.of(frequencyPenalty)) - - @JsonProperty("frequency_penalty") - @ExcludeMissing - fun frequencyPenalty(frequencyPenalty: JsonField) = apply { - this.frequencyPenalty = frequencyPenalty - } - - fun presencePenalty(presencePenalty: Double) = - presencePenalty(JsonField.of(presencePenalty)) - - @JsonProperty("presence_penalty") - @ExcludeMissing - fun presencePenalty(presencePenalty: JsonField) = apply { - this.presencePenalty = presencePenalty - } - - fun responseFormat(responseFormat: ResponseFormat) = - responseFormat(JsonField.of(responseFormat)) - - @JsonProperty("response_format") - @ExcludeMissing - fun responseFormat(responseFormat: JsonField) = apply { - this.responseFormat = responseFormat - } - - fun toolChoice(toolChoice: ToolChoice) = - toolChoice(JsonField.of(toolChoice)) - - @JsonProperty("tool_choice") - @ExcludeMissing - fun toolChoice(toolChoice: JsonField) = apply { - this.toolChoice = toolChoice - } - - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun n(n: Double) = n(JsonField.of(n)) - - @JsonProperty("n") - @ExcludeMissing - fun n(n: JsonField) = apply { this.n = n } - - fun stop(stop: List) = stop(JsonField.of(stop)) - - @JsonProperty("stop") - @ExcludeMissing - fun stop(stop: JsonField>) = apply { this.stop = stop } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember0 = - UnionMember0( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = FunctionCall.Deserializer::class) - @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val name: Name? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun name(): Optional = Optional.ofNullable(name) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isName(): Boolean = name != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asName(): Name = name.getOrThrow("name") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - name != null -> visitor.visitName(name) - else -> visitor.unknown(_json) - } - } - - fun validate(): FunctionCall = apply { - if (!validated) { - if (unionMember0 == null && unionMember1 == null && name == null) { - throw BraintrustInvalidDataException( - "Unknown FunctionCall: $_json" - ) - } - name?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCall && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.name == other.name - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - name, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" - unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" - name != null -> "FunctionCall{name=$name}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - FunctionCall(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - FunctionCall(unionMember1 = unionMember1) - - @JvmStatic fun ofName(name: Name) = FunctionCall(name = name) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitName(name: Name): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") - } - } - - class Deserializer : BaseDeserializer(FunctionCall::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionCall(name = it, _json = json) - } - - return FunctionCall(_json = json) - } - } - - class Serializer : BaseSerializer(FunctionCall::class) { - - override fun serialize( - value: FunctionCall, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.name != null -> generator.writeObject(value.name) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } - } - } - - class UnionMember0 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = UnionMember0(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 BraintrustInvalidDataException( - "Unknown UnionMember0: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - class UnionMember1 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = UnionMember1(JsonField.of("none")) - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> - throw BraintrustInvalidDataException( - "Unknown UnionMember1: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = Name.Builder::class) - @NoAutoDetect - class Name - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Name = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Name && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Name{name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - additionalProperties(name.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Name = - Name(name, additionalProperties.toUnmodifiable()) - } - } - } - - @JsonDeserialize(builder = ResponseFormat.Builder::class) - @NoAutoDetect - class ResponseFormat - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ResponseFormat = apply { - if (!validated) { - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = - "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(responseFormat: ResponseFormat) = apply { - this.type = responseFormat.type - additionalProperties(responseFormat.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): ResponseFormat = - ResponseFormat(type, additionalProperties.toUnmodifiable()) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val JSON_OBJECT = Type(JsonField.of("json_object")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - JSON_OBJECT, - } - - enum class Value { - JSON_OBJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(using = ToolChoice.Deserializer::class) - @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = - Optional.ofNullable(unionMember2) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } - } - - fun validate(): ToolChoice = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null - ) { - throw BraintrustInvalidDataException( - "Unknown ToolChoice: $_json" - ) - } - unionMember2?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ToolChoice && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" - unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" - unionMember2 != null -> "ToolChoice{unionMember2=$unionMember2}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - ToolChoice(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - ToolChoice(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - ToolChoice(unionMember2 = unionMember2) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") - } - } - - class Deserializer : BaseDeserializer(ToolChoice::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ToolChoice(unionMember2 = it, _json = json) - } - - return ToolChoice(_json = json) - } - } - - class Serializer : BaseSerializer(ToolChoice::class) { - - override fun serialize( - value: ToolChoice, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.unionMember2 != null -> - generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - } - - class UnionMember0 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = UnionMember0(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 BraintrustInvalidDataException( - "Unknown UnionMember0: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - class UnionMember1 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = UnionMember1(JsonField.of("none")) - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> - throw BraintrustInvalidDataException( - "Unknown UnionMember1: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val type: JsonField, - private val function: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun function(): Function = function.getRequired("function") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("function") @ExcludeMissing fun _function() = function - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - type() - function().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{type=$type, function=$function, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.function = unionMember2.function - additionalProperties(unionMember2.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun function(function: Function) = function(JsonField.of(function)) - - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { - this.function = function - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - type, - function, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Function = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.name = function.name - additionalProperties(function.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Function = - Function(name, additionalProperties.toUnmodifiable()) - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun maxTokens(): Double = maxTokens.getRequired("max_tokens") - - fun temperature(): Double = temperature.getRequired("temperature") - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - - fun stopSequences(): Optional> = - Optional.ofNullable(stopSequences.getNullable("stop_sequences")) - - /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = - Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - - @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK - - @JsonProperty("stop_sequences") - @ExcludeMissing - fun _stopSequences() = stopSequences - - /** This is a legacy parameter that should not be used. */ - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - fun _maxTokensToSample() = maxTokensToSample - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var stopSequences: JsonField> = JsonMissing.of() - private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.useCache = unionMember1.useCache - this.maxTokens = unionMember1.maxTokens - this.temperature = unionMember1.temperature - this.topP = unionMember1.topP - this.topK = unionMember1.topK - this.stopSequences = unionMember1.stopSequences - this.maxTokensToSample = unionMember1.maxTokensToSample - additionalProperties(unionMember1.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - - @JsonProperty("max_tokens") - @ExcludeMissing - fun maxTokens(maxTokens: JsonField) = apply { - this.maxTokens = maxTokens - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun topK(topK: Double) = topK(JsonField.of(topK)) - - @JsonProperty("top_k") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } - - fun stopSequences(stopSequences: List) = - stopSequences(JsonField.of(stopSequences)) - - @JsonProperty("stop_sequences") - @ExcludeMissing - fun stopSequences(stopSequences: JsonField>) = apply { - this.stopSequences = stopSequences - } - - /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = - maxTokensToSample(JsonField.of(maxTokensToSample)) - - /** This is a legacy parameter that should not be used. */ - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - fun maxTokensToSample(maxTokensToSample: JsonField) = apply { - this.maxTokensToSample = maxTokensToSample - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember1 = - UnionMember1( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Double = temperature.getRequired("temperature") - - fun maxOutputTokens(): Optional = - Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("maxOutputTokens") - @ExcludeMissing - fun _maxOutputTokens() = maxOutputTokens - - @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - - @JsonProperty("topK") @ExcludeMissing fun _topK() = topK - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var maxOutputTokens: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.useCache = unionMember2.useCache - this.temperature = unionMember2.temperature - this.maxOutputTokens = unionMember2.maxOutputTokens - this.topP = unionMember2.topP - this.topK = unionMember2.topK - additionalProperties(unionMember2.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun maxOutputTokens(maxOutputTokens: Double) = - maxOutputTokens(JsonField.of(maxOutputTokens)) - - @JsonProperty("maxOutputTokens") - @ExcludeMissing - fun maxOutputTokens(maxOutputTokens: JsonField) = apply { - this.maxOutputTokens = maxOutputTokens - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("topP") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun topK(topK: Double) = topK(JsonField.of(topK)) - - @JsonProperty("topK") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = UseCache.Builder::class) - @NoAutoDetect - class UseCache - private constructor( - private val useCache: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UseCache = apply { - if (!validated) { - useCache() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UseCache && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode - } - - override fun toString() = - "UseCache{useCache=$useCache, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(useCache: UseCache) = apply { - this.useCache = useCache.useCache - additionalProperties(useCache.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UseCache = - UseCache(useCache, additionalProperties.toUnmodifiable()) - } - } - } - } - - @JsonDeserialize(builder = Origin.Builder::class) - @NoAutoDetect - class Origin - private constructor( - private val promptId: JsonField, - private val projectId: JsonField, - private val promptVersion: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun promptId(): Optional = - Optional.ofNullable(promptId.getNullable("prompt_id")) - - fun projectId(): Optional = - Optional.ofNullable(projectId.getNullable("project_id")) - - fun promptVersion(): Optional = - Optional.ofNullable(promptVersion.getNullable("prompt_version")) - - @JsonProperty("prompt_id") @ExcludeMissing fun _promptId() = promptId - - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - @JsonProperty("prompt_version") @ExcludeMissing fun _promptVersion() = promptVersion - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Origin = apply { - if (!validated) { - promptId() - projectId() - promptVersion() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var promptId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var promptVersion: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(origin: Origin) = apply { - this.promptId = origin.promptId - this.projectId = origin.projectId - this.promptVersion = origin.promptVersion - additionalProperties(origin.additionalProperties) - } - - fun promptId(promptId: String) = promptId(JsonField.of(promptId)) - - @JsonProperty("prompt_id") - @ExcludeMissing - fun promptId(promptId: JsonField) = apply { this.promptId = promptId } - - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - fun promptVersion(promptVersion: String) = - promptVersion(JsonField.of(promptVersion)) - - @JsonProperty("prompt_version") - @ExcludeMissing - fun promptVersion(promptVersion: JsonField) = apply { - this.promptVersion = promptVersion - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Origin = - Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(using = Prompt.Deserializer::class) - @JsonSerialize(using = Prompt.Serializer::class) - class Prompt - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val _reservedOnlyAllowNull: _ReservedOnlyAllowNull? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun _reservedOnlyAllowNull(): Optional<_ReservedOnlyAllowNull> = - Optional.ofNullable(_reservedOnlyAllowNull) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun is_ReservedOnlyAllowNull(): Boolean = _reservedOnlyAllowNull != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun as_ReservedOnlyAllowNull(): _ReservedOnlyAllowNull = - _reservedOnlyAllowNull.getOrThrow("_reservedOnlyAllowNull") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - _reservedOnlyAllowNull != null -> - visitor.visit_ReservedOnlyAllowNull(_reservedOnlyAllowNull) - else -> visitor.unknown(_json) - } - } - - fun validate(): Prompt = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - _reservedOnlyAllowNull == null - ) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - _reservedOnlyAllowNull?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this._reservedOnlyAllowNull == other._reservedOnlyAllowNull - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - _reservedOnlyAllowNull, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Prompt{unionMember0=$unionMember0}" - unionMember1 != null -> "Prompt{unionMember1=$unionMember1}" - _reservedOnlyAllowNull != null -> - "Prompt{_reservedOnlyAllowNull=$_reservedOnlyAllowNull}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Prompt(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Prompt(unionMember1 = unionMember1) - - @JvmStatic - fun of_ReservedOnlyAllowNull(_reservedOnlyAllowNull: _ReservedOnlyAllowNull) = - Prompt(_reservedOnlyAllowNull = _reservedOnlyAllowNull) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visit_ReservedOnlyAllowNull(_reservedOnlyAllowNull: _ReservedOnlyAllowNull): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") - } - } - - class Deserializer : BaseDeserializer(Prompt::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef<_ReservedOnlyAllowNull>()) { it.validate() } - ?.let { - return Prompt(_reservedOnlyAllowNull = it, _json = json) - } - - return Prompt(_json = json) - } - } - - class Serializer : BaseSerializer(Prompt::class) { - - override fun serialize( - value: Prompt, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value._reservedOnlyAllowNull != null -> - generator.writeObject(value._reservedOnlyAllowNull) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val type: JsonField, - private val content: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun content(): String = content.getRequired("content") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - type() - content() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{type=$type, content=$content, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.type = unionMember0.type - this.content = unionMember0.content - additionalProperties(unionMember0.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = - UnionMember0( - type, - content, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val COMPLETION = Type(JsonField.of("completion")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - COMPLETION, - } - - enum class Value { - COMPLETION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun messages(): List = messages.getRequired("messages") - - fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("messages") @ExcludeMissing fun _messages() = messages - - @JsonProperty("tools") @ExcludeMissing fun _tools() = tools - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - type() - messages() - tools() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var messages: JsonField> = JsonMissing.of() - private var tools: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.messages = unionMember1.messages - this.tools = unionMember1.tools - additionalProperties(unionMember1.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun messages(messages: List) = messages(JsonField.of(messages)) - - @JsonProperty("messages") - @ExcludeMissing - fun messages(messages: JsonField>) = apply { - this.messages = messages - } - - fun tools(tools: String) = tools(JsonField.of(tools)) - - @JsonProperty("tools") - @ExcludeMissing - fun tools(tools: JsonField) = apply { this.tools = tools } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = - UnionMember1( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Message.Deserializer::class) - @JsonSerialize(using = Message.Serializer::class) - class Message - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUnionMember3(): Boolean = unionMember3 != null - - fun isUnionMember4(): Boolean = unionMember4 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - else -> visitor.unknown(_json) - } - } - - fun validate(): Message = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null && - unionMember3 == null && - unionMember4 == null - ) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - unionMember4?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.unionMember4 == other.unionMember4 - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Message{unionMember0=$unionMember0}" - unionMember1 != null -> "Message{unionMember1=$unionMember1}" - unionMember2 != null -> "Message{unionMember2=$unionMember2}" - unionMember3 != null -> "Message{unionMember3=$unionMember3}" - unionMember4 != null -> "Message{unionMember4=$unionMember4}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - Message(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - Message(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - Message(unionMember2 = unionMember2) - - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = - Message(unionMember3 = unionMember3) - - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = - Message(unionMember4 = unionMember4) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUnionMember3(unionMember3: UnionMember3): T - - fun visitUnionMember4(unionMember4: UnionMember4): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") - } - } - - class Deserializer : BaseDeserializer(Message::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember4 = it, _json = json) - } - - return Message(_json = json) - } - } - - class Serializer : BaseSerializer(Message::class) { - - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.unionMember2 != null -> - generator.writeObject(value.unionMember2) - value.unionMember3 != null -> - generator.writeObject(value.unionMember3) - value.unionMember4 != null -> - generator.writeObject(value.unionMember4) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.content = unionMember0.content - this.role = unionMember0.role - this.name = unionMember0.name - additionalProperties(unionMember0.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember0 = - UnionMember0( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SYSTEM = Role(JsonField.of("system")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - SYSTEM, - } - - enum class Value { - SYSTEM, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SYSTEM -> Known.SYSTEM - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.content = unionMember1.content - this.role = unionMember1.role - this.name = unionMember1.name - additionalProperties(unionMember1.additionalProperties) - } - - fun content(content: Content) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember1 = - UnionMember1( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val USER = Role(JsonField.of("user")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - USER, - } - - enum class Value { - USER, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - USER -> Known.USER - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(using = Content.Deserializer::class) - @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( - private val string: String? = null, - private val unnamedSchemaWithArrayParent7s: - List? = - null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun unnamedSchemaWithArrayParent7s(): - Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent7s) - - fun isString(): Boolean = string != null - - fun isUnnamedSchemaWithArrayParent7s(): Boolean = - unnamedSchemaWithArrayParent7s != null - - fun asString(): String = string.getOrThrow("string") - - fun asUnnamedSchemaWithArrayParent7s(): - List = - unnamedSchemaWithArrayParent7s.getOrThrow( - "unnamedSchemaWithArrayParent7s" - ) - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent7s != null -> - visitor.visitUnnamedSchemaWithArrayParent7s( - unnamedSchemaWithArrayParent7s - ) - else -> visitor.unknown(_json) - } - } - - fun validate(): Content = apply { - if (!validated) { - if (string == null && unnamedSchemaWithArrayParent7s == null) { - throw BraintrustInvalidDataException( - "Unknown Content: $_json" - ) - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent7s == - other.unnamedSchemaWithArrayParent7s - } - - override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent7s) - } - - override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent7s != null -> - "Content{unnamedSchemaWithArrayParent7s=$unnamedSchemaWithArrayParent7s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Content(string = string) - - @JvmStatic - fun ofUnnamedSchemaWithArrayParent7s( - unnamedSchemaWithArrayParent7s: - List - ) = - Content( - unnamedSchemaWithArrayParent7s = - unnamedSchemaWithArrayParent7s - ) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitUnnamedSchemaWithArrayParent7s( - unnamedSchemaWithArrayParent7s: - List - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") - } - } - - class Deserializer : BaseDeserializer(Content::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize( - node, - jacksonTypeRef>() - ) - ?.let { - return Content( - unnamedSchemaWithArrayParent7s = it, - _json = json - ) - } - - return Content(_json = json) - } - } - - class Serializer : BaseSerializer(Content::class) { - - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent7s != null -> - generator.writeObject( - value.unnamedSchemaWithArrayParent7s - ) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } - } - } - - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent7.Deserializer::class - ) - @JsonSerialize(using = UnnamedSchemaWithArrayParent7.Serializer::class) - class UnnamedSchemaWithArrayParent7 - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun asUnionMember0(): UnionMember0 = - unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = - unionMember1.getOrThrow("unionMember1") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> - visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> - visitor.visitUnionMember1(unionMember1) - else -> visitor.unknown(_json) - } - } - - fun validate(): UnnamedSchemaWithArrayParent7 = apply { - if (!validated) { - if (unionMember0 == null && unionMember1 == null) { - throw BraintrustInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent7: $_json" - ) - } - unionMember0?.validate() - unionMember1?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent7 && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 - } - - override fun hashCode(): Int { - return Objects.hash(unionMember0, unionMember1) - } - - override fun toString(): String { - return when { - unionMember0 != null -> - "UnnamedSchemaWithArrayParent7{unionMember0=$unionMember0}" - unionMember1 != null -> - "UnnamedSchemaWithArrayParent7{unionMember1=$unionMember1}" - _json != null -> - "UnnamedSchemaWithArrayParent7{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent7" - ) - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - UnnamedSchemaWithArrayParent7(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - UnnamedSchemaWithArrayParent7(unionMember1 = unionMember1) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent7: $json" - ) - } - } - - class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent7::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent7 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return UnnamedSchemaWithArrayParent7( - unionMember0 = it, - _json = json - ) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return UnnamedSchemaWithArrayParent7( - unionMember1 = it, - _json = json - ) - } - - return UnnamedSchemaWithArrayParent7(_json = json) - } - } - - class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent7::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent7, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent7" - ) - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val text: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun text(): Optional = - Optional.ofNullable(text.getNullable("text")) - - fun type(): Type = type.getRequired("type") - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - text() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{text=$text, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var text: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.text = unionMember0.text - this.type = unionMember0.type - additionalProperties(unionMember0.additionalProperties) - } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { - this.text = text - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = - UnionMember0( - text, - type, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TEXT = Type(JsonField.of("text")) - - @JvmStatic - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - TEXT, - } - - enum class Value { - TEXT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TEXT -> Known.TEXT - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val imageUrl: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") - - fun type(): Type = type.getRequired("type") - - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl() = imageUrl - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - imageUrl().validate() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var imageUrl: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.imageUrl = unionMember1.imageUrl - this.type = unionMember1.type - additionalProperties(unionMember1.additionalProperties) - } - - fun imageUrl(imageUrl: ImageUrl) = - imageUrl(JsonField.of(imageUrl)) - - @JsonProperty("image_url") - @ExcludeMissing - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = - UnionMember1( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = ImageUrl.Builder::class) - @NoAutoDetect - class ImageUrl - private constructor( - private val url: JsonField, - private val detail: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun url(): String = url.getRequired("url") - - fun detail(): Optional = - Optional.ofNullable(detail.getNullable("detail")) - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonProperty("detail") - @ExcludeMissing - fun _detail() = detail - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): ImageUrl = apply { - if (!validated) { - url() - detail() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == - other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var url: JsonField = JsonMissing.of() - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(imageUrl: ImageUrl) = apply { - this.url = imageUrl.url - this.detail = imageUrl.detail - additionalProperties(imageUrl.additionalProperties) - } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { - this.url = url - } - - fun detail(detail: Detail) = - detail(JsonField.of(detail)) - - @JsonProperty("detail") - @ExcludeMissing - fun detail(detail: JsonField) = apply { - this.detail = detail - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll( - additionalProperties - ) - } - - @JsonAnySetter - fun putAdditionalProperty( - key: String, - value: JsonValue - ) = apply { this.additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun build(): ImageUrl = - ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) - } - - class Detail - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Detail && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = Detail(JsonField.of("auto")) - - @JvmField val LOW = Detail(JsonField.of("low")) - - @JvmField val HIGH = Detail(JsonField.of("high")) - - @JvmStatic - fun of(value: String) = Detail(JsonField.of(value)) - } - - enum class Known { - AUTO, - LOW, - HIGH, - } - - enum class Value { - AUTO, - LOW, - HIGH, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> - throw BraintrustInvalidDataException( - "Unknown Detail: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField - val IMAGE_URL = Type(JsonField.of("image_url")) - - @JvmStatic - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - IMAGE_URL, - } - - enum class Value { - IMAGE_URL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - } - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun role(): Role = role.getRequired("role") - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun toolCalls(): Optional> = - Optional.ofNullable(toolCalls.getNullable("tool_calls")) - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("function_call") - @ExcludeMissing - fun _functionCall() = functionCall - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var role: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.role = unionMember2.role - this.content = unionMember2.content - this.functionCall = unionMember2.functionCall - this.name = unionMember2.name - this.toolCalls = unionMember2.toolCalls - additionalProperties(unionMember2.additionalProperties) - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun toolCalls(toolCalls: List) = - toolCalls(JsonField.of(toolCalls)) - - @JsonProperty("tool_calls") - @ExcludeMissing - fun toolCalls(toolCalls: JsonField>) = apply { - this.toolCalls = toolCalls - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val ASSISTANT = Role(JsonField.of("assistant")) - - @JvmStatic fun of(value: String) = Role(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 BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = FunctionCall.Builder::class) - @NoAutoDetect - class FunctionCall - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun arguments(): String = arguments.getRequired("arguments") - - fun name(): String = name.getRequired("name") - - @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): FunctionCall = apply { - if (!validated) { - arguments() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(functionCall: FunctionCall) = apply { - this.arguments = functionCall.arguments - this.name = functionCall.name - additionalProperties(functionCall.additionalProperties) - } - - fun arguments(arguments: String) = - arguments(JsonField.of(arguments)) - - @JsonProperty("arguments") - @ExcludeMissing - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): FunctionCall = - FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = ToolCall.Builder::class) - @NoAutoDetect - class ToolCall - private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun id(): String = id.getRequired("id") - - fun function(): Function = function.getRequired("function") - - fun type(): Type = type.getRequired("type") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("function") @ExcludeMissing fun _function() = function - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): ToolCall = apply { - if (!validated) { - id() - function().validate() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(toolCall: ToolCall) = apply { - this.id = toolCall.id - this.function = toolCall.function - this.type = toolCall.type - additionalProperties(toolCall.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun function(function: Function) = function(JsonField.of(function)) - - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { - this.function = function - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): ToolCall = - ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun arguments(): String = arguments.getRequired("arguments") - - fun name(): String = name.getRequired("name") - - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments() = arguments - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Function = apply { - if (!validated) { - arguments() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.arguments = function.arguments - this.name = function.name - additionalProperties(function.additionalProperties) - } - - fun arguments(arguments: String) = - arguments(JsonField.of(arguments)) - - @JsonProperty("arguments") - @ExcludeMissing - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Function = - Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - @JsonDeserialize(builder = UnionMember3.Builder::class) - @NoAutoDetect - class UnionMember3 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun toolCallId(): String = toolCallId.getRequired("tool_call_id") - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember3 = apply { - if (!validated) { - content() - role() - toolCallId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember3{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.content = unionMember3.content - this.role = unionMember3.role - this.toolCallId = unionMember3.toolCallId - additionalProperties(unionMember3.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun toolCallId(toolCallId: String) = - toolCallId(JsonField.of(toolCallId)) - - @JsonProperty("tool_call_id") - @ExcludeMissing - fun toolCallId(toolCallId: JsonField) = apply { - this.toolCallId = toolCallId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember3 = - UnionMember3( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TOOL = Role(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - TOOL, - } - - enum class Value { - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TOOL -> Known.TOOL - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember4.Builder::class) - @NoAutoDetect - class UnionMember4 - private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun name(): String = name.getRequired("name") - - fun role(): Role = role.getRequired("role") - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember4 = apply { - if (!validated) { - content() - name() - role() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember4 && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember4{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - this.content = unionMember4.content - this.name = unionMember4.name - this.role = unionMember4.role - additionalProperties(unionMember4.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember4 = - UnionMember4( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Role(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val CHAT = Type(JsonField.of("chat")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - CHAT, - } - - enum class Value { - CHAT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = _ReservedOnlyAllowNull.Builder::class) - @NoAutoDetect - class _ReservedOnlyAllowNull - private constructor( - private val _reservedOnlyAllowNull: JsonValue, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * This is just a placeholder nullable object. Only pass null, not the object itself - */ - @JsonProperty("__reserved_only_allow_null") - @ExcludeMissing - fun __reservedOnlyAllowNull() = _reservedOnlyAllowNull - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): _ReservedOnlyAllowNull = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is _ReservedOnlyAllowNull && - this._reservedOnlyAllowNull == other._reservedOnlyAllowNull && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(_reservedOnlyAllowNull, additionalProperties) - } - return hashCode - } - - override fun toString() = - "_ReservedOnlyAllowNull{_reservedOnlyAllowNull=$_reservedOnlyAllowNull, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var _reservedOnlyAllowNull: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(_reservedOnlyAllowNull: _ReservedOnlyAllowNull) = apply { - this._reservedOnlyAllowNull = _reservedOnlyAllowNull._reservedOnlyAllowNull - additionalProperties(_reservedOnlyAllowNull.additionalProperties) - } - - /** - * This is just a placeholder nullable object. Only pass null, not the object - * itself - */ - @JsonProperty("__reserved_only_allow_null") - @ExcludeMissing - fun _reservedOnlyAllowNull(_reservedOnlyAllowNull: JsonValue) = apply { - this._reservedOnlyAllowNull = _reservedOnlyAllowNull - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): _ReservedOnlyAllowNull = - _ReservedOnlyAllowNull( - _reservedOnlyAllowNull, - additionalProperties.toUnmodifiable() - ) - } - } - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptListPage.kt index 1f81cbf..7bac495 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptListPage.kt @@ -27,7 +27,7 @@ private constructor( fun response(): Response = response - fun objects(): List = response().objects() + fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { if (this === other) { @@ -92,16 +92,16 @@ private constructor( @NoAutoDetect class Response constructor( - private val objects: JsonField>, + private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() + fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") - fun _objects(): Optional>> = Optional.ofNullable(objects) + fun _objects(): Optional>> = Optional.ofNullable(objects) @JsonAnyGetter @ExcludeMissing @@ -140,7 +140,7 @@ private constructor( class Builder { - private var objects: JsonField> = JsonMissing.of() + private var objects: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -149,12 +149,10 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun objects(objects: List) = objects(JsonField.of(objects)) + fun objects(objects: List) = objects(JsonField.of(objects)) @JsonProperty("objects") - fun objects(objects: JsonField>) = apply { - this.objects = objects - } + fun objects(objects: JsonField>) = apply { this.objects = objects } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { @@ -168,9 +166,9 @@ private constructor( class AutoPager constructor( private val firstPage: PromptListPage, - ) : Iterable { + ) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -182,7 +180,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptListPageAsync.kt index 17fc56b..55ac351 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptListPageAsync.kt @@ -28,7 +28,7 @@ private constructor( fun response(): Response = response - fun objects(): List = response().objects() + fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { if (this === other) { @@ -95,16 +95,16 @@ private constructor( @NoAutoDetect class Response constructor( - private val objects: JsonField>, + private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() + fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") - fun _objects(): Optional>> = Optional.ofNullable(objects) + fun _objects(): Optional>> = Optional.ofNullable(objects) @JsonAnyGetter @ExcludeMissing @@ -143,7 +143,7 @@ private constructor( class Builder { - private var objects: JsonField> = JsonMissing.of() + private var objects: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -152,12 +152,10 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun objects(objects: List) = objects(JsonField.of(objects)) + fun objects(objects: List) = objects(JsonField.of(objects)) @JsonProperty("objects") - fun objects(objects: JsonField>) = apply { - this.objects = objects - } + fun objects(objects: JsonField>) = apply { this.objects = objects } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { @@ -173,12 +171,9 @@ private constructor( private val firstPage: PromptListPageAsync, ) { - fun forEach( - action: Predicate, - executor: Executor - ): CompletableFuture { + fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( - action: (PromptListResponse) -> Boolean, + action: (Prompt) -> Boolean, executor: Executor ): CompletableFuture = thenComposeAsync( @@ -194,8 +189,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptListResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptListResponse.kt deleted file mode 100644 index 4576094..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptListResponse.kt +++ /dev/null @@ -1,6057 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrust.api.models - -import com.braintrust.api.core.BaseDeserializer -import com.braintrust.api.core.BaseSerializer -import com.braintrust.api.core.Enum -import com.braintrust.api.core.ExcludeMissing -import com.braintrust.api.core.JsonField -import com.braintrust.api.core.JsonMissing -import com.braintrust.api.core.JsonValue -import com.braintrust.api.core.NoAutoDetect -import com.braintrust.api.core.getOrThrow -import com.braintrust.api.core.toUnmodifiable -import com.braintrust.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = PromptListResponse.Builder::class) -@NoAutoDetect -class PromptListResponse -private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val description: JsonField, - private val created: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val metadata: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Unique identifier for the prompt */ - fun id(): String = id.getRequired("id") - - /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) - */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - - /** A literal 'p' which identifies the object as a project prompt */ - fun logId(): LogId = logId.getRequired("log_id") - - /** Unique identifier for the organization */ - fun orgId(): String = orgId.getRequired("org_id") - - /** Name of the prompt */ - fun name(): String = name.getRequired("name") - - /** Unique identifier for the prompt */ - fun slug(): String = slug.getRequired("slug") - - /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** Date of prompt creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - - /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) - - /** A list of tags for the prompt */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** User-controlled metadata about the prompt */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) - */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId - - /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId - - /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** Date of prompt creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData - - /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PromptListResponse = apply { - if (!validated) { - id() - _xactId() - projectId() - logId() - orgId() - name() - slug() - description() - created() - promptData().map { it.validate() } - tags() - metadata().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptListResponse && - this.id == other.id && - this._xactId == other._xactId && - this.projectId == other.projectId && - this.logId == other.logId && - this.orgId == other.orgId && - this.name == other.name && - this.slug == other.slug && - this.description == other.description && - this.created == other.created && - this.promptData == other.promptData && - this.tags == other.tags && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags, - metadata, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptListResponse{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var logId: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var promptData: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptListResponse: PromptListResponse) = apply { - this.id = promptListResponse.id - this._xactId = promptListResponse._xactId - this.projectId = promptListResponse.projectId - this.logId = promptListResponse.logId - this.orgId = promptListResponse.orgId - this.name = promptListResponse.name - this.slug = promptListResponse.slug - this.description = promptListResponse.description - this.created = promptListResponse.created - this.promptData = promptListResponse.promptData - this.tags = promptListResponse.tags - this.metadata = promptListResponse.metadata - additionalProperties(promptListResponse.additionalProperties) - } - - /** Unique identifier for the prompt */ - fun id(id: String) = id(JsonField.of(id)) - - /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) - */ - fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) - */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** A literal 'p' which identifies the object as a project prompt */ - fun logId(logId: LogId) = logId(JsonField.of(logId)) - - /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") - @ExcludeMissing - fun logId(logId: JsonField) = apply { this.logId = logId } - - /** Unique identifier for the organization */ - fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - - /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - - /** Name of the prompt */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Unique identifier for the prompt */ - fun slug(slug: String) = slug(JsonField.of(slug)) - - /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - /** Textual description of the prompt */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** Date of prompt creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** Date of prompt creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - @ExcludeMissing - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } - - /** A list of tags for the prompt */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** User-controlled metadata about the prompt */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PromptListResponse = - PromptListResponse( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags.map { it.toUnmodifiable() }, - metadata, - additionalProperties.toUnmodifiable(), - ) - } - - class LogId - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LogId && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val P = LogId(JsonField.of("p")) - - @JvmStatic fun of(value: String) = LogId(JsonField.of(value)) - } - - enum class Known { - P, - } - - enum class Value { - P, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - P -> Value.P - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - P -> Known.P - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - /** User-controlled metadata about the prompt */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** The prompt, model, and its parameters */ - @JsonDeserialize(builder = PromptData.Builder::class) - @NoAutoDetect - class PromptData - private constructor( - private val prompt: JsonField, - private val options: JsonField, - private val origin: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) - - fun options(): Optional = Optional.ofNullable(options.getNullable("options")) - - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) - - @JsonProperty("prompt") @ExcludeMissing fun _prompt() = prompt - - @JsonProperty("options") @ExcludeMissing fun _options() = options - - @JsonProperty("origin") @ExcludeMissing fun _origin() = origin - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PromptData = apply { - if (!validated) { - prompt() - options().map { it.validate() } - origin().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - prompt, - options, - origin, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var prompt: JsonField = JsonMissing.of() - private var options: JsonField = JsonMissing.of() - private var origin: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptData: PromptData) = apply { - this.prompt = promptData.prompt - this.options = promptData.options - this.origin = promptData.origin - additionalProperties(promptData.additionalProperties) - } - - fun prompt(prompt: Prompt) = prompt(JsonField.of(prompt)) - - @JsonProperty("prompt") - @ExcludeMissing - fun prompt(prompt: JsonField) = apply { this.prompt = prompt } - - fun options(options: Options) = options(JsonField.of(options)) - - @JsonProperty("options") - @ExcludeMissing - fun options(options: JsonField) = apply { this.options = options } - - fun origin(origin: Origin) = origin(JsonField.of(origin)) - - @JsonProperty("origin") - @ExcludeMissing - fun origin(origin: JsonField) = apply { this.origin = origin } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PromptData = - PromptData( - prompt, - options, - origin, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Options.Builder::class) - @NoAutoDetect - class Options - private constructor( - private val model: JsonField, - private val params: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) - - fun params(): Optional = Optional.ofNullable(params.getNullable("params")) - - fun position(): Optional = Optional.ofNullable(position.getNullable("position")) - - @JsonProperty("model") @ExcludeMissing fun _model() = model - - @JsonProperty("params") @ExcludeMissing fun _params() = params - - @JsonProperty("position") @ExcludeMissing fun _position() = position - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Options = apply { - if (!validated) { - model() - params() - position() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var model: JsonField = JsonMissing.of() - private var params: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - this.model = options.model - this.params = options.params - this.position = options.position - additionalProperties(options.additionalProperties) - } - - fun model(model: String) = model(JsonField.of(model)) - - @JsonProperty("model") - @ExcludeMissing - fun model(model: JsonField) = apply { this.model = model } - - fun params(params: Params) = params(JsonField.of(params)) - - @JsonProperty("params") - @ExcludeMissing - fun params(params: JsonField) = apply { this.params = params } - - fun position(position: String) = position(JsonField.of(position)) - - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Options = - Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Params.Deserializer::class) - @JsonSerialize(using = Params.Serializer::class) - class Params - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val useCache: UseCache? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun useCache(): Optional = Optional.ofNullable(useCache) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUseCache(): Boolean = useCache != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUseCache(): UseCache = useCache.getOrThrow("useCache") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - useCache != null -> visitor.visitUseCache(useCache) - else -> visitor.unknown(_json) - } - } - - fun validate(): Params = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null && - useCache == null - ) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - useCache?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.useCache == other.useCache - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - useCache, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Params{unionMember0=$unionMember0}" - unionMember1 != null -> "Params{unionMember1=$unionMember1}" - unionMember2 != null -> "Params{unionMember2=$unionMember2}" - useCache != null -> "Params{useCache=$useCache}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - Params(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - Params(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - Params(unionMember2 = unionMember2) - - @JvmStatic fun ofUseCache(useCache: UseCache) = Params(useCache = useCache) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUseCache(useCache: UseCache): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") - } - } - - class Deserializer : BaseDeserializer(Params::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(useCache = it, _json = json) - } - - return Params(_json = json) - } - } - - class Serializer : BaseSerializer(Params::class) { - - override fun serialize( - value: Params, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.useCache != null -> generator.writeObject(value.useCache) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - - fun maxTokens(): Optional = - Optional.ofNullable(maxTokens.getNullable("max_tokens")) - - fun frequencyPenalty(): Optional = - Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - - fun presencePenalty(): Optional = - Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - - fun responseFormat(): Optional = - Optional.ofNullable(responseFormat.getNullable("response_format")) - - fun toolChoice(): Optional = - Optional.ofNullable(toolChoice.getNullable("tool_choice")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - - fun stop(): Optional> = - Optional.ofNullable(stop.getNullable("stop")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - - @JsonProperty("frequency_penalty") - @ExcludeMissing - fun _frequencyPenalty() = frequencyPenalty - - @JsonProperty("presence_penalty") - @ExcludeMissing - fun _presencePenalty() = presencePenalty - - @JsonProperty("response_format") - @ExcludeMissing - fun _responseFormat() = responseFormat - - @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice - - @JsonProperty("function_call") - @ExcludeMissing - fun _functionCall() = functionCall - - @JsonProperty("n") @ExcludeMissing fun _n() = n - - @JsonProperty("stop") @ExcludeMissing fun _stop() = stop - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat().map { it.validate() } - toolChoice() - functionCall() - n() - stop() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() - private var frequencyPenalty: JsonField = JsonMissing.of() - private var presencePenalty: JsonField = JsonMissing.of() - private var responseFormat: JsonField = JsonMissing.of() - private var toolChoice: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var n: JsonField = JsonMissing.of() - private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.useCache = unionMember0.useCache - this.temperature = unionMember0.temperature - this.topP = unionMember0.topP - this.maxTokens = unionMember0.maxTokens - this.frequencyPenalty = unionMember0.frequencyPenalty - this.presencePenalty = unionMember0.presencePenalty - this.responseFormat = unionMember0.responseFormat - this.toolChoice = unionMember0.toolChoice - this.functionCall = unionMember0.functionCall - this.n = unionMember0.n - this.stop = unionMember0.stop - additionalProperties(unionMember0.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - - @JsonProperty("max_tokens") - @ExcludeMissing - fun maxTokens(maxTokens: JsonField) = apply { - this.maxTokens = maxTokens - } - - fun frequencyPenalty(frequencyPenalty: Double) = - frequencyPenalty(JsonField.of(frequencyPenalty)) - - @JsonProperty("frequency_penalty") - @ExcludeMissing - fun frequencyPenalty(frequencyPenalty: JsonField) = apply { - this.frequencyPenalty = frequencyPenalty - } - - fun presencePenalty(presencePenalty: Double) = - presencePenalty(JsonField.of(presencePenalty)) - - @JsonProperty("presence_penalty") - @ExcludeMissing - fun presencePenalty(presencePenalty: JsonField) = apply { - this.presencePenalty = presencePenalty - } - - fun responseFormat(responseFormat: ResponseFormat) = - responseFormat(JsonField.of(responseFormat)) - - @JsonProperty("response_format") - @ExcludeMissing - fun responseFormat(responseFormat: JsonField) = apply { - this.responseFormat = responseFormat - } - - fun toolChoice(toolChoice: ToolChoice) = - toolChoice(JsonField.of(toolChoice)) - - @JsonProperty("tool_choice") - @ExcludeMissing - fun toolChoice(toolChoice: JsonField) = apply { - this.toolChoice = toolChoice - } - - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun n(n: Double) = n(JsonField.of(n)) - - @JsonProperty("n") - @ExcludeMissing - fun n(n: JsonField) = apply { this.n = n } - - fun stop(stop: List) = stop(JsonField.of(stop)) - - @JsonProperty("stop") - @ExcludeMissing - fun stop(stop: JsonField>) = apply { this.stop = stop } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember0 = - UnionMember0( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = FunctionCall.Deserializer::class) - @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val name: Name? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun name(): Optional = Optional.ofNullable(name) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isName(): Boolean = name != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asName(): Name = name.getOrThrow("name") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - name != null -> visitor.visitName(name) - else -> visitor.unknown(_json) - } - } - - fun validate(): FunctionCall = apply { - if (!validated) { - if (unionMember0 == null && unionMember1 == null && name == null) { - throw BraintrustInvalidDataException( - "Unknown FunctionCall: $_json" - ) - } - name?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCall && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.name == other.name - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - name, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" - unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" - name != null -> "FunctionCall{name=$name}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - FunctionCall(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - FunctionCall(unionMember1 = unionMember1) - - @JvmStatic fun ofName(name: Name) = FunctionCall(name = name) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitName(name: Name): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") - } - } - - class Deserializer : BaseDeserializer(FunctionCall::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionCall(name = it, _json = json) - } - - return FunctionCall(_json = json) - } - } - - class Serializer : BaseSerializer(FunctionCall::class) { - - override fun serialize( - value: FunctionCall, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.name != null -> generator.writeObject(value.name) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } - } - } - - class UnionMember0 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = UnionMember0(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 BraintrustInvalidDataException( - "Unknown UnionMember0: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - class UnionMember1 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = UnionMember1(JsonField.of("none")) - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> - throw BraintrustInvalidDataException( - "Unknown UnionMember1: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = Name.Builder::class) - @NoAutoDetect - class Name - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Name = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Name && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Name{name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - additionalProperties(name.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Name = - Name(name, additionalProperties.toUnmodifiable()) - } - } - } - - @JsonDeserialize(builder = ResponseFormat.Builder::class) - @NoAutoDetect - class ResponseFormat - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ResponseFormat = apply { - if (!validated) { - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = - "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(responseFormat: ResponseFormat) = apply { - this.type = responseFormat.type - additionalProperties(responseFormat.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): ResponseFormat = - ResponseFormat(type, additionalProperties.toUnmodifiable()) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val JSON_OBJECT = Type(JsonField.of("json_object")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - JSON_OBJECT, - } - - enum class Value { - JSON_OBJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(using = ToolChoice.Deserializer::class) - @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = - Optional.ofNullable(unionMember2) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } - } - - fun validate(): ToolChoice = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null - ) { - throw BraintrustInvalidDataException( - "Unknown ToolChoice: $_json" - ) - } - unionMember2?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ToolChoice && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" - unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" - unionMember2 != null -> "ToolChoice{unionMember2=$unionMember2}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - ToolChoice(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - ToolChoice(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - ToolChoice(unionMember2 = unionMember2) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") - } - } - - class Deserializer : BaseDeserializer(ToolChoice::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ToolChoice(unionMember2 = it, _json = json) - } - - return ToolChoice(_json = json) - } - } - - class Serializer : BaseSerializer(ToolChoice::class) { - - override fun serialize( - value: ToolChoice, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.unionMember2 != null -> - generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - } - - class UnionMember0 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = UnionMember0(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 BraintrustInvalidDataException( - "Unknown UnionMember0: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - class UnionMember1 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = UnionMember1(JsonField.of("none")) - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> - throw BraintrustInvalidDataException( - "Unknown UnionMember1: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val type: JsonField, - private val function: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun function(): Function = function.getRequired("function") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("function") @ExcludeMissing fun _function() = function - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - type() - function().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{type=$type, function=$function, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.function = unionMember2.function - additionalProperties(unionMember2.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun function(function: Function) = function(JsonField.of(function)) - - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { - this.function = function - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - type, - function, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Function = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.name = function.name - additionalProperties(function.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Function = - Function(name, additionalProperties.toUnmodifiable()) - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun maxTokens(): Double = maxTokens.getRequired("max_tokens") - - fun temperature(): Double = temperature.getRequired("temperature") - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - - fun stopSequences(): Optional> = - Optional.ofNullable(stopSequences.getNullable("stop_sequences")) - - /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = - Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - - @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK - - @JsonProperty("stop_sequences") - @ExcludeMissing - fun _stopSequences() = stopSequences - - /** This is a legacy parameter that should not be used. */ - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - fun _maxTokensToSample() = maxTokensToSample - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var stopSequences: JsonField> = JsonMissing.of() - private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.useCache = unionMember1.useCache - this.maxTokens = unionMember1.maxTokens - this.temperature = unionMember1.temperature - this.topP = unionMember1.topP - this.topK = unionMember1.topK - this.stopSequences = unionMember1.stopSequences - this.maxTokensToSample = unionMember1.maxTokensToSample - additionalProperties(unionMember1.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - - @JsonProperty("max_tokens") - @ExcludeMissing - fun maxTokens(maxTokens: JsonField) = apply { - this.maxTokens = maxTokens - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun topK(topK: Double) = topK(JsonField.of(topK)) - - @JsonProperty("top_k") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } - - fun stopSequences(stopSequences: List) = - stopSequences(JsonField.of(stopSequences)) - - @JsonProperty("stop_sequences") - @ExcludeMissing - fun stopSequences(stopSequences: JsonField>) = apply { - this.stopSequences = stopSequences - } - - /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = - maxTokensToSample(JsonField.of(maxTokensToSample)) - - /** This is a legacy parameter that should not be used. */ - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - fun maxTokensToSample(maxTokensToSample: JsonField) = apply { - this.maxTokensToSample = maxTokensToSample - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember1 = - UnionMember1( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Double = temperature.getRequired("temperature") - - fun maxOutputTokens(): Optional = - Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("maxOutputTokens") - @ExcludeMissing - fun _maxOutputTokens() = maxOutputTokens - - @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - - @JsonProperty("topK") @ExcludeMissing fun _topK() = topK - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var maxOutputTokens: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.useCache = unionMember2.useCache - this.temperature = unionMember2.temperature - this.maxOutputTokens = unionMember2.maxOutputTokens - this.topP = unionMember2.topP - this.topK = unionMember2.topK - additionalProperties(unionMember2.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun maxOutputTokens(maxOutputTokens: Double) = - maxOutputTokens(JsonField.of(maxOutputTokens)) - - @JsonProperty("maxOutputTokens") - @ExcludeMissing - fun maxOutputTokens(maxOutputTokens: JsonField) = apply { - this.maxOutputTokens = maxOutputTokens - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("topP") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun topK(topK: Double) = topK(JsonField.of(topK)) - - @JsonProperty("topK") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = UseCache.Builder::class) - @NoAutoDetect - class UseCache - private constructor( - private val useCache: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UseCache = apply { - if (!validated) { - useCache() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UseCache && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode - } - - override fun toString() = - "UseCache{useCache=$useCache, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(useCache: UseCache) = apply { - this.useCache = useCache.useCache - additionalProperties(useCache.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UseCache = - UseCache(useCache, additionalProperties.toUnmodifiable()) - } - } - } - } - - @JsonDeserialize(builder = Origin.Builder::class) - @NoAutoDetect - class Origin - private constructor( - private val promptId: JsonField, - private val projectId: JsonField, - private val promptVersion: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun promptId(): Optional = - Optional.ofNullable(promptId.getNullable("prompt_id")) - - fun projectId(): Optional = - Optional.ofNullable(projectId.getNullable("project_id")) - - fun promptVersion(): Optional = - Optional.ofNullable(promptVersion.getNullable("prompt_version")) - - @JsonProperty("prompt_id") @ExcludeMissing fun _promptId() = promptId - - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - @JsonProperty("prompt_version") @ExcludeMissing fun _promptVersion() = promptVersion - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Origin = apply { - if (!validated) { - promptId() - projectId() - promptVersion() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var promptId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var promptVersion: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(origin: Origin) = apply { - this.promptId = origin.promptId - this.projectId = origin.projectId - this.promptVersion = origin.promptVersion - additionalProperties(origin.additionalProperties) - } - - fun promptId(promptId: String) = promptId(JsonField.of(promptId)) - - @JsonProperty("prompt_id") - @ExcludeMissing - fun promptId(promptId: JsonField) = apply { this.promptId = promptId } - - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - fun promptVersion(promptVersion: String) = - promptVersion(JsonField.of(promptVersion)) - - @JsonProperty("prompt_version") - @ExcludeMissing - fun promptVersion(promptVersion: JsonField) = apply { - this.promptVersion = promptVersion - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Origin = - Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(using = Prompt.Deserializer::class) - @JsonSerialize(using = Prompt.Serializer::class) - class Prompt - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val _reservedOnlyAllowNull: _ReservedOnlyAllowNull? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun _reservedOnlyAllowNull(): Optional<_ReservedOnlyAllowNull> = - Optional.ofNullable(_reservedOnlyAllowNull) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun is_ReservedOnlyAllowNull(): Boolean = _reservedOnlyAllowNull != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun as_ReservedOnlyAllowNull(): _ReservedOnlyAllowNull = - _reservedOnlyAllowNull.getOrThrow("_reservedOnlyAllowNull") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - _reservedOnlyAllowNull != null -> - visitor.visit_ReservedOnlyAllowNull(_reservedOnlyAllowNull) - else -> visitor.unknown(_json) - } - } - - fun validate(): Prompt = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - _reservedOnlyAllowNull == null - ) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - _reservedOnlyAllowNull?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this._reservedOnlyAllowNull == other._reservedOnlyAllowNull - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - _reservedOnlyAllowNull, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Prompt{unionMember0=$unionMember0}" - unionMember1 != null -> "Prompt{unionMember1=$unionMember1}" - _reservedOnlyAllowNull != null -> - "Prompt{_reservedOnlyAllowNull=$_reservedOnlyAllowNull}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Prompt(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Prompt(unionMember1 = unionMember1) - - @JvmStatic - fun of_ReservedOnlyAllowNull(_reservedOnlyAllowNull: _ReservedOnlyAllowNull) = - Prompt(_reservedOnlyAllowNull = _reservedOnlyAllowNull) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visit_ReservedOnlyAllowNull(_reservedOnlyAllowNull: _ReservedOnlyAllowNull): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") - } - } - - class Deserializer : BaseDeserializer(Prompt::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef<_ReservedOnlyAllowNull>()) { it.validate() } - ?.let { - return Prompt(_reservedOnlyAllowNull = it, _json = json) - } - - return Prompt(_json = json) - } - } - - class Serializer : BaseSerializer(Prompt::class) { - - override fun serialize( - value: Prompt, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value._reservedOnlyAllowNull != null -> - generator.writeObject(value._reservedOnlyAllowNull) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val type: JsonField, - private val content: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun content(): String = content.getRequired("content") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - type() - content() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{type=$type, content=$content, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.type = unionMember0.type - this.content = unionMember0.content - additionalProperties(unionMember0.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = - UnionMember0( - type, - content, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val COMPLETION = Type(JsonField.of("completion")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - COMPLETION, - } - - enum class Value { - COMPLETION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun messages(): List = messages.getRequired("messages") - - fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("messages") @ExcludeMissing fun _messages() = messages - - @JsonProperty("tools") @ExcludeMissing fun _tools() = tools - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - type() - messages() - tools() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var messages: JsonField> = JsonMissing.of() - private var tools: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.messages = unionMember1.messages - this.tools = unionMember1.tools - additionalProperties(unionMember1.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun messages(messages: List) = messages(JsonField.of(messages)) - - @JsonProperty("messages") - @ExcludeMissing - fun messages(messages: JsonField>) = apply { - this.messages = messages - } - - fun tools(tools: String) = tools(JsonField.of(tools)) - - @JsonProperty("tools") - @ExcludeMissing - fun tools(tools: JsonField) = apply { this.tools = tools } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = - UnionMember1( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Message.Deserializer::class) - @JsonSerialize(using = Message.Serializer::class) - class Message - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUnionMember3(): Boolean = unionMember3 != null - - fun isUnionMember4(): Boolean = unionMember4 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - else -> visitor.unknown(_json) - } - } - - fun validate(): Message = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null && - unionMember3 == null && - unionMember4 == null - ) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - unionMember4?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.unionMember4 == other.unionMember4 - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Message{unionMember0=$unionMember0}" - unionMember1 != null -> "Message{unionMember1=$unionMember1}" - unionMember2 != null -> "Message{unionMember2=$unionMember2}" - unionMember3 != null -> "Message{unionMember3=$unionMember3}" - unionMember4 != null -> "Message{unionMember4=$unionMember4}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - Message(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - Message(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - Message(unionMember2 = unionMember2) - - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = - Message(unionMember3 = unionMember3) - - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = - Message(unionMember4 = unionMember4) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUnionMember3(unionMember3: UnionMember3): T - - fun visitUnionMember4(unionMember4: UnionMember4): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") - } - } - - class Deserializer : BaseDeserializer(Message::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember4 = it, _json = json) - } - - return Message(_json = json) - } - } - - class Serializer : BaseSerializer(Message::class) { - - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.unionMember2 != null -> - generator.writeObject(value.unionMember2) - value.unionMember3 != null -> - generator.writeObject(value.unionMember3) - value.unionMember4 != null -> - generator.writeObject(value.unionMember4) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.content = unionMember0.content - this.role = unionMember0.role - this.name = unionMember0.name - additionalProperties(unionMember0.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember0 = - UnionMember0( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SYSTEM = Role(JsonField.of("system")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - SYSTEM, - } - - enum class Value { - SYSTEM, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SYSTEM -> Known.SYSTEM - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.content = unionMember1.content - this.role = unionMember1.role - this.name = unionMember1.name - additionalProperties(unionMember1.additionalProperties) - } - - fun content(content: Content) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember1 = - UnionMember1( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val USER = Role(JsonField.of("user")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - USER, - } - - enum class Value { - USER, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - USER -> Known.USER - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(using = Content.Deserializer::class) - @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( - private val string: String? = null, - private val unnamedSchemaWithArrayParent6s: - List? = - null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun unnamedSchemaWithArrayParent6s(): - Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent6s) - - fun isString(): Boolean = string != null - - fun isUnnamedSchemaWithArrayParent6s(): Boolean = - unnamedSchemaWithArrayParent6s != null - - fun asString(): String = string.getOrThrow("string") - - fun asUnnamedSchemaWithArrayParent6s(): - List = - unnamedSchemaWithArrayParent6s.getOrThrow( - "unnamedSchemaWithArrayParent6s" - ) - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent6s != null -> - visitor.visitUnnamedSchemaWithArrayParent6s( - unnamedSchemaWithArrayParent6s - ) - else -> visitor.unknown(_json) - } - } - - fun validate(): Content = apply { - if (!validated) { - if (string == null && unnamedSchemaWithArrayParent6s == null) { - throw BraintrustInvalidDataException( - "Unknown Content: $_json" - ) - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent6s == - other.unnamedSchemaWithArrayParent6s - } - - override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent6s) - } - - override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent6s != null -> - "Content{unnamedSchemaWithArrayParent6s=$unnamedSchemaWithArrayParent6s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Content(string = string) - - @JvmStatic - fun ofUnnamedSchemaWithArrayParent6s( - unnamedSchemaWithArrayParent6s: - List - ) = - Content( - unnamedSchemaWithArrayParent6s = - unnamedSchemaWithArrayParent6s - ) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitUnnamedSchemaWithArrayParent6s( - unnamedSchemaWithArrayParent6s: - List - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") - } - } - - class Deserializer : BaseDeserializer(Content::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize( - node, - jacksonTypeRef>() - ) - ?.let { - return Content( - unnamedSchemaWithArrayParent6s = it, - _json = json - ) - } - - return Content(_json = json) - } - } - - class Serializer : BaseSerializer(Content::class) { - - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent6s != null -> - generator.writeObject( - value.unnamedSchemaWithArrayParent6s - ) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } - } - } - - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent6.Deserializer::class - ) - @JsonSerialize(using = UnnamedSchemaWithArrayParent6.Serializer::class) - class UnnamedSchemaWithArrayParent6 - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun asUnionMember0(): UnionMember0 = - unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = - unionMember1.getOrThrow("unionMember1") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> - visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> - visitor.visitUnionMember1(unionMember1) - else -> visitor.unknown(_json) - } - } - - fun validate(): UnnamedSchemaWithArrayParent6 = apply { - if (!validated) { - if (unionMember0 == null && unionMember1 == null) { - throw BraintrustInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent6: $_json" - ) - } - unionMember0?.validate() - unionMember1?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent6 && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 - } - - override fun hashCode(): Int { - return Objects.hash(unionMember0, unionMember1) - } - - override fun toString(): String { - return when { - unionMember0 != null -> - "UnnamedSchemaWithArrayParent6{unionMember0=$unionMember0}" - unionMember1 != null -> - "UnnamedSchemaWithArrayParent6{unionMember1=$unionMember1}" - _json != null -> - "UnnamedSchemaWithArrayParent6{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent6" - ) - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - UnnamedSchemaWithArrayParent6(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - UnnamedSchemaWithArrayParent6(unionMember1 = unionMember1) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent6: $json" - ) - } - } - - class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent6::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent6 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return UnnamedSchemaWithArrayParent6( - unionMember0 = it, - _json = json - ) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return UnnamedSchemaWithArrayParent6( - unionMember1 = it, - _json = json - ) - } - - return UnnamedSchemaWithArrayParent6(_json = json) - } - } - - class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent6::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent6, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent6" - ) - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val text: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun text(): Optional = - Optional.ofNullable(text.getNullable("text")) - - fun type(): Type = type.getRequired("type") - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - text() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{text=$text, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var text: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.text = unionMember0.text - this.type = unionMember0.type - additionalProperties(unionMember0.additionalProperties) - } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { - this.text = text - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = - UnionMember0( - text, - type, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TEXT = Type(JsonField.of("text")) - - @JvmStatic - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - TEXT, - } - - enum class Value { - TEXT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TEXT -> Known.TEXT - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val imageUrl: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") - - fun type(): Type = type.getRequired("type") - - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl() = imageUrl - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - imageUrl().validate() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var imageUrl: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.imageUrl = unionMember1.imageUrl - this.type = unionMember1.type - additionalProperties(unionMember1.additionalProperties) - } - - fun imageUrl(imageUrl: ImageUrl) = - imageUrl(JsonField.of(imageUrl)) - - @JsonProperty("image_url") - @ExcludeMissing - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = - UnionMember1( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = ImageUrl.Builder::class) - @NoAutoDetect - class ImageUrl - private constructor( - private val url: JsonField, - private val detail: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun url(): String = url.getRequired("url") - - fun detail(): Optional = - Optional.ofNullable(detail.getNullable("detail")) - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonProperty("detail") - @ExcludeMissing - fun _detail() = detail - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): ImageUrl = apply { - if (!validated) { - url() - detail() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == - other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var url: JsonField = JsonMissing.of() - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(imageUrl: ImageUrl) = apply { - this.url = imageUrl.url - this.detail = imageUrl.detail - additionalProperties(imageUrl.additionalProperties) - } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { - this.url = url - } - - fun detail(detail: Detail) = - detail(JsonField.of(detail)) - - @JsonProperty("detail") - @ExcludeMissing - fun detail(detail: JsonField) = apply { - this.detail = detail - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll( - additionalProperties - ) - } - - @JsonAnySetter - fun putAdditionalProperty( - key: String, - value: JsonValue - ) = apply { this.additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun build(): ImageUrl = - ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) - } - - class Detail - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Detail && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = Detail(JsonField.of("auto")) - - @JvmField val LOW = Detail(JsonField.of("low")) - - @JvmField val HIGH = Detail(JsonField.of("high")) - - @JvmStatic - fun of(value: String) = Detail(JsonField.of(value)) - } - - enum class Known { - AUTO, - LOW, - HIGH, - } - - enum class Value { - AUTO, - LOW, - HIGH, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> - throw BraintrustInvalidDataException( - "Unknown Detail: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField - val IMAGE_URL = Type(JsonField.of("image_url")) - - @JvmStatic - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - IMAGE_URL, - } - - enum class Value { - IMAGE_URL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - } - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun role(): Role = role.getRequired("role") - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun toolCalls(): Optional> = - Optional.ofNullable(toolCalls.getNullable("tool_calls")) - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("function_call") - @ExcludeMissing - fun _functionCall() = functionCall - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var role: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.role = unionMember2.role - this.content = unionMember2.content - this.functionCall = unionMember2.functionCall - this.name = unionMember2.name - this.toolCalls = unionMember2.toolCalls - additionalProperties(unionMember2.additionalProperties) - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun toolCalls(toolCalls: List) = - toolCalls(JsonField.of(toolCalls)) - - @JsonProperty("tool_calls") - @ExcludeMissing - fun toolCalls(toolCalls: JsonField>) = apply { - this.toolCalls = toolCalls - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val ASSISTANT = Role(JsonField.of("assistant")) - - @JvmStatic fun of(value: String) = Role(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 BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = FunctionCall.Builder::class) - @NoAutoDetect - class FunctionCall - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun arguments(): String = arguments.getRequired("arguments") - - fun name(): String = name.getRequired("name") - - @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): FunctionCall = apply { - if (!validated) { - arguments() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(functionCall: FunctionCall) = apply { - this.arguments = functionCall.arguments - this.name = functionCall.name - additionalProperties(functionCall.additionalProperties) - } - - fun arguments(arguments: String) = - arguments(JsonField.of(arguments)) - - @JsonProperty("arguments") - @ExcludeMissing - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): FunctionCall = - FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = ToolCall.Builder::class) - @NoAutoDetect - class ToolCall - private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun id(): String = id.getRequired("id") - - fun function(): Function = function.getRequired("function") - - fun type(): Type = type.getRequired("type") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("function") @ExcludeMissing fun _function() = function - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): ToolCall = apply { - if (!validated) { - id() - function().validate() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(toolCall: ToolCall) = apply { - this.id = toolCall.id - this.function = toolCall.function - this.type = toolCall.type - additionalProperties(toolCall.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun function(function: Function) = function(JsonField.of(function)) - - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { - this.function = function - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): ToolCall = - ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun arguments(): String = arguments.getRequired("arguments") - - fun name(): String = name.getRequired("name") - - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments() = arguments - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Function = apply { - if (!validated) { - arguments() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.arguments = function.arguments - this.name = function.name - additionalProperties(function.additionalProperties) - } - - fun arguments(arguments: String) = - arguments(JsonField.of(arguments)) - - @JsonProperty("arguments") - @ExcludeMissing - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Function = - Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - @JsonDeserialize(builder = UnionMember3.Builder::class) - @NoAutoDetect - class UnionMember3 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun toolCallId(): String = toolCallId.getRequired("tool_call_id") - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember3 = apply { - if (!validated) { - content() - role() - toolCallId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember3{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.content = unionMember3.content - this.role = unionMember3.role - this.toolCallId = unionMember3.toolCallId - additionalProperties(unionMember3.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun toolCallId(toolCallId: String) = - toolCallId(JsonField.of(toolCallId)) - - @JsonProperty("tool_call_id") - @ExcludeMissing - fun toolCallId(toolCallId: JsonField) = apply { - this.toolCallId = toolCallId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember3 = - UnionMember3( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TOOL = Role(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - TOOL, - } - - enum class Value { - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TOOL -> Known.TOOL - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember4.Builder::class) - @NoAutoDetect - class UnionMember4 - private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun name(): String = name.getRequired("name") - - fun role(): Role = role.getRequired("role") - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember4 = apply { - if (!validated) { - content() - name() - role() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember4 && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember4{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - this.content = unionMember4.content - this.name = unionMember4.name - this.role = unionMember4.role - additionalProperties(unionMember4.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember4 = - UnionMember4( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Role(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val CHAT = Type(JsonField.of("chat")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - CHAT, - } - - enum class Value { - CHAT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = _ReservedOnlyAllowNull.Builder::class) - @NoAutoDetect - class _ReservedOnlyAllowNull - private constructor( - private val _reservedOnlyAllowNull: JsonValue, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * This is just a placeholder nullable object. Only pass null, not the object itself - */ - @JsonProperty("__reserved_only_allow_null") - @ExcludeMissing - fun __reservedOnlyAllowNull() = _reservedOnlyAllowNull - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): _ReservedOnlyAllowNull = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is _ReservedOnlyAllowNull && - this._reservedOnlyAllowNull == other._reservedOnlyAllowNull && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(_reservedOnlyAllowNull, additionalProperties) - } - return hashCode - } - - override fun toString() = - "_ReservedOnlyAllowNull{_reservedOnlyAllowNull=$_reservedOnlyAllowNull, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var _reservedOnlyAllowNull: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(_reservedOnlyAllowNull: _ReservedOnlyAllowNull) = apply { - this._reservedOnlyAllowNull = _reservedOnlyAllowNull._reservedOnlyAllowNull - additionalProperties(_reservedOnlyAllowNull.additionalProperties) - } - - /** - * This is just a placeholder nullable object. Only pass null, not the object - * itself - */ - @JsonProperty("__reserved_only_allow_null") - @ExcludeMissing - fun _reservedOnlyAllowNull(_reservedOnlyAllowNull: JsonValue) = apply { - this._reservedOnlyAllowNull = _reservedOnlyAllowNull - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): _ReservedOnlyAllowNull = - _ReservedOnlyAllowNull( - _reservedOnlyAllowNull, - additionalProperties.toUnmodifiable() - ) - } - } - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptReplaceResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptReplaceResponse.kt deleted file mode 100644 index fc2ca15..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptReplaceResponse.kt +++ /dev/null @@ -1,6057 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrust.api.models - -import com.braintrust.api.core.BaseDeserializer -import com.braintrust.api.core.BaseSerializer -import com.braintrust.api.core.Enum -import com.braintrust.api.core.ExcludeMissing -import com.braintrust.api.core.JsonField -import com.braintrust.api.core.JsonMissing -import com.braintrust.api.core.JsonValue -import com.braintrust.api.core.NoAutoDetect -import com.braintrust.api.core.getOrThrow -import com.braintrust.api.core.toUnmodifiable -import com.braintrust.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = PromptReplaceResponse.Builder::class) -@NoAutoDetect -class PromptReplaceResponse -private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val description: JsonField, - private val created: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val metadata: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Unique identifier for the prompt */ - fun id(): String = id.getRequired("id") - - /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) - */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - - /** A literal 'p' which identifies the object as a project prompt */ - fun logId(): LogId = logId.getRequired("log_id") - - /** Unique identifier for the organization */ - fun orgId(): String = orgId.getRequired("org_id") - - /** Name of the prompt */ - fun name(): String = name.getRequired("name") - - /** Unique identifier for the prompt */ - fun slug(): String = slug.getRequired("slug") - - /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** Date of prompt creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - - /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) - - /** A list of tags for the prompt */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** User-controlled metadata about the prompt */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) - */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId - - /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId - - /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** Date of prompt creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData - - /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PromptReplaceResponse = apply { - if (!validated) { - id() - _xactId() - projectId() - logId() - orgId() - name() - slug() - description() - created() - promptData().map { it.validate() } - tags() - metadata().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptReplaceResponse && - this.id == other.id && - this._xactId == other._xactId && - this.projectId == other.projectId && - this.logId == other.logId && - this.orgId == other.orgId && - this.name == other.name && - this.slug == other.slug && - this.description == other.description && - this.created == other.created && - this.promptData == other.promptData && - this.tags == other.tags && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags, - metadata, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptReplaceResponse{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var logId: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var promptData: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptReplaceResponse: PromptReplaceResponse) = apply { - this.id = promptReplaceResponse.id - this._xactId = promptReplaceResponse._xactId - this.projectId = promptReplaceResponse.projectId - this.logId = promptReplaceResponse.logId - this.orgId = promptReplaceResponse.orgId - this.name = promptReplaceResponse.name - this.slug = promptReplaceResponse.slug - this.description = promptReplaceResponse.description - this.created = promptReplaceResponse.created - this.promptData = promptReplaceResponse.promptData - this.tags = promptReplaceResponse.tags - this.metadata = promptReplaceResponse.metadata - additionalProperties(promptReplaceResponse.additionalProperties) - } - - /** Unique identifier for the prompt */ - fun id(id: String) = id(JsonField.of(id)) - - /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) - */ - fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) - */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** A literal 'p' which identifies the object as a project prompt */ - fun logId(logId: LogId) = logId(JsonField.of(logId)) - - /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") - @ExcludeMissing - fun logId(logId: JsonField) = apply { this.logId = logId } - - /** Unique identifier for the organization */ - fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - - /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - - /** Name of the prompt */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Unique identifier for the prompt */ - fun slug(slug: String) = slug(JsonField.of(slug)) - - /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - /** Textual description of the prompt */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** Date of prompt creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** Date of prompt creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - @ExcludeMissing - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } - - /** A list of tags for the prompt */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** User-controlled metadata about the prompt */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PromptReplaceResponse = - PromptReplaceResponse( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags.map { it.toUnmodifiable() }, - metadata, - additionalProperties.toUnmodifiable(), - ) - } - - class LogId - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LogId && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val P = LogId(JsonField.of("p")) - - @JvmStatic fun of(value: String) = LogId(JsonField.of(value)) - } - - enum class Known { - P, - } - - enum class Value { - P, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - P -> Value.P - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - P -> Known.P - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - /** User-controlled metadata about the prompt */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** The prompt, model, and its parameters */ - @JsonDeserialize(builder = PromptData.Builder::class) - @NoAutoDetect - class PromptData - private constructor( - private val prompt: JsonField, - private val options: JsonField, - private val origin: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) - - fun options(): Optional = Optional.ofNullable(options.getNullable("options")) - - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) - - @JsonProperty("prompt") @ExcludeMissing fun _prompt() = prompt - - @JsonProperty("options") @ExcludeMissing fun _options() = options - - @JsonProperty("origin") @ExcludeMissing fun _origin() = origin - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PromptData = apply { - if (!validated) { - prompt() - options().map { it.validate() } - origin().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - prompt, - options, - origin, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var prompt: JsonField = JsonMissing.of() - private var options: JsonField = JsonMissing.of() - private var origin: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptData: PromptData) = apply { - this.prompt = promptData.prompt - this.options = promptData.options - this.origin = promptData.origin - additionalProperties(promptData.additionalProperties) - } - - fun prompt(prompt: Prompt) = prompt(JsonField.of(prompt)) - - @JsonProperty("prompt") - @ExcludeMissing - fun prompt(prompt: JsonField) = apply { this.prompt = prompt } - - fun options(options: Options) = options(JsonField.of(options)) - - @JsonProperty("options") - @ExcludeMissing - fun options(options: JsonField) = apply { this.options = options } - - fun origin(origin: Origin) = origin(JsonField.of(origin)) - - @JsonProperty("origin") - @ExcludeMissing - fun origin(origin: JsonField) = apply { this.origin = origin } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PromptData = - PromptData( - prompt, - options, - origin, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Options.Builder::class) - @NoAutoDetect - class Options - private constructor( - private val model: JsonField, - private val params: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) - - fun params(): Optional = Optional.ofNullable(params.getNullable("params")) - - fun position(): Optional = Optional.ofNullable(position.getNullable("position")) - - @JsonProperty("model") @ExcludeMissing fun _model() = model - - @JsonProperty("params") @ExcludeMissing fun _params() = params - - @JsonProperty("position") @ExcludeMissing fun _position() = position - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Options = apply { - if (!validated) { - model() - params() - position() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var model: JsonField = JsonMissing.of() - private var params: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - this.model = options.model - this.params = options.params - this.position = options.position - additionalProperties(options.additionalProperties) - } - - fun model(model: String) = model(JsonField.of(model)) - - @JsonProperty("model") - @ExcludeMissing - fun model(model: JsonField) = apply { this.model = model } - - fun params(params: Params) = params(JsonField.of(params)) - - @JsonProperty("params") - @ExcludeMissing - fun params(params: JsonField) = apply { this.params = params } - - fun position(position: String) = position(JsonField.of(position)) - - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Options = - Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Params.Deserializer::class) - @JsonSerialize(using = Params.Serializer::class) - class Params - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val useCache: UseCache? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun useCache(): Optional = Optional.ofNullable(useCache) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUseCache(): Boolean = useCache != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUseCache(): UseCache = useCache.getOrThrow("useCache") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - useCache != null -> visitor.visitUseCache(useCache) - else -> visitor.unknown(_json) - } - } - - fun validate(): Params = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null && - useCache == null - ) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - useCache?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.useCache == other.useCache - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - useCache, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Params{unionMember0=$unionMember0}" - unionMember1 != null -> "Params{unionMember1=$unionMember1}" - unionMember2 != null -> "Params{unionMember2=$unionMember2}" - useCache != null -> "Params{useCache=$useCache}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - Params(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - Params(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - Params(unionMember2 = unionMember2) - - @JvmStatic fun ofUseCache(useCache: UseCache) = Params(useCache = useCache) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUseCache(useCache: UseCache): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") - } - } - - class Deserializer : BaseDeserializer(Params::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(useCache = it, _json = json) - } - - return Params(_json = json) - } - } - - class Serializer : BaseSerializer(Params::class) { - - override fun serialize( - value: Params, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.useCache != null -> generator.writeObject(value.useCache) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - - fun maxTokens(): Optional = - Optional.ofNullable(maxTokens.getNullable("max_tokens")) - - fun frequencyPenalty(): Optional = - Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - - fun presencePenalty(): Optional = - Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - - fun responseFormat(): Optional = - Optional.ofNullable(responseFormat.getNullable("response_format")) - - fun toolChoice(): Optional = - Optional.ofNullable(toolChoice.getNullable("tool_choice")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - - fun stop(): Optional> = - Optional.ofNullable(stop.getNullable("stop")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - - @JsonProperty("frequency_penalty") - @ExcludeMissing - fun _frequencyPenalty() = frequencyPenalty - - @JsonProperty("presence_penalty") - @ExcludeMissing - fun _presencePenalty() = presencePenalty - - @JsonProperty("response_format") - @ExcludeMissing - fun _responseFormat() = responseFormat - - @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice - - @JsonProperty("function_call") - @ExcludeMissing - fun _functionCall() = functionCall - - @JsonProperty("n") @ExcludeMissing fun _n() = n - - @JsonProperty("stop") @ExcludeMissing fun _stop() = stop - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat().map { it.validate() } - toolChoice() - functionCall() - n() - stop() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() - private var frequencyPenalty: JsonField = JsonMissing.of() - private var presencePenalty: JsonField = JsonMissing.of() - private var responseFormat: JsonField = JsonMissing.of() - private var toolChoice: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var n: JsonField = JsonMissing.of() - private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.useCache = unionMember0.useCache - this.temperature = unionMember0.temperature - this.topP = unionMember0.topP - this.maxTokens = unionMember0.maxTokens - this.frequencyPenalty = unionMember0.frequencyPenalty - this.presencePenalty = unionMember0.presencePenalty - this.responseFormat = unionMember0.responseFormat - this.toolChoice = unionMember0.toolChoice - this.functionCall = unionMember0.functionCall - this.n = unionMember0.n - this.stop = unionMember0.stop - additionalProperties(unionMember0.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - - @JsonProperty("max_tokens") - @ExcludeMissing - fun maxTokens(maxTokens: JsonField) = apply { - this.maxTokens = maxTokens - } - - fun frequencyPenalty(frequencyPenalty: Double) = - frequencyPenalty(JsonField.of(frequencyPenalty)) - - @JsonProperty("frequency_penalty") - @ExcludeMissing - fun frequencyPenalty(frequencyPenalty: JsonField) = apply { - this.frequencyPenalty = frequencyPenalty - } - - fun presencePenalty(presencePenalty: Double) = - presencePenalty(JsonField.of(presencePenalty)) - - @JsonProperty("presence_penalty") - @ExcludeMissing - fun presencePenalty(presencePenalty: JsonField) = apply { - this.presencePenalty = presencePenalty - } - - fun responseFormat(responseFormat: ResponseFormat) = - responseFormat(JsonField.of(responseFormat)) - - @JsonProperty("response_format") - @ExcludeMissing - fun responseFormat(responseFormat: JsonField) = apply { - this.responseFormat = responseFormat - } - - fun toolChoice(toolChoice: ToolChoice) = - toolChoice(JsonField.of(toolChoice)) - - @JsonProperty("tool_choice") - @ExcludeMissing - fun toolChoice(toolChoice: JsonField) = apply { - this.toolChoice = toolChoice - } - - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun n(n: Double) = n(JsonField.of(n)) - - @JsonProperty("n") - @ExcludeMissing - fun n(n: JsonField) = apply { this.n = n } - - fun stop(stop: List) = stop(JsonField.of(stop)) - - @JsonProperty("stop") - @ExcludeMissing - fun stop(stop: JsonField>) = apply { this.stop = stop } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember0 = - UnionMember0( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = FunctionCall.Deserializer::class) - @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val name: Name? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun name(): Optional = Optional.ofNullable(name) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isName(): Boolean = name != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asName(): Name = name.getOrThrow("name") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - name != null -> visitor.visitName(name) - else -> visitor.unknown(_json) - } - } - - fun validate(): FunctionCall = apply { - if (!validated) { - if (unionMember0 == null && unionMember1 == null && name == null) { - throw BraintrustInvalidDataException( - "Unknown FunctionCall: $_json" - ) - } - name?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCall && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.name == other.name - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - name, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" - unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" - name != null -> "FunctionCall{name=$name}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - FunctionCall(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - FunctionCall(unionMember1 = unionMember1) - - @JvmStatic fun ofName(name: Name) = FunctionCall(name = name) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitName(name: Name): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") - } - } - - class Deserializer : BaseDeserializer(FunctionCall::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionCall(name = it, _json = json) - } - - return FunctionCall(_json = json) - } - } - - class Serializer : BaseSerializer(FunctionCall::class) { - - override fun serialize( - value: FunctionCall, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.name != null -> generator.writeObject(value.name) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } - } - } - - class UnionMember0 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = UnionMember0(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 BraintrustInvalidDataException( - "Unknown UnionMember0: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - class UnionMember1 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = UnionMember1(JsonField.of("none")) - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> - throw BraintrustInvalidDataException( - "Unknown UnionMember1: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = Name.Builder::class) - @NoAutoDetect - class Name - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Name = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Name && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Name{name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - additionalProperties(name.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Name = - Name(name, additionalProperties.toUnmodifiable()) - } - } - } - - @JsonDeserialize(builder = ResponseFormat.Builder::class) - @NoAutoDetect - class ResponseFormat - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ResponseFormat = apply { - if (!validated) { - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = - "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(responseFormat: ResponseFormat) = apply { - this.type = responseFormat.type - additionalProperties(responseFormat.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): ResponseFormat = - ResponseFormat(type, additionalProperties.toUnmodifiable()) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val JSON_OBJECT = Type(JsonField.of("json_object")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - JSON_OBJECT, - } - - enum class Value { - JSON_OBJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(using = ToolChoice.Deserializer::class) - @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = - Optional.ofNullable(unionMember2) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } - } - - fun validate(): ToolChoice = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null - ) { - throw BraintrustInvalidDataException( - "Unknown ToolChoice: $_json" - ) - } - unionMember2?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ToolChoice && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" - unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" - unionMember2 != null -> "ToolChoice{unionMember2=$unionMember2}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - ToolChoice(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - ToolChoice(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - ToolChoice(unionMember2 = unionMember2) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") - } - } - - class Deserializer : BaseDeserializer(ToolChoice::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ToolChoice(unionMember2 = it, _json = json) - } - - return ToolChoice(_json = json) - } - } - - class Serializer : BaseSerializer(ToolChoice::class) { - - override fun serialize( - value: ToolChoice, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.unionMember2 != null -> - generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - } - - class UnionMember0 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = UnionMember0(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 BraintrustInvalidDataException( - "Unknown UnionMember0: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - class UnionMember1 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = UnionMember1(JsonField.of("none")) - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> - throw BraintrustInvalidDataException( - "Unknown UnionMember1: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val type: JsonField, - private val function: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun function(): Function = function.getRequired("function") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("function") @ExcludeMissing fun _function() = function - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - type() - function().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{type=$type, function=$function, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.function = unionMember2.function - additionalProperties(unionMember2.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun function(function: Function) = function(JsonField.of(function)) - - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { - this.function = function - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - type, - function, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Function = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.name = function.name - additionalProperties(function.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Function = - Function(name, additionalProperties.toUnmodifiable()) - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun maxTokens(): Double = maxTokens.getRequired("max_tokens") - - fun temperature(): Double = temperature.getRequired("temperature") - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - - fun stopSequences(): Optional> = - Optional.ofNullable(stopSequences.getNullable("stop_sequences")) - - /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = - Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - - @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK - - @JsonProperty("stop_sequences") - @ExcludeMissing - fun _stopSequences() = stopSequences - - /** This is a legacy parameter that should not be used. */ - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - fun _maxTokensToSample() = maxTokensToSample - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var stopSequences: JsonField> = JsonMissing.of() - private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.useCache = unionMember1.useCache - this.maxTokens = unionMember1.maxTokens - this.temperature = unionMember1.temperature - this.topP = unionMember1.topP - this.topK = unionMember1.topK - this.stopSequences = unionMember1.stopSequences - this.maxTokensToSample = unionMember1.maxTokensToSample - additionalProperties(unionMember1.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - - @JsonProperty("max_tokens") - @ExcludeMissing - fun maxTokens(maxTokens: JsonField) = apply { - this.maxTokens = maxTokens - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun topK(topK: Double) = topK(JsonField.of(topK)) - - @JsonProperty("top_k") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } - - fun stopSequences(stopSequences: List) = - stopSequences(JsonField.of(stopSequences)) - - @JsonProperty("stop_sequences") - @ExcludeMissing - fun stopSequences(stopSequences: JsonField>) = apply { - this.stopSequences = stopSequences - } - - /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = - maxTokensToSample(JsonField.of(maxTokensToSample)) - - /** This is a legacy parameter that should not be used. */ - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - fun maxTokensToSample(maxTokensToSample: JsonField) = apply { - this.maxTokensToSample = maxTokensToSample - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember1 = - UnionMember1( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Double = temperature.getRequired("temperature") - - fun maxOutputTokens(): Optional = - Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("maxOutputTokens") - @ExcludeMissing - fun _maxOutputTokens() = maxOutputTokens - - @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - - @JsonProperty("topK") @ExcludeMissing fun _topK() = topK - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var maxOutputTokens: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.useCache = unionMember2.useCache - this.temperature = unionMember2.temperature - this.maxOutputTokens = unionMember2.maxOutputTokens - this.topP = unionMember2.topP - this.topK = unionMember2.topK - additionalProperties(unionMember2.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun maxOutputTokens(maxOutputTokens: Double) = - maxOutputTokens(JsonField.of(maxOutputTokens)) - - @JsonProperty("maxOutputTokens") - @ExcludeMissing - fun maxOutputTokens(maxOutputTokens: JsonField) = apply { - this.maxOutputTokens = maxOutputTokens - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("topP") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun topK(topK: Double) = topK(JsonField.of(topK)) - - @JsonProperty("topK") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = UseCache.Builder::class) - @NoAutoDetect - class UseCache - private constructor( - private val useCache: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UseCache = apply { - if (!validated) { - useCache() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UseCache && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode - } - - override fun toString() = - "UseCache{useCache=$useCache, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(useCache: UseCache) = apply { - this.useCache = useCache.useCache - additionalProperties(useCache.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UseCache = - UseCache(useCache, additionalProperties.toUnmodifiable()) - } - } - } - } - - @JsonDeserialize(builder = Origin.Builder::class) - @NoAutoDetect - class Origin - private constructor( - private val promptId: JsonField, - private val projectId: JsonField, - private val promptVersion: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun promptId(): Optional = - Optional.ofNullable(promptId.getNullable("prompt_id")) - - fun projectId(): Optional = - Optional.ofNullable(projectId.getNullable("project_id")) - - fun promptVersion(): Optional = - Optional.ofNullable(promptVersion.getNullable("prompt_version")) - - @JsonProperty("prompt_id") @ExcludeMissing fun _promptId() = promptId - - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - @JsonProperty("prompt_version") @ExcludeMissing fun _promptVersion() = promptVersion - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Origin = apply { - if (!validated) { - promptId() - projectId() - promptVersion() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var promptId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var promptVersion: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(origin: Origin) = apply { - this.promptId = origin.promptId - this.projectId = origin.projectId - this.promptVersion = origin.promptVersion - additionalProperties(origin.additionalProperties) - } - - fun promptId(promptId: String) = promptId(JsonField.of(promptId)) - - @JsonProperty("prompt_id") - @ExcludeMissing - fun promptId(promptId: JsonField) = apply { this.promptId = promptId } - - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - fun promptVersion(promptVersion: String) = - promptVersion(JsonField.of(promptVersion)) - - @JsonProperty("prompt_version") - @ExcludeMissing - fun promptVersion(promptVersion: JsonField) = apply { - this.promptVersion = promptVersion - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Origin = - Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(using = Prompt.Deserializer::class) - @JsonSerialize(using = Prompt.Serializer::class) - class Prompt - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val _reservedOnlyAllowNull: _ReservedOnlyAllowNull? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun _reservedOnlyAllowNull(): Optional<_ReservedOnlyAllowNull> = - Optional.ofNullable(_reservedOnlyAllowNull) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun is_ReservedOnlyAllowNull(): Boolean = _reservedOnlyAllowNull != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun as_ReservedOnlyAllowNull(): _ReservedOnlyAllowNull = - _reservedOnlyAllowNull.getOrThrow("_reservedOnlyAllowNull") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - _reservedOnlyAllowNull != null -> - visitor.visit_ReservedOnlyAllowNull(_reservedOnlyAllowNull) - else -> visitor.unknown(_json) - } - } - - fun validate(): Prompt = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - _reservedOnlyAllowNull == null - ) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - _reservedOnlyAllowNull?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this._reservedOnlyAllowNull == other._reservedOnlyAllowNull - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - _reservedOnlyAllowNull, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Prompt{unionMember0=$unionMember0}" - unionMember1 != null -> "Prompt{unionMember1=$unionMember1}" - _reservedOnlyAllowNull != null -> - "Prompt{_reservedOnlyAllowNull=$_reservedOnlyAllowNull}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Prompt(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Prompt(unionMember1 = unionMember1) - - @JvmStatic - fun of_ReservedOnlyAllowNull(_reservedOnlyAllowNull: _ReservedOnlyAllowNull) = - Prompt(_reservedOnlyAllowNull = _reservedOnlyAllowNull) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visit_ReservedOnlyAllowNull(_reservedOnlyAllowNull: _ReservedOnlyAllowNull): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") - } - } - - class Deserializer : BaseDeserializer(Prompt::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef<_ReservedOnlyAllowNull>()) { it.validate() } - ?.let { - return Prompt(_reservedOnlyAllowNull = it, _json = json) - } - - return Prompt(_json = json) - } - } - - class Serializer : BaseSerializer(Prompt::class) { - - override fun serialize( - value: Prompt, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value._reservedOnlyAllowNull != null -> - generator.writeObject(value._reservedOnlyAllowNull) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val type: JsonField, - private val content: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun content(): String = content.getRequired("content") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - type() - content() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{type=$type, content=$content, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.type = unionMember0.type - this.content = unionMember0.content - additionalProperties(unionMember0.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = - UnionMember0( - type, - content, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val COMPLETION = Type(JsonField.of("completion")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - COMPLETION, - } - - enum class Value { - COMPLETION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun messages(): List = messages.getRequired("messages") - - fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("messages") @ExcludeMissing fun _messages() = messages - - @JsonProperty("tools") @ExcludeMissing fun _tools() = tools - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - type() - messages() - tools() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var messages: JsonField> = JsonMissing.of() - private var tools: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.messages = unionMember1.messages - this.tools = unionMember1.tools - additionalProperties(unionMember1.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun messages(messages: List) = messages(JsonField.of(messages)) - - @JsonProperty("messages") - @ExcludeMissing - fun messages(messages: JsonField>) = apply { - this.messages = messages - } - - fun tools(tools: String) = tools(JsonField.of(tools)) - - @JsonProperty("tools") - @ExcludeMissing - fun tools(tools: JsonField) = apply { this.tools = tools } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = - UnionMember1( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Message.Deserializer::class) - @JsonSerialize(using = Message.Serializer::class) - class Message - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUnionMember3(): Boolean = unionMember3 != null - - fun isUnionMember4(): Boolean = unionMember4 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - else -> visitor.unknown(_json) - } - } - - fun validate(): Message = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null && - unionMember3 == null && - unionMember4 == null - ) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - unionMember4?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.unionMember4 == other.unionMember4 - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Message{unionMember0=$unionMember0}" - unionMember1 != null -> "Message{unionMember1=$unionMember1}" - unionMember2 != null -> "Message{unionMember2=$unionMember2}" - unionMember3 != null -> "Message{unionMember3=$unionMember3}" - unionMember4 != null -> "Message{unionMember4=$unionMember4}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - Message(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - Message(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - Message(unionMember2 = unionMember2) - - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = - Message(unionMember3 = unionMember3) - - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = - Message(unionMember4 = unionMember4) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUnionMember3(unionMember3: UnionMember3): T - - fun visitUnionMember4(unionMember4: UnionMember4): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") - } - } - - class Deserializer : BaseDeserializer(Message::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember4 = it, _json = json) - } - - return Message(_json = json) - } - } - - class Serializer : BaseSerializer(Message::class) { - - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.unionMember2 != null -> - generator.writeObject(value.unionMember2) - value.unionMember3 != null -> - generator.writeObject(value.unionMember3) - value.unionMember4 != null -> - generator.writeObject(value.unionMember4) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.content = unionMember0.content - this.role = unionMember0.role - this.name = unionMember0.name - additionalProperties(unionMember0.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember0 = - UnionMember0( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SYSTEM = Role(JsonField.of("system")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - SYSTEM, - } - - enum class Value { - SYSTEM, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SYSTEM -> Known.SYSTEM - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.content = unionMember1.content - this.role = unionMember1.role - this.name = unionMember1.name - additionalProperties(unionMember1.additionalProperties) - } - - fun content(content: Content) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember1 = - UnionMember1( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val USER = Role(JsonField.of("user")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - USER, - } - - enum class Value { - USER, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - USER -> Known.USER - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(using = Content.Deserializer::class) - @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( - private val string: String? = null, - private val unnamedSchemaWithArrayParent8s: - List? = - null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun unnamedSchemaWithArrayParent8s(): - Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent8s) - - fun isString(): Boolean = string != null - - fun isUnnamedSchemaWithArrayParent8s(): Boolean = - unnamedSchemaWithArrayParent8s != null - - fun asString(): String = string.getOrThrow("string") - - fun asUnnamedSchemaWithArrayParent8s(): - List = - unnamedSchemaWithArrayParent8s.getOrThrow( - "unnamedSchemaWithArrayParent8s" - ) - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent8s != null -> - visitor.visitUnnamedSchemaWithArrayParent8s( - unnamedSchemaWithArrayParent8s - ) - else -> visitor.unknown(_json) - } - } - - fun validate(): Content = apply { - if (!validated) { - if (string == null && unnamedSchemaWithArrayParent8s == null) { - throw BraintrustInvalidDataException( - "Unknown Content: $_json" - ) - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent8s == - other.unnamedSchemaWithArrayParent8s - } - - override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent8s) - } - - override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent8s != null -> - "Content{unnamedSchemaWithArrayParent8s=$unnamedSchemaWithArrayParent8s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Content(string = string) - - @JvmStatic - fun ofUnnamedSchemaWithArrayParent8s( - unnamedSchemaWithArrayParent8s: - List - ) = - Content( - unnamedSchemaWithArrayParent8s = - unnamedSchemaWithArrayParent8s - ) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitUnnamedSchemaWithArrayParent8s( - unnamedSchemaWithArrayParent8s: - List - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") - } - } - - class Deserializer : BaseDeserializer(Content::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize( - node, - jacksonTypeRef>() - ) - ?.let { - return Content( - unnamedSchemaWithArrayParent8s = it, - _json = json - ) - } - - return Content(_json = json) - } - } - - class Serializer : BaseSerializer(Content::class) { - - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent8s != null -> - generator.writeObject( - value.unnamedSchemaWithArrayParent8s - ) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } - } - } - - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent8.Deserializer::class - ) - @JsonSerialize(using = UnnamedSchemaWithArrayParent8.Serializer::class) - class UnnamedSchemaWithArrayParent8 - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun asUnionMember0(): UnionMember0 = - unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = - unionMember1.getOrThrow("unionMember1") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> - visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> - visitor.visitUnionMember1(unionMember1) - else -> visitor.unknown(_json) - } - } - - fun validate(): UnnamedSchemaWithArrayParent8 = apply { - if (!validated) { - if (unionMember0 == null && unionMember1 == null) { - throw BraintrustInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent8: $_json" - ) - } - unionMember0?.validate() - unionMember1?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent8 && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 - } - - override fun hashCode(): Int { - return Objects.hash(unionMember0, unionMember1) - } - - override fun toString(): String { - return when { - unionMember0 != null -> - "UnnamedSchemaWithArrayParent8{unionMember0=$unionMember0}" - unionMember1 != null -> - "UnnamedSchemaWithArrayParent8{unionMember1=$unionMember1}" - _json != null -> - "UnnamedSchemaWithArrayParent8{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent8" - ) - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - UnnamedSchemaWithArrayParent8(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - UnnamedSchemaWithArrayParent8(unionMember1 = unionMember1) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent8: $json" - ) - } - } - - class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent8::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent8 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return UnnamedSchemaWithArrayParent8( - unionMember0 = it, - _json = json - ) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return UnnamedSchemaWithArrayParent8( - unionMember1 = it, - _json = json - ) - } - - return UnnamedSchemaWithArrayParent8(_json = json) - } - } - - class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent8::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent8, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent8" - ) - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val text: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun text(): Optional = - Optional.ofNullable(text.getNullable("text")) - - fun type(): Type = type.getRequired("type") - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - text() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{text=$text, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var text: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.text = unionMember0.text - this.type = unionMember0.type - additionalProperties(unionMember0.additionalProperties) - } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { - this.text = text - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = - UnionMember0( - text, - type, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TEXT = Type(JsonField.of("text")) - - @JvmStatic - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - TEXT, - } - - enum class Value { - TEXT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TEXT -> Known.TEXT - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val imageUrl: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") - - fun type(): Type = type.getRequired("type") - - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl() = imageUrl - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - imageUrl().validate() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var imageUrl: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.imageUrl = unionMember1.imageUrl - this.type = unionMember1.type - additionalProperties(unionMember1.additionalProperties) - } - - fun imageUrl(imageUrl: ImageUrl) = - imageUrl(JsonField.of(imageUrl)) - - @JsonProperty("image_url") - @ExcludeMissing - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = - UnionMember1( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = ImageUrl.Builder::class) - @NoAutoDetect - class ImageUrl - private constructor( - private val url: JsonField, - private val detail: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun url(): String = url.getRequired("url") - - fun detail(): Optional = - Optional.ofNullable(detail.getNullable("detail")) - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonProperty("detail") - @ExcludeMissing - fun _detail() = detail - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): ImageUrl = apply { - if (!validated) { - url() - detail() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == - other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var url: JsonField = JsonMissing.of() - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(imageUrl: ImageUrl) = apply { - this.url = imageUrl.url - this.detail = imageUrl.detail - additionalProperties(imageUrl.additionalProperties) - } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { - this.url = url - } - - fun detail(detail: Detail) = - detail(JsonField.of(detail)) - - @JsonProperty("detail") - @ExcludeMissing - fun detail(detail: JsonField) = apply { - this.detail = detail - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll( - additionalProperties - ) - } - - @JsonAnySetter - fun putAdditionalProperty( - key: String, - value: JsonValue - ) = apply { this.additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun build(): ImageUrl = - ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) - } - - class Detail - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Detail && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = Detail(JsonField.of("auto")) - - @JvmField val LOW = Detail(JsonField.of("low")) - - @JvmField val HIGH = Detail(JsonField.of("high")) - - @JvmStatic - fun of(value: String) = Detail(JsonField.of(value)) - } - - enum class Known { - AUTO, - LOW, - HIGH, - } - - enum class Value { - AUTO, - LOW, - HIGH, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> - throw BraintrustInvalidDataException( - "Unknown Detail: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField - val IMAGE_URL = Type(JsonField.of("image_url")) - - @JvmStatic - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - IMAGE_URL, - } - - enum class Value { - IMAGE_URL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - } - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun role(): Role = role.getRequired("role") - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun toolCalls(): Optional> = - Optional.ofNullable(toolCalls.getNullable("tool_calls")) - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("function_call") - @ExcludeMissing - fun _functionCall() = functionCall - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var role: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.role = unionMember2.role - this.content = unionMember2.content - this.functionCall = unionMember2.functionCall - this.name = unionMember2.name - this.toolCalls = unionMember2.toolCalls - additionalProperties(unionMember2.additionalProperties) - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun toolCalls(toolCalls: List) = - toolCalls(JsonField.of(toolCalls)) - - @JsonProperty("tool_calls") - @ExcludeMissing - fun toolCalls(toolCalls: JsonField>) = apply { - this.toolCalls = toolCalls - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val ASSISTANT = Role(JsonField.of("assistant")) - - @JvmStatic fun of(value: String) = Role(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 BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = FunctionCall.Builder::class) - @NoAutoDetect - class FunctionCall - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun arguments(): String = arguments.getRequired("arguments") - - fun name(): String = name.getRequired("name") - - @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): FunctionCall = apply { - if (!validated) { - arguments() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(functionCall: FunctionCall) = apply { - this.arguments = functionCall.arguments - this.name = functionCall.name - additionalProperties(functionCall.additionalProperties) - } - - fun arguments(arguments: String) = - arguments(JsonField.of(arguments)) - - @JsonProperty("arguments") - @ExcludeMissing - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): FunctionCall = - FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = ToolCall.Builder::class) - @NoAutoDetect - class ToolCall - private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun id(): String = id.getRequired("id") - - fun function(): Function = function.getRequired("function") - - fun type(): Type = type.getRequired("type") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("function") @ExcludeMissing fun _function() = function - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): ToolCall = apply { - if (!validated) { - id() - function().validate() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(toolCall: ToolCall) = apply { - this.id = toolCall.id - this.function = toolCall.function - this.type = toolCall.type - additionalProperties(toolCall.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun function(function: Function) = function(JsonField.of(function)) - - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { - this.function = function - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): ToolCall = - ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun arguments(): String = arguments.getRequired("arguments") - - fun name(): String = name.getRequired("name") - - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments() = arguments - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Function = apply { - if (!validated) { - arguments() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.arguments = function.arguments - this.name = function.name - additionalProperties(function.additionalProperties) - } - - fun arguments(arguments: String) = - arguments(JsonField.of(arguments)) - - @JsonProperty("arguments") - @ExcludeMissing - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Function = - Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - @JsonDeserialize(builder = UnionMember3.Builder::class) - @NoAutoDetect - class UnionMember3 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun toolCallId(): String = toolCallId.getRequired("tool_call_id") - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember3 = apply { - if (!validated) { - content() - role() - toolCallId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember3{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.content = unionMember3.content - this.role = unionMember3.role - this.toolCallId = unionMember3.toolCallId - additionalProperties(unionMember3.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun toolCallId(toolCallId: String) = - toolCallId(JsonField.of(toolCallId)) - - @JsonProperty("tool_call_id") - @ExcludeMissing - fun toolCallId(toolCallId: JsonField) = apply { - this.toolCallId = toolCallId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember3 = - UnionMember3( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TOOL = Role(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - TOOL, - } - - enum class Value { - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TOOL -> Known.TOOL - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember4.Builder::class) - @NoAutoDetect - class UnionMember4 - private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun name(): String = name.getRequired("name") - - fun role(): Role = role.getRequired("role") - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember4 = apply { - if (!validated) { - content() - name() - role() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember4 && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember4{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - this.content = unionMember4.content - this.name = unionMember4.name - this.role = unionMember4.role - additionalProperties(unionMember4.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember4 = - UnionMember4( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Role(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val CHAT = Type(JsonField.of("chat")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - CHAT, - } - - enum class Value { - CHAT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = _ReservedOnlyAllowNull.Builder::class) - @NoAutoDetect - class _ReservedOnlyAllowNull - private constructor( - private val _reservedOnlyAllowNull: JsonValue, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * This is just a placeholder nullable object. Only pass null, not the object itself - */ - @JsonProperty("__reserved_only_allow_null") - @ExcludeMissing - fun __reservedOnlyAllowNull() = _reservedOnlyAllowNull - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): _ReservedOnlyAllowNull = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is _ReservedOnlyAllowNull && - this._reservedOnlyAllowNull == other._reservedOnlyAllowNull && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(_reservedOnlyAllowNull, additionalProperties) - } - return hashCode - } - - override fun toString() = - "_ReservedOnlyAllowNull{_reservedOnlyAllowNull=$_reservedOnlyAllowNull, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var _reservedOnlyAllowNull: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(_reservedOnlyAllowNull: _ReservedOnlyAllowNull) = apply { - this._reservedOnlyAllowNull = _reservedOnlyAllowNull._reservedOnlyAllowNull - additionalProperties(_reservedOnlyAllowNull.additionalProperties) - } - - /** - * This is just a placeholder nullable object. Only pass null, not the object - * itself - */ - @JsonProperty("__reserved_only_allow_null") - @ExcludeMissing - fun _reservedOnlyAllowNull(_reservedOnlyAllowNull: JsonValue) = apply { - this._reservedOnlyAllowNull = _reservedOnlyAllowNull - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): _ReservedOnlyAllowNull = - _ReservedOnlyAllowNull( - _reservedOnlyAllowNull, - additionalProperties.toUnmodifiable() - ) - } - } - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptRetrieveResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptRetrieveResponse.kt deleted file mode 100644 index a422561..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptRetrieveResponse.kt +++ /dev/null @@ -1,6057 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrust.api.models - -import com.braintrust.api.core.BaseDeserializer -import com.braintrust.api.core.BaseSerializer -import com.braintrust.api.core.Enum -import com.braintrust.api.core.ExcludeMissing -import com.braintrust.api.core.JsonField -import com.braintrust.api.core.JsonMissing -import com.braintrust.api.core.JsonValue -import com.braintrust.api.core.NoAutoDetect -import com.braintrust.api.core.getOrThrow -import com.braintrust.api.core.toUnmodifiable -import com.braintrust.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = PromptRetrieveResponse.Builder::class) -@NoAutoDetect -class PromptRetrieveResponse -private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val description: JsonField, - private val created: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val metadata: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Unique identifier for the prompt */ - fun id(): String = id.getRequired("id") - - /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) - */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - - /** A literal 'p' which identifies the object as a project prompt */ - fun logId(): LogId = logId.getRequired("log_id") - - /** Unique identifier for the organization */ - fun orgId(): String = orgId.getRequired("org_id") - - /** Name of the prompt */ - fun name(): String = name.getRequired("name") - - /** Unique identifier for the prompt */ - fun slug(): String = slug.getRequired("slug") - - /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** Date of prompt creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - - /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) - - /** A list of tags for the prompt */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** User-controlled metadata about the prompt */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) - */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId - - /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId - - /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** Date of prompt creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData - - /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PromptRetrieveResponse = apply { - if (!validated) { - id() - _xactId() - projectId() - logId() - orgId() - name() - slug() - description() - created() - promptData().map { it.validate() } - tags() - metadata().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptRetrieveResponse && - this.id == other.id && - this._xactId == other._xactId && - this.projectId == other.projectId && - this.logId == other.logId && - this.orgId == other.orgId && - this.name == other.name && - this.slug == other.slug && - this.description == other.description && - this.created == other.created && - this.promptData == other.promptData && - this.tags == other.tags && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags, - metadata, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptRetrieveResponse{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var logId: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var promptData: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptRetrieveResponse: PromptRetrieveResponse) = apply { - this.id = promptRetrieveResponse.id - this._xactId = promptRetrieveResponse._xactId - this.projectId = promptRetrieveResponse.projectId - this.logId = promptRetrieveResponse.logId - this.orgId = promptRetrieveResponse.orgId - this.name = promptRetrieveResponse.name - this.slug = promptRetrieveResponse.slug - this.description = promptRetrieveResponse.description - this.created = promptRetrieveResponse.created - this.promptData = promptRetrieveResponse.promptData - this.tags = promptRetrieveResponse.tags - this.metadata = promptRetrieveResponse.metadata - additionalProperties(promptRetrieveResponse.additionalProperties) - } - - /** Unique identifier for the prompt */ - fun id(id: String) = id(JsonField.of(id)) - - /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) - */ - fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) - */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** A literal 'p' which identifies the object as a project prompt */ - fun logId(logId: LogId) = logId(JsonField.of(logId)) - - /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") - @ExcludeMissing - fun logId(logId: JsonField) = apply { this.logId = logId } - - /** Unique identifier for the organization */ - fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - - /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - - /** Name of the prompt */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Unique identifier for the prompt */ - fun slug(slug: String) = slug(JsonField.of(slug)) - - /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - /** Textual description of the prompt */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** Date of prompt creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** Date of prompt creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - @ExcludeMissing - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } - - /** A list of tags for the prompt */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** User-controlled metadata about the prompt */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PromptRetrieveResponse = - PromptRetrieveResponse( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags.map { it.toUnmodifiable() }, - metadata, - additionalProperties.toUnmodifiable(), - ) - } - - class LogId - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LogId && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val P = LogId(JsonField.of("p")) - - @JvmStatic fun of(value: String) = LogId(JsonField.of(value)) - } - - enum class Known { - P, - } - - enum class Value { - P, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - P -> Value.P - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - P -> Known.P - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - /** User-controlled metadata about the prompt */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** The prompt, model, and its parameters */ - @JsonDeserialize(builder = PromptData.Builder::class) - @NoAutoDetect - class PromptData - private constructor( - private val prompt: JsonField, - private val options: JsonField, - private val origin: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) - - fun options(): Optional = Optional.ofNullable(options.getNullable("options")) - - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) - - @JsonProperty("prompt") @ExcludeMissing fun _prompt() = prompt - - @JsonProperty("options") @ExcludeMissing fun _options() = options - - @JsonProperty("origin") @ExcludeMissing fun _origin() = origin - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PromptData = apply { - if (!validated) { - prompt() - options().map { it.validate() } - origin().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - prompt, - options, - origin, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var prompt: JsonField = JsonMissing.of() - private var options: JsonField = JsonMissing.of() - private var origin: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptData: PromptData) = apply { - this.prompt = promptData.prompt - this.options = promptData.options - this.origin = promptData.origin - additionalProperties(promptData.additionalProperties) - } - - fun prompt(prompt: Prompt) = prompt(JsonField.of(prompt)) - - @JsonProperty("prompt") - @ExcludeMissing - fun prompt(prompt: JsonField) = apply { this.prompt = prompt } - - fun options(options: Options) = options(JsonField.of(options)) - - @JsonProperty("options") - @ExcludeMissing - fun options(options: JsonField) = apply { this.options = options } - - fun origin(origin: Origin) = origin(JsonField.of(origin)) - - @JsonProperty("origin") - @ExcludeMissing - fun origin(origin: JsonField) = apply { this.origin = origin } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PromptData = - PromptData( - prompt, - options, - origin, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Options.Builder::class) - @NoAutoDetect - class Options - private constructor( - private val model: JsonField, - private val params: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) - - fun params(): Optional = Optional.ofNullable(params.getNullable("params")) - - fun position(): Optional = Optional.ofNullable(position.getNullable("position")) - - @JsonProperty("model") @ExcludeMissing fun _model() = model - - @JsonProperty("params") @ExcludeMissing fun _params() = params - - @JsonProperty("position") @ExcludeMissing fun _position() = position - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Options = apply { - if (!validated) { - model() - params() - position() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var model: JsonField = JsonMissing.of() - private var params: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - this.model = options.model - this.params = options.params - this.position = options.position - additionalProperties(options.additionalProperties) - } - - fun model(model: String) = model(JsonField.of(model)) - - @JsonProperty("model") - @ExcludeMissing - fun model(model: JsonField) = apply { this.model = model } - - fun params(params: Params) = params(JsonField.of(params)) - - @JsonProperty("params") - @ExcludeMissing - fun params(params: JsonField) = apply { this.params = params } - - fun position(position: String) = position(JsonField.of(position)) - - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Options = - Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Params.Deserializer::class) - @JsonSerialize(using = Params.Serializer::class) - class Params - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val useCache: UseCache? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun useCache(): Optional = Optional.ofNullable(useCache) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUseCache(): Boolean = useCache != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUseCache(): UseCache = useCache.getOrThrow("useCache") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - useCache != null -> visitor.visitUseCache(useCache) - else -> visitor.unknown(_json) - } - } - - fun validate(): Params = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null && - useCache == null - ) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - useCache?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.useCache == other.useCache - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - useCache, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Params{unionMember0=$unionMember0}" - unionMember1 != null -> "Params{unionMember1=$unionMember1}" - unionMember2 != null -> "Params{unionMember2=$unionMember2}" - useCache != null -> "Params{useCache=$useCache}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - Params(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - Params(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - Params(unionMember2 = unionMember2) - - @JvmStatic fun ofUseCache(useCache: UseCache) = Params(useCache = useCache) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUseCache(useCache: UseCache): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") - } - } - - class Deserializer : BaseDeserializer(Params::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(useCache = it, _json = json) - } - - return Params(_json = json) - } - } - - class Serializer : BaseSerializer(Params::class) { - - override fun serialize( - value: Params, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.useCache != null -> generator.writeObject(value.useCache) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - - fun maxTokens(): Optional = - Optional.ofNullable(maxTokens.getNullable("max_tokens")) - - fun frequencyPenalty(): Optional = - Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - - fun presencePenalty(): Optional = - Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - - fun responseFormat(): Optional = - Optional.ofNullable(responseFormat.getNullable("response_format")) - - fun toolChoice(): Optional = - Optional.ofNullable(toolChoice.getNullable("tool_choice")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - - fun stop(): Optional> = - Optional.ofNullable(stop.getNullable("stop")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - - @JsonProperty("frequency_penalty") - @ExcludeMissing - fun _frequencyPenalty() = frequencyPenalty - - @JsonProperty("presence_penalty") - @ExcludeMissing - fun _presencePenalty() = presencePenalty - - @JsonProperty("response_format") - @ExcludeMissing - fun _responseFormat() = responseFormat - - @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice - - @JsonProperty("function_call") - @ExcludeMissing - fun _functionCall() = functionCall - - @JsonProperty("n") @ExcludeMissing fun _n() = n - - @JsonProperty("stop") @ExcludeMissing fun _stop() = stop - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat().map { it.validate() } - toolChoice() - functionCall() - n() - stop() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() - private var frequencyPenalty: JsonField = JsonMissing.of() - private var presencePenalty: JsonField = JsonMissing.of() - private var responseFormat: JsonField = JsonMissing.of() - private var toolChoice: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var n: JsonField = JsonMissing.of() - private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.useCache = unionMember0.useCache - this.temperature = unionMember0.temperature - this.topP = unionMember0.topP - this.maxTokens = unionMember0.maxTokens - this.frequencyPenalty = unionMember0.frequencyPenalty - this.presencePenalty = unionMember0.presencePenalty - this.responseFormat = unionMember0.responseFormat - this.toolChoice = unionMember0.toolChoice - this.functionCall = unionMember0.functionCall - this.n = unionMember0.n - this.stop = unionMember0.stop - additionalProperties(unionMember0.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - - @JsonProperty("max_tokens") - @ExcludeMissing - fun maxTokens(maxTokens: JsonField) = apply { - this.maxTokens = maxTokens - } - - fun frequencyPenalty(frequencyPenalty: Double) = - frequencyPenalty(JsonField.of(frequencyPenalty)) - - @JsonProperty("frequency_penalty") - @ExcludeMissing - fun frequencyPenalty(frequencyPenalty: JsonField) = apply { - this.frequencyPenalty = frequencyPenalty - } - - fun presencePenalty(presencePenalty: Double) = - presencePenalty(JsonField.of(presencePenalty)) - - @JsonProperty("presence_penalty") - @ExcludeMissing - fun presencePenalty(presencePenalty: JsonField) = apply { - this.presencePenalty = presencePenalty - } - - fun responseFormat(responseFormat: ResponseFormat) = - responseFormat(JsonField.of(responseFormat)) - - @JsonProperty("response_format") - @ExcludeMissing - fun responseFormat(responseFormat: JsonField) = apply { - this.responseFormat = responseFormat - } - - fun toolChoice(toolChoice: ToolChoice) = - toolChoice(JsonField.of(toolChoice)) - - @JsonProperty("tool_choice") - @ExcludeMissing - fun toolChoice(toolChoice: JsonField) = apply { - this.toolChoice = toolChoice - } - - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun n(n: Double) = n(JsonField.of(n)) - - @JsonProperty("n") - @ExcludeMissing - fun n(n: JsonField) = apply { this.n = n } - - fun stop(stop: List) = stop(JsonField.of(stop)) - - @JsonProperty("stop") - @ExcludeMissing - fun stop(stop: JsonField>) = apply { this.stop = stop } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember0 = - UnionMember0( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = FunctionCall.Deserializer::class) - @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val name: Name? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun name(): Optional = Optional.ofNullable(name) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isName(): Boolean = name != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asName(): Name = name.getOrThrow("name") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - name != null -> visitor.visitName(name) - else -> visitor.unknown(_json) - } - } - - fun validate(): FunctionCall = apply { - if (!validated) { - if (unionMember0 == null && unionMember1 == null && name == null) { - throw BraintrustInvalidDataException( - "Unknown FunctionCall: $_json" - ) - } - name?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCall && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.name == other.name - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - name, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" - unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" - name != null -> "FunctionCall{name=$name}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - FunctionCall(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - FunctionCall(unionMember1 = unionMember1) - - @JvmStatic fun ofName(name: Name) = FunctionCall(name = name) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitName(name: Name): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") - } - } - - class Deserializer : BaseDeserializer(FunctionCall::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionCall(name = it, _json = json) - } - - return FunctionCall(_json = json) - } - } - - class Serializer : BaseSerializer(FunctionCall::class) { - - override fun serialize( - value: FunctionCall, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.name != null -> generator.writeObject(value.name) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } - } - } - - class UnionMember0 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = UnionMember0(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 BraintrustInvalidDataException( - "Unknown UnionMember0: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - class UnionMember1 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = UnionMember1(JsonField.of("none")) - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> - throw BraintrustInvalidDataException( - "Unknown UnionMember1: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = Name.Builder::class) - @NoAutoDetect - class Name - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Name = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Name && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Name{name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - additionalProperties(name.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Name = - Name(name, additionalProperties.toUnmodifiable()) - } - } - } - - @JsonDeserialize(builder = ResponseFormat.Builder::class) - @NoAutoDetect - class ResponseFormat - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ResponseFormat = apply { - if (!validated) { - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = - "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(responseFormat: ResponseFormat) = apply { - this.type = responseFormat.type - additionalProperties(responseFormat.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): ResponseFormat = - ResponseFormat(type, additionalProperties.toUnmodifiable()) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val JSON_OBJECT = Type(JsonField.of("json_object")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - JSON_OBJECT, - } - - enum class Value { - JSON_OBJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(using = ToolChoice.Deserializer::class) - @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = - Optional.ofNullable(unionMember2) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } - } - - fun validate(): ToolChoice = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null - ) { - throw BraintrustInvalidDataException( - "Unknown ToolChoice: $_json" - ) - } - unionMember2?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ToolChoice && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" - unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" - unionMember2 != null -> "ToolChoice{unionMember2=$unionMember2}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - ToolChoice(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - ToolChoice(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - ToolChoice(unionMember2 = unionMember2) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") - } - } - - class Deserializer : BaseDeserializer(ToolChoice::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ToolChoice(unionMember2 = it, _json = json) - } - - return ToolChoice(_json = json) - } - } - - class Serializer : BaseSerializer(ToolChoice::class) { - - override fun serialize( - value: ToolChoice, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.unionMember2 != null -> - generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - } - - class UnionMember0 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = UnionMember0(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 BraintrustInvalidDataException( - "Unknown UnionMember0: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - class UnionMember1 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = UnionMember1(JsonField.of("none")) - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> - throw BraintrustInvalidDataException( - "Unknown UnionMember1: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val type: JsonField, - private val function: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun function(): Function = function.getRequired("function") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("function") @ExcludeMissing fun _function() = function - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - type() - function().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{type=$type, function=$function, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.function = unionMember2.function - additionalProperties(unionMember2.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun function(function: Function) = function(JsonField.of(function)) - - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { - this.function = function - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - type, - function, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Function = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.name = function.name - additionalProperties(function.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Function = - Function(name, additionalProperties.toUnmodifiable()) - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun maxTokens(): Double = maxTokens.getRequired("max_tokens") - - fun temperature(): Double = temperature.getRequired("temperature") - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - - fun stopSequences(): Optional> = - Optional.ofNullable(stopSequences.getNullable("stop_sequences")) - - /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = - Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - - @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK - - @JsonProperty("stop_sequences") - @ExcludeMissing - fun _stopSequences() = stopSequences - - /** This is a legacy parameter that should not be used. */ - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - fun _maxTokensToSample() = maxTokensToSample - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var stopSequences: JsonField> = JsonMissing.of() - private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.useCache = unionMember1.useCache - this.maxTokens = unionMember1.maxTokens - this.temperature = unionMember1.temperature - this.topP = unionMember1.topP - this.topK = unionMember1.topK - this.stopSequences = unionMember1.stopSequences - this.maxTokensToSample = unionMember1.maxTokensToSample - additionalProperties(unionMember1.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - - @JsonProperty("max_tokens") - @ExcludeMissing - fun maxTokens(maxTokens: JsonField) = apply { - this.maxTokens = maxTokens - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun topK(topK: Double) = topK(JsonField.of(topK)) - - @JsonProperty("top_k") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } - - fun stopSequences(stopSequences: List) = - stopSequences(JsonField.of(stopSequences)) - - @JsonProperty("stop_sequences") - @ExcludeMissing - fun stopSequences(stopSequences: JsonField>) = apply { - this.stopSequences = stopSequences - } - - /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = - maxTokensToSample(JsonField.of(maxTokensToSample)) - - /** This is a legacy parameter that should not be used. */ - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - fun maxTokensToSample(maxTokensToSample: JsonField) = apply { - this.maxTokensToSample = maxTokensToSample - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember1 = - UnionMember1( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Double = temperature.getRequired("temperature") - - fun maxOutputTokens(): Optional = - Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("maxOutputTokens") - @ExcludeMissing - fun _maxOutputTokens() = maxOutputTokens - - @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - - @JsonProperty("topK") @ExcludeMissing fun _topK() = topK - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var maxOutputTokens: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.useCache = unionMember2.useCache - this.temperature = unionMember2.temperature - this.maxOutputTokens = unionMember2.maxOutputTokens - this.topP = unionMember2.topP - this.topK = unionMember2.topK - additionalProperties(unionMember2.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun maxOutputTokens(maxOutputTokens: Double) = - maxOutputTokens(JsonField.of(maxOutputTokens)) - - @JsonProperty("maxOutputTokens") - @ExcludeMissing - fun maxOutputTokens(maxOutputTokens: JsonField) = apply { - this.maxOutputTokens = maxOutputTokens - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("topP") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun topK(topK: Double) = topK(JsonField.of(topK)) - - @JsonProperty("topK") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = UseCache.Builder::class) - @NoAutoDetect - class UseCache - private constructor( - private val useCache: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UseCache = apply { - if (!validated) { - useCache() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UseCache && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode - } - - override fun toString() = - "UseCache{useCache=$useCache, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(useCache: UseCache) = apply { - this.useCache = useCache.useCache - additionalProperties(useCache.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UseCache = - UseCache(useCache, additionalProperties.toUnmodifiable()) - } - } - } - } - - @JsonDeserialize(builder = Origin.Builder::class) - @NoAutoDetect - class Origin - private constructor( - private val promptId: JsonField, - private val projectId: JsonField, - private val promptVersion: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun promptId(): Optional = - Optional.ofNullable(promptId.getNullable("prompt_id")) - - fun projectId(): Optional = - Optional.ofNullable(projectId.getNullable("project_id")) - - fun promptVersion(): Optional = - Optional.ofNullable(promptVersion.getNullable("prompt_version")) - - @JsonProperty("prompt_id") @ExcludeMissing fun _promptId() = promptId - - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - @JsonProperty("prompt_version") @ExcludeMissing fun _promptVersion() = promptVersion - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Origin = apply { - if (!validated) { - promptId() - projectId() - promptVersion() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var promptId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var promptVersion: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(origin: Origin) = apply { - this.promptId = origin.promptId - this.projectId = origin.projectId - this.promptVersion = origin.promptVersion - additionalProperties(origin.additionalProperties) - } - - fun promptId(promptId: String) = promptId(JsonField.of(promptId)) - - @JsonProperty("prompt_id") - @ExcludeMissing - fun promptId(promptId: JsonField) = apply { this.promptId = promptId } - - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - fun promptVersion(promptVersion: String) = - promptVersion(JsonField.of(promptVersion)) - - @JsonProperty("prompt_version") - @ExcludeMissing - fun promptVersion(promptVersion: JsonField) = apply { - this.promptVersion = promptVersion - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Origin = - Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(using = Prompt.Deserializer::class) - @JsonSerialize(using = Prompt.Serializer::class) - class Prompt - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val _reservedOnlyAllowNull: _ReservedOnlyAllowNull? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun _reservedOnlyAllowNull(): Optional<_ReservedOnlyAllowNull> = - Optional.ofNullable(_reservedOnlyAllowNull) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun is_ReservedOnlyAllowNull(): Boolean = _reservedOnlyAllowNull != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun as_ReservedOnlyAllowNull(): _ReservedOnlyAllowNull = - _reservedOnlyAllowNull.getOrThrow("_reservedOnlyAllowNull") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - _reservedOnlyAllowNull != null -> - visitor.visit_ReservedOnlyAllowNull(_reservedOnlyAllowNull) - else -> visitor.unknown(_json) - } - } - - fun validate(): Prompt = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - _reservedOnlyAllowNull == null - ) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - _reservedOnlyAllowNull?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this._reservedOnlyAllowNull == other._reservedOnlyAllowNull - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - _reservedOnlyAllowNull, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Prompt{unionMember0=$unionMember0}" - unionMember1 != null -> "Prompt{unionMember1=$unionMember1}" - _reservedOnlyAllowNull != null -> - "Prompt{_reservedOnlyAllowNull=$_reservedOnlyAllowNull}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Prompt(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Prompt(unionMember1 = unionMember1) - - @JvmStatic - fun of_ReservedOnlyAllowNull(_reservedOnlyAllowNull: _ReservedOnlyAllowNull) = - Prompt(_reservedOnlyAllowNull = _reservedOnlyAllowNull) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visit_ReservedOnlyAllowNull(_reservedOnlyAllowNull: _ReservedOnlyAllowNull): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") - } - } - - class Deserializer : BaseDeserializer(Prompt::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef<_ReservedOnlyAllowNull>()) { it.validate() } - ?.let { - return Prompt(_reservedOnlyAllowNull = it, _json = json) - } - - return Prompt(_json = json) - } - } - - class Serializer : BaseSerializer(Prompt::class) { - - override fun serialize( - value: Prompt, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value._reservedOnlyAllowNull != null -> - generator.writeObject(value._reservedOnlyAllowNull) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val type: JsonField, - private val content: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun content(): String = content.getRequired("content") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - type() - content() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{type=$type, content=$content, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.type = unionMember0.type - this.content = unionMember0.content - additionalProperties(unionMember0.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = - UnionMember0( - type, - content, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val COMPLETION = Type(JsonField.of("completion")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - COMPLETION, - } - - enum class Value { - COMPLETION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun messages(): List = messages.getRequired("messages") - - fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("messages") @ExcludeMissing fun _messages() = messages - - @JsonProperty("tools") @ExcludeMissing fun _tools() = tools - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - type() - messages() - tools() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var messages: JsonField> = JsonMissing.of() - private var tools: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.messages = unionMember1.messages - this.tools = unionMember1.tools - additionalProperties(unionMember1.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun messages(messages: List) = messages(JsonField.of(messages)) - - @JsonProperty("messages") - @ExcludeMissing - fun messages(messages: JsonField>) = apply { - this.messages = messages - } - - fun tools(tools: String) = tools(JsonField.of(tools)) - - @JsonProperty("tools") - @ExcludeMissing - fun tools(tools: JsonField) = apply { this.tools = tools } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = - UnionMember1( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Message.Deserializer::class) - @JsonSerialize(using = Message.Serializer::class) - class Message - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUnionMember3(): Boolean = unionMember3 != null - - fun isUnionMember4(): Boolean = unionMember4 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - else -> visitor.unknown(_json) - } - } - - fun validate(): Message = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null && - unionMember3 == null && - unionMember4 == null - ) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - unionMember4?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.unionMember4 == other.unionMember4 - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Message{unionMember0=$unionMember0}" - unionMember1 != null -> "Message{unionMember1=$unionMember1}" - unionMember2 != null -> "Message{unionMember2=$unionMember2}" - unionMember3 != null -> "Message{unionMember3=$unionMember3}" - unionMember4 != null -> "Message{unionMember4=$unionMember4}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - Message(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - Message(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - Message(unionMember2 = unionMember2) - - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = - Message(unionMember3 = unionMember3) - - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = - Message(unionMember4 = unionMember4) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUnionMember3(unionMember3: UnionMember3): T - - fun visitUnionMember4(unionMember4: UnionMember4): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") - } - } - - class Deserializer : BaseDeserializer(Message::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember4 = it, _json = json) - } - - return Message(_json = json) - } - } - - class Serializer : BaseSerializer(Message::class) { - - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.unionMember2 != null -> - generator.writeObject(value.unionMember2) - value.unionMember3 != null -> - generator.writeObject(value.unionMember3) - value.unionMember4 != null -> - generator.writeObject(value.unionMember4) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.content = unionMember0.content - this.role = unionMember0.role - this.name = unionMember0.name - additionalProperties(unionMember0.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember0 = - UnionMember0( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SYSTEM = Role(JsonField.of("system")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - SYSTEM, - } - - enum class Value { - SYSTEM, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SYSTEM -> Known.SYSTEM - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.content = unionMember1.content - this.role = unionMember1.role - this.name = unionMember1.name - additionalProperties(unionMember1.additionalProperties) - } - - fun content(content: Content) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember1 = - UnionMember1( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val USER = Role(JsonField.of("user")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - USER, - } - - enum class Value { - USER, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - USER -> Known.USER - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(using = Content.Deserializer::class) - @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( - private val string: String? = null, - private val unnamedSchemaWithArrayParent4s: - List? = - null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun unnamedSchemaWithArrayParent4s(): - Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent4s) - - fun isString(): Boolean = string != null - - fun isUnnamedSchemaWithArrayParent4s(): Boolean = - unnamedSchemaWithArrayParent4s != null - - fun asString(): String = string.getOrThrow("string") - - fun asUnnamedSchemaWithArrayParent4s(): - List = - unnamedSchemaWithArrayParent4s.getOrThrow( - "unnamedSchemaWithArrayParent4s" - ) - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent4s != null -> - visitor.visitUnnamedSchemaWithArrayParent4s( - unnamedSchemaWithArrayParent4s - ) - else -> visitor.unknown(_json) - } - } - - fun validate(): Content = apply { - if (!validated) { - if (string == null && unnamedSchemaWithArrayParent4s == null) { - throw BraintrustInvalidDataException( - "Unknown Content: $_json" - ) - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent4s == - other.unnamedSchemaWithArrayParent4s - } - - override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent4s) - } - - override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent4s != null -> - "Content{unnamedSchemaWithArrayParent4s=$unnamedSchemaWithArrayParent4s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Content(string = string) - - @JvmStatic - fun ofUnnamedSchemaWithArrayParent4s( - unnamedSchemaWithArrayParent4s: - List - ) = - Content( - unnamedSchemaWithArrayParent4s = - unnamedSchemaWithArrayParent4s - ) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitUnnamedSchemaWithArrayParent4s( - unnamedSchemaWithArrayParent4s: - List - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") - } - } - - class Deserializer : BaseDeserializer(Content::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize( - node, - jacksonTypeRef>() - ) - ?.let { - return Content( - unnamedSchemaWithArrayParent4s = it, - _json = json - ) - } - - return Content(_json = json) - } - } - - class Serializer : BaseSerializer(Content::class) { - - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent4s != null -> - generator.writeObject( - value.unnamedSchemaWithArrayParent4s - ) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } - } - } - - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent4.Deserializer::class - ) - @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) - class UnnamedSchemaWithArrayParent4 - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun asUnionMember0(): UnionMember0 = - unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = - unionMember1.getOrThrow("unionMember1") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> - visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> - visitor.visitUnionMember1(unionMember1) - else -> visitor.unknown(_json) - } - } - - fun validate(): UnnamedSchemaWithArrayParent4 = apply { - if (!validated) { - if (unionMember0 == null && unionMember1 == null) { - throw BraintrustInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent4: $_json" - ) - } - unionMember0?.validate() - unionMember1?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent4 && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 - } - - override fun hashCode(): Int { - return Objects.hash(unionMember0, unionMember1) - } - - override fun toString(): String { - return when { - unionMember0 != null -> - "UnnamedSchemaWithArrayParent4{unionMember0=$unionMember0}" - unionMember1 != null -> - "UnnamedSchemaWithArrayParent4{unionMember1=$unionMember1}" - _json != null -> - "UnnamedSchemaWithArrayParent4{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent4" - ) - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - UnnamedSchemaWithArrayParent4(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - UnnamedSchemaWithArrayParent4(unionMember1 = unionMember1) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent4: $json" - ) - } - } - - class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent4::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent4 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return UnnamedSchemaWithArrayParent4( - unionMember0 = it, - _json = json - ) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return UnnamedSchemaWithArrayParent4( - unionMember1 = it, - _json = json - ) - } - - return UnnamedSchemaWithArrayParent4(_json = json) - } - } - - class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent4::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent4, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent4" - ) - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val text: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun text(): Optional = - Optional.ofNullable(text.getNullable("text")) - - fun type(): Type = type.getRequired("type") - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - text() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{text=$text, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var text: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.text = unionMember0.text - this.type = unionMember0.type - additionalProperties(unionMember0.additionalProperties) - } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { - this.text = text - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = - UnionMember0( - text, - type, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TEXT = Type(JsonField.of("text")) - - @JvmStatic - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - TEXT, - } - - enum class Value { - TEXT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TEXT -> Known.TEXT - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val imageUrl: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") - - fun type(): Type = type.getRequired("type") - - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl() = imageUrl - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - imageUrl().validate() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var imageUrl: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.imageUrl = unionMember1.imageUrl - this.type = unionMember1.type - additionalProperties(unionMember1.additionalProperties) - } - - fun imageUrl(imageUrl: ImageUrl) = - imageUrl(JsonField.of(imageUrl)) - - @JsonProperty("image_url") - @ExcludeMissing - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = - UnionMember1( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = ImageUrl.Builder::class) - @NoAutoDetect - class ImageUrl - private constructor( - private val url: JsonField, - private val detail: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun url(): String = url.getRequired("url") - - fun detail(): Optional = - Optional.ofNullable(detail.getNullable("detail")) - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonProperty("detail") - @ExcludeMissing - fun _detail() = detail - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): ImageUrl = apply { - if (!validated) { - url() - detail() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == - other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var url: JsonField = JsonMissing.of() - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(imageUrl: ImageUrl) = apply { - this.url = imageUrl.url - this.detail = imageUrl.detail - additionalProperties(imageUrl.additionalProperties) - } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { - this.url = url - } - - fun detail(detail: Detail) = - detail(JsonField.of(detail)) - - @JsonProperty("detail") - @ExcludeMissing - fun detail(detail: JsonField) = apply { - this.detail = detail - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll( - additionalProperties - ) - } - - @JsonAnySetter - fun putAdditionalProperty( - key: String, - value: JsonValue - ) = apply { this.additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun build(): ImageUrl = - ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) - } - - class Detail - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Detail && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = Detail(JsonField.of("auto")) - - @JvmField val LOW = Detail(JsonField.of("low")) - - @JvmField val HIGH = Detail(JsonField.of("high")) - - @JvmStatic - fun of(value: String) = Detail(JsonField.of(value)) - } - - enum class Known { - AUTO, - LOW, - HIGH, - } - - enum class Value { - AUTO, - LOW, - HIGH, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> - throw BraintrustInvalidDataException( - "Unknown Detail: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField - val IMAGE_URL = Type(JsonField.of("image_url")) - - @JvmStatic - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - IMAGE_URL, - } - - enum class Value { - IMAGE_URL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - } - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun role(): Role = role.getRequired("role") - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun toolCalls(): Optional> = - Optional.ofNullable(toolCalls.getNullable("tool_calls")) - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("function_call") - @ExcludeMissing - fun _functionCall() = functionCall - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var role: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.role = unionMember2.role - this.content = unionMember2.content - this.functionCall = unionMember2.functionCall - this.name = unionMember2.name - this.toolCalls = unionMember2.toolCalls - additionalProperties(unionMember2.additionalProperties) - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun toolCalls(toolCalls: List) = - toolCalls(JsonField.of(toolCalls)) - - @JsonProperty("tool_calls") - @ExcludeMissing - fun toolCalls(toolCalls: JsonField>) = apply { - this.toolCalls = toolCalls - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val ASSISTANT = Role(JsonField.of("assistant")) - - @JvmStatic fun of(value: String) = Role(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 BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = FunctionCall.Builder::class) - @NoAutoDetect - class FunctionCall - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun arguments(): String = arguments.getRequired("arguments") - - fun name(): String = name.getRequired("name") - - @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): FunctionCall = apply { - if (!validated) { - arguments() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(functionCall: FunctionCall) = apply { - this.arguments = functionCall.arguments - this.name = functionCall.name - additionalProperties(functionCall.additionalProperties) - } - - fun arguments(arguments: String) = - arguments(JsonField.of(arguments)) - - @JsonProperty("arguments") - @ExcludeMissing - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): FunctionCall = - FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = ToolCall.Builder::class) - @NoAutoDetect - class ToolCall - private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun id(): String = id.getRequired("id") - - fun function(): Function = function.getRequired("function") - - fun type(): Type = type.getRequired("type") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("function") @ExcludeMissing fun _function() = function - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): ToolCall = apply { - if (!validated) { - id() - function().validate() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(toolCall: ToolCall) = apply { - this.id = toolCall.id - this.function = toolCall.function - this.type = toolCall.type - additionalProperties(toolCall.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun function(function: Function) = function(JsonField.of(function)) - - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { - this.function = function - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): ToolCall = - ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun arguments(): String = arguments.getRequired("arguments") - - fun name(): String = name.getRequired("name") - - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments() = arguments - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Function = apply { - if (!validated) { - arguments() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.arguments = function.arguments - this.name = function.name - additionalProperties(function.additionalProperties) - } - - fun arguments(arguments: String) = - arguments(JsonField.of(arguments)) - - @JsonProperty("arguments") - @ExcludeMissing - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Function = - Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - @JsonDeserialize(builder = UnionMember3.Builder::class) - @NoAutoDetect - class UnionMember3 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun toolCallId(): String = toolCallId.getRequired("tool_call_id") - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember3 = apply { - if (!validated) { - content() - role() - toolCallId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember3{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.content = unionMember3.content - this.role = unionMember3.role - this.toolCallId = unionMember3.toolCallId - additionalProperties(unionMember3.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun toolCallId(toolCallId: String) = - toolCallId(JsonField.of(toolCallId)) - - @JsonProperty("tool_call_id") - @ExcludeMissing - fun toolCallId(toolCallId: JsonField) = apply { - this.toolCallId = toolCallId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember3 = - UnionMember3( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TOOL = Role(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - TOOL, - } - - enum class Value { - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TOOL -> Known.TOOL - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember4.Builder::class) - @NoAutoDetect - class UnionMember4 - private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun name(): String = name.getRequired("name") - - fun role(): Role = role.getRequired("role") - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember4 = apply { - if (!validated) { - content() - name() - role() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember4 && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember4{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - this.content = unionMember4.content - this.name = unionMember4.name - this.role = unionMember4.role - additionalProperties(unionMember4.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember4 = - UnionMember4( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Role(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val CHAT = Type(JsonField.of("chat")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - CHAT, - } - - enum class Value { - CHAT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = _ReservedOnlyAllowNull.Builder::class) - @NoAutoDetect - class _ReservedOnlyAllowNull - private constructor( - private val _reservedOnlyAllowNull: JsonValue, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * This is just a placeholder nullable object. Only pass null, not the object itself - */ - @JsonProperty("__reserved_only_allow_null") - @ExcludeMissing - fun __reservedOnlyAllowNull() = _reservedOnlyAllowNull - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): _ReservedOnlyAllowNull = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is _ReservedOnlyAllowNull && - this._reservedOnlyAllowNull == other._reservedOnlyAllowNull && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(_reservedOnlyAllowNull, additionalProperties) - } - return hashCode - } - - override fun toString() = - "_ReservedOnlyAllowNull{_reservedOnlyAllowNull=$_reservedOnlyAllowNull, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var _reservedOnlyAllowNull: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(_reservedOnlyAllowNull: _ReservedOnlyAllowNull) = apply { - this._reservedOnlyAllowNull = _reservedOnlyAllowNull._reservedOnlyAllowNull - additionalProperties(_reservedOnlyAllowNull.additionalProperties) - } - - /** - * This is just a placeholder nullable object. Only pass null, not the object - * itself - */ - @JsonProperty("__reserved_only_allow_null") - @ExcludeMissing - fun _reservedOnlyAllowNull(_reservedOnlyAllowNull: JsonValue) = apply { - this._reservedOnlyAllowNull = _reservedOnlyAllowNull - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): _ReservedOnlyAllowNull = - _ReservedOnlyAllowNull( - _reservedOnlyAllowNull, - additionalProperties.toUnmodifiable() - ) - } - } - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptUpdateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptUpdateResponse.kt deleted file mode 100644 index 9072d6c..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/models/PromptUpdateResponse.kt +++ /dev/null @@ -1,6057 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrust.api.models - -import com.braintrust.api.core.BaseDeserializer -import com.braintrust.api.core.BaseSerializer -import com.braintrust.api.core.Enum -import com.braintrust.api.core.ExcludeMissing -import com.braintrust.api.core.JsonField -import com.braintrust.api.core.JsonMissing -import com.braintrust.api.core.JsonValue -import com.braintrust.api.core.NoAutoDetect -import com.braintrust.api.core.getOrThrow -import com.braintrust.api.core.toUnmodifiable -import com.braintrust.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = PromptUpdateResponse.Builder::class) -@NoAutoDetect -class PromptUpdateResponse -private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val description: JsonField, - private val created: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val metadata: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Unique identifier for the prompt */ - fun id(): String = id.getRequired("id") - - /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) - */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - - /** A literal 'p' which identifies the object as a project prompt */ - fun logId(): LogId = logId.getRequired("log_id") - - /** Unique identifier for the organization */ - fun orgId(): String = orgId.getRequired("org_id") - - /** Name of the prompt */ - fun name(): String = name.getRequired("name") - - /** Unique identifier for the prompt */ - fun slug(): String = slug.getRequired("slug") - - /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** Date of prompt creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - - /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) - - /** A list of tags for the prompt */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** User-controlled metadata about the prompt */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) - */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId - - /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId - - /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** Date of prompt creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData - - /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PromptUpdateResponse = apply { - if (!validated) { - id() - _xactId() - projectId() - logId() - orgId() - name() - slug() - description() - created() - promptData().map { it.validate() } - tags() - metadata().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptUpdateResponse && - this.id == other.id && - this._xactId == other._xactId && - this.projectId == other.projectId && - this.logId == other.logId && - this.orgId == other.orgId && - this.name == other.name && - this.slug == other.slug && - this.description == other.description && - this.created == other.created && - this.promptData == other.promptData && - this.tags == other.tags && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags, - metadata, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptUpdateResponse{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var logId: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var promptData: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptUpdateResponse: PromptUpdateResponse) = apply { - this.id = promptUpdateResponse.id - this._xactId = promptUpdateResponse._xactId - this.projectId = promptUpdateResponse.projectId - this.logId = promptUpdateResponse.logId - this.orgId = promptUpdateResponse.orgId - this.name = promptUpdateResponse.name - this.slug = promptUpdateResponse.slug - this.description = promptUpdateResponse.description - this.created = promptUpdateResponse.created - this.promptData = promptUpdateResponse.promptData - this.tags = promptUpdateResponse.tags - this.metadata = promptUpdateResponse.metadata - additionalProperties(promptUpdateResponse.additionalProperties) - } - - /** Unique identifier for the prompt */ - fun id(id: String) = id(JsonField.of(id)) - - /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) - */ - fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) - */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** A literal 'p' which identifies the object as a project prompt */ - fun logId(logId: LogId) = logId(JsonField.of(logId)) - - /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") - @ExcludeMissing - fun logId(logId: JsonField) = apply { this.logId = logId } - - /** Unique identifier for the organization */ - fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - - /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - - /** Name of the prompt */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Unique identifier for the prompt */ - fun slug(slug: String) = slug(JsonField.of(slug)) - - /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - /** Textual description of the prompt */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** Date of prompt creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** Date of prompt creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - @ExcludeMissing - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } - - /** A list of tags for the prompt */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** User-controlled metadata about the prompt */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PromptUpdateResponse = - PromptUpdateResponse( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags.map { it.toUnmodifiable() }, - metadata, - additionalProperties.toUnmodifiable(), - ) - } - - class LogId - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LogId && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val P = LogId(JsonField.of("p")) - - @JvmStatic fun of(value: String) = LogId(JsonField.of(value)) - } - - enum class Known { - P, - } - - enum class Value { - P, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - P -> Value.P - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - P -> Known.P - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - /** User-controlled metadata about the prompt */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** The prompt, model, and its parameters */ - @JsonDeserialize(builder = PromptData.Builder::class) - @NoAutoDetect - class PromptData - private constructor( - private val prompt: JsonField, - private val options: JsonField, - private val origin: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) - - fun options(): Optional = Optional.ofNullable(options.getNullable("options")) - - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) - - @JsonProperty("prompt") @ExcludeMissing fun _prompt() = prompt - - @JsonProperty("options") @ExcludeMissing fun _options() = options - - @JsonProperty("origin") @ExcludeMissing fun _origin() = origin - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PromptData = apply { - if (!validated) { - prompt() - options().map { it.validate() } - origin().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - prompt, - options, - origin, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var prompt: JsonField = JsonMissing.of() - private var options: JsonField = JsonMissing.of() - private var origin: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptData: PromptData) = apply { - this.prompt = promptData.prompt - this.options = promptData.options - this.origin = promptData.origin - additionalProperties(promptData.additionalProperties) - } - - fun prompt(prompt: Prompt) = prompt(JsonField.of(prompt)) - - @JsonProperty("prompt") - @ExcludeMissing - fun prompt(prompt: JsonField) = apply { this.prompt = prompt } - - fun options(options: Options) = options(JsonField.of(options)) - - @JsonProperty("options") - @ExcludeMissing - fun options(options: JsonField) = apply { this.options = options } - - fun origin(origin: Origin) = origin(JsonField.of(origin)) - - @JsonProperty("origin") - @ExcludeMissing - fun origin(origin: JsonField) = apply { this.origin = origin } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PromptData = - PromptData( - prompt, - options, - origin, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Options.Builder::class) - @NoAutoDetect - class Options - private constructor( - private val model: JsonField, - private val params: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) - - fun params(): Optional = Optional.ofNullable(params.getNullable("params")) - - fun position(): Optional = Optional.ofNullable(position.getNullable("position")) - - @JsonProperty("model") @ExcludeMissing fun _model() = model - - @JsonProperty("params") @ExcludeMissing fun _params() = params - - @JsonProperty("position") @ExcludeMissing fun _position() = position - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Options = apply { - if (!validated) { - model() - params() - position() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var model: JsonField = JsonMissing.of() - private var params: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - this.model = options.model - this.params = options.params - this.position = options.position - additionalProperties(options.additionalProperties) - } - - fun model(model: String) = model(JsonField.of(model)) - - @JsonProperty("model") - @ExcludeMissing - fun model(model: JsonField) = apply { this.model = model } - - fun params(params: Params) = params(JsonField.of(params)) - - @JsonProperty("params") - @ExcludeMissing - fun params(params: JsonField) = apply { this.params = params } - - fun position(position: String) = position(JsonField.of(position)) - - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Options = - Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Params.Deserializer::class) - @JsonSerialize(using = Params.Serializer::class) - class Params - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val useCache: UseCache? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun useCache(): Optional = Optional.ofNullable(useCache) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUseCache(): Boolean = useCache != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUseCache(): UseCache = useCache.getOrThrow("useCache") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - useCache != null -> visitor.visitUseCache(useCache) - else -> visitor.unknown(_json) - } - } - - fun validate(): Params = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null && - useCache == null - ) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - useCache?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.useCache == other.useCache - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - useCache, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Params{unionMember0=$unionMember0}" - unionMember1 != null -> "Params{unionMember1=$unionMember1}" - unionMember2 != null -> "Params{unionMember2=$unionMember2}" - useCache != null -> "Params{useCache=$useCache}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - Params(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - Params(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - Params(unionMember2 = unionMember2) - - @JvmStatic fun ofUseCache(useCache: UseCache) = Params(useCache = useCache) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUseCache(useCache: UseCache): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") - } - } - - class Deserializer : BaseDeserializer(Params::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(useCache = it, _json = json) - } - - return Params(_json = json) - } - } - - class Serializer : BaseSerializer(Params::class) { - - override fun serialize( - value: Params, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.useCache != null -> generator.writeObject(value.useCache) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - - fun maxTokens(): Optional = - Optional.ofNullable(maxTokens.getNullable("max_tokens")) - - fun frequencyPenalty(): Optional = - Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - - fun presencePenalty(): Optional = - Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - - fun responseFormat(): Optional = - Optional.ofNullable(responseFormat.getNullable("response_format")) - - fun toolChoice(): Optional = - Optional.ofNullable(toolChoice.getNullable("tool_choice")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - - fun stop(): Optional> = - Optional.ofNullable(stop.getNullable("stop")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - - @JsonProperty("frequency_penalty") - @ExcludeMissing - fun _frequencyPenalty() = frequencyPenalty - - @JsonProperty("presence_penalty") - @ExcludeMissing - fun _presencePenalty() = presencePenalty - - @JsonProperty("response_format") - @ExcludeMissing - fun _responseFormat() = responseFormat - - @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice - - @JsonProperty("function_call") - @ExcludeMissing - fun _functionCall() = functionCall - - @JsonProperty("n") @ExcludeMissing fun _n() = n - - @JsonProperty("stop") @ExcludeMissing fun _stop() = stop - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat().map { it.validate() } - toolChoice() - functionCall() - n() - stop() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() - private var frequencyPenalty: JsonField = JsonMissing.of() - private var presencePenalty: JsonField = JsonMissing.of() - private var responseFormat: JsonField = JsonMissing.of() - private var toolChoice: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var n: JsonField = JsonMissing.of() - private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.useCache = unionMember0.useCache - this.temperature = unionMember0.temperature - this.topP = unionMember0.topP - this.maxTokens = unionMember0.maxTokens - this.frequencyPenalty = unionMember0.frequencyPenalty - this.presencePenalty = unionMember0.presencePenalty - this.responseFormat = unionMember0.responseFormat - this.toolChoice = unionMember0.toolChoice - this.functionCall = unionMember0.functionCall - this.n = unionMember0.n - this.stop = unionMember0.stop - additionalProperties(unionMember0.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - - @JsonProperty("max_tokens") - @ExcludeMissing - fun maxTokens(maxTokens: JsonField) = apply { - this.maxTokens = maxTokens - } - - fun frequencyPenalty(frequencyPenalty: Double) = - frequencyPenalty(JsonField.of(frequencyPenalty)) - - @JsonProperty("frequency_penalty") - @ExcludeMissing - fun frequencyPenalty(frequencyPenalty: JsonField) = apply { - this.frequencyPenalty = frequencyPenalty - } - - fun presencePenalty(presencePenalty: Double) = - presencePenalty(JsonField.of(presencePenalty)) - - @JsonProperty("presence_penalty") - @ExcludeMissing - fun presencePenalty(presencePenalty: JsonField) = apply { - this.presencePenalty = presencePenalty - } - - fun responseFormat(responseFormat: ResponseFormat) = - responseFormat(JsonField.of(responseFormat)) - - @JsonProperty("response_format") - @ExcludeMissing - fun responseFormat(responseFormat: JsonField) = apply { - this.responseFormat = responseFormat - } - - fun toolChoice(toolChoice: ToolChoice) = - toolChoice(JsonField.of(toolChoice)) - - @JsonProperty("tool_choice") - @ExcludeMissing - fun toolChoice(toolChoice: JsonField) = apply { - this.toolChoice = toolChoice - } - - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun n(n: Double) = n(JsonField.of(n)) - - @JsonProperty("n") - @ExcludeMissing - fun n(n: JsonField) = apply { this.n = n } - - fun stop(stop: List) = stop(JsonField.of(stop)) - - @JsonProperty("stop") - @ExcludeMissing - fun stop(stop: JsonField>) = apply { this.stop = stop } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember0 = - UnionMember0( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = FunctionCall.Deserializer::class) - @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val name: Name? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun name(): Optional = Optional.ofNullable(name) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isName(): Boolean = name != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asName(): Name = name.getOrThrow("name") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - name != null -> visitor.visitName(name) - else -> visitor.unknown(_json) - } - } - - fun validate(): FunctionCall = apply { - if (!validated) { - if (unionMember0 == null && unionMember1 == null && name == null) { - throw BraintrustInvalidDataException( - "Unknown FunctionCall: $_json" - ) - } - name?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCall && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.name == other.name - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - name, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" - unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" - name != null -> "FunctionCall{name=$name}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - FunctionCall(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - FunctionCall(unionMember1 = unionMember1) - - @JvmStatic fun ofName(name: Name) = FunctionCall(name = name) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitName(name: Name): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") - } - } - - class Deserializer : BaseDeserializer(FunctionCall::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionCall(name = it, _json = json) - } - - return FunctionCall(_json = json) - } - } - - class Serializer : BaseSerializer(FunctionCall::class) { - - override fun serialize( - value: FunctionCall, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.name != null -> generator.writeObject(value.name) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } - } - } - - class UnionMember0 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = UnionMember0(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 BraintrustInvalidDataException( - "Unknown UnionMember0: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - class UnionMember1 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = UnionMember1(JsonField.of("none")) - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> - throw BraintrustInvalidDataException( - "Unknown UnionMember1: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = Name.Builder::class) - @NoAutoDetect - class Name - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Name = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Name && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Name{name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - additionalProperties(name.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Name = - Name(name, additionalProperties.toUnmodifiable()) - } - } - } - - @JsonDeserialize(builder = ResponseFormat.Builder::class) - @NoAutoDetect - class ResponseFormat - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ResponseFormat = apply { - if (!validated) { - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = - "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(responseFormat: ResponseFormat) = apply { - this.type = responseFormat.type - additionalProperties(responseFormat.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): ResponseFormat = - ResponseFormat(type, additionalProperties.toUnmodifiable()) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val JSON_OBJECT = Type(JsonField.of("json_object")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - JSON_OBJECT, - } - - enum class Value { - JSON_OBJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(using = ToolChoice.Deserializer::class) - @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = - Optional.ofNullable(unionMember2) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } - } - - fun validate(): ToolChoice = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null - ) { - throw BraintrustInvalidDataException( - "Unknown ToolChoice: $_json" - ) - } - unionMember2?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ToolChoice && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" - unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" - unionMember2 != null -> "ToolChoice{unionMember2=$unionMember2}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - ToolChoice(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - ToolChoice(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - ToolChoice(unionMember2 = unionMember2) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") - } - } - - class Deserializer : BaseDeserializer(ToolChoice::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ToolChoice(unionMember2 = it, _json = json) - } - - return ToolChoice(_json = json) - } - } - - class Serializer : BaseSerializer(ToolChoice::class) { - - override fun serialize( - value: ToolChoice, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.unionMember2 != null -> - generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - } - - class UnionMember0 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = UnionMember0(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 BraintrustInvalidDataException( - "Unknown UnionMember0: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - class UnionMember1 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = UnionMember1(JsonField.of("none")) - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> - throw BraintrustInvalidDataException( - "Unknown UnionMember1: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val type: JsonField, - private val function: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun function(): Function = function.getRequired("function") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("function") @ExcludeMissing fun _function() = function - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - type() - function().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{type=$type, function=$function, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.function = unionMember2.function - additionalProperties(unionMember2.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun function(function: Function) = function(JsonField.of(function)) - - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { - this.function = function - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - type, - function, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Function = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.name = function.name - additionalProperties(function.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Function = - Function(name, additionalProperties.toUnmodifiable()) - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun maxTokens(): Double = maxTokens.getRequired("max_tokens") - - fun temperature(): Double = temperature.getRequired("temperature") - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - - fun stopSequences(): Optional> = - Optional.ofNullable(stopSequences.getNullable("stop_sequences")) - - /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = - Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - - @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK - - @JsonProperty("stop_sequences") - @ExcludeMissing - fun _stopSequences() = stopSequences - - /** This is a legacy parameter that should not be used. */ - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - fun _maxTokensToSample() = maxTokensToSample - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var stopSequences: JsonField> = JsonMissing.of() - private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.useCache = unionMember1.useCache - this.maxTokens = unionMember1.maxTokens - this.temperature = unionMember1.temperature - this.topP = unionMember1.topP - this.topK = unionMember1.topK - this.stopSequences = unionMember1.stopSequences - this.maxTokensToSample = unionMember1.maxTokensToSample - additionalProperties(unionMember1.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - - @JsonProperty("max_tokens") - @ExcludeMissing - fun maxTokens(maxTokens: JsonField) = apply { - this.maxTokens = maxTokens - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun topK(topK: Double) = topK(JsonField.of(topK)) - - @JsonProperty("top_k") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } - - fun stopSequences(stopSequences: List) = - stopSequences(JsonField.of(stopSequences)) - - @JsonProperty("stop_sequences") - @ExcludeMissing - fun stopSequences(stopSequences: JsonField>) = apply { - this.stopSequences = stopSequences - } - - /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = - maxTokensToSample(JsonField.of(maxTokensToSample)) - - /** This is a legacy parameter that should not be used. */ - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - fun maxTokensToSample(maxTokensToSample: JsonField) = apply { - this.maxTokensToSample = maxTokensToSample - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember1 = - UnionMember1( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Double = temperature.getRequired("temperature") - - fun maxOutputTokens(): Optional = - Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("maxOutputTokens") - @ExcludeMissing - fun _maxOutputTokens() = maxOutputTokens - - @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - - @JsonProperty("topK") @ExcludeMissing fun _topK() = topK - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var maxOutputTokens: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.useCache = unionMember2.useCache - this.temperature = unionMember2.temperature - this.maxOutputTokens = unionMember2.maxOutputTokens - this.topP = unionMember2.topP - this.topK = unionMember2.topK - additionalProperties(unionMember2.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun temperature(temperature: Double) = - temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun maxOutputTokens(maxOutputTokens: Double) = - maxOutputTokens(JsonField.of(maxOutputTokens)) - - @JsonProperty("maxOutputTokens") - @ExcludeMissing - fun maxOutputTokens(maxOutputTokens: JsonField) = apply { - this.maxOutputTokens = maxOutputTokens - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("topP") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun topK(topK: Double) = topK(JsonField.of(topK)) - - @JsonProperty("topK") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = UseCache.Builder::class) - @NoAutoDetect - class UseCache - private constructor( - private val useCache: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UseCache = apply { - if (!validated) { - useCache() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UseCache && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode - } - - override fun toString() = - "UseCache{useCache=$useCache, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(useCache: UseCache) = apply { - this.useCache = useCache.useCache - additionalProperties(useCache.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { - this.useCache = useCache - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UseCache = - UseCache(useCache, additionalProperties.toUnmodifiable()) - } - } - } - } - - @JsonDeserialize(builder = Origin.Builder::class) - @NoAutoDetect - class Origin - private constructor( - private val promptId: JsonField, - private val projectId: JsonField, - private val promptVersion: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun promptId(): Optional = - Optional.ofNullable(promptId.getNullable("prompt_id")) - - fun projectId(): Optional = - Optional.ofNullable(projectId.getNullable("project_id")) - - fun promptVersion(): Optional = - Optional.ofNullable(promptVersion.getNullable("prompt_version")) - - @JsonProperty("prompt_id") @ExcludeMissing fun _promptId() = promptId - - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - @JsonProperty("prompt_version") @ExcludeMissing fun _promptVersion() = promptVersion - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Origin = apply { - if (!validated) { - promptId() - projectId() - promptVersion() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var promptId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var promptVersion: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(origin: Origin) = apply { - this.promptId = origin.promptId - this.projectId = origin.projectId - this.promptVersion = origin.promptVersion - additionalProperties(origin.additionalProperties) - } - - fun promptId(promptId: String) = promptId(JsonField.of(promptId)) - - @JsonProperty("prompt_id") - @ExcludeMissing - fun promptId(promptId: JsonField) = apply { this.promptId = promptId } - - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - fun promptVersion(promptVersion: String) = - promptVersion(JsonField.of(promptVersion)) - - @JsonProperty("prompt_version") - @ExcludeMissing - fun promptVersion(promptVersion: JsonField) = apply { - this.promptVersion = promptVersion - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Origin = - Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(using = Prompt.Deserializer::class) - @JsonSerialize(using = Prompt.Serializer::class) - class Prompt - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val _reservedOnlyAllowNull: _ReservedOnlyAllowNull? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun _reservedOnlyAllowNull(): Optional<_ReservedOnlyAllowNull> = - Optional.ofNullable(_reservedOnlyAllowNull) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun is_ReservedOnlyAllowNull(): Boolean = _reservedOnlyAllowNull != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun as_ReservedOnlyAllowNull(): _ReservedOnlyAllowNull = - _reservedOnlyAllowNull.getOrThrow("_reservedOnlyAllowNull") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - _reservedOnlyAllowNull != null -> - visitor.visit_ReservedOnlyAllowNull(_reservedOnlyAllowNull) - else -> visitor.unknown(_json) - } - } - - fun validate(): Prompt = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - _reservedOnlyAllowNull == null - ) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - _reservedOnlyAllowNull?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this._reservedOnlyAllowNull == other._reservedOnlyAllowNull - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - _reservedOnlyAllowNull, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Prompt{unionMember0=$unionMember0}" - unionMember1 != null -> "Prompt{unionMember1=$unionMember1}" - _reservedOnlyAllowNull != null -> - "Prompt{_reservedOnlyAllowNull=$_reservedOnlyAllowNull}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Prompt(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Prompt(unionMember1 = unionMember1) - - @JvmStatic - fun of_ReservedOnlyAllowNull(_reservedOnlyAllowNull: _ReservedOnlyAllowNull) = - Prompt(_reservedOnlyAllowNull = _reservedOnlyAllowNull) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visit_ReservedOnlyAllowNull(_reservedOnlyAllowNull: _ReservedOnlyAllowNull): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") - } - } - - class Deserializer : BaseDeserializer(Prompt::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef<_ReservedOnlyAllowNull>()) { it.validate() } - ?.let { - return Prompt(_reservedOnlyAllowNull = it, _json = json) - } - - return Prompt(_json = json) - } - } - - class Serializer : BaseSerializer(Prompt::class) { - - override fun serialize( - value: Prompt, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value._reservedOnlyAllowNull != null -> - generator.writeObject(value._reservedOnlyAllowNull) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val type: JsonField, - private val content: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun content(): String = content.getRequired("content") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - type() - content() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{type=$type, content=$content, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.type = unionMember0.type - this.content = unionMember0.content - additionalProperties(unionMember0.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = - UnionMember0( - type, - content, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val COMPLETION = Type(JsonField.of("completion")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - COMPLETION, - } - - enum class Value { - COMPLETION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun messages(): List = messages.getRequired("messages") - - fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("messages") @ExcludeMissing fun _messages() = messages - - @JsonProperty("tools") @ExcludeMissing fun _tools() = tools - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - type() - messages() - tools() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var messages: JsonField> = JsonMissing.of() - private var tools: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.messages = unionMember1.messages - this.tools = unionMember1.tools - additionalProperties(unionMember1.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun messages(messages: List) = messages(JsonField.of(messages)) - - @JsonProperty("messages") - @ExcludeMissing - fun messages(messages: JsonField>) = apply { - this.messages = messages - } - - fun tools(tools: String) = tools(JsonField.of(tools)) - - @JsonProperty("tools") - @ExcludeMissing - fun tools(tools: JsonField) = apply { this.tools = tools } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = - UnionMember1( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Message.Deserializer::class) - @JsonSerialize(using = Message.Serializer::class) - class Message - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUnionMember3(): Boolean = unionMember3 != null - - fun isUnionMember4(): Boolean = unionMember4 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - else -> visitor.unknown(_json) - } - } - - fun validate(): Message = apply { - if (!validated) { - if ( - unionMember0 == null && - unionMember1 == null && - unionMember2 == null && - unionMember3 == null && - unionMember4 == null - ) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - unionMember4?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.unionMember4 == other.unionMember4 - } - - override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - ) - } - - override fun toString(): String { - return when { - unionMember0 != null -> "Message{unionMember0=$unionMember0}" - unionMember1 != null -> "Message{unionMember1=$unionMember1}" - unionMember2 != null -> "Message{unionMember2=$unionMember2}" - unionMember3 != null -> "Message{unionMember3=$unionMember3}" - unionMember4 != null -> "Message{unionMember4=$unionMember4}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - Message(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - Message(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - Message(unionMember2 = unionMember2) - - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = - Message(unionMember3 = unionMember3) - - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = - Message(unionMember4 = unionMember4) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUnionMember3(unionMember3: UnionMember3): T - - fun visitUnionMember4(unionMember4: UnionMember4): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") - } - } - - class Deserializer : BaseDeserializer(Message::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(unionMember4 = it, _json = json) - } - - return Message(_json = json) - } - } - - class Serializer : BaseSerializer(Message::class) { - - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value.unionMember2 != null -> - generator.writeObject(value.unionMember2) - value.unionMember3 != null -> - generator.writeObject(value.unionMember3) - value.unionMember4 != null -> - generator.writeObject(value.unionMember4) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.content = unionMember0.content - this.role = unionMember0.role - this.name = unionMember0.name - additionalProperties(unionMember0.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember0 = - UnionMember0( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SYSTEM = Role(JsonField.of("system")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - SYSTEM, - } - - enum class Value { - SYSTEM, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SYSTEM -> Known.SYSTEM - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.content = unionMember1.content - this.role = unionMember1.role - this.name = unionMember1.name - additionalProperties(unionMember1.additionalProperties) - } - - fun content(content: Content) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember1 = - UnionMember1( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val USER = Role(JsonField.of("user")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - USER, - } - - enum class Value { - USER, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - USER -> Known.USER - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(using = Content.Deserializer::class) - @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( - private val string: String? = null, - private val unnamedSchemaWithArrayParent5s: - List? = - null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun unnamedSchemaWithArrayParent5s(): - Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent5s) - - fun isString(): Boolean = string != null - - fun isUnnamedSchemaWithArrayParent5s(): Boolean = - unnamedSchemaWithArrayParent5s != null - - fun asString(): String = string.getOrThrow("string") - - fun asUnnamedSchemaWithArrayParent5s(): - List = - unnamedSchemaWithArrayParent5s.getOrThrow( - "unnamedSchemaWithArrayParent5s" - ) - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent5s != null -> - visitor.visitUnnamedSchemaWithArrayParent5s( - unnamedSchemaWithArrayParent5s - ) - else -> visitor.unknown(_json) - } - } - - fun validate(): Content = apply { - if (!validated) { - if (string == null && unnamedSchemaWithArrayParent5s == null) { - throw BraintrustInvalidDataException( - "Unknown Content: $_json" - ) - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent5s == - other.unnamedSchemaWithArrayParent5s - } - - override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent5s) - } - - override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent5s != null -> - "Content{unnamedSchemaWithArrayParent5s=$unnamedSchemaWithArrayParent5s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Content(string = string) - - @JvmStatic - fun ofUnnamedSchemaWithArrayParent5s( - unnamedSchemaWithArrayParent5s: - List - ) = - Content( - unnamedSchemaWithArrayParent5s = - unnamedSchemaWithArrayParent5s - ) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitUnnamedSchemaWithArrayParent5s( - unnamedSchemaWithArrayParent5s: - List - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") - } - } - - class Deserializer : BaseDeserializer(Content::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize( - node, - jacksonTypeRef>() - ) - ?.let { - return Content( - unnamedSchemaWithArrayParent5s = it, - _json = json - ) - } - - return Content(_json = json) - } - } - - class Serializer : BaseSerializer(Content::class) { - - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent5s != null -> - generator.writeObject( - value.unnamedSchemaWithArrayParent5s - ) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } - } - } - - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent5.Deserializer::class - ) - @JsonSerialize(using = UnnamedSchemaWithArrayParent5.Serializer::class) - class UnnamedSchemaWithArrayParent5 - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = - Optional.ofNullable(unionMember1) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun asUnionMember0(): UnionMember0 = - unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = - unionMember1.getOrThrow("unionMember1") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> - visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> - visitor.visitUnionMember1(unionMember1) - else -> visitor.unknown(_json) - } - } - - fun validate(): UnnamedSchemaWithArrayParent5 = apply { - if (!validated) { - if (unionMember0 == null && unionMember1 == null) { - throw BraintrustInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent5: $_json" - ) - } - unionMember0?.validate() - unionMember1?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent5 && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 - } - - override fun hashCode(): Int { - return Objects.hash(unionMember0, unionMember1) - } - - override fun toString(): String { - return when { - unionMember0 != null -> - "UnnamedSchemaWithArrayParent5{unionMember0=$unionMember0}" - unionMember1 != null -> - "UnnamedSchemaWithArrayParent5{unionMember1=$unionMember1}" - _json != null -> - "UnnamedSchemaWithArrayParent5{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent5" - ) - } - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - UnnamedSchemaWithArrayParent5(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - UnnamedSchemaWithArrayParent5(unionMember1 = unionMember1) - } - - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent5: $json" - ) - } - } - - class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent5::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent5 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return UnnamedSchemaWithArrayParent5( - unionMember0 = it, - _json = json - ) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return UnnamedSchemaWithArrayParent5( - unionMember1 = it, - _json = json - ) - } - - return UnnamedSchemaWithArrayParent5(_json = json) - } - } - - class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent5::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent5, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) - value.unionMember1 != null -> - generator.writeObject(value.unionMember1) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent5" - ) - } - } - } - - @JsonDeserialize(builder = UnionMember0.Builder::class) - @NoAutoDetect - class UnionMember0 - private constructor( - private val text: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun text(): Optional = - Optional.ofNullable(text.getNullable("text")) - - fun type(): Type = type.getRequired("type") - - @JsonProperty("text") @ExcludeMissing fun _text() = text - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember0 = apply { - if (!validated) { - text() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember0{text=$text, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var text: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.text = unionMember0.text - this.type = unionMember0.type - additionalProperties(unionMember0.additionalProperties) - } - - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { - this.text = text - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = - UnionMember0( - text, - type, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TEXT = Type(JsonField.of("text")) - - @JvmStatic - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - TEXT, - } - - enum class Value { - TEXT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TEXT -> Known.TEXT - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember1.Builder::class) - @NoAutoDetect - class UnionMember1 - private constructor( - private val imageUrl: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") - - fun type(): Type = type.getRequired("type") - - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl() = imageUrl - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): UnionMember1 = apply { - if (!validated) { - imageUrl().validate() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember1{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var imageUrl: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.imageUrl = unionMember1.imageUrl - this.type = unionMember1.type - additionalProperties(unionMember1.additionalProperties) - } - - fun imageUrl(imageUrl: ImageUrl) = - imageUrl(JsonField.of(imageUrl)) - - @JsonProperty("image_url") - @ExcludeMissing - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = - UnionMember1( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = ImageUrl.Builder::class) - @NoAutoDetect - class ImageUrl - private constructor( - private val url: JsonField, - private val detail: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun url(): String = url.getRequired("url") - - fun detail(): Optional = - Optional.ofNullable(detail.getNullable("detail")) - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonProperty("detail") - @ExcludeMissing - fun _detail() = detail - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): ImageUrl = apply { - if (!validated) { - url() - detail() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == - other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var url: JsonField = JsonMissing.of() - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(imageUrl: ImageUrl) = apply { - this.url = imageUrl.url - this.detail = imageUrl.detail - additionalProperties(imageUrl.additionalProperties) - } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { - this.url = url - } - - fun detail(detail: Detail) = - detail(JsonField.of(detail)) - - @JsonProperty("detail") - @ExcludeMissing - fun detail(detail: JsonField) = apply { - this.detail = detail - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll( - additionalProperties - ) - } - - @JsonAnySetter - fun putAdditionalProperty( - key: String, - value: JsonValue - ) = apply { this.additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun build(): ImageUrl = - ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) - } - - class Detail - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Detail && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = Detail(JsonField.of("auto")) - - @JvmField val LOW = Detail(JsonField.of("low")) - - @JvmField val HIGH = Detail(JsonField.of("high")) - - @JvmStatic - fun of(value: String) = Detail(JsonField.of(value)) - } - - enum class Known { - AUTO, - LOW, - HIGH, - } - - enum class Value { - AUTO, - LOW, - HIGH, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> - throw BraintrustInvalidDataException( - "Unknown Detail: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField - val IMAGE_URL = Type(JsonField.of("image_url")) - - @JvmStatic - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - IMAGE_URL, - } - - enum class Value { - IMAGE_URL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - } - } - - @JsonDeserialize(builder = UnionMember2.Builder::class) - @NoAutoDetect - class UnionMember2 - private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun role(): Role = role.getRequired("role") - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun toolCalls(): Optional> = - Optional.ofNullable(toolCalls.getNullable("tool_calls")) - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("function_call") - @ExcludeMissing - fun _functionCall() = functionCall - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember2 = apply { - if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember2{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var role: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.role = unionMember2.role - this.content = unionMember2.content - this.functionCall = unionMember2.functionCall - this.name = unionMember2.name - this.toolCalls = unionMember2.toolCalls - additionalProperties(unionMember2.additionalProperties) - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun toolCalls(toolCalls: List) = - toolCalls(JsonField.of(toolCalls)) - - @JsonProperty("tool_calls") - @ExcludeMissing - fun toolCalls(toolCalls: JsonField>) = apply { - this.toolCalls = toolCalls - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember2 = - UnionMember2( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val ASSISTANT = Role(JsonField.of("assistant")) - - @JvmStatic fun of(value: String) = Role(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 BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = FunctionCall.Builder::class) - @NoAutoDetect - class FunctionCall - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun arguments(): String = arguments.getRequired("arguments") - - fun name(): String = name.getRequired("name") - - @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): FunctionCall = apply { - if (!validated) { - arguments() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(functionCall: FunctionCall) = apply { - this.arguments = functionCall.arguments - this.name = functionCall.name - additionalProperties(functionCall.additionalProperties) - } - - fun arguments(arguments: String) = - arguments(JsonField.of(arguments)) - - @JsonProperty("arguments") - @ExcludeMissing - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): FunctionCall = - FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) - } - } - - @JsonDeserialize(builder = ToolCall.Builder::class) - @NoAutoDetect - class ToolCall - private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun id(): String = id.getRequired("id") - - fun function(): Function = function.getRequired("function") - - fun type(): Type = type.getRequired("type") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("function") @ExcludeMissing fun _function() = function - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): ToolCall = apply { - if (!validated) { - id() - function().validate() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(toolCall: ToolCall) = apply { - this.id = toolCall.id - this.function = toolCall.function - this.type = toolCall.type - additionalProperties(toolCall.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun function(function: Function) = function(JsonField.of(function)) - - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { - this.function = function - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): ToolCall = - ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun arguments(): String = arguments.getRequired("arguments") - - fun name(): String = name.getRequired("name") - - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments() = arguments - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Function = apply { - if (!validated) { - arguments() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.arguments = function.arguments - this.name = function.name - additionalProperties(function.additionalProperties) - } - - fun arguments(arguments: String) = - arguments(JsonField.of(arguments)) - - @JsonProperty("arguments") - @ExcludeMissing - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Function = - Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - @JsonDeserialize(builder = UnionMember3.Builder::class) - @NoAutoDetect - class UnionMember3 - private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun toolCallId(): String = toolCallId.getRequired("tool_call_id") - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember3 = apply { - if (!validated) { - content() - role() - toolCallId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember3{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.content = unionMember3.content - this.role = unionMember3.role - this.toolCallId = unionMember3.toolCallId - additionalProperties(unionMember3.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun toolCallId(toolCallId: String) = - toolCallId(JsonField.of(toolCallId)) - - @JsonProperty("tool_call_id") - @ExcludeMissing - fun toolCallId(toolCallId: JsonField) = apply { - this.toolCallId = toolCallId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember3 = - UnionMember3( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TOOL = Role(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - TOOL, - } - - enum class Value { - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TOOL -> Known.TOOL - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = UnionMember4.Builder::class) - @NoAutoDetect - class UnionMember4 - private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun name(): String = name.getRequired("name") - - fun role(): Role = role.getRequired("role") - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnionMember4 = apply { - if (!validated) { - content() - name() - role() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember4 && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "UnionMember4{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - this.content = unionMember4.content - this.name = unionMember4.name - this.role = unionMember4.role - additionalProperties(unionMember4.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): UnionMember4 = - UnionMember4( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Role(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val CHAT = Type(JsonField.of("chat")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - CHAT, - } - - enum class Value { - CHAT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = _ReservedOnlyAllowNull.Builder::class) - @NoAutoDetect - class _ReservedOnlyAllowNull - private constructor( - private val _reservedOnlyAllowNull: JsonValue, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * This is just a placeholder nullable object. Only pass null, not the object itself - */ - @JsonProperty("__reserved_only_allow_null") - @ExcludeMissing - fun __reservedOnlyAllowNull() = _reservedOnlyAllowNull - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): _ReservedOnlyAllowNull = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is _ReservedOnlyAllowNull && - this._reservedOnlyAllowNull == other._reservedOnlyAllowNull && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(_reservedOnlyAllowNull, additionalProperties) - } - return hashCode - } - - override fun toString() = - "_ReservedOnlyAllowNull{_reservedOnlyAllowNull=$_reservedOnlyAllowNull, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var _reservedOnlyAllowNull: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(_reservedOnlyAllowNull: _ReservedOnlyAllowNull) = apply { - this._reservedOnlyAllowNull = _reservedOnlyAllowNull._reservedOnlyAllowNull - additionalProperties(_reservedOnlyAllowNull.additionalProperties) - } - - /** - * This is just a placeholder nullable object. Only pass null, not the object - * itself - */ - @JsonProperty("__reserved_only_allow_null") - @ExcludeMissing - fun _reservedOnlyAllowNull(_reservedOnlyAllowNull: JsonValue) = apply { - this._reservedOnlyAllowNull = _reservedOnlyAllowNull - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): _ReservedOnlyAllowNull = - _ReservedOnlyAllowNull( - _reservedOnlyAllowNull, - additionalProperties.toUnmodifiable() - ) - } - } - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptServiceAsync.kt index 16a6ff1..654b335 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptServiceAsync.kt @@ -5,19 +5,15 @@ package com.braintrust.api.services.async import com.braintrust.api.core.RequestOptions +import com.braintrust.api.models.Prompt import com.braintrust.api.models.PromptCreateParams -import com.braintrust.api.models.PromptCreateResponse import com.braintrust.api.models.PromptDeleteParams -import com.braintrust.api.models.PromptDeleteResponse import com.braintrust.api.models.PromptFeedbackParams import com.braintrust.api.models.PromptListPageAsync import com.braintrust.api.models.PromptListParams import com.braintrust.api.models.PromptReplaceParams -import com.braintrust.api.models.PromptReplaceResponse import com.braintrust.api.models.PromptRetrieveParams -import com.braintrust.api.models.PromptRetrieveResponse import com.braintrust.api.models.PromptUpdateParams -import com.braintrust.api.models.PromptUpdateResponse import java.util.concurrent.CompletableFuture interface PromptServiceAsync { @@ -30,14 +26,14 @@ interface PromptServiceAsync { fun create( params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Get a prompt object by its id */ @JvmOverloads fun retrieve( params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** * Partially update a prompt object. Specify the fields to update in the payload. Any @@ -48,7 +44,7 @@ interface PromptServiceAsync { fun update( params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** * List out all prompts. The prompts are sorted by creation date, with the most recently-created @@ -65,7 +61,7 @@ interface PromptServiceAsync { fun delete( params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Log feedback for a set of prompt events */ @JvmOverloads @@ -84,5 +80,5 @@ interface PromptServiceAsync { fun replace( params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptServiceAsyncImpl.kt index f967be3..a0f610d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptServiceAsyncImpl.kt @@ -8,19 +8,15 @@ import com.braintrust.api.core.http.HttpMethod import com.braintrust.api.core.http.HttpRequest import com.braintrust.api.core.http.HttpResponse.Handler import com.braintrust.api.errors.BraintrustError +import com.braintrust.api.models.Prompt import com.braintrust.api.models.PromptCreateParams -import com.braintrust.api.models.PromptCreateResponse import com.braintrust.api.models.PromptDeleteParams -import com.braintrust.api.models.PromptDeleteResponse import com.braintrust.api.models.PromptFeedbackParams import com.braintrust.api.models.PromptListPageAsync import com.braintrust.api.models.PromptListParams import com.braintrust.api.models.PromptReplaceParams -import com.braintrust.api.models.PromptReplaceResponse import com.braintrust.api.models.PromptRetrieveParams -import com.braintrust.api.models.PromptRetrieveResponse import com.braintrust.api.models.PromptUpdateParams -import com.braintrust.api.models.PromptUpdateResponse import com.braintrust.api.services.emptyHandler import com.braintrust.api.services.errorHandler import com.braintrust.api.services.json @@ -35,8 +31,8 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** * Create a new prompt. If there is an existing prompt in the project with the same slug as the @@ -45,7 +41,7 @@ constructor( override fun create( params: PromptCreateParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -67,14 +63,14 @@ constructor( } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a prompt object by its id */ override fun retrieve( params: PromptRetrieveParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -95,8 +91,8 @@ constructor( } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** * Partially update a prompt object. Specify the fields to update in the payload. Any @@ -106,7 +102,7 @@ constructor( override fun update( params: PromptUpdateParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.PATCH) @@ -161,14 +157,14 @@ constructor( } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a prompt object by its id */ override fun delete( params: PromptDeleteParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -212,8 +208,8 @@ constructor( } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** * NOTE: This operation is deprecated and will be removed in a future revision of the API. @@ -224,7 +220,7 @@ constructor( override fun replace( params: PromptReplaceParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.PUT) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptSessionServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptSessionServiceAsync.kt deleted file mode 100644 index 511cbde..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptSessionServiceAsync.kt +++ /dev/null @@ -1,7 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.braintrust.api.services.async - -interface PromptSessionServiceAsync diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptSessionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptSessionServiceAsyncImpl.kt deleted file mode 100644 index f7f3d70..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/async/PromptSessionServiceAsyncImpl.kt +++ /dev/null @@ -1,16 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrust.api.services.async - -import com.braintrust.api.core.ClientOptions -import com.braintrust.api.core.http.HttpResponse.Handler -import com.braintrust.api.errors.BraintrustError -import com.braintrust.api.services.errorHandler - -class PromptSessionServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : PromptSessionServiceAsync { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptService.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptService.kt index 0ae5cd0..a9fbdfe 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptService.kt @@ -5,19 +5,15 @@ package com.braintrust.api.services.blocking import com.braintrust.api.core.RequestOptions +import com.braintrust.api.models.Prompt import com.braintrust.api.models.PromptCreateParams -import com.braintrust.api.models.PromptCreateResponse import com.braintrust.api.models.PromptDeleteParams -import com.braintrust.api.models.PromptDeleteResponse import com.braintrust.api.models.PromptFeedbackParams import com.braintrust.api.models.PromptListPage import com.braintrust.api.models.PromptListParams import com.braintrust.api.models.PromptReplaceParams -import com.braintrust.api.models.PromptReplaceResponse import com.braintrust.api.models.PromptRetrieveParams -import com.braintrust.api.models.PromptRetrieveResponse import com.braintrust.api.models.PromptUpdateParams -import com.braintrust.api.models.PromptUpdateResponse interface PromptService { @@ -29,14 +25,14 @@ interface PromptService { fun create( params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none() - ): PromptCreateResponse + ): Prompt /** Get a prompt object by its id */ @JvmOverloads fun retrieve( params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none() - ): PromptRetrieveResponse + ): Prompt /** * Partially update a prompt object. Specify the fields to update in the payload. Any @@ -47,7 +43,7 @@ interface PromptService { fun update( params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none() - ): PromptUpdateResponse + ): Prompt /** * List out all prompts. The prompts are sorted by creation date, with the most recently-created @@ -64,7 +60,7 @@ interface PromptService { fun delete( params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none() - ): PromptDeleteResponse + ): Prompt /** Log feedback for a set of prompt events */ @JvmOverloads @@ -83,5 +79,5 @@ interface PromptService { fun replace( params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none() - ): PromptReplaceResponse + ): Prompt } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptServiceImpl.kt index e8726b3..dafd50b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptServiceImpl.kt @@ -8,19 +8,15 @@ import com.braintrust.api.core.http.HttpMethod import com.braintrust.api.core.http.HttpRequest import com.braintrust.api.core.http.HttpResponse.Handler import com.braintrust.api.errors.BraintrustError +import com.braintrust.api.models.Prompt import com.braintrust.api.models.PromptCreateParams -import com.braintrust.api.models.PromptCreateResponse import com.braintrust.api.models.PromptDeleteParams -import com.braintrust.api.models.PromptDeleteResponse import com.braintrust.api.models.PromptFeedbackParams import com.braintrust.api.models.PromptListPage import com.braintrust.api.models.PromptListParams import com.braintrust.api.models.PromptReplaceParams -import com.braintrust.api.models.PromptReplaceResponse import com.braintrust.api.models.PromptRetrieveParams -import com.braintrust.api.models.PromptRetrieveResponse import com.braintrust.api.models.PromptUpdateParams -import com.braintrust.api.models.PromptUpdateResponse import com.braintrust.api.services.emptyHandler import com.braintrust.api.services.errorHandler import com.braintrust.api.services.json @@ -34,17 +30,14 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** * Create a new prompt. If there is an existing prompt in the project with the same slug as the * one specified in the request, will return the existing prompt unmodified */ - override fun create( - params: PromptCreateParams, - requestOptions: RequestOptions - ): PromptCreateResponse { + override fun create(params: PromptCreateParams, requestOptions: RequestOptions): Prompt { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -65,14 +58,11 @@ constructor( } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a prompt object by its id */ - override fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions - ): PromptRetrieveResponse { + override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): Prompt { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -92,18 +82,15 @@ constructor( } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** * Partially update a prompt object. Specify the fields to update in the payload. Any * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - override fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions - ): PromptUpdateResponse { + override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): Prompt { val request = HttpRequest.builder() .method(HttpMethod.PATCH) @@ -153,14 +140,11 @@ constructor( } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a prompt object by its id */ - override fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions - ): PromptDeleteResponse { + override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): Prompt { val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -199,8 +183,8 @@ constructor( } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** * NOTE: This operation is deprecated and will be removed in a future revision of the API. @@ -208,10 +192,7 @@ constructor( * slug as the one specified in the request, will return the existing prompt unmodified, will * replace the existing prompt with the provided fields */ - override fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions - ): PromptReplaceResponse { + override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): Prompt { val request = HttpRequest.builder() .method(HttpMethod.PUT) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptSessionService.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptSessionService.kt deleted file mode 100644 index d54fc9e..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptSessionService.kt +++ /dev/null @@ -1,7 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.braintrust.api.services.blocking - -interface PromptSessionService diff --git a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptSessionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptSessionServiceImpl.kt deleted file mode 100644 index 8ebf083..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrust/api/services/blocking/PromptSessionServiceImpl.kt +++ /dev/null @@ -1,16 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrust.api.services.blocking - -import com.braintrust.api.core.ClientOptions -import com.braintrust.api.core.http.HttpResponse.Handler -import com.braintrust.api.errors.BraintrustError -import com.braintrust.api.services.errorHandler - -class PromptSessionServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : PromptSessionService { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptCreateResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptCreateResponseTest.kt deleted file mode 100644 index 97081fd..0000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptCreateResponseTest.kt +++ /dev/null @@ -1,209 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrust.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PromptCreateResponseTest { - - @Test - fun createPromptCreateResponse() { - val promptCreateResponse = - PromptCreateResponse.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._xactId("string") - .logId(PromptCreateResponse.LogId.P) - .name("string") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("string") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("string") - .metadata(PromptCreateResponse.Metadata.builder().build()) - .promptData( - PromptCreateResponse.PromptData.builder() - .options( - PromptCreateResponse.PromptData.Options.builder() - .model("string") - .params( - PromptCreateResponse.PromptData.Options.Params.ofUnionMember0( - PromptCreateResponse.PromptData.Options.Params.UnionMember0 - .builder() - .frequencyPenalty(42.23) - .functionCall( - PromptCreateResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .ofUnionMember0( - PromptCreateResponse.PromptData.Options - .Params - .UnionMember0 - .FunctionCall - .UnionMember0 - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptCreateResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .builder() - .type( - PromptCreateResponse.PromptData.Options - .Params - .UnionMember0 - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptCreateResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .ofUnionMember0( - PromptCreateResponse.PromptData.Options - .Params - .UnionMember0 - .ToolChoice - .UnionMember0 - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("string") - .build() - ) - .origin( - PromptCreateResponse.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") - .build() - ) - .prompt( - PromptCreateResponse.PromptData.Prompt.ofUnionMember0( - PromptCreateResponse.PromptData.Prompt.UnionMember0.builder() - .content("string") - .type( - PromptCreateResponse.PromptData.Prompt.UnionMember0.Type - .COMPLETION - ) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(promptCreateResponse).isNotNull - assertThat(promptCreateResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptCreateResponse._xactId()).isEqualTo("string") - assertThat(promptCreateResponse.logId()).isEqualTo(PromptCreateResponse.LogId.P) - assertThat(promptCreateResponse.name()).isEqualTo("string") - assertThat(promptCreateResponse.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptCreateResponse.projectId()) - .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptCreateResponse.slug()).isEqualTo("string") - assertThat(promptCreateResponse.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(promptCreateResponse.description()).contains("string") - assertThat(promptCreateResponse.metadata()) - .contains(PromptCreateResponse.Metadata.builder().build()) - assertThat(promptCreateResponse.promptData()) - .contains( - PromptCreateResponse.PromptData.builder() - .options( - PromptCreateResponse.PromptData.Options.builder() - .model("string") - .params( - PromptCreateResponse.PromptData.Options.Params.ofUnionMember0( - PromptCreateResponse.PromptData.Options.Params.UnionMember0 - .builder() - .frequencyPenalty(42.23) - .functionCall( - PromptCreateResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .ofUnionMember0( - PromptCreateResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .UnionMember0 - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptCreateResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .builder() - .type( - PromptCreateResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptCreateResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .ofUnionMember0( - PromptCreateResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .UnionMember0 - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("string") - .build() - ) - .origin( - PromptCreateResponse.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") - .build() - ) - .prompt( - PromptCreateResponse.PromptData.Prompt.ofUnionMember0( - PromptCreateResponse.PromptData.Prompt.UnionMember0.builder() - .content("string") - .type( - PromptCreateResponse.PromptData.Prompt.UnionMember0.Type - .COMPLETION - ) - .build() - ) - ) - .build() - ) - assertThat(promptCreateResponse.tags().get()).containsExactly("string") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptDeleteResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptDeleteResponseTest.kt deleted file mode 100644 index feea81c..0000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptDeleteResponseTest.kt +++ /dev/null @@ -1,209 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrust.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PromptDeleteResponseTest { - - @Test - fun createPromptDeleteResponse() { - val promptDeleteResponse = - PromptDeleteResponse.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._xactId("string") - .logId(PromptDeleteResponse.LogId.P) - .name("string") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("string") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("string") - .metadata(PromptDeleteResponse.Metadata.builder().build()) - .promptData( - PromptDeleteResponse.PromptData.builder() - .options( - PromptDeleteResponse.PromptData.Options.builder() - .model("string") - .params( - PromptDeleteResponse.PromptData.Options.Params.ofUnionMember0( - PromptDeleteResponse.PromptData.Options.Params.UnionMember0 - .builder() - .frequencyPenalty(42.23) - .functionCall( - PromptDeleteResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .ofUnionMember0( - PromptDeleteResponse.PromptData.Options - .Params - .UnionMember0 - .FunctionCall - .UnionMember0 - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptDeleteResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .builder() - .type( - PromptDeleteResponse.PromptData.Options - .Params - .UnionMember0 - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptDeleteResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .ofUnionMember0( - PromptDeleteResponse.PromptData.Options - .Params - .UnionMember0 - .ToolChoice - .UnionMember0 - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("string") - .build() - ) - .origin( - PromptDeleteResponse.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") - .build() - ) - .prompt( - PromptDeleteResponse.PromptData.Prompt.ofUnionMember0( - PromptDeleteResponse.PromptData.Prompt.UnionMember0.builder() - .content("string") - .type( - PromptDeleteResponse.PromptData.Prompt.UnionMember0.Type - .COMPLETION - ) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(promptDeleteResponse).isNotNull - assertThat(promptDeleteResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptDeleteResponse._xactId()).isEqualTo("string") - assertThat(promptDeleteResponse.logId()).isEqualTo(PromptDeleteResponse.LogId.P) - assertThat(promptDeleteResponse.name()).isEqualTo("string") - assertThat(promptDeleteResponse.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptDeleteResponse.projectId()) - .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptDeleteResponse.slug()).isEqualTo("string") - assertThat(promptDeleteResponse.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(promptDeleteResponse.description()).contains("string") - assertThat(promptDeleteResponse.metadata()) - .contains(PromptDeleteResponse.Metadata.builder().build()) - assertThat(promptDeleteResponse.promptData()) - .contains( - PromptDeleteResponse.PromptData.builder() - .options( - PromptDeleteResponse.PromptData.Options.builder() - .model("string") - .params( - PromptDeleteResponse.PromptData.Options.Params.ofUnionMember0( - PromptDeleteResponse.PromptData.Options.Params.UnionMember0 - .builder() - .frequencyPenalty(42.23) - .functionCall( - PromptDeleteResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .ofUnionMember0( - PromptDeleteResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .UnionMember0 - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptDeleteResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .builder() - .type( - PromptDeleteResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptDeleteResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .ofUnionMember0( - PromptDeleteResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .UnionMember0 - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("string") - .build() - ) - .origin( - PromptDeleteResponse.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") - .build() - ) - .prompt( - PromptDeleteResponse.PromptData.Prompt.ofUnionMember0( - PromptDeleteResponse.PromptData.Prompt.UnionMember0.builder() - .content("string") - .type( - PromptDeleteResponse.PromptData.Prompt.UnionMember0.Type - .COMPLETION - ) - .build() - ) - ) - .build() - ) - assertThat(promptDeleteResponse.tags().get()).containsExactly("string") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptReplaceResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptReplaceResponseTest.kt deleted file mode 100644 index d5fc7f1..0000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptReplaceResponseTest.kt +++ /dev/null @@ -1,209 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrust.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PromptReplaceResponseTest { - - @Test - fun createPromptReplaceResponse() { - val promptReplaceResponse = - PromptReplaceResponse.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._xactId("string") - .logId(PromptReplaceResponse.LogId.P) - .name("string") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("string") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("string") - .metadata(PromptReplaceResponse.Metadata.builder().build()) - .promptData( - PromptReplaceResponse.PromptData.builder() - .options( - PromptReplaceResponse.PromptData.Options.builder() - .model("string") - .params( - PromptReplaceResponse.PromptData.Options.Params.ofUnionMember0( - PromptReplaceResponse.PromptData.Options.Params.UnionMember0 - .builder() - .frequencyPenalty(42.23) - .functionCall( - PromptReplaceResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .ofUnionMember0( - PromptReplaceResponse.PromptData.Options - .Params - .UnionMember0 - .FunctionCall - .UnionMember0 - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptReplaceResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .builder() - .type( - PromptReplaceResponse.PromptData.Options - .Params - .UnionMember0 - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptReplaceResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .ofUnionMember0( - PromptReplaceResponse.PromptData.Options - .Params - .UnionMember0 - .ToolChoice - .UnionMember0 - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("string") - .build() - ) - .origin( - PromptReplaceResponse.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") - .build() - ) - .prompt( - PromptReplaceResponse.PromptData.Prompt.ofUnionMember0( - PromptReplaceResponse.PromptData.Prompt.UnionMember0.builder() - .content("string") - .type( - PromptReplaceResponse.PromptData.Prompt.UnionMember0.Type - .COMPLETION - ) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(promptReplaceResponse).isNotNull - assertThat(promptReplaceResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptReplaceResponse._xactId()).isEqualTo("string") - assertThat(promptReplaceResponse.logId()).isEqualTo(PromptReplaceResponse.LogId.P) - assertThat(promptReplaceResponse.name()).isEqualTo("string") - assertThat(promptReplaceResponse.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptReplaceResponse.projectId()) - .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptReplaceResponse.slug()).isEqualTo("string") - assertThat(promptReplaceResponse.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(promptReplaceResponse.description()).contains("string") - assertThat(promptReplaceResponse.metadata()) - .contains(PromptReplaceResponse.Metadata.builder().build()) - assertThat(promptReplaceResponse.promptData()) - .contains( - PromptReplaceResponse.PromptData.builder() - .options( - PromptReplaceResponse.PromptData.Options.builder() - .model("string") - .params( - PromptReplaceResponse.PromptData.Options.Params.ofUnionMember0( - PromptReplaceResponse.PromptData.Options.Params.UnionMember0 - .builder() - .frequencyPenalty(42.23) - .functionCall( - PromptReplaceResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .ofUnionMember0( - PromptReplaceResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .UnionMember0 - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptReplaceResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .builder() - .type( - PromptReplaceResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptReplaceResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .ofUnionMember0( - PromptReplaceResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .UnionMember0 - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("string") - .build() - ) - .origin( - PromptReplaceResponse.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") - .build() - ) - .prompt( - PromptReplaceResponse.PromptData.Prompt.ofUnionMember0( - PromptReplaceResponse.PromptData.Prompt.UnionMember0.builder() - .content("string") - .type( - PromptReplaceResponse.PromptData.Prompt.UnionMember0.Type - .COMPLETION - ) - .build() - ) - ) - .build() - ) - assertThat(promptReplaceResponse.tags().get()).containsExactly("string") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptRetrieveResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptRetrieveResponseTest.kt deleted file mode 100644 index dbc8a63..0000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptRetrieveResponseTest.kt +++ /dev/null @@ -1,210 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrust.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PromptRetrieveResponseTest { - - @Test - fun createPromptRetrieveResponse() { - val promptRetrieveResponse = - PromptRetrieveResponse.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._xactId("string") - .logId(PromptRetrieveResponse.LogId.P) - .name("string") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("string") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("string") - .metadata(PromptRetrieveResponse.Metadata.builder().build()) - .promptData( - PromptRetrieveResponse.PromptData.builder() - .options( - PromptRetrieveResponse.PromptData.Options.builder() - .model("string") - .params( - PromptRetrieveResponse.PromptData.Options.Params.ofUnionMember0( - PromptRetrieveResponse.PromptData.Options.Params - .UnionMember0 - .builder() - .frequencyPenalty(42.23) - .functionCall( - PromptRetrieveResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .ofUnionMember0( - PromptRetrieveResponse.PromptData.Options - .Params - .UnionMember0 - .FunctionCall - .UnionMember0 - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptRetrieveResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .builder() - .type( - PromptRetrieveResponse.PromptData.Options - .Params - .UnionMember0 - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptRetrieveResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .ofUnionMember0( - PromptRetrieveResponse.PromptData.Options - .Params - .UnionMember0 - .ToolChoice - .UnionMember0 - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("string") - .build() - ) - .origin( - PromptRetrieveResponse.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") - .build() - ) - .prompt( - PromptRetrieveResponse.PromptData.Prompt.ofUnionMember0( - PromptRetrieveResponse.PromptData.Prompt.UnionMember0.builder() - .content("string") - .type( - PromptRetrieveResponse.PromptData.Prompt.UnionMember0.Type - .COMPLETION - ) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(promptRetrieveResponse).isNotNull - assertThat(promptRetrieveResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptRetrieveResponse._xactId()).isEqualTo("string") - assertThat(promptRetrieveResponse.logId()).isEqualTo(PromptRetrieveResponse.LogId.P) - assertThat(promptRetrieveResponse.name()).isEqualTo("string") - assertThat(promptRetrieveResponse.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptRetrieveResponse.projectId()) - .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptRetrieveResponse.slug()).isEqualTo("string") - assertThat(promptRetrieveResponse.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(promptRetrieveResponse.description()).contains("string") - assertThat(promptRetrieveResponse.metadata()) - .contains(PromptRetrieveResponse.Metadata.builder().build()) - assertThat(promptRetrieveResponse.promptData()) - .contains( - PromptRetrieveResponse.PromptData.builder() - .options( - PromptRetrieveResponse.PromptData.Options.builder() - .model("string") - .params( - PromptRetrieveResponse.PromptData.Options.Params.ofUnionMember0( - PromptRetrieveResponse.PromptData.Options.Params.UnionMember0 - .builder() - .frequencyPenalty(42.23) - .functionCall( - PromptRetrieveResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .ofUnionMember0( - PromptRetrieveResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .UnionMember0 - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptRetrieveResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .builder() - .type( - PromptRetrieveResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptRetrieveResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .ofUnionMember0( - PromptRetrieveResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .UnionMember0 - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("string") - .build() - ) - .origin( - PromptRetrieveResponse.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") - .build() - ) - .prompt( - PromptRetrieveResponse.PromptData.Prompt.ofUnionMember0( - PromptRetrieveResponse.PromptData.Prompt.UnionMember0.builder() - .content("string") - .type( - PromptRetrieveResponse.PromptData.Prompt.UnionMember0.Type - .COMPLETION - ) - .build() - ) - ) - .build() - ) - assertThat(promptRetrieveResponse.tags().get()).containsExactly("string") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptListResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptTest.kt similarity index 59% rename from braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptListResponseTest.kt rename to braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptTest.kt index 9490c4e..83e9e4e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptListResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptTest.kt @@ -6,38 +6,36 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class PromptListResponseTest { +class PromptTest { @Test - fun createPromptListResponse() { - val promptListResponse = - PromptListResponse.builder() + fun createPrompt() { + val prompt = + Prompt.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") ._xactId("string") - .logId(PromptListResponse.LogId.P) + .logId(Prompt.LogId.P) .name("string") .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("string") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("string") - .metadata(PromptListResponse.Metadata.builder().build()) + .metadata(Prompt.Metadata.builder().build()) .promptData( - PromptListResponse.PromptData.builder() + Prompt.PromptData.builder() .options( - PromptListResponse.PromptData.Options.builder() + Prompt.PromptData.Options.builder() .model("string") .params( - PromptListResponse.PromptData.Options.Params.ofUnionMember0( - PromptListResponse.PromptData.Options.Params.UnionMember0 - .builder() + Prompt.PromptData.Options.Params.ofUnionMember0( + Prompt.PromptData.Options.Params.UnionMember0.builder() .frequencyPenalty(42.23) .functionCall( - PromptListResponse.PromptData.Options.Params - .UnionMember0 + Prompt.PromptData.Options.Params.UnionMember0 .FunctionCall .ofUnionMember0( - PromptListResponse.PromptData.Options.Params + Prompt.PromptData.Options.Params .UnionMember0 .FunctionCall .UnionMember0 @@ -48,12 +46,11 @@ class PromptListResponseTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptListResponse.PromptData.Options.Params - .UnionMember0 + Prompt.PromptData.Options.Params.UnionMember0 .ResponseFormat .builder() .type( - PromptListResponse.PromptData.Options.Params + Prompt.PromptData.Options.Params .UnionMember0 .ResponseFormat .Type @@ -64,11 +61,10 @@ class PromptListResponseTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptListResponse.PromptData.Options.Params - .UnionMember0 + Prompt.PromptData.Options.Params.UnionMember0 .ToolChoice .ofUnionMember0( - PromptListResponse.PromptData.Options.Params + Prompt.PromptData.Options.Params .UnionMember0 .ToolChoice .UnionMember0 @@ -84,20 +80,17 @@ class PromptListResponseTest { .build() ) .origin( - PromptListResponse.PromptData.Origin.builder() + Prompt.PromptData.Origin.builder() .projectId("string") .promptId("string") .promptVersion("string") .build() ) .prompt( - PromptListResponse.PromptData.Prompt.ofUnionMember0( - PromptListResponse.PromptData.Prompt.UnionMember0.builder() + Prompt.PromptData.Prompt.ofUnionMember0( + Prompt.PromptData.Prompt.UnionMember0.builder() .content("string") - .type( - PromptListResponse.PromptData.Prompt.UnionMember0.Type - .COMPLETION - ) + .type(Prompt.PromptData.Prompt.UnionMember0.Type.COMPLETION) .build() ) ) @@ -105,37 +98,32 @@ class PromptListResponseTest { ) .tags(listOf("string")) .build() - assertThat(promptListResponse).isNotNull - assertThat(promptListResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptListResponse._xactId()).isEqualTo("string") - assertThat(promptListResponse.logId()).isEqualTo(PromptListResponse.LogId.P) - assertThat(promptListResponse.name()).isEqualTo("string") - assertThat(promptListResponse.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptListResponse.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptListResponse.slug()).isEqualTo("string") - assertThat(promptListResponse.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(promptListResponse.description()).contains("string") - assertThat(promptListResponse.metadata()) - .contains(PromptListResponse.Metadata.builder().build()) - assertThat(promptListResponse.promptData()) + assertThat(prompt).isNotNull + assertThat(prompt.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(prompt._xactId()).isEqualTo("string") + assertThat(prompt.logId()).isEqualTo(Prompt.LogId.P) + assertThat(prompt.name()).isEqualTo("string") + assertThat(prompt.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(prompt.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(prompt.slug()).isEqualTo("string") + assertThat(prompt.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(prompt.description()).contains("string") + assertThat(prompt.metadata()).contains(Prompt.Metadata.builder().build()) + assertThat(prompt.promptData()) .contains( - PromptListResponse.PromptData.builder() + Prompt.PromptData.builder() .options( - PromptListResponse.PromptData.Options.builder() + Prompt.PromptData.Options.builder() .model("string") .params( - PromptListResponse.PromptData.Options.Params.ofUnionMember0( - PromptListResponse.PromptData.Options.Params.UnionMember0 - .builder() + Prompt.PromptData.Options.Params.ofUnionMember0( + Prompt.PromptData.Options.Params.UnionMember0.builder() .frequencyPenalty(42.23) .functionCall( - PromptListResponse.PromptData.Options.Params - .UnionMember0 + Prompt.PromptData.Options.Params.UnionMember0 .FunctionCall .ofUnionMember0( - PromptListResponse.PromptData.Options.Params - .UnionMember0 + Prompt.PromptData.Options.Params.UnionMember0 .FunctionCall .UnionMember0 .AUTO @@ -145,13 +133,11 @@ class PromptListResponseTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptListResponse.PromptData.Options.Params - .UnionMember0 + Prompt.PromptData.Options.Params.UnionMember0 .ResponseFormat .builder() .type( - PromptListResponse.PromptData.Options.Params - .UnionMember0 + Prompt.PromptData.Options.Params.UnionMember0 .ResponseFormat .Type .JSON_OBJECT @@ -161,12 +147,9 @@ class PromptListResponseTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptListResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice + Prompt.PromptData.Options.Params.UnionMember0.ToolChoice .ofUnionMember0( - PromptListResponse.PromptData.Options.Params - .UnionMember0 + Prompt.PromptData.Options.Params.UnionMember0 .ToolChoice .UnionMember0 .AUTO @@ -181,25 +164,22 @@ class PromptListResponseTest { .build() ) .origin( - PromptListResponse.PromptData.Origin.builder() + Prompt.PromptData.Origin.builder() .projectId("string") .promptId("string") .promptVersion("string") .build() ) .prompt( - PromptListResponse.PromptData.Prompt.ofUnionMember0( - PromptListResponse.PromptData.Prompt.UnionMember0.builder() + Prompt.PromptData.Prompt.ofUnionMember0( + Prompt.PromptData.Prompt.UnionMember0.builder() .content("string") - .type( - PromptListResponse.PromptData.Prompt.UnionMember0.Type - .COMPLETION - ) + .type(Prompt.PromptData.Prompt.UnionMember0.Type.COMPLETION) .build() ) ) .build() ) - assertThat(promptListResponse.tags().get()).containsExactly("string") + assertThat(prompt.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptUpdateResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptUpdateResponseTest.kt deleted file mode 100644 index 953410a..0000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrust/api/models/PromptUpdateResponseTest.kt +++ /dev/null @@ -1,209 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrust.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PromptUpdateResponseTest { - - @Test - fun createPromptUpdateResponse() { - val promptUpdateResponse = - PromptUpdateResponse.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._xactId("string") - .logId(PromptUpdateResponse.LogId.P) - .name("string") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("string") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("string") - .metadata(PromptUpdateResponse.Metadata.builder().build()) - .promptData( - PromptUpdateResponse.PromptData.builder() - .options( - PromptUpdateResponse.PromptData.Options.builder() - .model("string") - .params( - PromptUpdateResponse.PromptData.Options.Params.ofUnionMember0( - PromptUpdateResponse.PromptData.Options.Params.UnionMember0 - .builder() - .frequencyPenalty(42.23) - .functionCall( - PromptUpdateResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .ofUnionMember0( - PromptUpdateResponse.PromptData.Options - .Params - .UnionMember0 - .FunctionCall - .UnionMember0 - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptUpdateResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .builder() - .type( - PromptUpdateResponse.PromptData.Options - .Params - .UnionMember0 - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptUpdateResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .ofUnionMember0( - PromptUpdateResponse.PromptData.Options - .Params - .UnionMember0 - .ToolChoice - .UnionMember0 - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("string") - .build() - ) - .origin( - PromptUpdateResponse.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") - .build() - ) - .prompt( - PromptUpdateResponse.PromptData.Prompt.ofUnionMember0( - PromptUpdateResponse.PromptData.Prompt.UnionMember0.builder() - .content("string") - .type( - PromptUpdateResponse.PromptData.Prompt.UnionMember0.Type - .COMPLETION - ) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(promptUpdateResponse).isNotNull - assertThat(promptUpdateResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptUpdateResponse._xactId()).isEqualTo("string") - assertThat(promptUpdateResponse.logId()).isEqualTo(PromptUpdateResponse.LogId.P) - assertThat(promptUpdateResponse.name()).isEqualTo("string") - assertThat(promptUpdateResponse.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptUpdateResponse.projectId()) - .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(promptUpdateResponse.slug()).isEqualTo("string") - assertThat(promptUpdateResponse.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(promptUpdateResponse.description()).contains("string") - assertThat(promptUpdateResponse.metadata()) - .contains(PromptUpdateResponse.Metadata.builder().build()) - assertThat(promptUpdateResponse.promptData()) - .contains( - PromptUpdateResponse.PromptData.builder() - .options( - PromptUpdateResponse.PromptData.Options.builder() - .model("string") - .params( - PromptUpdateResponse.PromptData.Options.Params.ofUnionMember0( - PromptUpdateResponse.PromptData.Options.Params.UnionMember0 - .builder() - .frequencyPenalty(42.23) - .functionCall( - PromptUpdateResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .ofUnionMember0( - PromptUpdateResponse.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .UnionMember0 - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptUpdateResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .builder() - .type( - PromptUpdateResponse.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptUpdateResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .ofUnionMember0( - PromptUpdateResponse.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .UnionMember0 - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("string") - .build() - ) - .origin( - PromptUpdateResponse.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") - .build() - ) - .prompt( - PromptUpdateResponse.PromptData.Prompt.ofUnionMember0( - PromptUpdateResponse.PromptData.Prompt.UnionMember0.builder() - .content("string") - .type( - PromptUpdateResponse.PromptData.Prompt.UnionMember0.Type - .COMPLETION - ) - .build() - ) - ) - .build() - ) - assertThat(promptUpdateResponse.tags().get()).containsExactly("string") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrust/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrust/api/services/blocking/PromptServiceTest.kt index e30b562..974e390 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrust/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrust/api/services/blocking/PromptServiceTest.kt @@ -20,7 +20,7 @@ class PromptServiceTest { .apiKey("My API Key") .build() val promptService = client.prompt() - val promptCreateResponse = + val prompt = promptService.create( PromptCreateParams.builder() .name("string") @@ -115,8 +115,8 @@ class PromptServiceTest { .tags(listOf("string")) .build() ) - println(promptCreateResponse) - promptCreateResponse.validate() + println(prompt) + prompt.validate() } @Test @@ -127,14 +127,14 @@ class PromptServiceTest { .apiKey("My API Key") .build() val promptService = client.prompt() - val promptRetrieveResponse = + val prompt = promptService.retrieve( PromptRetrieveParams.builder() .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(promptRetrieveResponse) - promptRetrieveResponse.validate() + println(prompt) + prompt.validate() } @Test @@ -145,7 +145,7 @@ class PromptServiceTest { .apiKey("My API Key") .build() val promptService = client.prompt() - val promptUpdateResponse = + val prompt = promptService.update( PromptUpdateParams.builder() .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -239,8 +239,8 @@ class PromptServiceTest { .tags(listOf("string")) .build() ) - println(promptUpdateResponse) - promptUpdateResponse.validate() + println(prompt) + prompt.validate() } @Test @@ -264,14 +264,14 @@ class PromptServiceTest { .apiKey("My API Key") .build() val promptService = client.prompt() - val promptDeleteResponse = + val prompt = promptService.delete( PromptDeleteParams.builder() .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(promptDeleteResponse) - promptDeleteResponse.validate() + println(prompt) + prompt.validate() } @Test @@ -307,7 +307,7 @@ class PromptServiceTest { .apiKey("My API Key") .build() val promptService = client.prompt() - val promptReplaceResponse = + val prompt = promptService.replace( PromptReplaceParams.builder() .name("string") @@ -409,7 +409,7 @@ class PromptServiceTest { .tags(listOf("string")) .build() ) - println(promptReplaceResponse) - promptReplaceResponse.validate() + println(prompt) + prompt.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrust/api/services/blocking/PromptSessionServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrust/api/services/blocking/PromptSessionServiceTest.kt deleted file mode 100644 index 6f3d11f..0000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrust/api/services/blocking/PromptSessionServiceTest.kt +++ /dev/null @@ -1,9 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrust.api.services.blocking - -import com.braintrust.api.TestServerExtension -import com.braintrust.api.models.* -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) class PromptSessionServiceTest