From 29174d7275d95ef5a6d4f88d4ebe2bcd178746b5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 13 Dec 2025 00:06:43 +0000 Subject: [PATCH 1/4] feat(api): api update --- .stats.yml | 4 +- .../openai/models/evals/EvalCreateParams.kt | 1111 +++++++++++++-- .../CreateEvalCompletionsRunDataSource.kt | 1111 +++++++++++++-- .../models/evals/runs/RunCancelResponse.kt | 1192 +++++++++++++++-- .../models/evals/runs/RunCreateParams.kt | 1192 +++++++++++++++-- .../models/evals/runs/RunCreateResponse.kt | 1192 +++++++++++++++-- .../models/evals/runs/RunListResponse.kt | 1192 +++++++++++++++-- .../models/evals/runs/RunRetrieveResponse.kt | 1192 +++++++++++++++-- .../graders/gradermodels/LabelModelGrader.kt | 1029 ++++++++++++-- .../graders/gradermodels/ScoreModelGrader.kt | 1029 ++++++++++++-- .../com/openai/models/videos/VideoModel.kt | 18 + 11 files changed, 9434 insertions(+), 828 deletions(-) diff --git a/.stats.yml b/.stats.yml index da4ec1f6..f7929828 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 136 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-41f98da99f44ebe6204fce5c1dc9940f85f3472779e797b674c4fdc20306c77d.yml -openapi_spec_hash: c61259027f421f501bdc6b23cf9e430e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-386042697a8769999956bdc26ff1e70bfc2a56913f724eedc6bfaf82679e9956.yml +openapi_spec_hash: 7072a6a4a43d7ff0bb4098a3e8a6b9a7 config_hash: 141b101c9f13b90e21af74e1686f1f41 diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt index 7807447f..5350009c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt @@ -3239,7 +3239,9 @@ private constructor( ) : this(content, role, type, mutableMapOf()) /** - * Inputs to the model - can contain template strings. + * Inputs to the model - can contain template strings. Supports text, output + * text, input images, and input audio, either as a single item or an array of + * items. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with an @@ -3334,7 +3336,11 @@ private constructor( additionalProperties = evalItem.additionalProperties.toMutableMap() } - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports text, output + * text, input images, and input audio, either as a single item or an array + * of items. + */ fun content(content: Content) = content(JsonField.of(content)) /** @@ -3360,9 +3366,12 @@ private constructor( fun content(outputText: Content.OutputText) = content(Content.ofOutputText(outputText)) - /** Alias for calling [content] with `Content.ofInputImage(inputImage)`. */ - fun content(inputImage: Content.InputImage) = - content(Content.ofInputImage(inputImage)) + /** + * Alias for calling [content] with + * `Content.ofEvalItemInputImage(evalItemInputImage)`. + */ + fun content(evalItemInputImage: Content.EvalItemInputImage) = + content(Content.ofEvalItemInputImage(evalItemInputImage)) /** * Alias for calling [content] with @@ -3373,14 +3382,15 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextInputImageAndInputAudio(anArrayOfInputTextInputImageAndInputAudio)`. + * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. */ - fun contentOfAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = content( - Content.ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio + Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio ) ) @@ -3488,7 +3498,11 @@ private constructor( (role.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports text, output + * text, input images, and input audio, either as a single item or an array of + * items. + */ @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) class Content @@ -3496,9 +3510,10 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, + private val evalItemInputImage: EvalItemInputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextInputImageAndInputAudio: List? = + private val anArrayOfInputTextOutputTextInputImageAndInputAudio: + List? = null, private val _json: JsonValue? = null, ) { @@ -3513,19 +3528,21 @@ private constructor( /** A text output from the model. */ fun outputText(): Optional = Optional.ofNullable(outputText) - /** An image input to the model. */ - fun inputImage(): Optional = Optional.ofNullable(inputImage) + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = Optional.ofNullable(responseInputAudio) /** - * A list of inputs, each of which may be either an input text, input image, - * or input audio object. + * A list of inputs, each of which may be either an input text, output text, + * input image, or input audio object. */ - fun anArrayOfInputTextInputImageAndInputAudio(): Optional> = - Optional.ofNullable(anArrayOfInputTextInputImageAndInputAudio) + fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): + Optional> = + Optional.ofNullable(anArrayOfInputTextOutputTextInputImageAndInputAudio) fun isTextInput(): Boolean = textInput != null @@ -3533,12 +3550,12 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isInputImage(): Boolean = inputImage != null + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextInputImageAndInputAudio(): Boolean = - anArrayOfInputTextInputImageAndInputAudio != null + fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): Boolean = + anArrayOfInputTextOutputTextInputImageAndInputAudio != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -3550,20 +3567,22 @@ private constructor( /** A text output from the model. */ fun asOutputText(): OutputText = outputText.getOrThrow("outputText") - /** An image input to the model. */ - fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = responseInputAudio.getOrThrow("responseInputAudio") /** - * A list of inputs, each of which may be either an input text, input image, - * or input audio object. + * A list of inputs, each of which may be either an input text, output text, + * input image, or input audio object. */ - fun asAnArrayOfInputTextInputImageAndInputAudio(): List = - anArrayOfInputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextInputImageAndInputAudio" + fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + List = + anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( + "anArrayOfInputTextOutputTextInputImageAndInputAudio" ) fun _json(): Optional = Optional.ofNullable(_json) @@ -3574,13 +3593,15 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - inputImage != null -> visitor.visitInputImage(inputImage) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextInputImageAndInputAudio != null -> - visitor.visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio - ) + anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> + visitor + .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) else -> visitor.unknown(_json) } @@ -3605,8 +3626,10 @@ private constructor( outputText.validate() } - override fun visitInputImage(inputImage: InputImage) { - inputImage.validate() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() } override fun visitResponseInputAudio( @@ -3615,9 +3638,13 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List - ) {} + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) { + anArrayOfInputTextOutputTextInputImageAndInputAudio + .forEach { it.validate() } + } } ) validated = true @@ -3650,16 +3677,21 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitInputImage(inputImage: InputImage) = - inputImage.validity() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List - ) = anArrayOfInputTextInputImageAndInputAudio.size + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) = + anArrayOfInputTextOutputTextInputImageAndInputAudio.sumOf { + it.validity().toInt() + } override fun unknown(json: JsonValue?) = 0 } @@ -3674,10 +3706,10 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - inputImage == other.inputImage && + evalItemInputImage == other.evalItemInputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextInputImageAndInputAudio == - other.anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio == + other.anArrayOfInputTextOutputTextInputImageAndInputAudio } override fun hashCode(): Int = @@ -3685,9 +3717,9 @@ private constructor( textInput, responseInputText, outputText, - inputImage, + evalItemInputImage, responseInputAudio, - anArrayOfInputTextInputImageAndInputAudio, + anArrayOfInputTextOutputTextInputImageAndInputAudio, ) override fun toString(): String = @@ -3696,11 +3728,12 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - inputImage != null -> "Content{inputImage=$inputImage}" + evalItemInputImage != null -> + "Content{evalItemInputImage=$evalItemInputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextInputImageAndInputAudio != null -> - "Content{anArrayOfInputTextInputImageAndInputAudio=$anArrayOfInputTextInputImageAndInputAudio}" + anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> + "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -3721,10 +3754,10 @@ private constructor( fun ofOutputText(outputText: OutputText) = Content(outputText = outputText) - /** An image input to the model. */ + /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofInputImage(inputImage: InputImage) = - Content(inputImage = inputImage) + fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = + Content(evalItemInputImage = evalItemInputImage) /** An audio input to the model. */ @JvmStatic @@ -3732,16 +3765,18 @@ private constructor( Content(responseInputAudio = responseInputAudio) /** - * A list of inputs, each of which may be either an input text, input - * image, or input audio object. + * A list of inputs, each of which may be either an input text, output + * text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = Content( - anArrayOfInputTextInputImageAndInputAudio = - anArrayOfInputTextInputImageAndInputAudio.toImmutable() + anArrayOfInputTextOutputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio + .toImmutable() ) } @@ -3760,18 +3795,19 @@ private constructor( /** A text output from the model. */ fun visitOutputText(outputText: OutputText): T - /** An image input to the model. */ - fun visitInputImage(inputImage: InputImage): T + /** An image input block used within EvalItem content arrays. */ + fun visitEvalItemInputImage(evalItemInputImage: EvalItemInputImage): T /** An audio input to the model. */ fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T /** - * A list of inputs, each of which may be either an input text, input - * image, or input audio object. + * A list of inputs, each of which may be either an input text, output + * text, input image, or input audio object. */ - fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ): T /** @@ -3805,8 +3841,13 @@ private constructor( }, tryDeserialize(node, jacksonTypeRef()) ?.let { Content(outputText = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Content(inputImage = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Content(evalItemInputImage = it, _json = json) + }, tryDeserialize( node, jacksonTypeRef(), @@ -3817,10 +3858,15 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Content(textInput = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef>()) + tryDeserialize( + node, + jacksonTypeRef< + List + >(), + ) ?.let { Content( - anArrayOfInputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio = it, _json = json, ) @@ -3858,13 +3904,15 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value.anArrayOfInputTextInputImageAndInputAudio != null -> + value.anArrayOfInputTextOutputTextInputImageAndInputAudio != + null -> generator.writeObject( - value.anArrayOfInputTextInputImageAndInputAudio + value + .anArrayOfInputTextOutputTextInputImageAndInputAudio ) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") @@ -4093,8 +4141,8 @@ private constructor( "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" } - /** An image input to the model. */ - class InputImage + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -4184,7 +4232,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [InputImage]. + * [EvalItemInputImage]. * * The following fields are required: * ```java @@ -4194,7 +4242,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [InputImage]. */ + /** A builder for [EvalItemInputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -4204,12 +4252,12 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail + internal fun from(evalItemInputImage: EvalItemInputImage) = apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail additionalProperties = - inputImage.additionalProperties.toMutableMap() + evalItemInputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -4281,7 +4329,7 @@ private constructor( } /** - * Returns an immutable instance of [InputImage]. + * Returns an immutable instance of [EvalItemInputImage]. * * Further updates to this [Builder] will not mutate the returned * instance. @@ -4293,8 +4341,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): InputImage = - InputImage( + fun build(): EvalItemInputImage = + EvalItemInputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -4304,7 +4352,7 @@ private constructor( private var validated: Boolean = false - fun validate(): InputImage = apply { + fun validate(): EvalItemInputImage = apply { if (validated) { return@apply } @@ -4346,7 +4394,7 @@ private constructor( return true } - return other is InputImage && + return other is EvalItemInputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -4360,7 +4408,890 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } + + /** A text input to the model. */ + @JsonDeserialize(using = UnnamedSchemaWithArrayParent7.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent7.Serializer::class) + class UnnamedSchemaWithArrayParent7 + private constructor( + private val textInput: String? = null, + private val responseInputText: ResponseInputText? = null, + private val outputText: OutputText? = null, + private val evalItemInputImage: EvalItemInputImage? = null, + private val responseInputAudio: ResponseInputAudio? = null, + private val _json: JsonValue? = null, + ) { + + /** A text input to the model. */ + fun textInput(): Optional = Optional.ofNullable(textInput) + + /** A text input to the model. */ + fun responseInputText(): Optional = + Optional.ofNullable(responseInputText) + + /** A text output from the model. */ + fun outputText(): Optional = Optional.ofNullable(outputText) + + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) + + /** An audio input to the model. */ + fun responseInputAudio(): Optional = + Optional.ofNullable(responseInputAudio) + + fun isTextInput(): Boolean = textInput != null + + fun isResponseInputText(): Boolean = responseInputText != null + + fun isOutputText(): Boolean = outputText != null + + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + + fun isResponseInputAudio(): Boolean = responseInputAudio != null + + /** A text input to the model. */ + fun asTextInput(): String = textInput.getOrThrow("textInput") + + /** A text input to the model. */ + fun asResponseInputText(): ResponseInputText = + responseInputText.getOrThrow("responseInputText") + + /** A text output from the model. */ + fun asOutputText(): OutputText = outputText.getOrThrow("outputText") + + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") + + /** An audio input to the model. */ + fun asResponseInputAudio(): ResponseInputAudio = + responseInputAudio.getOrThrow("responseInputAudio") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + textInput != null -> visitor.visitTextInput(textInput) + responseInputText != null -> + visitor.visitResponseInputText(responseInputText) + outputText != null -> visitor.visitOutputText(outputText) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) + responseInputAudio != null -> + visitor.visitResponseInputAudio(responseInputAudio) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent7 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTextInput(textInput: String) {} + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) { + responseInputText.validate() + } + + override fun visitOutputText(outputText: OutputText) { + outputText.validate() + } + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() + } + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) { + responseInputAudio.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTextInput(textInput: String) = 1 + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) = responseInputText.validity() + + override fun visitOutputText(outputText: OutputText) = + outputText.validity() + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = responseInputAudio.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent7 && + textInput == other.textInput && + responseInputText == other.responseInputText && + outputText == other.outputText && + evalItemInputImage == other.evalItemInputImage && + responseInputAudio == other.responseInputAudio + } + + override fun hashCode(): Int = + Objects.hash( + textInput, + responseInputText, + outputText, + evalItemInputImage, + responseInputAudio, + ) + + override fun toString(): String = + when { + textInput != null -> + "UnnamedSchemaWithArrayParent7{textInput=$textInput}" + responseInputText != null -> + "UnnamedSchemaWithArrayParent7{responseInputText=$responseInputText}" + outputText != null -> + "UnnamedSchemaWithArrayParent7{outputText=$outputText}" + evalItemInputImage != null -> + "UnnamedSchemaWithArrayParent7{evalItemInputImage=$evalItemInputImage}" + responseInputAudio != null -> + "UnnamedSchemaWithArrayParent7{responseInputAudio=$responseInputAudio}" + _json != null -> + "UnnamedSchemaWithArrayParent7{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent7" + ) + } + + companion object { + + /** A text input to the model. */ + @JvmStatic + fun ofTextInput(textInput: String) = + UnnamedSchemaWithArrayParent7(textInput = textInput) + + /** A text input to the model. */ + @JvmStatic + fun ofResponseInputText(responseInputText: ResponseInputText) = + UnnamedSchemaWithArrayParent7( + responseInputText = responseInputText + ) + + /** A text output from the model. */ + @JvmStatic + fun ofOutputText(outputText: OutputText) = + UnnamedSchemaWithArrayParent7(outputText = outputText) + + /** An image input block used within EvalItem content arrays. */ + @JvmStatic + fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = + UnnamedSchemaWithArrayParent7( + evalItemInputImage = evalItemInputImage + ) + + /** An audio input to the model. */ + @JvmStatic + fun ofResponseInputAudio(responseInputAudio: ResponseInputAudio) = + UnnamedSchemaWithArrayParent7( + responseInputAudio = responseInputAudio + ) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent7] to a value of type [T]. + */ + interface Visitor { + + /** A text input to the model. */ + fun visitTextInput(textInput: String): T + + /** A text input to the model. */ + fun visitResponseInputText(responseInputText: ResponseInputText): T + + /** A text output from the model. */ + fun visitOutputText(outputText: OutputText): T + + /** An image input block used within EvalItem content arrays. */ + fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ): T + + /** An audio input to the model. */ + fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent7] to a + * value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent7] can contain an + * unknown variant if it was deserialized from data that doesn't + * match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent7: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent7::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent7 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent7( + responseInputText = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent7( + outputText = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent7( + evalItemInputImage = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent7( + responseInputAudio = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent7( + textInput = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from array). + 0 -> UnnamedSchemaWithArrayParent7(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent7::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent7, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.textInput != null -> + generator.writeObject(value.textInput) + value.responseInputText != null -> + generator.writeObject(value.responseInputText) + value.outputText != null -> + generator.writeObject(value.outputText) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) + value.responseInputAudio != null -> + generator.writeObject(value.responseInputAudio) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent7" + ) + } + } + } + + /** A text output from the model. */ + class OutputText + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + ) : this(text, type, mutableMapOf()) + + /** + * The text output from the model. + * + * @throws OpenAIInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * The type of the output text. Always `output_text`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * However, this method can be useful for debugging and logging + * (e.g. if the server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("text") + @ExcludeMissing + fun _text(): JsonField = text + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OutputText]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputText]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("output_text") + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(outputText: OutputText) = apply { + text = outputText.text + type = outputText.type + additionalProperties = + outputText.additionalProperties.toMutableMap() + } + + /** The text output from the model. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the + * field defaults to the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OutputText]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OutputText = + OutputText( + checkRequired("text", text), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OutputText = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("output_text")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("output_text")) 1 else 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputText && + text == other.text && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" + } + + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val imageUrl: JsonField, + private val type: JsonValue, + private val detail: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("image_url") + @ExcludeMissing + imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + detail: JsonField = JsonMissing.of(), + ) : this(imageUrl, type, detail, mutableMapOf()) + + /** + * The URL of the image input. + * + * @throws OpenAIInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun imageUrl(): String = imageUrl.getRequired("image_url") + + /** + * The type of the image input. Always `input_image`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * However, this method can be useful for debugging and logging + * (e.g. if the server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * The detail level of the image to be sent to the model. One of + * `high`, `low`, or `auto`. Defaults to `auto`. + * + * @throws OpenAIInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an + * unexpected value). + */ + fun detail(): Optional = detail.getOptional("detail") + + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("image_url") + @ExcludeMissing + fun _imageUrl(): JsonField = imageUrl + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EvalItemInputImage]. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EvalItemInputImage]. */ + class Builder internal constructor() { + + private var imageUrl: JsonField? = null + private var type: JsonValue = JsonValue.from("input_image") + private var detail: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(evalItemInputImage: EvalItemInputImage) = + apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties + .toMutableMap() + } + + /** The URL of the image input. */ + fun imageUrl(imageUrl: String) = + imageUrl(JsonField.of(imageUrl)) + + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun imageUrl(imageUrl: JsonField) = apply { + this.imageUrl = imageUrl + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the + * field defaults to the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * The detail level of the image to be sent to the model. One of + * `high`, `low`, or `auto`. Defaults to `auto`. + */ + fun detail(detail: String) = detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun detail(detail: JsonField) = apply { + this.detail = detail + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EvalItemInputImage]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EvalItemInputImage = + EvalItemInputImage( + checkRequired("imageUrl", imageUrl), + type, + detail, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EvalItemInputImage = apply { + if (validated) { + return@apply + } + + imageUrl() + _type().let { + if (it != JsonValue.from("input_image")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + detail() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (imageUrl.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("input_image")) 1 else 0 + } + + (if (detail.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EvalItemInputImage && + imageUrl == other.imageUrl && + type == other.type && + detail == other.detail && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(imageUrl, type, detail, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt index c010ad47..edf60977 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt @@ -2754,7 +2754,9 @@ private constructor( ) : this(content, role, type, mutableMapOf()) /** - * Inputs to the model - can contain template strings. + * Inputs to the model - can contain template strings. Supports text, output + * text, input images, and input audio, either as a single item or an array of + * items. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with an @@ -2849,7 +2851,11 @@ private constructor( additionalProperties = evalItem.additionalProperties.toMutableMap() } - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports text, output + * text, input images, and input audio, either as a single item or an array + * of items. + */ fun content(content: Content) = content(JsonField.of(content)) /** @@ -2875,9 +2881,12 @@ private constructor( fun content(outputText: Content.OutputText) = content(Content.ofOutputText(outputText)) - /** Alias for calling [content] with `Content.ofInputImage(inputImage)`. */ - fun content(inputImage: Content.InputImage) = - content(Content.ofInputImage(inputImage)) + /** + * Alias for calling [content] with + * `Content.ofEvalItemInputImage(evalItemInputImage)`. + */ + fun content(evalItemInputImage: Content.EvalItemInputImage) = + content(Content.ofEvalItemInputImage(evalItemInputImage)) /** * Alias for calling [content] with @@ -2888,14 +2897,15 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextInputImageAndInputAudio(anArrayOfInputTextInputImageAndInputAudio)`. + * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. */ - fun contentOfAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = content( - Content.ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio + Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio ) ) @@ -3003,7 +3013,11 @@ private constructor( (role.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports text, output + * text, input images, and input audio, either as a single item or an array of + * items. + */ @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) class Content @@ -3011,9 +3025,10 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, + private val evalItemInputImage: EvalItemInputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextInputImageAndInputAudio: List? = + private val anArrayOfInputTextOutputTextInputImageAndInputAudio: + List? = null, private val _json: JsonValue? = null, ) { @@ -3028,19 +3043,21 @@ private constructor( /** A text output from the model. */ fun outputText(): Optional = Optional.ofNullable(outputText) - /** An image input to the model. */ - fun inputImage(): Optional = Optional.ofNullable(inputImage) + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = Optional.ofNullable(responseInputAudio) /** - * A list of inputs, each of which may be either an input text, input image, - * or input audio object. + * A list of inputs, each of which may be either an input text, output text, + * input image, or input audio object. */ - fun anArrayOfInputTextInputImageAndInputAudio(): Optional> = - Optional.ofNullable(anArrayOfInputTextInputImageAndInputAudio) + fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): + Optional> = + Optional.ofNullable(anArrayOfInputTextOutputTextInputImageAndInputAudio) fun isTextInput(): Boolean = textInput != null @@ -3048,12 +3065,12 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isInputImage(): Boolean = inputImage != null + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextInputImageAndInputAudio(): Boolean = - anArrayOfInputTextInputImageAndInputAudio != null + fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): Boolean = + anArrayOfInputTextOutputTextInputImageAndInputAudio != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -3065,20 +3082,22 @@ private constructor( /** A text output from the model. */ fun asOutputText(): OutputText = outputText.getOrThrow("outputText") - /** An image input to the model. */ - fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = responseInputAudio.getOrThrow("responseInputAudio") /** - * A list of inputs, each of which may be either an input text, input image, - * or input audio object. + * A list of inputs, each of which may be either an input text, output text, + * input image, or input audio object. */ - fun asAnArrayOfInputTextInputImageAndInputAudio(): List = - anArrayOfInputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextInputImageAndInputAudio" + fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + List = + anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( + "anArrayOfInputTextOutputTextInputImageAndInputAudio" ) fun _json(): Optional = Optional.ofNullable(_json) @@ -3089,13 +3108,15 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - inputImage != null -> visitor.visitInputImage(inputImage) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextInputImageAndInputAudio != null -> - visitor.visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio - ) + anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> + visitor + .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) else -> visitor.unknown(_json) } @@ -3120,8 +3141,10 @@ private constructor( outputText.validate() } - override fun visitInputImage(inputImage: InputImage) { - inputImage.validate() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() } override fun visitResponseInputAudio( @@ -3130,9 +3153,13 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List - ) {} + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) { + anArrayOfInputTextOutputTextInputImageAndInputAudio + .forEach { it.validate() } + } } ) validated = true @@ -3165,16 +3192,21 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitInputImage(inputImage: InputImage) = - inputImage.validity() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List - ) = anArrayOfInputTextInputImageAndInputAudio.size + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) = + anArrayOfInputTextOutputTextInputImageAndInputAudio.sumOf { + it.validity().toInt() + } override fun unknown(json: JsonValue?) = 0 } @@ -3189,10 +3221,10 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - inputImage == other.inputImage && + evalItemInputImage == other.evalItemInputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextInputImageAndInputAudio == - other.anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio == + other.anArrayOfInputTextOutputTextInputImageAndInputAudio } override fun hashCode(): Int = @@ -3200,9 +3232,9 @@ private constructor( textInput, responseInputText, outputText, - inputImage, + evalItemInputImage, responseInputAudio, - anArrayOfInputTextInputImageAndInputAudio, + anArrayOfInputTextOutputTextInputImageAndInputAudio, ) override fun toString(): String = @@ -3211,11 +3243,12 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - inputImage != null -> "Content{inputImage=$inputImage}" + evalItemInputImage != null -> + "Content{evalItemInputImage=$evalItemInputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextInputImageAndInputAudio != null -> - "Content{anArrayOfInputTextInputImageAndInputAudio=$anArrayOfInputTextInputImageAndInputAudio}" + anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> + "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -3236,10 +3269,10 @@ private constructor( fun ofOutputText(outputText: OutputText) = Content(outputText = outputText) - /** An image input to the model. */ + /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofInputImage(inputImage: InputImage) = - Content(inputImage = inputImage) + fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = + Content(evalItemInputImage = evalItemInputImage) /** An audio input to the model. */ @JvmStatic @@ -3247,16 +3280,18 @@ private constructor( Content(responseInputAudio = responseInputAudio) /** - * A list of inputs, each of which may be either an input text, input - * image, or input audio object. + * A list of inputs, each of which may be either an input text, output + * text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = Content( - anArrayOfInputTextInputImageAndInputAudio = - anArrayOfInputTextInputImageAndInputAudio.toImmutable() + anArrayOfInputTextOutputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio + .toImmutable() ) } @@ -3275,18 +3310,19 @@ private constructor( /** A text output from the model. */ fun visitOutputText(outputText: OutputText): T - /** An image input to the model. */ - fun visitInputImage(inputImage: InputImage): T + /** An image input block used within EvalItem content arrays. */ + fun visitEvalItemInputImage(evalItemInputImage: EvalItemInputImage): T /** An audio input to the model. */ fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T /** - * A list of inputs, each of which may be either an input text, input - * image, or input audio object. + * A list of inputs, each of which may be either an input text, output + * text, input image, or input audio object. */ - fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ): T /** @@ -3320,8 +3356,13 @@ private constructor( }, tryDeserialize(node, jacksonTypeRef()) ?.let { Content(outputText = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Content(inputImage = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Content(evalItemInputImage = it, _json = json) + }, tryDeserialize( node, jacksonTypeRef(), @@ -3332,10 +3373,15 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Content(textInput = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef>()) + tryDeserialize( + node, + jacksonTypeRef< + List + >(), + ) ?.let { Content( - anArrayOfInputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio = it, _json = json, ) @@ -3373,13 +3419,15 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value.anArrayOfInputTextInputImageAndInputAudio != null -> + value.anArrayOfInputTextOutputTextInputImageAndInputAudio != + null -> generator.writeObject( - value.anArrayOfInputTextInputImageAndInputAudio + value + .anArrayOfInputTextOutputTextInputImageAndInputAudio ) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") @@ -3608,8 +3656,8 @@ private constructor( "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" } - /** An image input to the model. */ - class InputImage + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -3699,7 +3747,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [InputImage]. + * [EvalItemInputImage]. * * The following fields are required: * ```java @@ -3709,7 +3757,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [InputImage]. */ + /** A builder for [EvalItemInputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -3719,12 +3767,12 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail + internal fun from(evalItemInputImage: EvalItemInputImage) = apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail additionalProperties = - inputImage.additionalProperties.toMutableMap() + evalItemInputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -3796,7 +3844,7 @@ private constructor( } /** - * Returns an immutable instance of [InputImage]. + * Returns an immutable instance of [EvalItemInputImage]. * * Further updates to this [Builder] will not mutate the returned * instance. @@ -3808,8 +3856,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): InputImage = - InputImage( + fun build(): EvalItemInputImage = + EvalItemInputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -3819,7 +3867,7 @@ private constructor( private var validated: Boolean = false - fun validate(): InputImage = apply { + fun validate(): EvalItemInputImage = apply { if (validated) { return@apply } @@ -3861,7 +3909,7 @@ private constructor( return true } - return other is InputImage && + return other is EvalItemInputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -3875,7 +3923,890 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } + + /** A text input to the model. */ + @JsonDeserialize(using = UnnamedSchemaWithArrayParent2.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) + class UnnamedSchemaWithArrayParent2 + private constructor( + private val textInput: String? = null, + private val responseInputText: ResponseInputText? = null, + private val outputText: OutputText? = null, + private val evalItemInputImage: EvalItemInputImage? = null, + private val responseInputAudio: ResponseInputAudio? = null, + private val _json: JsonValue? = null, + ) { + + /** A text input to the model. */ + fun textInput(): Optional = Optional.ofNullable(textInput) + + /** A text input to the model. */ + fun responseInputText(): Optional = + Optional.ofNullable(responseInputText) + + /** A text output from the model. */ + fun outputText(): Optional = Optional.ofNullable(outputText) + + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) + + /** An audio input to the model. */ + fun responseInputAudio(): Optional = + Optional.ofNullable(responseInputAudio) + + fun isTextInput(): Boolean = textInput != null + + fun isResponseInputText(): Boolean = responseInputText != null + + fun isOutputText(): Boolean = outputText != null + + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + + fun isResponseInputAudio(): Boolean = responseInputAudio != null + + /** A text input to the model. */ + fun asTextInput(): String = textInput.getOrThrow("textInput") + + /** A text input to the model. */ + fun asResponseInputText(): ResponseInputText = + responseInputText.getOrThrow("responseInputText") + + /** A text output from the model. */ + fun asOutputText(): OutputText = outputText.getOrThrow("outputText") + + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") + + /** An audio input to the model. */ + fun asResponseInputAudio(): ResponseInputAudio = + responseInputAudio.getOrThrow("responseInputAudio") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + textInput != null -> visitor.visitTextInput(textInput) + responseInputText != null -> + visitor.visitResponseInputText(responseInputText) + outputText != null -> visitor.visitOutputText(outputText) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) + responseInputAudio != null -> + visitor.visitResponseInputAudio(responseInputAudio) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent2 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTextInput(textInput: String) {} + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) { + responseInputText.validate() + } + + override fun visitOutputText(outputText: OutputText) { + outputText.validate() + } + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() + } + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) { + responseInputAudio.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTextInput(textInput: String) = 1 + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) = responseInputText.validity() + + override fun visitOutputText(outputText: OutputText) = + outputText.validity() + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = responseInputAudio.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent2 && + textInput == other.textInput && + responseInputText == other.responseInputText && + outputText == other.outputText && + evalItemInputImage == other.evalItemInputImage && + responseInputAudio == other.responseInputAudio + } + + override fun hashCode(): Int = + Objects.hash( + textInput, + responseInputText, + outputText, + evalItemInputImage, + responseInputAudio, + ) + + override fun toString(): String = + when { + textInput != null -> + "UnnamedSchemaWithArrayParent2{textInput=$textInput}" + responseInputText != null -> + "UnnamedSchemaWithArrayParent2{responseInputText=$responseInputText}" + outputText != null -> + "UnnamedSchemaWithArrayParent2{outputText=$outputText}" + evalItemInputImage != null -> + "UnnamedSchemaWithArrayParent2{evalItemInputImage=$evalItemInputImage}" + responseInputAudio != null -> + "UnnamedSchemaWithArrayParent2{responseInputAudio=$responseInputAudio}" + _json != null -> + "UnnamedSchemaWithArrayParent2{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent2" + ) + } + + companion object { + + /** A text input to the model. */ + @JvmStatic + fun ofTextInput(textInput: String) = + UnnamedSchemaWithArrayParent2(textInput = textInput) + + /** A text input to the model. */ + @JvmStatic + fun ofResponseInputText(responseInputText: ResponseInputText) = + UnnamedSchemaWithArrayParent2( + responseInputText = responseInputText + ) + + /** A text output from the model. */ + @JvmStatic + fun ofOutputText(outputText: OutputText) = + UnnamedSchemaWithArrayParent2(outputText = outputText) + + /** An image input block used within EvalItem content arrays. */ + @JvmStatic + fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = + UnnamedSchemaWithArrayParent2( + evalItemInputImage = evalItemInputImage + ) + + /** An audio input to the model. */ + @JvmStatic + fun ofResponseInputAudio(responseInputAudio: ResponseInputAudio) = + UnnamedSchemaWithArrayParent2( + responseInputAudio = responseInputAudio + ) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent2] to a value of type [T]. + */ + interface Visitor { + + /** A text input to the model. */ + fun visitTextInput(textInput: String): T + + /** A text input to the model. */ + fun visitResponseInputText(responseInputText: ResponseInputText): T + + /** A text output from the model. */ + fun visitOutputText(outputText: OutputText): T + + /** An image input block used within EvalItem content arrays. */ + fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ): T + + /** An audio input to the model. */ + fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent2] to a + * value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent2] can contain an + * unknown variant if it was deserialized from data that doesn't + * match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent2: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent2::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent2 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent2( + responseInputText = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent2( + outputText = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent2( + evalItemInputImage = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent2( + responseInputAudio = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent2( + textInput = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from array). + 0 -> UnnamedSchemaWithArrayParent2(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent2::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent2, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.textInput != null -> + generator.writeObject(value.textInput) + value.responseInputText != null -> + generator.writeObject(value.responseInputText) + value.outputText != null -> + generator.writeObject(value.outputText) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) + value.responseInputAudio != null -> + generator.writeObject(value.responseInputAudio) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent2" + ) + } + } + } + + /** A text output from the model. */ + class OutputText + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + ) : this(text, type, mutableMapOf()) + + /** + * The text output from the model. + * + * @throws OpenAIInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * The type of the output text. Always `output_text`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * However, this method can be useful for debugging and logging + * (e.g. if the server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("text") + @ExcludeMissing + fun _text(): JsonField = text + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OutputText]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputText]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("output_text") + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(outputText: OutputText) = apply { + text = outputText.text + type = outputText.type + additionalProperties = + outputText.additionalProperties.toMutableMap() + } + + /** The text output from the model. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the + * field defaults to the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OutputText]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OutputText = + OutputText( + checkRequired("text", text), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OutputText = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("output_text")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("output_text")) 1 else 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputText && + text == other.text && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" + } + + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val imageUrl: JsonField, + private val type: JsonValue, + private val detail: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("image_url") + @ExcludeMissing + imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + detail: JsonField = JsonMissing.of(), + ) : this(imageUrl, type, detail, mutableMapOf()) + + /** + * The URL of the image input. + * + * @throws OpenAIInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun imageUrl(): String = imageUrl.getRequired("image_url") + + /** + * The type of the image input. Always `input_image`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * However, this method can be useful for debugging and logging + * (e.g. if the server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * The detail level of the image to be sent to the model. One of + * `high`, `low`, or `auto`. Defaults to `auto`. + * + * @throws OpenAIInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an + * unexpected value). + */ + fun detail(): Optional = detail.getOptional("detail") + + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("image_url") + @ExcludeMissing + fun _imageUrl(): JsonField = imageUrl + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EvalItemInputImage]. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EvalItemInputImage]. */ + class Builder internal constructor() { + + private var imageUrl: JsonField? = null + private var type: JsonValue = JsonValue.from("input_image") + private var detail: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(evalItemInputImage: EvalItemInputImage) = + apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties + .toMutableMap() + } + + /** The URL of the image input. */ + fun imageUrl(imageUrl: String) = + imageUrl(JsonField.of(imageUrl)) + + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun imageUrl(imageUrl: JsonField) = apply { + this.imageUrl = imageUrl + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the + * field defaults to the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * The detail level of the image to be sent to the model. One of + * `high`, `low`, or `auto`. Defaults to `auto`. + */ + fun detail(detail: String) = detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun detail(detail: JsonField) = apply { + this.detail = detail + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EvalItemInputImage]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EvalItemInputImage = + EvalItemInputImage( + checkRequired("imageUrl", imageUrl), + type, + detail, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EvalItemInputImage = apply { + if (validated) { + return@apply + } + + imageUrl() + _type().let { + if (it != JsonValue.from("input_image")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + detail() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (imageUrl.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("input_image")) 1 else 0 + } + + (if (detail.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EvalItemInputImage && + imageUrl == other.imageUrl && + type == other.type && + detail == other.detail && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(imageUrl, type, detail, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt index f05d4645..745aead0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt @@ -4230,7 +4230,9 @@ private constructor( ) : this(content, role, type, mutableMapOf()) /** - * Inputs to the model - can contain template strings. + * Inputs to the model - can contain template strings. Supports text, + * output text, input images, and input audio, either as a single item + * or an array of items. * * @throws OpenAIInvalidDataException if the JSON field has an * unexpected type or is unexpectedly missing or null (e.g. if the @@ -4332,7 +4334,11 @@ private constructor( evalItem.additionalProperties.toMutableMap() } - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports + * text, output text, input images, and input audio, either as a + * single item or an array of items. + */ fun content(content: Content) = content(JsonField.of(content)) /** @@ -4369,10 +4375,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofInputImage(inputImage)`. + * `Content.ofEvalItemInputImage(evalItemInputImage)`. */ - fun content(inputImage: Content.InputImage) = - content(Content.ofInputImage(inputImage)) + fun content(evalItemInputImage: Content.EvalItemInputImage) = + content(Content.ofEvalItemInputImage(evalItemInputImage)) /** * Alias for calling [content] with @@ -4383,15 +4389,17 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextInputImageAndInputAudio(anArrayOfInputTextInputImageAndInputAudio)`. + * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. */ - fun contentOfAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = content( - Content.ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio - ) + Content + .ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) ) /** @@ -4500,7 +4508,11 @@ private constructor( (role.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports text, + * output text, input images, and input audio, either as a single item + * or an array of items. + */ @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) class Content @@ -4508,10 +4520,10 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, + private val evalItemInputImage: EvalItemInputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextInputImageAndInputAudio: - List? = + private val anArrayOfInputTextOutputTextInputImageAndInputAudio: + List? = null, private val _json: JsonValue? = null, ) { @@ -4527,9 +4539,9 @@ private constructor( fun outputText(): Optional = Optional.ofNullable(outputText) - /** An image input to the model. */ - fun inputImage(): Optional = - Optional.ofNullable(inputImage) + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -4537,11 +4549,13 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun anArrayOfInputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable(anArrayOfInputTextInputImageAndInputAudio) + fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): + Optional> = + Optional.ofNullable( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) fun isTextInput(): Boolean = textInput != null @@ -4549,12 +4563,13 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isInputImage(): Boolean = inputImage != null + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextInputImageAndInputAudio(): Boolean = - anArrayOfInputTextInputImageAndInputAudio != null + fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + Boolean = + anArrayOfInputTextOutputTextInputImageAndInputAudio != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -4566,8 +4581,9 @@ private constructor( /** A text output from the model. */ fun asOutputText(): OutputText = outputText.getOrThrow("outputText") - /** An image input to the model. */ - fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -4575,11 +4591,12 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun asAnArrayOfInputTextInputImageAndInputAudio(): List = - anArrayOfInputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextInputImageAndInputAudio" + fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + List = + anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( + "anArrayOfInputTextOutputTextInputImageAndInputAudio" ) fun _json(): Optional = Optional.ofNullable(_json) @@ -4590,13 +4607,16 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - inputImage != null -> visitor.visitInputImage(inputImage) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextInputImageAndInputAudio != null -> - visitor.visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio - ) + anArrayOfInputTextOutputTextInputImageAndInputAudio != + null -> + visitor + .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) else -> visitor.unknown(_json) } @@ -4621,8 +4641,10 @@ private constructor( outputText.validate() } - override fun visitInputImage(inputImage: InputImage) { - inputImage.validate() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() } override fun visitResponseInputAudio( @@ -4631,10 +4653,13 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: - List - ) {} + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) { + anArrayOfInputTextOutputTextInputImageAndInputAudio + .forEach { it.validate() } + } } ) validated = true @@ -4667,17 +4692,20 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitInputImage(inputImage: InputImage) = - inputImage.validity() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: - List - ) = anArrayOfInputTextInputImageAndInputAudio.size + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) = + anArrayOfInputTextOutputTextInputImageAndInputAudio + .sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -4692,10 +4720,11 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - inputImage == other.inputImage && + evalItemInputImage == other.evalItemInputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextInputImageAndInputAudio == - other.anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio == + other + .anArrayOfInputTextOutputTextInputImageAndInputAudio } override fun hashCode(): Int = @@ -4703,9 +4732,9 @@ private constructor( textInput, responseInputText, outputText, - inputImage, + evalItemInputImage, responseInputAudio, - anArrayOfInputTextInputImageAndInputAudio, + anArrayOfInputTextOutputTextInputImageAndInputAudio, ) override fun toString(): String = @@ -4714,11 +4743,13 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - inputImage != null -> "Content{inputImage=$inputImage}" + evalItemInputImage != null -> + "Content{evalItemInputImage=$evalItemInputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextInputImageAndInputAudio != null -> - "Content{anArrayOfInputTextInputImageAndInputAudio=$anArrayOfInputTextInputImageAndInputAudio}" + anArrayOfInputTextOutputTextInputImageAndInputAudio != + null -> + "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -4740,10 +4771,11 @@ private constructor( fun ofOutputText(outputText: OutputText) = Content(outputText = outputText) - /** An image input to the model. */ + /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofInputImage(inputImage: InputImage) = - Content(inputImage = inputImage) + fun ofEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = Content(evalItemInputImage = evalItemInputImage) /** An audio input to the model. */ @JvmStatic @@ -4753,15 +4785,16 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = Content( - anArrayOfInputTextInputImageAndInputAudio = - anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio .toImmutable() ) } @@ -4783,8 +4816,10 @@ private constructor( /** A text output from the model. */ fun visitOutputText(outputText: OutputText): T - /** An image input to the model. */ - fun visitInputImage(inputImage: InputImage): T + /** An image input block used within EvalItem content arrays. */ + fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -4793,10 +4828,11 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ): T /** @@ -4843,10 +4879,13 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - Content(inputImage = it, _json = json) + Content( + evalItemInputImage = it, + _json = json, + ) }, tryDeserialize( node, @@ -4864,11 +4903,13 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef>(), + jacksonTypeRef< + List + >(), ) ?.let { Content( - anArrayOfInputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio = it, _json = json, ) @@ -4909,14 +4950,16 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value.anArrayOfInputTextInputImageAndInputAudio != + value + .anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> generator.writeObject( - value.anArrayOfInputTextInputImageAndInputAudio + value + .anArrayOfInputTextOutputTextInputImageAndInputAudio ) value._json != null -> generator.writeObject(value._json) @@ -5162,8 +5205,8 @@ private constructor( "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" } - /** An image input to the model. */ - class InputImage + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -5258,7 +5301,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [InputImage]. + * [EvalItemInputImage]. * * The following fields are required: * ```java @@ -5268,7 +5311,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [InputImage]. */ + /** A builder for [EvalItemInputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -5279,13 +5322,15 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = - inputImage.additionalProperties.toMutableMap() - } + internal fun from(evalItemInputImage: EvalItemInputImage) = + apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties + .toMutableMap() + } /** The URL of the image input. */ fun imageUrl(imageUrl: String) = @@ -5363,7 +5408,7 @@ private constructor( } /** - * Returns an immutable instance of [InputImage]. + * Returns an immutable instance of [EvalItemInputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -5376,8 +5421,8 @@ private constructor( * @throws IllegalStateException if any required field is * unset. */ - fun build(): InputImage = - InputImage( + fun build(): EvalItemInputImage = + EvalItemInputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -5387,7 +5432,7 @@ private constructor( private var validated: Boolean = false - fun validate(): InputImage = apply { + fun validate(): EvalItemInputImage = apply { if (validated) { return@apply } @@ -5431,7 +5476,7 @@ private constructor( return true } - return other is InputImage && + return other is EvalItemInputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -5445,7 +5490,966 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } + + /** A text input to the model. */ + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent6.Deserializer::class + ) + @JsonSerialize( + using = UnnamedSchemaWithArrayParent6.Serializer::class + ) + class UnnamedSchemaWithArrayParent6 + private constructor( + private val textInput: String? = null, + private val responseInputText: ResponseInputText? = null, + private val outputText: OutputText? = null, + private val evalItemInputImage: EvalItemInputImage? = null, + private val responseInputAudio: ResponseInputAudio? = null, + private val _json: JsonValue? = null, + ) { + + /** A text input to the model. */ + fun textInput(): Optional = + Optional.ofNullable(textInput) + + /** A text input to the model. */ + fun responseInputText(): Optional = + Optional.ofNullable(responseInputText) + + /** A text output from the model. */ + fun outputText(): Optional = + Optional.ofNullable(outputText) + + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) + + /** An audio input to the model. */ + fun responseInputAudio(): Optional = + Optional.ofNullable(responseInputAudio) + + fun isTextInput(): Boolean = textInput != null + + fun isResponseInputText(): Boolean = responseInputText != null + + fun isOutputText(): Boolean = outputText != null + + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + + fun isResponseInputAudio(): Boolean = responseInputAudio != null + + /** A text input to the model. */ + fun asTextInput(): String = textInput.getOrThrow("textInput") + + /** A text input to the model. */ + fun asResponseInputText(): ResponseInputText = + responseInputText.getOrThrow("responseInputText") + + /** A text output from the model. */ + fun asOutputText(): OutputText = + outputText.getOrThrow("outputText") + + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") + + /** An audio input to the model. */ + fun asResponseInputAudio(): ResponseInputAudio = + responseInputAudio.getOrThrow("responseInputAudio") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + textInput != null -> visitor.visitTextInput(textInput) + responseInputText != null -> + visitor.visitResponseInputText(responseInputText) + outputText != null -> + visitor.visitOutputText(outputText) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) + responseInputAudio != null -> + visitor.visitResponseInputAudio(responseInputAudio) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent6 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTextInput(textInput: String) {} + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) { + responseInputText.validate() + } + + override fun visitOutputText( + outputText: OutputText + ) { + outputText.validate() + } + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() + } + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) { + responseInputAudio.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTextInput(textInput: String) = 1 + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) = responseInputText.validity() + + override fun visitOutputText( + outputText: OutputText + ) = outputText.validity() + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = responseInputAudio.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent6 && + textInput == other.textInput && + responseInputText == other.responseInputText && + outputText == other.outputText && + evalItemInputImage == other.evalItemInputImage && + responseInputAudio == other.responseInputAudio + } + + override fun hashCode(): Int = + Objects.hash( + textInput, + responseInputText, + outputText, + evalItemInputImage, + responseInputAudio, + ) + + override fun toString(): String = + when { + textInput != null -> + "UnnamedSchemaWithArrayParent6{textInput=$textInput}" + responseInputText != null -> + "UnnamedSchemaWithArrayParent6{responseInputText=$responseInputText}" + outputText != null -> + "UnnamedSchemaWithArrayParent6{outputText=$outputText}" + evalItemInputImage != null -> + "UnnamedSchemaWithArrayParent6{evalItemInputImage=$evalItemInputImage}" + responseInputAudio != null -> + "UnnamedSchemaWithArrayParent6{responseInputAudio=$responseInputAudio}" + _json != null -> + "UnnamedSchemaWithArrayParent6{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent6" + ) + } + + companion object { + + /** A text input to the model. */ + @JvmStatic + fun ofTextInput(textInput: String) = + UnnamedSchemaWithArrayParent6(textInput = textInput) + + /** A text input to the model. */ + @JvmStatic + fun ofResponseInputText( + responseInputText: ResponseInputText + ) = + UnnamedSchemaWithArrayParent6( + responseInputText = responseInputText + ) + + /** A text output from the model. */ + @JvmStatic + fun ofOutputText(outputText: OutputText) = + UnnamedSchemaWithArrayParent6(outputText = outputText) + + /** + * An image input block used within EvalItem content arrays. + */ + @JvmStatic + fun ofEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = + UnnamedSchemaWithArrayParent6( + evalItemInputImage = evalItemInputImage + ) + + /** An audio input to the model. */ + @JvmStatic + fun ofResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = + UnnamedSchemaWithArrayParent6( + responseInputAudio = responseInputAudio + ) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent6] to a value of type [T]. + */ + interface Visitor { + + /** A text input to the model. */ + fun visitTextInput(textInput: String): T + + /** A text input to the model. */ + fun visitResponseInputText( + responseInputText: ResponseInputText + ): T + + /** A text output from the model. */ + fun visitOutputText(outputText: OutputText): T + + /** + * An image input block used within EvalItem content arrays. + */ + fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ): T + + /** An audio input to the model. */ + fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent6] to a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent6] can + * contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware + * of. + * + * @throws OpenAIInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent6: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent6::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent6 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent6( + responseInputText = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent6( + outputText = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent6( + evalItemInputImage = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent6( + responseInputAudio = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent6( + textInput = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from array). + 0 -> UnnamedSchemaWithArrayParent6(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid + // match, or simply the first match if none are + // completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent6::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent6, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.textInput != null -> + generator.writeObject(value.textInput) + value.responseInputText != null -> + generator.writeObject(value.responseInputText) + value.outputText != null -> + generator.writeObject(value.outputText) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) + value.responseInputAudio != null -> + generator.writeObject(value.responseInputAudio) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent6" + ) + } + } + } + + /** A text output from the model. */ + class OutputText + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val additionalProperties: + MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + ) : this(text, type, mutableMapOf()) + + /** + * The text output from the model. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type or is unexpectedly missing or null + * (e.g. if the server responded with an unexpected + * value). + */ + fun text(): String = text.getRequired("text") + + /** + * The type of the output text. Always `output_text`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * However, this method can be useful for debugging and + * logging (e.g. if the server responded with an unexpected + * value). + */ + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("text") + @ExcludeMissing + fun _text(): JsonField = text + + @JsonAnySetter + private fun putAdditionalProperty( + key: String, + value: JsonValue, + ) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an + * instance of [OutputText]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputText]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = + JsonValue.from("output_text") + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(outputText: OutputText) = apply { + text = outputText.text + type = outputText.type + additionalProperties = + outputText.additionalProperties.toMutableMap() + } + + /** The text output from the model. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun text(text: JsonField) = apply { + this.text = text + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because + * the field defaults to the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty( + key: String, + value: JsonValue, + ) = apply { additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OutputText]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field + * is unset. + */ + fun build(): OutputText = + OutputText( + checkRequired("text", text), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OutputText = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("output_text")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("output_text")) 1 + else 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputText && + text == other.text && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" + } + + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val imageUrl: JsonField, + private val type: JsonValue, + private val detail: JsonField, + private val additionalProperties: + MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("image_url") + @ExcludeMissing + imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + detail: JsonField = JsonMissing.of(), + ) : this(imageUrl, type, detail, mutableMapOf()) + + /** + * The URL of the image input. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type or is unexpectedly missing or null + * (e.g. if the server responded with an unexpected + * value). + */ + fun imageUrl(): String = imageUrl.getRequired("image_url") + + /** + * The type of the image input. Always `input_image`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * However, this method can be useful for debugging and + * logging (e.g. if the server responded with an unexpected + * value). + */ + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonValue = type + + /** + * The detail level of the image to be sent to the model. + * One of `high`, `low`, or `auto`. Defaults to `auto`. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type (e.g. if the server responded with + * an unexpected value). + */ + fun detail(): Optional = + detail.getOptional("detail") + + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("image_url") + @ExcludeMissing + fun _imageUrl(): JsonField = imageUrl + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail + + @JsonAnySetter + private fun putAdditionalProperty( + key: String, + value: JsonValue, + ) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an + * instance of [EvalItemInputImage]. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EvalItemInputImage]. */ + class Builder internal constructor() { + + private var imageUrl: JsonField? = null + private var type: JsonValue = + JsonValue.from("input_image") + private var detail: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + evalItemInputImage: EvalItemInputImage + ) = apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties + .toMutableMap() + } + + /** The URL of the image input. */ + fun imageUrl(imageUrl: String) = + imageUrl(JsonField.of(imageUrl)) + + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imageUrl(imageUrl: JsonField) = apply { + this.imageUrl = imageUrl + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because + * the field defaults to the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * The detail level of the image to be sent to the + * model. One of `high`, `low`, or `auto`. Defaults to + * `auto`. + */ + fun detail(detail: String) = + detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun detail(detail: JsonField) = apply { + this.detail = detail + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty( + key: String, + value: JsonValue, + ) = apply { additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [EvalItemInputImage]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + * + * @throws IllegalStateException if any required field + * is unset. + */ + fun build(): EvalItemInputImage = + EvalItemInputImage( + checkRequired("imageUrl", imageUrl), + type, + detail, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EvalItemInputImage = apply { + if (validated) { + return@apply + } + + imageUrl() + _type().let { + if (it != JsonValue.from("input_image")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + detail() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (imageUrl.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("input_image")) 1 + else 0 + } + + (if (detail.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EvalItemInputImage && + imageUrl == other.imageUrl && + type == other.type && + detail == other.detail && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + imageUrl, + type, + detail, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt index 263508bf..675dc8b5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt @@ -4115,7 +4115,9 @@ private constructor( ) : this(content, role, type, mutableMapOf()) /** - * Inputs to the model - can contain template strings. + * Inputs to the model - can contain template strings. Supports text, + * output text, input images, and input audio, either as a single item + * or an array of items. * * @throws OpenAIInvalidDataException if the JSON field has an * unexpected type or is unexpectedly missing or null (e.g. if the @@ -4217,7 +4219,11 @@ private constructor( evalItem.additionalProperties.toMutableMap() } - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports + * text, output text, input images, and input audio, either as a + * single item or an array of items. + */ fun content(content: Content) = content(JsonField.of(content)) /** @@ -4254,10 +4260,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofInputImage(inputImage)`. + * `Content.ofEvalItemInputImage(evalItemInputImage)`. */ - fun content(inputImage: Content.InputImage) = - content(Content.ofInputImage(inputImage)) + fun content(evalItemInputImage: Content.EvalItemInputImage) = + content(Content.ofEvalItemInputImage(evalItemInputImage)) /** * Alias for calling [content] with @@ -4268,15 +4274,17 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextInputImageAndInputAudio(anArrayOfInputTextInputImageAndInputAudio)`. + * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. */ - fun contentOfAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = content( - Content.ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio - ) + Content + .ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) ) /** @@ -4385,7 +4393,11 @@ private constructor( (role.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports text, + * output text, input images, and input audio, either as a single item + * or an array of items. + */ @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) class Content @@ -4393,10 +4405,10 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, + private val evalItemInputImage: EvalItemInputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextInputImageAndInputAudio: - List? = + private val anArrayOfInputTextOutputTextInputImageAndInputAudio: + List? = null, private val _json: JsonValue? = null, ) { @@ -4412,9 +4424,9 @@ private constructor( fun outputText(): Optional = Optional.ofNullable(outputText) - /** An image input to the model. */ - fun inputImage(): Optional = - Optional.ofNullable(inputImage) + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -4422,11 +4434,13 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun anArrayOfInputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable(anArrayOfInputTextInputImageAndInputAudio) + fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): + Optional> = + Optional.ofNullable( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) fun isTextInput(): Boolean = textInput != null @@ -4434,12 +4448,13 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isInputImage(): Boolean = inputImage != null + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextInputImageAndInputAudio(): Boolean = - anArrayOfInputTextInputImageAndInputAudio != null + fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + Boolean = + anArrayOfInputTextOutputTextInputImageAndInputAudio != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -4451,8 +4466,9 @@ private constructor( /** A text output from the model. */ fun asOutputText(): OutputText = outputText.getOrThrow("outputText") - /** An image input to the model. */ - fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -4460,11 +4476,12 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun asAnArrayOfInputTextInputImageAndInputAudio(): List = - anArrayOfInputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextInputImageAndInputAudio" + fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + List = + anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( + "anArrayOfInputTextOutputTextInputImageAndInputAudio" ) fun _json(): Optional = Optional.ofNullable(_json) @@ -4475,13 +4492,16 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - inputImage != null -> visitor.visitInputImage(inputImage) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextInputImageAndInputAudio != null -> - visitor.visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio - ) + anArrayOfInputTextOutputTextInputImageAndInputAudio != + null -> + visitor + .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) else -> visitor.unknown(_json) } @@ -4506,8 +4526,10 @@ private constructor( outputText.validate() } - override fun visitInputImage(inputImage: InputImage) { - inputImage.validate() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() } override fun visitResponseInputAudio( @@ -4516,10 +4538,13 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: - List - ) {} + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) { + anArrayOfInputTextOutputTextInputImageAndInputAudio + .forEach { it.validate() } + } } ) validated = true @@ -4552,17 +4577,20 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitInputImage(inputImage: InputImage) = - inputImage.validity() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: - List - ) = anArrayOfInputTextInputImageAndInputAudio.size + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) = + anArrayOfInputTextOutputTextInputImageAndInputAudio + .sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -4577,10 +4605,11 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - inputImage == other.inputImage && + evalItemInputImage == other.evalItemInputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextInputImageAndInputAudio == - other.anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio == + other + .anArrayOfInputTextOutputTextInputImageAndInputAudio } override fun hashCode(): Int = @@ -4588,9 +4617,9 @@ private constructor( textInput, responseInputText, outputText, - inputImage, + evalItemInputImage, responseInputAudio, - anArrayOfInputTextInputImageAndInputAudio, + anArrayOfInputTextOutputTextInputImageAndInputAudio, ) override fun toString(): String = @@ -4599,11 +4628,13 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - inputImage != null -> "Content{inputImage=$inputImage}" + evalItemInputImage != null -> + "Content{evalItemInputImage=$evalItemInputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextInputImageAndInputAudio != null -> - "Content{anArrayOfInputTextInputImageAndInputAudio=$anArrayOfInputTextInputImageAndInputAudio}" + anArrayOfInputTextOutputTextInputImageAndInputAudio != + null -> + "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -4625,10 +4656,11 @@ private constructor( fun ofOutputText(outputText: OutputText) = Content(outputText = outputText) - /** An image input to the model. */ + /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofInputImage(inputImage: InputImage) = - Content(inputImage = inputImage) + fun ofEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = Content(evalItemInputImage = evalItemInputImage) /** An audio input to the model. */ @JvmStatic @@ -4638,15 +4670,16 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = Content( - anArrayOfInputTextInputImageAndInputAudio = - anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio .toImmutable() ) } @@ -4668,8 +4701,10 @@ private constructor( /** A text output from the model. */ fun visitOutputText(outputText: OutputText): T - /** An image input to the model. */ - fun visitInputImage(inputImage: InputImage): T + /** An image input block used within EvalItem content arrays. */ + fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -4678,10 +4713,11 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ): T /** @@ -4728,10 +4764,13 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - Content(inputImage = it, _json = json) + Content( + evalItemInputImage = it, + _json = json, + ) }, tryDeserialize( node, @@ -4749,11 +4788,13 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef>(), + jacksonTypeRef< + List + >(), ) ?.let { Content( - anArrayOfInputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio = it, _json = json, ) @@ -4794,14 +4835,16 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value.anArrayOfInputTextInputImageAndInputAudio != + value + .anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> generator.writeObject( - value.anArrayOfInputTextInputImageAndInputAudio + value + .anArrayOfInputTextOutputTextInputImageAndInputAudio ) value._json != null -> generator.writeObject(value._json) @@ -5047,8 +5090,8 @@ private constructor( "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" } - /** An image input to the model. */ - class InputImage + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -5143,7 +5186,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [InputImage]. + * [EvalItemInputImage]. * * The following fields are required: * ```java @@ -5153,7 +5196,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [InputImage]. */ + /** A builder for [EvalItemInputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -5164,13 +5207,15 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = - inputImage.additionalProperties.toMutableMap() - } + internal fun from(evalItemInputImage: EvalItemInputImage) = + apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties + .toMutableMap() + } /** The URL of the image input. */ fun imageUrl(imageUrl: String) = @@ -5248,7 +5293,7 @@ private constructor( } /** - * Returns an immutable instance of [InputImage]. + * Returns an immutable instance of [EvalItemInputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -5261,8 +5306,8 @@ private constructor( * @throws IllegalStateException if any required field is * unset. */ - fun build(): InputImage = - InputImage( + fun build(): EvalItemInputImage = + EvalItemInputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -5272,7 +5317,7 @@ private constructor( private var validated: Boolean = false - fun validate(): InputImage = apply { + fun validate(): EvalItemInputImage = apply { if (validated) { return@apply } @@ -5316,7 +5361,7 @@ private constructor( return true } - return other is InputImage && + return other is EvalItemInputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -5330,7 +5375,966 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } + + /** A text input to the model. */ + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent8.Deserializer::class + ) + @JsonSerialize( + using = UnnamedSchemaWithArrayParent8.Serializer::class + ) + class UnnamedSchemaWithArrayParent8 + private constructor( + private val textInput: String? = null, + private val responseInputText: ResponseInputText? = null, + private val outputText: OutputText? = null, + private val evalItemInputImage: EvalItemInputImage? = null, + private val responseInputAudio: ResponseInputAudio? = null, + private val _json: JsonValue? = null, + ) { + + /** A text input to the model. */ + fun textInput(): Optional = + Optional.ofNullable(textInput) + + /** A text input to the model. */ + fun responseInputText(): Optional = + Optional.ofNullable(responseInputText) + + /** A text output from the model. */ + fun outputText(): Optional = + Optional.ofNullable(outputText) + + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) + + /** An audio input to the model. */ + fun responseInputAudio(): Optional = + Optional.ofNullable(responseInputAudio) + + fun isTextInput(): Boolean = textInput != null + + fun isResponseInputText(): Boolean = responseInputText != null + + fun isOutputText(): Boolean = outputText != null + + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + + fun isResponseInputAudio(): Boolean = responseInputAudio != null + + /** A text input to the model. */ + fun asTextInput(): String = textInput.getOrThrow("textInput") + + /** A text input to the model. */ + fun asResponseInputText(): ResponseInputText = + responseInputText.getOrThrow("responseInputText") + + /** A text output from the model. */ + fun asOutputText(): OutputText = + outputText.getOrThrow("outputText") + + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") + + /** An audio input to the model. */ + fun asResponseInputAudio(): ResponseInputAudio = + responseInputAudio.getOrThrow("responseInputAudio") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + textInput != null -> visitor.visitTextInput(textInput) + responseInputText != null -> + visitor.visitResponseInputText(responseInputText) + outputText != null -> + visitor.visitOutputText(outputText) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) + responseInputAudio != null -> + visitor.visitResponseInputAudio(responseInputAudio) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent8 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTextInput(textInput: String) {} + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) { + responseInputText.validate() + } + + override fun visitOutputText( + outputText: OutputText + ) { + outputText.validate() + } + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() + } + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) { + responseInputAudio.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTextInput(textInput: String) = 1 + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) = responseInputText.validity() + + override fun visitOutputText( + outputText: OutputText + ) = outputText.validity() + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = responseInputAudio.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent8 && + textInput == other.textInput && + responseInputText == other.responseInputText && + outputText == other.outputText && + evalItemInputImage == other.evalItemInputImage && + responseInputAudio == other.responseInputAudio + } + + override fun hashCode(): Int = + Objects.hash( + textInput, + responseInputText, + outputText, + evalItemInputImage, + responseInputAudio, + ) + + override fun toString(): String = + when { + textInput != null -> + "UnnamedSchemaWithArrayParent8{textInput=$textInput}" + responseInputText != null -> + "UnnamedSchemaWithArrayParent8{responseInputText=$responseInputText}" + outputText != null -> + "UnnamedSchemaWithArrayParent8{outputText=$outputText}" + evalItemInputImage != null -> + "UnnamedSchemaWithArrayParent8{evalItemInputImage=$evalItemInputImage}" + responseInputAudio != null -> + "UnnamedSchemaWithArrayParent8{responseInputAudio=$responseInputAudio}" + _json != null -> + "UnnamedSchemaWithArrayParent8{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent8" + ) + } + + companion object { + + /** A text input to the model. */ + @JvmStatic + fun ofTextInput(textInput: String) = + UnnamedSchemaWithArrayParent8(textInput = textInput) + + /** A text input to the model. */ + @JvmStatic + fun ofResponseInputText( + responseInputText: ResponseInputText + ) = + UnnamedSchemaWithArrayParent8( + responseInputText = responseInputText + ) + + /** A text output from the model. */ + @JvmStatic + fun ofOutputText(outputText: OutputText) = + UnnamedSchemaWithArrayParent8(outputText = outputText) + + /** + * An image input block used within EvalItem content arrays. + */ + @JvmStatic + fun ofEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = + UnnamedSchemaWithArrayParent8( + evalItemInputImage = evalItemInputImage + ) + + /** An audio input to the model. */ + @JvmStatic + fun ofResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = + UnnamedSchemaWithArrayParent8( + responseInputAudio = responseInputAudio + ) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent8] to a value of type [T]. + */ + interface Visitor { + + /** A text input to the model. */ + fun visitTextInput(textInput: String): T + + /** A text input to the model. */ + fun visitResponseInputText( + responseInputText: ResponseInputText + ): T + + /** A text output from the model. */ + fun visitOutputText(outputText: OutputText): T + + /** + * An image input block used within EvalItem content arrays. + */ + fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ): T + + /** An audio input to the model. */ + fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent8] to a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent8] can + * contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware + * of. + * + * @throws OpenAIInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent8: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent8::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent8 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent8( + responseInputText = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent8( + outputText = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent8( + evalItemInputImage = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent8( + responseInputAudio = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent8( + textInput = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from array). + 0 -> UnnamedSchemaWithArrayParent8(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid + // match, or simply the first match if none are + // completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent8::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent8, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.textInput != null -> + generator.writeObject(value.textInput) + value.responseInputText != null -> + generator.writeObject(value.responseInputText) + value.outputText != null -> + generator.writeObject(value.outputText) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) + value.responseInputAudio != null -> + generator.writeObject(value.responseInputAudio) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent8" + ) + } + } + } + + /** A text output from the model. */ + class OutputText + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val additionalProperties: + MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + ) : this(text, type, mutableMapOf()) + + /** + * The text output from the model. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type or is unexpectedly missing or null + * (e.g. if the server responded with an unexpected + * value). + */ + fun text(): String = text.getRequired("text") + + /** + * The type of the output text. Always `output_text`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * However, this method can be useful for debugging and + * logging (e.g. if the server responded with an unexpected + * value). + */ + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("text") + @ExcludeMissing + fun _text(): JsonField = text + + @JsonAnySetter + private fun putAdditionalProperty( + key: String, + value: JsonValue, + ) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an + * instance of [OutputText]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputText]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = + JsonValue.from("output_text") + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(outputText: OutputText) = apply { + text = outputText.text + type = outputText.type + additionalProperties = + outputText.additionalProperties.toMutableMap() + } + + /** The text output from the model. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun text(text: JsonField) = apply { + this.text = text + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because + * the field defaults to the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty( + key: String, + value: JsonValue, + ) = apply { additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OutputText]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field + * is unset. + */ + fun build(): OutputText = + OutputText( + checkRequired("text", text), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OutputText = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("output_text")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("output_text")) 1 + else 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputText && + text == other.text && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" + } + + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val imageUrl: JsonField, + private val type: JsonValue, + private val detail: JsonField, + private val additionalProperties: + MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("image_url") + @ExcludeMissing + imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + detail: JsonField = JsonMissing.of(), + ) : this(imageUrl, type, detail, mutableMapOf()) + + /** + * The URL of the image input. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type or is unexpectedly missing or null + * (e.g. if the server responded with an unexpected + * value). + */ + fun imageUrl(): String = imageUrl.getRequired("image_url") + + /** + * The type of the image input. Always `input_image`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * However, this method can be useful for debugging and + * logging (e.g. if the server responded with an unexpected + * value). + */ + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonValue = type + + /** + * The detail level of the image to be sent to the model. + * One of `high`, `low`, or `auto`. Defaults to `auto`. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type (e.g. if the server responded with + * an unexpected value). + */ + fun detail(): Optional = + detail.getOptional("detail") + + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("image_url") + @ExcludeMissing + fun _imageUrl(): JsonField = imageUrl + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail + + @JsonAnySetter + private fun putAdditionalProperty( + key: String, + value: JsonValue, + ) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an + * instance of [EvalItemInputImage]. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EvalItemInputImage]. */ + class Builder internal constructor() { + + private var imageUrl: JsonField? = null + private var type: JsonValue = + JsonValue.from("input_image") + private var detail: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + evalItemInputImage: EvalItemInputImage + ) = apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties + .toMutableMap() + } + + /** The URL of the image input. */ + fun imageUrl(imageUrl: String) = + imageUrl(JsonField.of(imageUrl)) + + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imageUrl(imageUrl: JsonField) = apply { + this.imageUrl = imageUrl + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because + * the field defaults to the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * The detail level of the image to be sent to the + * model. One of `high`, `low`, or `auto`. Defaults to + * `auto`. + */ + fun detail(detail: String) = + detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun detail(detail: JsonField) = apply { + this.detail = detail + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty( + key: String, + value: JsonValue, + ) = apply { additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [EvalItemInputImage]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + * + * @throws IllegalStateException if any required field + * is unset. + */ + fun build(): EvalItemInputImage = + EvalItemInputImage( + checkRequired("imageUrl", imageUrl), + type, + detail, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EvalItemInputImage = apply { + if (validated) { + return@apply + } + + imageUrl() + _type().let { + if (it != JsonValue.from("input_image")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + detail() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (imageUrl.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("input_image")) 1 + else 0 + } + + (if (detail.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EvalItemInputImage && + imageUrl == other.imageUrl && + type == other.type && + detail == other.detail && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + imageUrl, + type, + detail, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt index 589bd9a1..128f79fa 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt @@ -4230,7 +4230,9 @@ private constructor( ) : this(content, role, type, mutableMapOf()) /** - * Inputs to the model - can contain template strings. + * Inputs to the model - can contain template strings. Supports text, + * output text, input images, and input audio, either as a single item + * or an array of items. * * @throws OpenAIInvalidDataException if the JSON field has an * unexpected type or is unexpectedly missing or null (e.g. if the @@ -4332,7 +4334,11 @@ private constructor( evalItem.additionalProperties.toMutableMap() } - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports + * text, output text, input images, and input audio, either as a + * single item or an array of items. + */ fun content(content: Content) = content(JsonField.of(content)) /** @@ -4369,10 +4375,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofInputImage(inputImage)`. + * `Content.ofEvalItemInputImage(evalItemInputImage)`. */ - fun content(inputImage: Content.InputImage) = - content(Content.ofInputImage(inputImage)) + fun content(evalItemInputImage: Content.EvalItemInputImage) = + content(Content.ofEvalItemInputImage(evalItemInputImage)) /** * Alias for calling [content] with @@ -4383,15 +4389,17 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextInputImageAndInputAudio(anArrayOfInputTextInputImageAndInputAudio)`. + * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. */ - fun contentOfAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = content( - Content.ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio - ) + Content + .ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) ) /** @@ -4500,7 +4508,11 @@ private constructor( (role.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports text, + * output text, input images, and input audio, either as a single item + * or an array of items. + */ @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) class Content @@ -4508,10 +4520,10 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, + private val evalItemInputImage: EvalItemInputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextInputImageAndInputAudio: - List? = + private val anArrayOfInputTextOutputTextInputImageAndInputAudio: + List? = null, private val _json: JsonValue? = null, ) { @@ -4527,9 +4539,9 @@ private constructor( fun outputText(): Optional = Optional.ofNullable(outputText) - /** An image input to the model. */ - fun inputImage(): Optional = - Optional.ofNullable(inputImage) + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -4537,11 +4549,13 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun anArrayOfInputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable(anArrayOfInputTextInputImageAndInputAudio) + fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): + Optional> = + Optional.ofNullable( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) fun isTextInput(): Boolean = textInput != null @@ -4549,12 +4563,13 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isInputImage(): Boolean = inputImage != null + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextInputImageAndInputAudio(): Boolean = - anArrayOfInputTextInputImageAndInputAudio != null + fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + Boolean = + anArrayOfInputTextOutputTextInputImageAndInputAudio != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -4566,8 +4581,9 @@ private constructor( /** A text output from the model. */ fun asOutputText(): OutputText = outputText.getOrThrow("outputText") - /** An image input to the model. */ - fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -4575,11 +4591,12 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun asAnArrayOfInputTextInputImageAndInputAudio(): List = - anArrayOfInputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextInputImageAndInputAudio" + fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + List = + anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( + "anArrayOfInputTextOutputTextInputImageAndInputAudio" ) fun _json(): Optional = Optional.ofNullable(_json) @@ -4590,13 +4607,16 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - inputImage != null -> visitor.visitInputImage(inputImage) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextInputImageAndInputAudio != null -> - visitor.visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio - ) + anArrayOfInputTextOutputTextInputImageAndInputAudio != + null -> + visitor + .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) else -> visitor.unknown(_json) } @@ -4621,8 +4641,10 @@ private constructor( outputText.validate() } - override fun visitInputImage(inputImage: InputImage) { - inputImage.validate() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() } override fun visitResponseInputAudio( @@ -4631,10 +4653,13 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: - List - ) {} + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) { + anArrayOfInputTextOutputTextInputImageAndInputAudio + .forEach { it.validate() } + } } ) validated = true @@ -4667,17 +4692,20 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitInputImage(inputImage: InputImage) = - inputImage.validity() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: - List - ) = anArrayOfInputTextInputImageAndInputAudio.size + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) = + anArrayOfInputTextOutputTextInputImageAndInputAudio + .sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -4692,10 +4720,11 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - inputImage == other.inputImage && + evalItemInputImage == other.evalItemInputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextInputImageAndInputAudio == - other.anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio == + other + .anArrayOfInputTextOutputTextInputImageAndInputAudio } override fun hashCode(): Int = @@ -4703,9 +4732,9 @@ private constructor( textInput, responseInputText, outputText, - inputImage, + evalItemInputImage, responseInputAudio, - anArrayOfInputTextInputImageAndInputAudio, + anArrayOfInputTextOutputTextInputImageAndInputAudio, ) override fun toString(): String = @@ -4714,11 +4743,13 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - inputImage != null -> "Content{inputImage=$inputImage}" + evalItemInputImage != null -> + "Content{evalItemInputImage=$evalItemInputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextInputImageAndInputAudio != null -> - "Content{anArrayOfInputTextInputImageAndInputAudio=$anArrayOfInputTextInputImageAndInputAudio}" + anArrayOfInputTextOutputTextInputImageAndInputAudio != + null -> + "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -4740,10 +4771,11 @@ private constructor( fun ofOutputText(outputText: OutputText) = Content(outputText = outputText) - /** An image input to the model. */ + /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofInputImage(inputImage: InputImage) = - Content(inputImage = inputImage) + fun ofEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = Content(evalItemInputImage = evalItemInputImage) /** An audio input to the model. */ @JvmStatic @@ -4753,15 +4785,16 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = Content( - anArrayOfInputTextInputImageAndInputAudio = - anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio .toImmutable() ) } @@ -4783,8 +4816,10 @@ private constructor( /** A text output from the model. */ fun visitOutputText(outputText: OutputText): T - /** An image input to the model. */ - fun visitInputImage(inputImage: InputImage): T + /** An image input block used within EvalItem content arrays. */ + fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -4793,10 +4828,11 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ): T /** @@ -4843,10 +4879,13 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - Content(inputImage = it, _json = json) + Content( + evalItemInputImage = it, + _json = json, + ) }, tryDeserialize( node, @@ -4864,11 +4903,13 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef>(), + jacksonTypeRef< + List + >(), ) ?.let { Content( - anArrayOfInputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio = it, _json = json, ) @@ -4909,14 +4950,16 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value.anArrayOfInputTextInputImageAndInputAudio != + value + .anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> generator.writeObject( - value.anArrayOfInputTextInputImageAndInputAudio + value + .anArrayOfInputTextOutputTextInputImageAndInputAudio ) value._json != null -> generator.writeObject(value._json) @@ -5162,8 +5205,8 @@ private constructor( "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" } - /** An image input to the model. */ - class InputImage + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -5258,7 +5301,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [InputImage]. + * [EvalItemInputImage]. * * The following fields are required: * ```java @@ -5268,7 +5311,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [InputImage]. */ + /** A builder for [EvalItemInputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -5279,13 +5322,15 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = - inputImage.additionalProperties.toMutableMap() - } + internal fun from(evalItemInputImage: EvalItemInputImage) = + apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties + .toMutableMap() + } /** The URL of the image input. */ fun imageUrl(imageUrl: String) = @@ -5363,7 +5408,7 @@ private constructor( } /** - * Returns an immutable instance of [InputImage]. + * Returns an immutable instance of [EvalItemInputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -5376,8 +5421,8 @@ private constructor( * @throws IllegalStateException if any required field is * unset. */ - fun build(): InputImage = - InputImage( + fun build(): EvalItemInputImage = + EvalItemInputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -5387,7 +5432,7 @@ private constructor( private var validated: Boolean = false - fun validate(): InputImage = apply { + fun validate(): EvalItemInputImage = apply { if (validated) { return@apply } @@ -5431,7 +5476,7 @@ private constructor( return true } - return other is InputImage && + return other is EvalItemInputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -5445,7 +5490,966 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } + + /** A text input to the model. */ + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent3.Deserializer::class + ) + @JsonSerialize( + using = UnnamedSchemaWithArrayParent3.Serializer::class + ) + class UnnamedSchemaWithArrayParent3 + private constructor( + private val textInput: String? = null, + private val responseInputText: ResponseInputText? = null, + private val outputText: OutputText? = null, + private val evalItemInputImage: EvalItemInputImage? = null, + private val responseInputAudio: ResponseInputAudio? = null, + private val _json: JsonValue? = null, + ) { + + /** A text input to the model. */ + fun textInput(): Optional = + Optional.ofNullable(textInput) + + /** A text input to the model. */ + fun responseInputText(): Optional = + Optional.ofNullable(responseInputText) + + /** A text output from the model. */ + fun outputText(): Optional = + Optional.ofNullable(outputText) + + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) + + /** An audio input to the model. */ + fun responseInputAudio(): Optional = + Optional.ofNullable(responseInputAudio) + + fun isTextInput(): Boolean = textInput != null + + fun isResponseInputText(): Boolean = responseInputText != null + + fun isOutputText(): Boolean = outputText != null + + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + + fun isResponseInputAudio(): Boolean = responseInputAudio != null + + /** A text input to the model. */ + fun asTextInput(): String = textInput.getOrThrow("textInput") + + /** A text input to the model. */ + fun asResponseInputText(): ResponseInputText = + responseInputText.getOrThrow("responseInputText") + + /** A text output from the model. */ + fun asOutputText(): OutputText = + outputText.getOrThrow("outputText") + + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") + + /** An audio input to the model. */ + fun asResponseInputAudio(): ResponseInputAudio = + responseInputAudio.getOrThrow("responseInputAudio") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + textInput != null -> visitor.visitTextInput(textInput) + responseInputText != null -> + visitor.visitResponseInputText(responseInputText) + outputText != null -> + visitor.visitOutputText(outputText) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) + responseInputAudio != null -> + visitor.visitResponseInputAudio(responseInputAudio) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent3 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTextInput(textInput: String) {} + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) { + responseInputText.validate() + } + + override fun visitOutputText( + outputText: OutputText + ) { + outputText.validate() + } + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() + } + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) { + responseInputAudio.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTextInput(textInput: String) = 1 + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) = responseInputText.validity() + + override fun visitOutputText( + outputText: OutputText + ) = outputText.validity() + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = responseInputAudio.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent3 && + textInput == other.textInput && + responseInputText == other.responseInputText && + outputText == other.outputText && + evalItemInputImage == other.evalItemInputImage && + responseInputAudio == other.responseInputAudio + } + + override fun hashCode(): Int = + Objects.hash( + textInput, + responseInputText, + outputText, + evalItemInputImage, + responseInputAudio, + ) + + override fun toString(): String = + when { + textInput != null -> + "UnnamedSchemaWithArrayParent3{textInput=$textInput}" + responseInputText != null -> + "UnnamedSchemaWithArrayParent3{responseInputText=$responseInputText}" + outputText != null -> + "UnnamedSchemaWithArrayParent3{outputText=$outputText}" + evalItemInputImage != null -> + "UnnamedSchemaWithArrayParent3{evalItemInputImage=$evalItemInputImage}" + responseInputAudio != null -> + "UnnamedSchemaWithArrayParent3{responseInputAudio=$responseInputAudio}" + _json != null -> + "UnnamedSchemaWithArrayParent3{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent3" + ) + } + + companion object { + + /** A text input to the model. */ + @JvmStatic + fun ofTextInput(textInput: String) = + UnnamedSchemaWithArrayParent3(textInput = textInput) + + /** A text input to the model. */ + @JvmStatic + fun ofResponseInputText( + responseInputText: ResponseInputText + ) = + UnnamedSchemaWithArrayParent3( + responseInputText = responseInputText + ) + + /** A text output from the model. */ + @JvmStatic + fun ofOutputText(outputText: OutputText) = + UnnamedSchemaWithArrayParent3(outputText = outputText) + + /** + * An image input block used within EvalItem content arrays. + */ + @JvmStatic + fun ofEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = + UnnamedSchemaWithArrayParent3( + evalItemInputImage = evalItemInputImage + ) + + /** An audio input to the model. */ + @JvmStatic + fun ofResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = + UnnamedSchemaWithArrayParent3( + responseInputAudio = responseInputAudio + ) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent3] to a value of type [T]. + */ + interface Visitor { + + /** A text input to the model. */ + fun visitTextInput(textInput: String): T + + /** A text input to the model. */ + fun visitResponseInputText( + responseInputText: ResponseInputText + ): T + + /** A text output from the model. */ + fun visitOutputText(outputText: OutputText): T + + /** + * An image input block used within EvalItem content arrays. + */ + fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ): T + + /** An audio input to the model. */ + fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent3] to a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent3] can + * contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware + * of. + * + * @throws OpenAIInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent3: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent3::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent3 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent3( + responseInputText = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent3( + outputText = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent3( + evalItemInputImage = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent3( + responseInputAudio = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent3( + textInput = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from array). + 0 -> UnnamedSchemaWithArrayParent3(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid + // match, or simply the first match if none are + // completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent3::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent3, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.textInput != null -> + generator.writeObject(value.textInput) + value.responseInputText != null -> + generator.writeObject(value.responseInputText) + value.outputText != null -> + generator.writeObject(value.outputText) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) + value.responseInputAudio != null -> + generator.writeObject(value.responseInputAudio) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent3" + ) + } + } + } + + /** A text output from the model. */ + class OutputText + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val additionalProperties: + MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + ) : this(text, type, mutableMapOf()) + + /** + * The text output from the model. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type or is unexpectedly missing or null + * (e.g. if the server responded with an unexpected + * value). + */ + fun text(): String = text.getRequired("text") + + /** + * The type of the output text. Always `output_text`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * However, this method can be useful for debugging and + * logging (e.g. if the server responded with an unexpected + * value). + */ + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("text") + @ExcludeMissing + fun _text(): JsonField = text + + @JsonAnySetter + private fun putAdditionalProperty( + key: String, + value: JsonValue, + ) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an + * instance of [OutputText]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputText]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = + JsonValue.from("output_text") + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(outputText: OutputText) = apply { + text = outputText.text + type = outputText.type + additionalProperties = + outputText.additionalProperties.toMutableMap() + } + + /** The text output from the model. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun text(text: JsonField) = apply { + this.text = text + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because + * the field defaults to the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty( + key: String, + value: JsonValue, + ) = apply { additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OutputText]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field + * is unset. + */ + fun build(): OutputText = + OutputText( + checkRequired("text", text), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OutputText = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("output_text")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("output_text")) 1 + else 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputText && + text == other.text && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" + } + + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val imageUrl: JsonField, + private val type: JsonValue, + private val detail: JsonField, + private val additionalProperties: + MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("image_url") + @ExcludeMissing + imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + detail: JsonField = JsonMissing.of(), + ) : this(imageUrl, type, detail, mutableMapOf()) + + /** + * The URL of the image input. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type or is unexpectedly missing or null + * (e.g. if the server responded with an unexpected + * value). + */ + fun imageUrl(): String = imageUrl.getRequired("image_url") + + /** + * The type of the image input. Always `input_image`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * However, this method can be useful for debugging and + * logging (e.g. if the server responded with an unexpected + * value). + */ + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonValue = type + + /** + * The detail level of the image to be sent to the model. + * One of `high`, `low`, or `auto`. Defaults to `auto`. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type (e.g. if the server responded with + * an unexpected value). + */ + fun detail(): Optional = + detail.getOptional("detail") + + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("image_url") + @ExcludeMissing + fun _imageUrl(): JsonField = imageUrl + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail + + @JsonAnySetter + private fun putAdditionalProperty( + key: String, + value: JsonValue, + ) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an + * instance of [EvalItemInputImage]. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EvalItemInputImage]. */ + class Builder internal constructor() { + + private var imageUrl: JsonField? = null + private var type: JsonValue = + JsonValue.from("input_image") + private var detail: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + evalItemInputImage: EvalItemInputImage + ) = apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties + .toMutableMap() + } + + /** The URL of the image input. */ + fun imageUrl(imageUrl: String) = + imageUrl(JsonField.of(imageUrl)) + + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imageUrl(imageUrl: JsonField) = apply { + this.imageUrl = imageUrl + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because + * the field defaults to the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * The detail level of the image to be sent to the + * model. One of `high`, `low`, or `auto`. Defaults to + * `auto`. + */ + fun detail(detail: String) = + detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun detail(detail: JsonField) = apply { + this.detail = detail + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty( + key: String, + value: JsonValue, + ) = apply { additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [EvalItemInputImage]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + * + * @throws IllegalStateException if any required field + * is unset. + */ + fun build(): EvalItemInputImage = + EvalItemInputImage( + checkRequired("imageUrl", imageUrl), + type, + detail, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EvalItemInputImage = apply { + if (validated) { + return@apply + } + + imageUrl() + _type().let { + if (it != JsonValue.from("input_image")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + detail() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (imageUrl.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("input_image")) 1 + else 0 + } + + (if (detail.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EvalItemInputImage && + imageUrl == other.imageUrl && + type == other.type && + detail == other.detail && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + imageUrl, + type, + detail, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt index 6653a4d0..c6196956 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt @@ -4230,7 +4230,9 @@ private constructor( ) : this(content, role, type, mutableMapOf()) /** - * Inputs to the model - can contain template strings. + * Inputs to the model - can contain template strings. Supports text, + * output text, input images, and input audio, either as a single item + * or an array of items. * * @throws OpenAIInvalidDataException if the JSON field has an * unexpected type or is unexpectedly missing or null (e.g. if the @@ -4332,7 +4334,11 @@ private constructor( evalItem.additionalProperties.toMutableMap() } - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports + * text, output text, input images, and input audio, either as a + * single item or an array of items. + */ fun content(content: Content) = content(JsonField.of(content)) /** @@ -4369,10 +4375,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofInputImage(inputImage)`. + * `Content.ofEvalItemInputImage(evalItemInputImage)`. */ - fun content(inputImage: Content.InputImage) = - content(Content.ofInputImage(inputImage)) + fun content(evalItemInputImage: Content.EvalItemInputImage) = + content(Content.ofEvalItemInputImage(evalItemInputImage)) /** * Alias for calling [content] with @@ -4383,15 +4389,17 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextInputImageAndInputAudio(anArrayOfInputTextInputImageAndInputAudio)`. + * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. */ - fun contentOfAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = content( - Content.ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio - ) + Content + .ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) ) /** @@ -4500,7 +4508,11 @@ private constructor( (role.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports text, + * output text, input images, and input audio, either as a single item + * or an array of items. + */ @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) class Content @@ -4508,10 +4520,10 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, + private val evalItemInputImage: EvalItemInputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextInputImageAndInputAudio: - List? = + private val anArrayOfInputTextOutputTextInputImageAndInputAudio: + List? = null, private val _json: JsonValue? = null, ) { @@ -4527,9 +4539,9 @@ private constructor( fun outputText(): Optional = Optional.ofNullable(outputText) - /** An image input to the model. */ - fun inputImage(): Optional = - Optional.ofNullable(inputImage) + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -4537,11 +4549,13 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun anArrayOfInputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable(anArrayOfInputTextInputImageAndInputAudio) + fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): + Optional> = + Optional.ofNullable( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) fun isTextInput(): Boolean = textInput != null @@ -4549,12 +4563,13 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isInputImage(): Boolean = inputImage != null + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextInputImageAndInputAudio(): Boolean = - anArrayOfInputTextInputImageAndInputAudio != null + fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + Boolean = + anArrayOfInputTextOutputTextInputImageAndInputAudio != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -4566,8 +4581,9 @@ private constructor( /** A text output from the model. */ fun asOutputText(): OutputText = outputText.getOrThrow("outputText") - /** An image input to the model. */ - fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -4575,11 +4591,12 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun asAnArrayOfInputTextInputImageAndInputAudio(): List = - anArrayOfInputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextInputImageAndInputAudio" + fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + List = + anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( + "anArrayOfInputTextOutputTextInputImageAndInputAudio" ) fun _json(): Optional = Optional.ofNullable(_json) @@ -4590,13 +4607,16 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - inputImage != null -> visitor.visitInputImage(inputImage) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextInputImageAndInputAudio != null -> - visitor.visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio - ) + anArrayOfInputTextOutputTextInputImageAndInputAudio != + null -> + visitor + .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) else -> visitor.unknown(_json) } @@ -4621,8 +4641,10 @@ private constructor( outputText.validate() } - override fun visitInputImage(inputImage: InputImage) { - inputImage.validate() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() } override fun visitResponseInputAudio( @@ -4631,10 +4653,13 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: - List - ) {} + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) { + anArrayOfInputTextOutputTextInputImageAndInputAudio + .forEach { it.validate() } + } } ) validated = true @@ -4667,17 +4692,20 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitInputImage(inputImage: InputImage) = - inputImage.validity() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: - List - ) = anArrayOfInputTextInputImageAndInputAudio.size + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) = + anArrayOfInputTextOutputTextInputImageAndInputAudio + .sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -4692,10 +4720,11 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - inputImage == other.inputImage && + evalItemInputImage == other.evalItemInputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextInputImageAndInputAudio == - other.anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio == + other + .anArrayOfInputTextOutputTextInputImageAndInputAudio } override fun hashCode(): Int = @@ -4703,9 +4732,9 @@ private constructor( textInput, responseInputText, outputText, - inputImage, + evalItemInputImage, responseInputAudio, - anArrayOfInputTextInputImageAndInputAudio, + anArrayOfInputTextOutputTextInputImageAndInputAudio, ) override fun toString(): String = @@ -4714,11 +4743,13 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - inputImage != null -> "Content{inputImage=$inputImage}" + evalItemInputImage != null -> + "Content{evalItemInputImage=$evalItemInputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextInputImageAndInputAudio != null -> - "Content{anArrayOfInputTextInputImageAndInputAudio=$anArrayOfInputTextInputImageAndInputAudio}" + anArrayOfInputTextOutputTextInputImageAndInputAudio != + null -> + "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -4740,10 +4771,11 @@ private constructor( fun ofOutputText(outputText: OutputText) = Content(outputText = outputText) - /** An image input to the model. */ + /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofInputImage(inputImage: InputImage) = - Content(inputImage = inputImage) + fun ofEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = Content(evalItemInputImage = evalItemInputImage) /** An audio input to the model. */ @JvmStatic @@ -4753,15 +4785,16 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = Content( - anArrayOfInputTextInputImageAndInputAudio = - anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio .toImmutable() ) } @@ -4783,8 +4816,10 @@ private constructor( /** A text output from the model. */ fun visitOutputText(outputText: OutputText): T - /** An image input to the model. */ - fun visitInputImage(inputImage: InputImage): T + /** An image input block used within EvalItem content arrays. */ + fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -4793,10 +4828,11 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ): T /** @@ -4843,10 +4879,13 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - Content(inputImage = it, _json = json) + Content( + evalItemInputImage = it, + _json = json, + ) }, tryDeserialize( node, @@ -4864,11 +4903,13 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef>(), + jacksonTypeRef< + List + >(), ) ?.let { Content( - anArrayOfInputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio = it, _json = json, ) @@ -4909,14 +4950,16 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value.anArrayOfInputTextInputImageAndInputAudio != + value + .anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> generator.writeObject( - value.anArrayOfInputTextInputImageAndInputAudio + value + .anArrayOfInputTextOutputTextInputImageAndInputAudio ) value._json != null -> generator.writeObject(value._json) @@ -5162,8 +5205,8 @@ private constructor( "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" } - /** An image input to the model. */ - class InputImage + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -5258,7 +5301,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [InputImage]. + * [EvalItemInputImage]. * * The following fields are required: * ```java @@ -5268,7 +5311,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [InputImage]. */ + /** A builder for [EvalItemInputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -5279,13 +5322,15 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = - inputImage.additionalProperties.toMutableMap() - } + internal fun from(evalItemInputImage: EvalItemInputImage) = + apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties + .toMutableMap() + } /** The URL of the image input. */ fun imageUrl(imageUrl: String) = @@ -5363,7 +5408,7 @@ private constructor( } /** - * Returns an immutable instance of [InputImage]. + * Returns an immutable instance of [EvalItemInputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -5376,8 +5421,8 @@ private constructor( * @throws IllegalStateException if any required field is * unset. */ - fun build(): InputImage = - InputImage( + fun build(): EvalItemInputImage = + EvalItemInputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -5387,7 +5432,7 @@ private constructor( private var validated: Boolean = false - fun validate(): InputImage = apply { + fun validate(): EvalItemInputImage = apply { if (validated) { return@apply } @@ -5431,7 +5476,7 @@ private constructor( return true } - return other is InputImage && + return other is EvalItemInputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -5445,7 +5490,966 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } + + /** A text input to the model. */ + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent5.Deserializer::class + ) + @JsonSerialize( + using = UnnamedSchemaWithArrayParent5.Serializer::class + ) + class UnnamedSchemaWithArrayParent5 + private constructor( + private val textInput: String? = null, + private val responseInputText: ResponseInputText? = null, + private val outputText: OutputText? = null, + private val evalItemInputImage: EvalItemInputImage? = null, + private val responseInputAudio: ResponseInputAudio? = null, + private val _json: JsonValue? = null, + ) { + + /** A text input to the model. */ + fun textInput(): Optional = + Optional.ofNullable(textInput) + + /** A text input to the model. */ + fun responseInputText(): Optional = + Optional.ofNullable(responseInputText) + + /** A text output from the model. */ + fun outputText(): Optional = + Optional.ofNullable(outputText) + + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) + + /** An audio input to the model. */ + fun responseInputAudio(): Optional = + Optional.ofNullable(responseInputAudio) + + fun isTextInput(): Boolean = textInput != null + + fun isResponseInputText(): Boolean = responseInputText != null + + fun isOutputText(): Boolean = outputText != null + + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + + fun isResponseInputAudio(): Boolean = responseInputAudio != null + + /** A text input to the model. */ + fun asTextInput(): String = textInput.getOrThrow("textInput") + + /** A text input to the model. */ + fun asResponseInputText(): ResponseInputText = + responseInputText.getOrThrow("responseInputText") + + /** A text output from the model. */ + fun asOutputText(): OutputText = + outputText.getOrThrow("outputText") + + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") + + /** An audio input to the model. */ + fun asResponseInputAudio(): ResponseInputAudio = + responseInputAudio.getOrThrow("responseInputAudio") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + textInput != null -> visitor.visitTextInput(textInput) + responseInputText != null -> + visitor.visitResponseInputText(responseInputText) + outputText != null -> + visitor.visitOutputText(outputText) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) + responseInputAudio != null -> + visitor.visitResponseInputAudio(responseInputAudio) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent5 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTextInput(textInput: String) {} + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) { + responseInputText.validate() + } + + override fun visitOutputText( + outputText: OutputText + ) { + outputText.validate() + } + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() + } + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) { + responseInputAudio.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTextInput(textInput: String) = 1 + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) = responseInputText.validity() + + override fun visitOutputText( + outputText: OutputText + ) = outputText.validity() + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = responseInputAudio.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent5 && + textInput == other.textInput && + responseInputText == other.responseInputText && + outputText == other.outputText && + evalItemInputImage == other.evalItemInputImage && + responseInputAudio == other.responseInputAudio + } + + override fun hashCode(): Int = + Objects.hash( + textInput, + responseInputText, + outputText, + evalItemInputImage, + responseInputAudio, + ) + + override fun toString(): String = + when { + textInput != null -> + "UnnamedSchemaWithArrayParent5{textInput=$textInput}" + responseInputText != null -> + "UnnamedSchemaWithArrayParent5{responseInputText=$responseInputText}" + outputText != null -> + "UnnamedSchemaWithArrayParent5{outputText=$outputText}" + evalItemInputImage != null -> + "UnnamedSchemaWithArrayParent5{evalItemInputImage=$evalItemInputImage}" + responseInputAudio != null -> + "UnnamedSchemaWithArrayParent5{responseInputAudio=$responseInputAudio}" + _json != null -> + "UnnamedSchemaWithArrayParent5{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent5" + ) + } + + companion object { + + /** A text input to the model. */ + @JvmStatic + fun ofTextInput(textInput: String) = + UnnamedSchemaWithArrayParent5(textInput = textInput) + + /** A text input to the model. */ + @JvmStatic + fun ofResponseInputText( + responseInputText: ResponseInputText + ) = + UnnamedSchemaWithArrayParent5( + responseInputText = responseInputText + ) + + /** A text output from the model. */ + @JvmStatic + fun ofOutputText(outputText: OutputText) = + UnnamedSchemaWithArrayParent5(outputText = outputText) + + /** + * An image input block used within EvalItem content arrays. + */ + @JvmStatic + fun ofEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = + UnnamedSchemaWithArrayParent5( + evalItemInputImage = evalItemInputImage + ) + + /** An audio input to the model. */ + @JvmStatic + fun ofResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = + UnnamedSchemaWithArrayParent5( + responseInputAudio = responseInputAudio + ) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent5] to a value of type [T]. + */ + interface Visitor { + + /** A text input to the model. */ + fun visitTextInput(textInput: String): T + + /** A text input to the model. */ + fun visitResponseInputText( + responseInputText: ResponseInputText + ): T + + /** A text output from the model. */ + fun visitOutputText(outputText: OutputText): T + + /** + * An image input block used within EvalItem content arrays. + */ + fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ): T + + /** An audio input to the model. */ + fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent5] to a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent5] can + * contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware + * of. + * + * @throws OpenAIInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent5: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent5::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent5 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent5( + responseInputText = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent5( + outputText = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent5( + evalItemInputImage = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent5( + responseInputAudio = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent5( + textInput = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from array). + 0 -> UnnamedSchemaWithArrayParent5(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid + // match, or simply the first match if none are + // completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent5::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent5, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.textInput != null -> + generator.writeObject(value.textInput) + value.responseInputText != null -> + generator.writeObject(value.responseInputText) + value.outputText != null -> + generator.writeObject(value.outputText) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) + value.responseInputAudio != null -> + generator.writeObject(value.responseInputAudio) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent5" + ) + } + } + } + + /** A text output from the model. */ + class OutputText + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val additionalProperties: + MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + ) : this(text, type, mutableMapOf()) + + /** + * The text output from the model. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type or is unexpectedly missing or null + * (e.g. if the server responded with an unexpected + * value). + */ + fun text(): String = text.getRequired("text") + + /** + * The type of the output text. Always `output_text`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * However, this method can be useful for debugging and + * logging (e.g. if the server responded with an unexpected + * value). + */ + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("text") + @ExcludeMissing + fun _text(): JsonField = text + + @JsonAnySetter + private fun putAdditionalProperty( + key: String, + value: JsonValue, + ) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an + * instance of [OutputText]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputText]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = + JsonValue.from("output_text") + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(outputText: OutputText) = apply { + text = outputText.text + type = outputText.type + additionalProperties = + outputText.additionalProperties.toMutableMap() + } + + /** The text output from the model. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun text(text: JsonField) = apply { + this.text = text + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because + * the field defaults to the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty( + key: String, + value: JsonValue, + ) = apply { additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OutputText]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field + * is unset. + */ + fun build(): OutputText = + OutputText( + checkRequired("text", text), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OutputText = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("output_text")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("output_text")) 1 + else 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputText && + text == other.text && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" + } + + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val imageUrl: JsonField, + private val type: JsonValue, + private val detail: JsonField, + private val additionalProperties: + MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("image_url") + @ExcludeMissing + imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + detail: JsonField = JsonMissing.of(), + ) : this(imageUrl, type, detail, mutableMapOf()) + + /** + * The URL of the image input. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type or is unexpectedly missing or null + * (e.g. if the server responded with an unexpected + * value). + */ + fun imageUrl(): String = imageUrl.getRequired("image_url") + + /** + * The type of the image input. Always `input_image`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * However, this method can be useful for debugging and + * logging (e.g. if the server responded with an unexpected + * value). + */ + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonValue = type + + /** + * The detail level of the image to be sent to the model. + * One of `high`, `low`, or `auto`. Defaults to `auto`. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type (e.g. if the server responded with + * an unexpected value). + */ + fun detail(): Optional = + detail.getOptional("detail") + + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("image_url") + @ExcludeMissing + fun _imageUrl(): JsonField = imageUrl + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail + + @JsonAnySetter + private fun putAdditionalProperty( + key: String, + value: JsonValue, + ) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an + * instance of [EvalItemInputImage]. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EvalItemInputImage]. */ + class Builder internal constructor() { + + private var imageUrl: JsonField? = null + private var type: JsonValue = + JsonValue.from("input_image") + private var detail: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + evalItemInputImage: EvalItemInputImage + ) = apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties + .toMutableMap() + } + + /** The URL of the image input. */ + fun imageUrl(imageUrl: String) = + imageUrl(JsonField.of(imageUrl)) + + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imageUrl(imageUrl: JsonField) = apply { + this.imageUrl = imageUrl + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because + * the field defaults to the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * The detail level of the image to be sent to the + * model. One of `high`, `low`, or `auto`. Defaults to + * `auto`. + */ + fun detail(detail: String) = + detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun detail(detail: JsonField) = apply { + this.detail = detail + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty( + key: String, + value: JsonValue, + ) = apply { additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [EvalItemInputImage]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + * + * @throws IllegalStateException if any required field + * is unset. + */ + fun build(): EvalItemInputImage = + EvalItemInputImage( + checkRequired("imageUrl", imageUrl), + type, + detail, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EvalItemInputImage = apply { + if (validated) { + return@apply + } + + imageUrl() + _type().let { + if (it != JsonValue.from("input_image")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + detail() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (imageUrl.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("input_image")) 1 + else 0 + } + + (if (detail.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EvalItemInputImage && + imageUrl == other.imageUrl && + type == other.type && + detail == other.detail && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + imageUrl, + type, + detail, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt index 81d9ff1d..f6b4e58b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt @@ -4230,7 +4230,9 @@ private constructor( ) : this(content, role, type, mutableMapOf()) /** - * Inputs to the model - can contain template strings. + * Inputs to the model - can contain template strings. Supports text, + * output text, input images, and input audio, either as a single item + * or an array of items. * * @throws OpenAIInvalidDataException if the JSON field has an * unexpected type or is unexpectedly missing or null (e.g. if the @@ -4332,7 +4334,11 @@ private constructor( evalItem.additionalProperties.toMutableMap() } - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports + * text, output text, input images, and input audio, either as a + * single item or an array of items. + */ fun content(content: Content) = content(JsonField.of(content)) /** @@ -4369,10 +4375,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofInputImage(inputImage)`. + * `Content.ofEvalItemInputImage(evalItemInputImage)`. */ - fun content(inputImage: Content.InputImage) = - content(Content.ofInputImage(inputImage)) + fun content(evalItemInputImage: Content.EvalItemInputImage) = + content(Content.ofEvalItemInputImage(evalItemInputImage)) /** * Alias for calling [content] with @@ -4383,15 +4389,17 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextInputImageAndInputAudio(anArrayOfInputTextInputImageAndInputAudio)`. + * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. */ - fun contentOfAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = content( - Content.ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio - ) + Content + .ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) ) /** @@ -4500,7 +4508,11 @@ private constructor( (role.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports text, + * output text, input images, and input audio, either as a single item + * or an array of items. + */ @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) class Content @@ -4508,10 +4520,10 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, + private val evalItemInputImage: EvalItemInputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextInputImageAndInputAudio: - List? = + private val anArrayOfInputTextOutputTextInputImageAndInputAudio: + List? = null, private val _json: JsonValue? = null, ) { @@ -4527,9 +4539,9 @@ private constructor( fun outputText(): Optional = Optional.ofNullable(outputText) - /** An image input to the model. */ - fun inputImage(): Optional = - Optional.ofNullable(inputImage) + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -4537,11 +4549,13 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun anArrayOfInputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable(anArrayOfInputTextInputImageAndInputAudio) + fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): + Optional> = + Optional.ofNullable( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) fun isTextInput(): Boolean = textInput != null @@ -4549,12 +4563,13 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isInputImage(): Boolean = inputImage != null + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextInputImageAndInputAudio(): Boolean = - anArrayOfInputTextInputImageAndInputAudio != null + fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + Boolean = + anArrayOfInputTextOutputTextInputImageAndInputAudio != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -4566,8 +4581,9 @@ private constructor( /** A text output from the model. */ fun asOutputText(): OutputText = outputText.getOrThrow("outputText") - /** An image input to the model. */ - fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -4575,11 +4591,12 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun asAnArrayOfInputTextInputImageAndInputAudio(): List = - anArrayOfInputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextInputImageAndInputAudio" + fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + List = + anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( + "anArrayOfInputTextOutputTextInputImageAndInputAudio" ) fun _json(): Optional = Optional.ofNullable(_json) @@ -4590,13 +4607,16 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - inputImage != null -> visitor.visitInputImage(inputImage) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextInputImageAndInputAudio != null -> - visitor.visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio - ) + anArrayOfInputTextOutputTextInputImageAndInputAudio != + null -> + visitor + .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio + ) else -> visitor.unknown(_json) } @@ -4621,8 +4641,10 @@ private constructor( outputText.validate() } - override fun visitInputImage(inputImage: InputImage) { - inputImage.validate() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() } override fun visitResponseInputAudio( @@ -4631,10 +4653,13 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: - List - ) {} + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) { + anArrayOfInputTextOutputTextInputImageAndInputAudio + .forEach { it.validate() } + } } ) validated = true @@ -4667,17 +4692,20 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitInputImage(inputImage: InputImage) = - inputImage.validity() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: - List - ) = anArrayOfInputTextInputImageAndInputAudio.size + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) = + anArrayOfInputTextOutputTextInputImageAndInputAudio + .sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -4692,10 +4720,11 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - inputImage == other.inputImage && + evalItemInputImage == other.evalItemInputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextInputImageAndInputAudio == - other.anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio == + other + .anArrayOfInputTextOutputTextInputImageAndInputAudio } override fun hashCode(): Int = @@ -4703,9 +4732,9 @@ private constructor( textInput, responseInputText, outputText, - inputImage, + evalItemInputImage, responseInputAudio, - anArrayOfInputTextInputImageAndInputAudio, + anArrayOfInputTextOutputTextInputImageAndInputAudio, ) override fun toString(): String = @@ -4714,11 +4743,13 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - inputImage != null -> "Content{inputImage=$inputImage}" + evalItemInputImage != null -> + "Content{evalItemInputImage=$evalItemInputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextInputImageAndInputAudio != null -> - "Content{anArrayOfInputTextInputImageAndInputAudio=$anArrayOfInputTextInputImageAndInputAudio}" + anArrayOfInputTextOutputTextInputImageAndInputAudio != + null -> + "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -4740,10 +4771,11 @@ private constructor( fun ofOutputText(outputText: OutputText) = Content(outputText = outputText) - /** An image input to the model. */ + /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofInputImage(inputImage: InputImage) = - Content(inputImage = inputImage) + fun ofEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = Content(evalItemInputImage = evalItemInputImage) /** An audio input to the model. */ @JvmStatic @@ -4753,15 +4785,16 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = Content( - anArrayOfInputTextInputImageAndInputAudio = - anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio .toImmutable() ) } @@ -4783,8 +4816,10 @@ private constructor( /** A text output from the model. */ fun visitOutputText(outputText: OutputText): T - /** An image input to the model. */ - fun visitInputImage(inputImage: InputImage): T + /** An image input block used within EvalItem content arrays. */ + fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -4793,10 +4828,11 @@ private constructor( /** * A list of inputs, each of which may be either an input text, - * input image, or input audio object. + * output text, input image, or input audio object. */ - fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ): T /** @@ -4843,10 +4879,13 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - Content(inputImage = it, _json = json) + Content( + evalItemInputImage = it, + _json = json, + ) }, tryDeserialize( node, @@ -4864,11 +4903,13 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef>(), + jacksonTypeRef< + List + >(), ) ?.let { Content( - anArrayOfInputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio = it, _json = json, ) @@ -4909,14 +4950,16 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value.anArrayOfInputTextInputImageAndInputAudio != + value + .anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> generator.writeObject( - value.anArrayOfInputTextInputImageAndInputAudio + value + .anArrayOfInputTextOutputTextInputImageAndInputAudio ) value._json != null -> generator.writeObject(value._json) @@ -5162,8 +5205,8 @@ private constructor( "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" } - /** An image input to the model. */ - class InputImage + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -5258,7 +5301,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [InputImage]. + * [EvalItemInputImage]. * * The following fields are required: * ```java @@ -5268,7 +5311,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [InputImage]. */ + /** A builder for [EvalItemInputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -5279,13 +5322,15 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = - inputImage.additionalProperties.toMutableMap() - } + internal fun from(evalItemInputImage: EvalItemInputImage) = + apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties + .toMutableMap() + } /** The URL of the image input. */ fun imageUrl(imageUrl: String) = @@ -5363,7 +5408,7 @@ private constructor( } /** - * Returns an immutable instance of [InputImage]. + * Returns an immutable instance of [EvalItemInputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -5376,8 +5421,8 @@ private constructor( * @throws IllegalStateException if any required field is * unset. */ - fun build(): InputImage = - InputImage( + fun build(): EvalItemInputImage = + EvalItemInputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -5387,7 +5432,7 @@ private constructor( private var validated: Boolean = false - fun validate(): InputImage = apply { + fun validate(): EvalItemInputImage = apply { if (validated) { return@apply } @@ -5431,7 +5476,7 @@ private constructor( return true } - return other is InputImage && + return other is EvalItemInputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -5445,7 +5490,966 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } + + /** A text input to the model. */ + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent4.Deserializer::class + ) + @JsonSerialize( + using = UnnamedSchemaWithArrayParent4.Serializer::class + ) + class UnnamedSchemaWithArrayParent4 + private constructor( + private val textInput: String? = null, + private val responseInputText: ResponseInputText? = null, + private val outputText: OutputText? = null, + private val evalItemInputImage: EvalItemInputImage? = null, + private val responseInputAudio: ResponseInputAudio? = null, + private val _json: JsonValue? = null, + ) { + + /** A text input to the model. */ + fun textInput(): Optional = + Optional.ofNullable(textInput) + + /** A text input to the model. */ + fun responseInputText(): Optional = + Optional.ofNullable(responseInputText) + + /** A text output from the model. */ + fun outputText(): Optional = + Optional.ofNullable(outputText) + + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) + + /** An audio input to the model. */ + fun responseInputAudio(): Optional = + Optional.ofNullable(responseInputAudio) + + fun isTextInput(): Boolean = textInput != null + + fun isResponseInputText(): Boolean = responseInputText != null + + fun isOutputText(): Boolean = outputText != null + + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + + fun isResponseInputAudio(): Boolean = responseInputAudio != null + + /** A text input to the model. */ + fun asTextInput(): String = textInput.getOrThrow("textInput") + + /** A text input to the model. */ + fun asResponseInputText(): ResponseInputText = + responseInputText.getOrThrow("responseInputText") + + /** A text output from the model. */ + fun asOutputText(): OutputText = + outputText.getOrThrow("outputText") + + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") + + /** An audio input to the model. */ + fun asResponseInputAudio(): ResponseInputAudio = + responseInputAudio.getOrThrow("responseInputAudio") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + textInput != null -> visitor.visitTextInput(textInput) + responseInputText != null -> + visitor.visitResponseInputText(responseInputText) + outputText != null -> + visitor.visitOutputText(outputText) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) + responseInputAudio != null -> + visitor.visitResponseInputAudio(responseInputAudio) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent4 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTextInput(textInput: String) {} + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) { + responseInputText.validate() + } + + override fun visitOutputText( + outputText: OutputText + ) { + outputText.validate() + } + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() + } + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) { + responseInputAudio.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTextInput(textInput: String) = 1 + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) = responseInputText.validity() + + override fun visitOutputText( + outputText: OutputText + ) = outputText.validity() + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = responseInputAudio.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent4 && + textInput == other.textInput && + responseInputText == other.responseInputText && + outputText == other.outputText && + evalItemInputImage == other.evalItemInputImage && + responseInputAudio == other.responseInputAudio + } + + override fun hashCode(): Int = + Objects.hash( + textInput, + responseInputText, + outputText, + evalItemInputImage, + responseInputAudio, + ) + + override fun toString(): String = + when { + textInput != null -> + "UnnamedSchemaWithArrayParent4{textInput=$textInput}" + responseInputText != null -> + "UnnamedSchemaWithArrayParent4{responseInputText=$responseInputText}" + outputText != null -> + "UnnamedSchemaWithArrayParent4{outputText=$outputText}" + evalItemInputImage != null -> + "UnnamedSchemaWithArrayParent4{evalItemInputImage=$evalItemInputImage}" + responseInputAudio != null -> + "UnnamedSchemaWithArrayParent4{responseInputAudio=$responseInputAudio}" + _json != null -> + "UnnamedSchemaWithArrayParent4{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent4" + ) + } + + companion object { + + /** A text input to the model. */ + @JvmStatic + fun ofTextInput(textInput: String) = + UnnamedSchemaWithArrayParent4(textInput = textInput) + + /** A text input to the model. */ + @JvmStatic + fun ofResponseInputText( + responseInputText: ResponseInputText + ) = + UnnamedSchemaWithArrayParent4( + responseInputText = responseInputText + ) + + /** A text output from the model. */ + @JvmStatic + fun ofOutputText(outputText: OutputText) = + UnnamedSchemaWithArrayParent4(outputText = outputText) + + /** + * An image input block used within EvalItem content arrays. + */ + @JvmStatic + fun ofEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = + UnnamedSchemaWithArrayParent4( + evalItemInputImage = evalItemInputImage + ) + + /** An audio input to the model. */ + @JvmStatic + fun ofResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = + UnnamedSchemaWithArrayParent4( + responseInputAudio = responseInputAudio + ) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent4] to a value of type [T]. + */ + interface Visitor { + + /** A text input to the model. */ + fun visitTextInput(textInput: String): T + + /** A text input to the model. */ + fun visitResponseInputText( + responseInputText: ResponseInputText + ): T + + /** A text output from the model. */ + fun visitOutputText(outputText: OutputText): T + + /** + * An image input block used within EvalItem content arrays. + */ + fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ): T + + /** An audio input to the model. */ + fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent4] to a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent4] can + * contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware + * of. + * + * @throws OpenAIInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent4: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent4::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent4 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent4( + responseInputText = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent4( + outputText = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent4( + evalItemInputImage = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent4( + responseInputAudio = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent4( + textInput = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from array). + 0 -> UnnamedSchemaWithArrayParent4(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid + // match, or simply the first match if none are + // completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent4::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent4, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.textInput != null -> + generator.writeObject(value.textInput) + value.responseInputText != null -> + generator.writeObject(value.responseInputText) + value.outputText != null -> + generator.writeObject(value.outputText) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) + value.responseInputAudio != null -> + generator.writeObject(value.responseInputAudio) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent4" + ) + } + } + } + + /** A text output from the model. */ + class OutputText + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val additionalProperties: + MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + ) : this(text, type, mutableMapOf()) + + /** + * The text output from the model. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type or is unexpectedly missing or null + * (e.g. if the server responded with an unexpected + * value). + */ + fun text(): String = text.getRequired("text") + + /** + * The type of the output text. Always `output_text`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * However, this method can be useful for debugging and + * logging (e.g. if the server responded with an unexpected + * value). + */ + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("text") + @ExcludeMissing + fun _text(): JsonField = text + + @JsonAnySetter + private fun putAdditionalProperty( + key: String, + value: JsonValue, + ) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an + * instance of [OutputText]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputText]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = + JsonValue.from("output_text") + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(outputText: OutputText) = apply { + text = outputText.text + type = outputText.type + additionalProperties = + outputText.additionalProperties.toMutableMap() + } + + /** The text output from the model. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun text(text: JsonField) = apply { + this.text = text + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because + * the field defaults to the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty( + key: String, + value: JsonValue, + ) = apply { additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OutputText]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field + * is unset. + */ + fun build(): OutputText = + OutputText( + checkRequired("text", text), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OutputText = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("output_text")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("output_text")) 1 + else 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputText && + text == other.text && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" + } + + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val imageUrl: JsonField, + private val type: JsonValue, + private val detail: JsonField, + private val additionalProperties: + MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("image_url") + @ExcludeMissing + imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + detail: JsonField = JsonMissing.of(), + ) : this(imageUrl, type, detail, mutableMapOf()) + + /** + * The URL of the image input. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type or is unexpectedly missing or null + * (e.g. if the server responded with an unexpected + * value). + */ + fun imageUrl(): String = imageUrl.getRequired("image_url") + + /** + * The type of the image input. Always `input_image`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * However, this method can be useful for debugging and + * logging (e.g. if the server responded with an unexpected + * value). + */ + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonValue = type + + /** + * The detail level of the image to be sent to the model. + * One of `high`, `low`, or `auto`. Defaults to `auto`. + * + * @throws OpenAIInvalidDataException if the JSON field has + * an unexpected type (e.g. if the server responded with + * an unexpected value). + */ + fun detail(): Optional = + detail.getOptional("detail") + + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("image_url") + @ExcludeMissing + fun _imageUrl(): JsonField = imageUrl + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail + + @JsonAnySetter + private fun putAdditionalProperty( + key: String, + value: JsonValue, + ) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an + * instance of [EvalItemInputImage]. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EvalItemInputImage]. */ + class Builder internal constructor() { + + private var imageUrl: JsonField? = null + private var type: JsonValue = + JsonValue.from("input_image") + private var detail: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + evalItemInputImage: EvalItemInputImage + ) = apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties + .toMutableMap() + } + + /** The URL of the image input. */ + fun imageUrl(imageUrl: String) = + imageUrl(JsonField.of(imageUrl)) + + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imageUrl(imageUrl: JsonField) = apply { + this.imageUrl = imageUrl + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because + * the field defaults to the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * The detail level of the image to be sent to the + * model. One of `high`, `low`, or `auto`. Defaults to + * `auto`. + */ + fun detail(detail: String) = + detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a + * well-typed [String] value instead. This method is + * primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun detail(detail: JsonField) = apply { + this.detail = detail + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty( + key: String, + value: JsonValue, + ) = apply { additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of + * [EvalItemInputImage]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + * + * @throws IllegalStateException if any required field + * is unset. + */ + fun build(): EvalItemInputImage = + EvalItemInputImage( + checkRequired("imageUrl", imageUrl), + type, + detail, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EvalItemInputImage = apply { + if (validated) { + return@apply + } + + imageUrl() + _type().let { + if (it != JsonValue.from("input_image")) { + throw OpenAIInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + detail() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (imageUrl.asKnown().isPresent) 1 else 0) + + type.let { + if (it == JsonValue.from("input_image")) 1 + else 0 + } + + (if (detail.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EvalItemInputImage && + imageUrl == other.imageUrl && + type == other.type && + detail == other.detail && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + imageUrl, + type, + detail, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt index c101f32f..f03a2a81 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt @@ -422,7 +422,8 @@ private constructor( ) : this(content, role, type, mutableMapOf()) /** - * Inputs to the model - can contain template strings. + * Inputs to the model - can contain template strings. Supports text, output text, input + * images, and input audio, either as a single item or an array of items. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -508,7 +509,10 @@ private constructor( additionalProperties = input.additionalProperties.toMutableMap() } - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports text, output text, input + * images, and input audio, either as a single item or an array of items. + */ fun content(content: Content) = content(JsonField.of(content)) /** @@ -532,8 +536,11 @@ private constructor( /** Alias for calling [content] with `Content.ofOutputText(outputText)`. */ fun content(outputText: Content.OutputText) = content(Content.ofOutputText(outputText)) - /** Alias for calling [content] with `Content.ofInputImage(inputImage)`. */ - fun content(inputImage: Content.InputImage) = content(Content.ofInputImage(inputImage)) + /** + * Alias for calling [content] with `Content.ofEvalItemInputImage(evalItemInputImage)`. + */ + fun content(evalItemInputImage: Content.EvalItemInputImage) = + content(Content.ofEvalItemInputImage(evalItemInputImage)) /** * Alias for calling [content] with `Content.ofResponseInputAudio(responseInputAudio)`. @@ -543,14 +550,15 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextInputImageAndInputAudio(anArrayOfInputTextInputImageAndInputAudio)`. + * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. */ - fun contentOfAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = content( - Content.ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio + Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio ) ) @@ -654,7 +662,10 @@ private constructor( (role.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports text, output text, input + * images, and input audio, either as a single item or an array of items. + */ @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) class Content @@ -662,9 +673,11 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, + private val evalItemInputImage: EvalItemInputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextInputImageAndInputAudio: List? = null, + private val anArrayOfInputTextOutputTextInputImageAndInputAudio: + List? = + null, private val _json: JsonValue? = null, ) { @@ -678,19 +691,21 @@ private constructor( /** A text output from the model. */ fun outputText(): Optional = Optional.ofNullable(outputText) - /** An image input to the model. */ - fun inputImage(): Optional = Optional.ofNullable(inputImage) + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = Optional.ofNullable(responseInputAudio) /** - * A list of inputs, each of which may be either an input text, input image, or input - * audio object. + * A list of inputs, each of which may be either an input text, output text, input + * image, or input audio object. */ - fun anArrayOfInputTextInputImageAndInputAudio(): Optional> = - Optional.ofNullable(anArrayOfInputTextInputImageAndInputAudio) + fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): + Optional> = + Optional.ofNullable(anArrayOfInputTextOutputTextInputImageAndInputAudio) fun isTextInput(): Boolean = textInput != null @@ -698,12 +713,12 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isInputImage(): Boolean = inputImage != null + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextInputImageAndInputAudio(): Boolean = - anArrayOfInputTextInputImageAndInputAudio != null + fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): Boolean = + anArrayOfInputTextOutputTextInputImageAndInputAudio != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -715,20 +730,22 @@ private constructor( /** A text output from the model. */ fun asOutputText(): OutputText = outputText.getOrThrow("outputText") - /** An image input to the model. */ - fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = responseInputAudio.getOrThrow("responseInputAudio") /** - * A list of inputs, each of which may be either an input text, input image, or input - * audio object. + * A list of inputs, each of which may be either an input text, output text, input + * image, or input audio object. */ - fun asAnArrayOfInputTextInputImageAndInputAudio(): List = - anArrayOfInputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextInputImageAndInputAudio" + fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + List = + anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( + "anArrayOfInputTextOutputTextInputImageAndInputAudio" ) fun _json(): Optional = Optional.ofNullable(_json) @@ -738,12 +755,13 @@ private constructor( textInput != null -> visitor.visitTextInput(textInput) responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - inputImage != null -> visitor.visitInputImage(inputImage) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextInputImageAndInputAudio != null -> - visitor.visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> + visitor.visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio ) else -> visitor.unknown(_json) } @@ -767,8 +785,10 @@ private constructor( outputText.validate() } - override fun visitInputImage(inputImage: InputImage) { - inputImage.validate() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() } override fun visitResponseInputAudio( @@ -777,9 +797,14 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List - ) {} + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) { + anArrayOfInputTextOutputTextInputImageAndInputAudio.forEach { + it.validate() + } + } } ) validated = true @@ -810,15 +835,21 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitInputImage(inputImage: InputImage) = inputImage.validity() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List - ) = anArrayOfInputTextInputImageAndInputAudio.size + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) = + anArrayOfInputTextOutputTextInputImageAndInputAudio.sumOf { + it.validity().toInt() + } override fun unknown(json: JsonValue?) = 0 } @@ -833,10 +864,10 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - inputImage == other.inputImage && + evalItemInputImage == other.evalItemInputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextInputImageAndInputAudio == - other.anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio == + other.anArrayOfInputTextOutputTextInputImageAndInputAudio } override fun hashCode(): Int = @@ -844,9 +875,9 @@ private constructor( textInput, responseInputText, outputText, - inputImage, + evalItemInputImage, responseInputAudio, - anArrayOfInputTextInputImageAndInputAudio, + anArrayOfInputTextOutputTextInputImageAndInputAudio, ) override fun toString(): String = @@ -854,10 +885,10 @@ private constructor( textInput != null -> "Content{textInput=$textInput}" responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - inputImage != null -> "Content{inputImage=$inputImage}" + evalItemInputImage != null -> "Content{evalItemInputImage=$evalItemInputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextInputImageAndInputAudio != null -> - "Content{anArrayOfInputTextInputImageAndInputAudio=$anArrayOfInputTextInputImageAndInputAudio}" + anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> + "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -876,9 +907,10 @@ private constructor( @JvmStatic fun ofOutputText(outputText: OutputText) = Content(outputText = outputText) - /** An image input to the model. */ + /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofInputImage(inputImage: InputImage) = Content(inputImage = inputImage) + fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = + Content(evalItemInputImage = evalItemInputImage) /** An audio input to the model. */ @JvmStatic @@ -886,16 +918,17 @@ private constructor( Content(responseInputAudio = responseInputAudio) /** - * A list of inputs, each of which may be either an input text, input image, or - * input audio object. + * A list of inputs, each of which may be either an input text, output text, input + * image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = Content( - anArrayOfInputTextInputImageAndInputAudio = - anArrayOfInputTextInputImageAndInputAudio.toImmutable() + anArrayOfInputTextOutputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio.toImmutable() ) } @@ -914,18 +947,19 @@ private constructor( /** A text output from the model. */ fun visitOutputText(outputText: OutputText): T - /** An image input to the model. */ - fun visitInputImage(inputImage: InputImage): T + /** An image input block used within EvalItem content arrays. */ + fun visitEvalItemInputImage(evalItemInputImage: EvalItemInputImage): T /** An audio input to the model. */ fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T /** - * A list of inputs, each of which may be either an input text, input image, or - * input audio object. + * A list of inputs, each of which may be either an input text, output text, input + * image, or input audio object. */ - fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ): T /** @@ -956,8 +990,8 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Content(outputText = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Content(inputImage = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Content(evalItemInputImage = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { Content(responseInputAudio = it, _json = json) @@ -965,12 +999,17 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Content(textInput = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef>())?.let { - Content( - anArrayOfInputTextInputImageAndInputAudio = it, - _json = json, + tryDeserialize( + node, + jacksonTypeRef>(), ) - }, + ?.let { + Content( + anArrayOfInputTextOutputTextInputImageAndInputAudio = + it, + _json = json, + ) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1000,11 +1039,14 @@ private constructor( value.responseInputText != null -> generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.inputImage != null -> generator.writeObject(value.inputImage) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value.anArrayOfInputTextInputImageAndInputAudio != null -> - generator.writeObject(value.anArrayOfInputTextInputImageAndInputAudio) + value.anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> + generator.writeObject( + value.anArrayOfInputTextOutputTextInputImageAndInputAudio + ) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") } @@ -1219,8 +1261,8 @@ private constructor( "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" } - /** An image input to the model. */ - class InputImage + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -1304,7 +1346,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [InputImage]. + * Returns a mutable builder for constructing an instance of + * [EvalItemInputImage]. * * The following fields are required: * ```java @@ -1314,7 +1357,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [InputImage]. */ + /** A builder for [EvalItemInputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -1323,11 +1366,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = inputImage.additionalProperties.toMutableMap() + internal fun from(evalItemInputImage: EvalItemInputImage) = apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -1394,7 +1438,7 @@ private constructor( } /** - * Returns an immutable instance of [InputImage]. + * Returns an immutable instance of [EvalItemInputImage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -1405,8 +1449,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): InputImage = - InputImage( + fun build(): EvalItemInputImage = + EvalItemInputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -1416,7 +1460,7 @@ private constructor( private var validated: Boolean = false - fun validate(): InputImage = apply { + fun validate(): EvalItemInputImage = apply { if (validated) { return@apply } @@ -1456,7 +1500,7 @@ private constructor( return true } - return other is InputImage && + return other is EvalItemInputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -1470,7 +1514,816 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } + + /** A text input to the model. */ + @JsonDeserialize(using = UnnamedSchemaWithArrayParent0.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent0.Serializer::class) + class UnnamedSchemaWithArrayParent0 + private constructor( + private val textInput: String? = null, + private val responseInputText: ResponseInputText? = null, + private val outputText: OutputText? = null, + private val evalItemInputImage: EvalItemInputImage? = null, + private val responseInputAudio: ResponseInputAudio? = null, + private val _json: JsonValue? = null, + ) { + + /** A text input to the model. */ + fun textInput(): Optional = Optional.ofNullable(textInput) + + /** A text input to the model. */ + fun responseInputText(): Optional = + Optional.ofNullable(responseInputText) + + /** A text output from the model. */ + fun outputText(): Optional = Optional.ofNullable(outputText) + + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) + + /** An audio input to the model. */ + fun responseInputAudio(): Optional = + Optional.ofNullable(responseInputAudio) + + fun isTextInput(): Boolean = textInput != null + + fun isResponseInputText(): Boolean = responseInputText != null + + fun isOutputText(): Boolean = outputText != null + + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + + fun isResponseInputAudio(): Boolean = responseInputAudio != null + + /** A text input to the model. */ + fun asTextInput(): String = textInput.getOrThrow("textInput") + + /** A text input to the model. */ + fun asResponseInputText(): ResponseInputText = + responseInputText.getOrThrow("responseInputText") + + /** A text output from the model. */ + fun asOutputText(): OutputText = outputText.getOrThrow("outputText") + + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") + + /** An audio input to the model. */ + fun asResponseInputAudio(): ResponseInputAudio = + responseInputAudio.getOrThrow("responseInputAudio") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + textInput != null -> visitor.visitTextInput(textInput) + responseInputText != null -> + visitor.visitResponseInputText(responseInputText) + outputText != null -> visitor.visitOutputText(outputText) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) + responseInputAudio != null -> + visitor.visitResponseInputAudio(responseInputAudio) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent0 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTextInput(textInput: String) {} + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) { + responseInputText.validate() + } + + override fun visitOutputText(outputText: OutputText) { + outputText.validate() + } + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() + } + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) { + responseInputAudio.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTextInput(textInput: String) = 1 + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) = responseInputText.validity() + + override fun visitOutputText(outputText: OutputText) = + outputText.validity() + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = responseInputAudio.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent0 && + textInput == other.textInput && + responseInputText == other.responseInputText && + outputText == other.outputText && + evalItemInputImage == other.evalItemInputImage && + responseInputAudio == other.responseInputAudio + } + + override fun hashCode(): Int = + Objects.hash( + textInput, + responseInputText, + outputText, + evalItemInputImage, + responseInputAudio, + ) + + override fun toString(): String = + when { + textInput != null -> "UnnamedSchemaWithArrayParent0{textInput=$textInput}" + responseInputText != null -> + "UnnamedSchemaWithArrayParent0{responseInputText=$responseInputText}" + outputText != null -> + "UnnamedSchemaWithArrayParent0{outputText=$outputText}" + evalItemInputImage != null -> + "UnnamedSchemaWithArrayParent0{evalItemInputImage=$evalItemInputImage}" + responseInputAudio != null -> + "UnnamedSchemaWithArrayParent0{responseInputAudio=$responseInputAudio}" + _json != null -> "UnnamedSchemaWithArrayParent0{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent0") + } + + companion object { + + /** A text input to the model. */ + @JvmStatic + fun ofTextInput(textInput: String) = + UnnamedSchemaWithArrayParent0(textInput = textInput) + + /** A text input to the model. */ + @JvmStatic + fun ofResponseInputText(responseInputText: ResponseInputText) = + UnnamedSchemaWithArrayParent0(responseInputText = responseInputText) + + /** A text output from the model. */ + @JvmStatic + fun ofOutputText(outputText: OutputText) = + UnnamedSchemaWithArrayParent0(outputText = outputText) + + /** An image input block used within EvalItem content arrays. */ + @JvmStatic + fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = + UnnamedSchemaWithArrayParent0(evalItemInputImage = evalItemInputImage) + + /** An audio input to the model. */ + @JvmStatic + fun ofResponseInputAudio(responseInputAudio: ResponseInputAudio) = + UnnamedSchemaWithArrayParent0(responseInputAudio = responseInputAudio) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent0] to a value of type [T]. + */ + interface Visitor { + + /** A text input to the model. */ + fun visitTextInput(textInput: String): T + + /** A text input to the model. */ + fun visitResponseInputText(responseInputText: ResponseInputText): T + + /** A text output from the model. */ + fun visitOutputText(outputText: OutputText): T + + /** An image input block used within EvalItem content arrays. */ + fun visitEvalItemInputImage(evalItemInputImage: EvalItemInputImage): T + + /** An audio input to the model. */ + fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent0] to a value of type + * [T]. + * + * An instance of [UnnamedSchemaWithArrayParent0] can contain an unknown variant + * if it was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new variants that the SDK is unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent0: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent0::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent0 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent0( + responseInputText = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent0(outputText = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent0( + evalItemInputImage = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent0( + responseInputAudio = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent0(textInput = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // array). + 0 -> UnnamedSchemaWithArrayParent0(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent0::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent0, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.textInput != null -> generator.writeObject(value.textInput) + value.responseInputText != null -> + generator.writeObject(value.responseInputText) + value.outputText != null -> generator.writeObject(value.outputText) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) + value.responseInputAudio != null -> + generator.writeObject(value.responseInputAudio) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent0") + } + } + } + + /** A text output from the model. */ + class OutputText + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(text, type, mutableMapOf()) + + /** + * The text output from the model. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * The type of the output text. Always `output_text`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OutputText]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputText]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("output_text") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(outputText: OutputText) = apply { + text = outputText.text + type = outputText.type + additionalProperties = outputText.additionalProperties.toMutableMap() + } + + /** The text output from the model. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OutputText]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OutputText = + OutputText( + checkRequired("text", text), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OutputText = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("output_text")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("output_text")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputText && + text == other.text && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" + } + + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val imageUrl: JsonField, + private val type: JsonValue, + private val detail: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("image_url") + @ExcludeMissing + imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + detail: JsonField = JsonMissing.of(), + ) : this(imageUrl, type, detail, mutableMapOf()) + + /** + * The URL of the image input. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun imageUrl(): String = imageUrl.getRequired("image_url") + + /** + * The type of the image input. Always `input_image`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * The detail level of the image to be sent to the model. One of `high`, `low`, + * or `auto`. Defaults to `auto`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun detail(): Optional = detail.getOptional("detail") + + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("image_url") + @ExcludeMissing + fun _imageUrl(): JsonField = imageUrl + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EvalItemInputImage]. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EvalItemInputImage]. */ + class Builder internal constructor() { + + private var imageUrl: JsonField? = null + private var type: JsonValue = JsonValue.from("input_image") + private var detail: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(evalItemInputImage: EvalItemInputImage) = apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties.toMutableMap() + } + + /** The URL of the image input. */ + fun imageUrl(imageUrl: String) = imageUrl(JsonField.of(imageUrl)) + + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageUrl(imageUrl: JsonField) = apply { + this.imageUrl = imageUrl + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * The detail level of the image to be sent to the model. One of `high`, + * `low`, or `auto`. Defaults to `auto`. + */ + fun detail(detail: String) = detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun detail(detail: JsonField) = apply { this.detail = detail } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EvalItemInputImage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EvalItemInputImage = + EvalItemInputImage( + checkRequired("imageUrl", imageUrl), + type, + detail, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EvalItemInputImage = apply { + if (validated) { + return@apply + } + + imageUrl() + _type().let { + if (it != JsonValue.from("input_image")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + detail() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (imageUrl.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("input_image")) 1 else 0 } + + (if (detail.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EvalItemInputImage && + imageUrl == other.imageUrl && + type == other.type && + detail == other.detail && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(imageUrl, type, detail, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt index 67b34ab5..690bdcc6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt @@ -415,7 +415,8 @@ private constructor( ) : this(content, role, type, mutableMapOf()) /** - * Inputs to the model - can contain template strings. + * Inputs to the model - can contain template strings. Supports text, output text, input + * images, and input audio, either as a single item or an array of items. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -501,7 +502,10 @@ private constructor( additionalProperties = input.additionalProperties.toMutableMap() } - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports text, output text, input + * images, and input audio, either as a single item or an array of items. + */ fun content(content: Content) = content(JsonField.of(content)) /** @@ -525,8 +529,11 @@ private constructor( /** Alias for calling [content] with `Content.ofOutputText(outputText)`. */ fun content(outputText: Content.OutputText) = content(Content.ofOutputText(outputText)) - /** Alias for calling [content] with `Content.ofInputImage(inputImage)`. */ - fun content(inputImage: Content.InputImage) = content(Content.ofInputImage(inputImage)) + /** + * Alias for calling [content] with `Content.ofEvalItemInputImage(evalItemInputImage)`. + */ + fun content(evalItemInputImage: Content.EvalItemInputImage) = + content(Content.ofEvalItemInputImage(evalItemInputImage)) /** * Alias for calling [content] with `Content.ofResponseInputAudio(responseInputAudio)`. @@ -536,14 +543,15 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextInputImageAndInputAudio(anArrayOfInputTextInputImageAndInputAudio)`. + * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. */ - fun contentOfAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = content( - Content.ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio + Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio ) ) @@ -647,7 +655,10 @@ private constructor( (role.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - /** Inputs to the model - can contain template strings. */ + /** + * Inputs to the model - can contain template strings. Supports text, output text, input + * images, and input audio, either as a single item or an array of items. + */ @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) class Content @@ -655,9 +666,11 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, + private val evalItemInputImage: EvalItemInputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextInputImageAndInputAudio: List? = null, + private val anArrayOfInputTextOutputTextInputImageAndInputAudio: + List? = + null, private val _json: JsonValue? = null, ) { @@ -671,19 +684,21 @@ private constructor( /** A text output from the model. */ fun outputText(): Optional = Optional.ofNullable(outputText) - /** An image input to the model. */ - fun inputImage(): Optional = Optional.ofNullable(inputImage) + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = Optional.ofNullable(responseInputAudio) /** - * A list of inputs, each of which may be either an input text, input image, or input - * audio object. + * A list of inputs, each of which may be either an input text, output text, input + * image, or input audio object. */ - fun anArrayOfInputTextInputImageAndInputAudio(): Optional> = - Optional.ofNullable(anArrayOfInputTextInputImageAndInputAudio) + fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): + Optional> = + Optional.ofNullable(anArrayOfInputTextOutputTextInputImageAndInputAudio) fun isTextInput(): Boolean = textInput != null @@ -691,12 +706,12 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isInputImage(): Boolean = inputImage != null + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextInputImageAndInputAudio(): Boolean = - anArrayOfInputTextInputImageAndInputAudio != null + fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): Boolean = + anArrayOfInputTextOutputTextInputImageAndInputAudio != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -708,20 +723,22 @@ private constructor( /** A text output from the model. */ fun asOutputText(): OutputText = outputText.getOrThrow("outputText") - /** An image input to the model. */ - fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = responseInputAudio.getOrThrow("responseInputAudio") /** - * A list of inputs, each of which may be either an input text, input image, or input - * audio object. + * A list of inputs, each of which may be either an input text, output text, input + * image, or input audio object. */ - fun asAnArrayOfInputTextInputImageAndInputAudio(): List = - anArrayOfInputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextInputImageAndInputAudio" + fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): + List = + anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( + "anArrayOfInputTextOutputTextInputImageAndInputAudio" ) fun _json(): Optional = Optional.ofNullable(_json) @@ -731,12 +748,13 @@ private constructor( textInput != null -> visitor.visitTextInput(textInput) responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - inputImage != null -> visitor.visitInputImage(inputImage) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextInputImageAndInputAudio != null -> - visitor.visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> + visitor.visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio ) else -> visitor.unknown(_json) } @@ -760,8 +778,10 @@ private constructor( outputText.validate() } - override fun visitInputImage(inputImage: InputImage) { - inputImage.validate() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() } override fun visitResponseInputAudio( @@ -770,9 +790,14 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List - ) {} + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) { + anArrayOfInputTextOutputTextInputImageAndInputAudio.forEach { + it.validate() + } + } } ) validated = true @@ -803,15 +828,21 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitInputImage(inputImage: InputImage) = inputImage.validity() + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List - ) = anArrayOfInputTextInputImageAndInputAudio.size + override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List + ) = + anArrayOfInputTextOutputTextInputImageAndInputAudio.sumOf { + it.validity().toInt() + } override fun unknown(json: JsonValue?) = 0 } @@ -826,10 +857,10 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - inputImage == other.inputImage && + evalItemInputImage == other.evalItemInputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextInputImageAndInputAudio == - other.anArrayOfInputTextInputImageAndInputAudio + anArrayOfInputTextOutputTextInputImageAndInputAudio == + other.anArrayOfInputTextOutputTextInputImageAndInputAudio } override fun hashCode(): Int = @@ -837,9 +868,9 @@ private constructor( textInput, responseInputText, outputText, - inputImage, + evalItemInputImage, responseInputAudio, - anArrayOfInputTextInputImageAndInputAudio, + anArrayOfInputTextOutputTextInputImageAndInputAudio, ) override fun toString(): String = @@ -847,10 +878,10 @@ private constructor( textInput != null -> "Content{textInput=$textInput}" responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - inputImage != null -> "Content{inputImage=$inputImage}" + evalItemInputImage != null -> "Content{evalItemInputImage=$evalItemInputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextInputImageAndInputAudio != null -> - "Content{anArrayOfInputTextInputImageAndInputAudio=$anArrayOfInputTextInputImageAndInputAudio}" + anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> + "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -869,9 +900,10 @@ private constructor( @JvmStatic fun ofOutputText(outputText: OutputText) = Content(outputText = outputText) - /** An image input to the model. */ + /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofInputImage(inputImage: InputImage) = Content(inputImage = inputImage) + fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = + Content(evalItemInputImage = evalItemInputImage) /** An audio input to the model. */ @JvmStatic @@ -879,16 +911,17 @@ private constructor( Content(responseInputAudio = responseInputAudio) /** - * A list of inputs, each of which may be either an input text, input image, or - * input audio object. + * A list of inputs, each of which may be either an input text, output text, input + * image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ) = Content( - anArrayOfInputTextInputImageAndInputAudio = - anArrayOfInputTextInputImageAndInputAudio.toImmutable() + anArrayOfInputTextOutputTextInputImageAndInputAudio = + anArrayOfInputTextOutputTextInputImageAndInputAudio.toImmutable() ) } @@ -907,18 +940,19 @@ private constructor( /** A text output from the model. */ fun visitOutputText(outputText: OutputText): T - /** An image input to the model. */ - fun visitInputImage(inputImage: InputImage): T + /** An image input block used within EvalItem content arrays. */ + fun visitEvalItemInputImage(evalItemInputImage: EvalItemInputImage): T /** An audio input to the model. */ fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T /** - * A list of inputs, each of which may be either an input text, input image, or - * input audio object. + * A list of inputs, each of which may be either an input text, output text, input + * image, or input audio object. */ - fun visitAnArrayOfInputTextInputImageAndInputAudio( - anArrayOfInputTextInputImageAndInputAudio: List + fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( + anArrayOfInputTextOutputTextInputImageAndInputAudio: + List ): T /** @@ -949,8 +983,8 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Content(outputText = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Content(inputImage = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Content(evalItemInputImage = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { Content(responseInputAudio = it, _json = json) @@ -958,12 +992,17 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Content(textInput = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef>())?.let { - Content( - anArrayOfInputTextInputImageAndInputAudio = it, - _json = json, + tryDeserialize( + node, + jacksonTypeRef>(), ) - }, + ?.let { + Content( + anArrayOfInputTextOutputTextInputImageAndInputAudio = + it, + _json = json, + ) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -993,11 +1032,14 @@ private constructor( value.responseInputText != null -> generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.inputImage != null -> generator.writeObject(value.inputImage) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value.anArrayOfInputTextInputImageAndInputAudio != null -> - generator.writeObject(value.anArrayOfInputTextInputImageAndInputAudio) + value.anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> + generator.writeObject( + value.anArrayOfInputTextOutputTextInputImageAndInputAudio + ) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") } @@ -1212,8 +1254,8 @@ private constructor( "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" } - /** An image input to the model. */ - class InputImage + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -1297,7 +1339,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [InputImage]. + * Returns a mutable builder for constructing an instance of + * [EvalItemInputImage]. * * The following fields are required: * ```java @@ -1307,7 +1350,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [InputImage]. */ + /** A builder for [EvalItemInputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -1316,11 +1359,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = inputImage.additionalProperties.toMutableMap() + internal fun from(evalItemInputImage: EvalItemInputImage) = apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -1387,7 +1431,7 @@ private constructor( } /** - * Returns an immutable instance of [InputImage]. + * Returns an immutable instance of [EvalItemInputImage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -1398,8 +1442,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): InputImage = - InputImage( + fun build(): EvalItemInputImage = + EvalItemInputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -1409,7 +1453,7 @@ private constructor( private var validated: Boolean = false - fun validate(): InputImage = apply { + fun validate(): EvalItemInputImage = apply { if (validated) { return@apply } @@ -1449,7 +1493,7 @@ private constructor( return true } - return other is InputImage && + return other is EvalItemInputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -1463,7 +1507,816 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } + + /** A text input to the model. */ + @JsonDeserialize(using = UnnamedSchemaWithArrayParent1.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) + class UnnamedSchemaWithArrayParent1 + private constructor( + private val textInput: String? = null, + private val responseInputText: ResponseInputText? = null, + private val outputText: OutputText? = null, + private val evalItemInputImage: EvalItemInputImage? = null, + private val responseInputAudio: ResponseInputAudio? = null, + private val _json: JsonValue? = null, + ) { + + /** A text input to the model. */ + fun textInput(): Optional = Optional.ofNullable(textInput) + + /** A text input to the model. */ + fun responseInputText(): Optional = + Optional.ofNullable(responseInputText) + + /** A text output from the model. */ + fun outputText(): Optional = Optional.ofNullable(outputText) + + /** An image input block used within EvalItem content arrays. */ + fun evalItemInputImage(): Optional = + Optional.ofNullable(evalItemInputImage) + + /** An audio input to the model. */ + fun responseInputAudio(): Optional = + Optional.ofNullable(responseInputAudio) + + fun isTextInput(): Boolean = textInput != null + + fun isResponseInputText(): Boolean = responseInputText != null + + fun isOutputText(): Boolean = outputText != null + + fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + + fun isResponseInputAudio(): Boolean = responseInputAudio != null + + /** A text input to the model. */ + fun asTextInput(): String = textInput.getOrThrow("textInput") + + /** A text input to the model. */ + fun asResponseInputText(): ResponseInputText = + responseInputText.getOrThrow("responseInputText") + + /** A text output from the model. */ + fun asOutputText(): OutputText = outputText.getOrThrow("outputText") + + /** An image input block used within EvalItem content arrays. */ + fun asEvalItemInputImage(): EvalItemInputImage = + evalItemInputImage.getOrThrow("evalItemInputImage") + + /** An audio input to the model. */ + fun asResponseInputAudio(): ResponseInputAudio = + responseInputAudio.getOrThrow("responseInputAudio") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + textInput != null -> visitor.visitTextInput(textInput) + responseInputText != null -> + visitor.visitResponseInputText(responseInputText) + outputText != null -> visitor.visitOutputText(outputText) + evalItemInputImage != null -> + visitor.visitEvalItemInputImage(evalItemInputImage) + responseInputAudio != null -> + visitor.visitResponseInputAudio(responseInputAudio) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent1 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTextInput(textInput: String) {} + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) { + responseInputText.validate() + } + + override fun visitOutputText(outputText: OutputText) { + outputText.validate() + } + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) { + evalItemInputImage.validate() + } + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) { + responseInputAudio.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTextInput(textInput: String) = 1 + + override fun visitResponseInputText( + responseInputText: ResponseInputText + ) = responseInputText.validity() + + override fun visitOutputText(outputText: OutputText) = + outputText.validity() + + override fun visitEvalItemInputImage( + evalItemInputImage: EvalItemInputImage + ) = evalItemInputImage.validity() + + override fun visitResponseInputAudio( + responseInputAudio: ResponseInputAudio + ) = responseInputAudio.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent1 && + textInput == other.textInput && + responseInputText == other.responseInputText && + outputText == other.outputText && + evalItemInputImage == other.evalItemInputImage && + responseInputAudio == other.responseInputAudio + } + + override fun hashCode(): Int = + Objects.hash( + textInput, + responseInputText, + outputText, + evalItemInputImage, + responseInputAudio, + ) + + override fun toString(): String = + when { + textInput != null -> "UnnamedSchemaWithArrayParent1{textInput=$textInput}" + responseInputText != null -> + "UnnamedSchemaWithArrayParent1{responseInputText=$responseInputText}" + outputText != null -> + "UnnamedSchemaWithArrayParent1{outputText=$outputText}" + evalItemInputImage != null -> + "UnnamedSchemaWithArrayParent1{evalItemInputImage=$evalItemInputImage}" + responseInputAudio != null -> + "UnnamedSchemaWithArrayParent1{responseInputAudio=$responseInputAudio}" + _json != null -> "UnnamedSchemaWithArrayParent1{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + } + + companion object { + + /** A text input to the model. */ + @JvmStatic + fun ofTextInput(textInput: String) = + UnnamedSchemaWithArrayParent1(textInput = textInput) + + /** A text input to the model. */ + @JvmStatic + fun ofResponseInputText(responseInputText: ResponseInputText) = + UnnamedSchemaWithArrayParent1(responseInputText = responseInputText) + + /** A text output from the model. */ + @JvmStatic + fun ofOutputText(outputText: OutputText) = + UnnamedSchemaWithArrayParent1(outputText = outputText) + + /** An image input block used within EvalItem content arrays. */ + @JvmStatic + fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = + UnnamedSchemaWithArrayParent1(evalItemInputImage = evalItemInputImage) + + /** An audio input to the model. */ + @JvmStatic + fun ofResponseInputAudio(responseInputAudio: ResponseInputAudio) = + UnnamedSchemaWithArrayParent1(responseInputAudio = responseInputAudio) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent1] to a value of type [T]. + */ + interface Visitor { + + /** A text input to the model. */ + fun visitTextInput(textInput: String): T + + /** A text input to the model. */ + fun visitResponseInputText(responseInputText: ResponseInputText): T + + /** A text output from the model. */ + fun visitOutputText(outputText: OutputText): T + + /** An image input block used within EvalItem content arrays. */ + fun visitEvalItemInputImage(evalItemInputImage: EvalItemInputImage): T + + /** An audio input to the model. */ + fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of type + * [T]. + * + * An instance of [UnnamedSchemaWithArrayParent1] can contain an unknown variant + * if it was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new variants that the SDK is unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent1: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent1::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent1 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent1( + responseInputText = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent1(outputText = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent1( + evalItemInputImage = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent1( + responseInputAudio = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent1(textInput = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // array). + 0 -> UnnamedSchemaWithArrayParent1(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent1::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent1, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.textInput != null -> generator.writeObject(value.textInput) + value.responseInputText != null -> + generator.writeObject(value.responseInputText) + value.outputText != null -> generator.writeObject(value.outputText) + value.evalItemInputImage != null -> + generator.writeObject(value.evalItemInputImage) + value.responseInputAudio != null -> + generator.writeObject(value.responseInputAudio) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + } + } + } + + /** A text output from the model. */ + class OutputText + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(text, type, mutableMapOf()) + + /** + * The text output from the model. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * The type of the output text. Always `output_text`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OutputText]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputText]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("output_text") + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(outputText: OutputText) = apply { + text = outputText.text + type = outputText.type + additionalProperties = outputText.additionalProperties.toMutableMap() + } + + /** The text output from the model. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OutputText]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OutputText = + OutputText( + checkRequired("text", text), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OutputText = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("output_text")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("output_text")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputText && + text == other.text && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(text, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" + } + + /** An image input block used within EvalItem content arrays. */ + class EvalItemInputImage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val imageUrl: JsonField, + private val type: JsonValue, + private val detail: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("image_url") + @ExcludeMissing + imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + detail: JsonField = JsonMissing.of(), + ) : this(imageUrl, type, detail, mutableMapOf()) + + /** + * The URL of the image input. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun imageUrl(): String = imageUrl.getRequired("image_url") + + /** + * The type of the image input. Always `input_image`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * The detail level of the image to be sent to the model. One of `high`, `low`, + * or `auto`. Defaults to `auto`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun detail(): Optional = detail.getOptional("detail") + + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("image_url") + @ExcludeMissing + fun _imageUrl(): JsonField = imageUrl + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EvalItemInputImage]. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EvalItemInputImage]. */ + class Builder internal constructor() { + + private var imageUrl: JsonField? = null + private var type: JsonValue = JsonValue.from("input_image") + private var detail: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(evalItemInputImage: EvalItemInputImage) = apply { + imageUrl = evalItemInputImage.imageUrl + type = evalItemInputImage.type + detail = evalItemInputImage.detail + additionalProperties = + evalItemInputImage.additionalProperties.toMutableMap() + } + + /** The URL of the image input. */ + fun imageUrl(imageUrl: String) = imageUrl(JsonField.of(imageUrl)) + + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageUrl(imageUrl: JsonField) = apply { + this.imageUrl = imageUrl + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * The detail level of the image to be sent to the model. One of `high`, + * `low`, or `auto`. Defaults to `auto`. + */ + fun detail(detail: String) = detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun detail(detail: JsonField) = apply { this.detail = detail } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EvalItemInputImage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EvalItemInputImage = + EvalItemInputImage( + checkRequired("imageUrl", imageUrl), + type, + detail, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EvalItemInputImage = apply { + if (validated) { + return@apply + } + + imageUrl() + _type().let { + if (it != JsonValue.from("input_image")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + detail() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (imageUrl.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("input_image")) 1 else 0 } + + (if (detail.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EvalItemInputImage && + imageUrl == other.imageUrl && + type == other.type && + detail == other.detail && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(imageUrl, type, detail, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/videos/VideoModel.kt b/openai-java-core/src/main/kotlin/com/openai/models/videos/VideoModel.kt index 084bfe17..c20fd7b2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/videos/VideoModel.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/videos/VideoModel.kt @@ -24,6 +24,12 @@ class VideoModel @JsonCreator private constructor(private val value: JsonField Value.SORA_2 SORA_2_PRO -> Value.SORA_2_PRO + SORA_2_2025_10_06 -> Value.SORA_2_2025_10_06 + SORA_2_PRO_2025_10_06 -> Value.SORA_2_PRO_2025_10_06 + SORA_2_2025_12_08 -> Value.SORA_2_2025_12_08 else -> Value._UNKNOWN } @@ -75,6 +90,9 @@ class VideoModel @JsonCreator private constructor(private val value: JsonField Known.SORA_2 SORA_2_PRO -> Known.SORA_2_PRO + SORA_2_2025_10_06 -> Known.SORA_2_2025_10_06 + SORA_2_PRO_2025_10_06 -> Known.SORA_2_PRO_2025_10_06 + SORA_2_2025_12_08 -> Known.SORA_2_2025_12_08 else -> throw OpenAIInvalidDataException("Unknown VideoModel: $value") } From f75af830fdaf2874313c125a8de0aecde6f447b7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 13 Dec 2025 03:23:39 +0000 Subject: [PATCH 2/4] feat(api): fix grader input list, add dated slugs for sora-2 --- .stats.yml | 6 +- .../openai/models/evals/EvalCreateParams.kt | 366 +++++++---------- .../CreateEvalCompletionsRunDataSource.kt | 366 +++++++---------- .../models/evals/runs/RunCancelResponse.kt | 379 +++++++----------- .../models/evals/runs/RunCreateParams.kt | 379 +++++++----------- .../models/evals/runs/RunCreateResponse.kt | 379 +++++++----------- .../models/evals/runs/RunListResponse.kt | 379 +++++++----------- .../models/evals/runs/RunRetrieveResponse.kt | 379 +++++++----------- .../graders/gradermodels/LabelModelGrader.kt | 343 ++++++---------- .../graders/gradermodels/ScoreModelGrader.kt | 343 ++++++---------- 10 files changed, 1251 insertions(+), 2068 deletions(-) diff --git a/.stats.yml b/.stats.yml index f7929828..a6811613 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 136 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-386042697a8769999956bdc26ff1e70bfc2a56913f724eedc6bfaf82679e9956.yml -openapi_spec_hash: 7072a6a4a43d7ff0bb4098a3e8a6b9a7 -config_hash: 141b101c9f13b90e21af74e1686f1f41 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-fe8e67bdc351a518b113ab48e775750190e207807903d6b03ab22c438c38a588.yml +openapi_spec_hash: 8af972190647ffb9dcec516e19d8761a +config_hash: 856bee50ee3617e85a9bc9274db01dbb diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt index 5350009c..1974483f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt @@ -29,6 +29,7 @@ import com.openai.core.http.Headers import com.openai.core.http.QueryParams import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.EvalContentItem import com.openai.models.graders.gradermodels.PythonGrader import com.openai.models.graders.gradermodels.ScoreModelGrader import com.openai.models.graders.gradermodels.StringCheckGrader @@ -3366,12 +3367,9 @@ private constructor( fun content(outputText: Content.OutputText) = content(Content.ofOutputText(outputText)) - /** - * Alias for calling [content] with - * `Content.ofEvalItemInputImage(evalItemInputImage)`. - */ - fun content(evalItemInputImage: Content.EvalItemInputImage) = - content(Content.ofEvalItemInputImage(evalItemInputImage)) + /** Alias for calling [content] with `Content.ofInputImage(inputImage)`. */ + fun content(inputImage: Content.InputImage) = + content(Content.ofInputImage(inputImage)) /** * Alias for calling [content] with @@ -3381,18 +3379,10 @@ private constructor( content(Content.ofResponseInputAudio(responseInputAudio)) /** - * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. + * Alias for calling [content] with `Content.ofGraderInputs(graderInputs)`. */ - fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - content( - Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) - ) + fun contentOfGraderInputs(graderInputs: List) = + content(Content.ofGraderInputs(graderInputs)) /** * The role of the message input. One of `user`, `assistant`, `system`, or @@ -3510,11 +3500,9 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextOutputTextInputImageAndInputAudio: - List? = - null, + private val graderInputs: List? = null, private val _json: JsonValue? = null, ) { @@ -3529,8 +3517,7 @@ private constructor( fun outputText(): Optional = Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -3540,9 +3527,8 @@ private constructor( * A list of inputs, each of which may be either an input text, output text, * input image, or input audio object. */ - fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable(anArrayOfInputTextOutputTextInputImageAndInputAudio) + fun graderInputs(): Optional> = + Optional.ofNullable(graderInputs) fun isTextInput(): Boolean = textInput != null @@ -3550,12 +3536,11 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): Boolean = - anArrayOfInputTextOutputTextInputImageAndInputAudio != null + fun isGraderInputs(): Boolean = graderInputs != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -3568,8 +3553,7 @@ private constructor( fun asOutputText(): OutputText = outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -3579,11 +3563,8 @@ private constructor( * A list of inputs, each of which may be either an input text, output text, * input image, or input audio object. */ - fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - List = - anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextOutputTextInputImageAndInputAudio" - ) + fun asGraderInputs(): List = + graderInputs.getOrThrow("graderInputs") fun _json(): Optional = Optional.ofNullable(_json) @@ -3593,15 +3574,10 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> - visitor - .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + graderInputs != null -> visitor.visitGraderInputs(graderInputs) else -> visitor.unknown(_json) } @@ -3626,10 +3602,8 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) { - evalItemInputImage.validate() + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() } override fun visitResponseInputAudio( @@ -3638,12 +3612,10 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List + override fun visitGraderInputs( + graderInputs: List ) { - anArrayOfInputTextOutputTextInputImageAndInputAudio - .forEach { it.validate() } + graderInputs.forEach { it.validate() } } } ) @@ -3677,21 +3649,16 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage(inputImage: InputImage) = + inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - anArrayOfInputTextOutputTextInputImageAndInputAudio.sumOf { - it.validity().toInt() - } + override fun visitGraderInputs( + graderInputs: List + ) = graderInputs.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -3706,10 +3673,9 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextOutputTextInputImageAndInputAudio == - other.anArrayOfInputTextOutputTextInputImageAndInputAudio + graderInputs == other.graderInputs } override fun hashCode(): Int = @@ -3717,9 +3683,9 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, - anArrayOfInputTextOutputTextInputImageAndInputAudio, + graderInputs, ) override fun toString(): String = @@ -3728,12 +3694,10 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - evalItemInputImage != null -> - "Content{evalItemInputImage=$evalItemInputImage}" + inputImage != null -> "Content{inputImage=$inputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> - "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" + graderInputs != null -> "Content{graderInputs=$graderInputs}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -3756,8 +3720,8 @@ private constructor( /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = - Content(evalItemInputImage = evalItemInputImage) + fun ofInputImage(inputImage: InputImage) = + Content(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic @@ -3769,15 +3733,8 @@ private constructor( * text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - anArrayOfInputTextOutputTextInputImageAndInputAudio - .toImmutable() - ) + fun ofGraderInputs(graderInputs: List) = + Content(graderInputs = graderInputs.toImmutable()) } /** @@ -3796,7 +3753,7 @@ private constructor( fun visitOutputText(outputText: OutputText): T /** An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage(evalItemInputImage: EvalItemInputImage): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T @@ -3805,10 +3762,7 @@ private constructor( * A list of inputs, each of which may be either an input text, output * text, input image, or input audio object. */ - fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ): T + fun visitGraderInputs(graderInputs: List): T /** * Maps an unknown variant of [Content] to a value of type [T]. @@ -3841,13 +3795,8 @@ private constructor( }, tryDeserialize(node, jacksonTypeRef()) ?.let { Content(outputText = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Content(evalItemInputImage = it, _json = json) - }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Content(inputImage = it, _json = json) }, tryDeserialize( node, jacksonTypeRef(), @@ -3860,17 +3809,9 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef< - List - >(), + jacksonTypeRef>(), ) - ?.let { - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - it, - _json = json, - ) - }, + ?.let { Content(graderInputs = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -3904,16 +3845,12 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value.anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - generator.writeObject( - value - .anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + value.graderInputs != null -> + generator.writeObject(value.graderInputs) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") } @@ -4142,7 +4079,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -4232,7 +4169,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EvalItemInputImage]. + * [InputImage]. * * The following fields are required: * ```java @@ -4242,7 +4179,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -4252,12 +4189,12 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(evalItemInputImage: EvalItemInputImage) = apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail additionalProperties = - evalItemInputImage.additionalProperties.toMutableMap() + inputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -4329,7 +4266,7 @@ private constructor( } /** - * Returns an immutable instance of [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the returned * instance. @@ -4341,8 +4278,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -4352,7 +4289,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -4394,7 +4331,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -4408,18 +4345,21 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - /** A text input to the model. */ - @JsonDeserialize(using = UnnamedSchemaWithArrayParent7.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent7.Serializer::class) - class UnnamedSchemaWithArrayParent7 + /** + * A single content item: input text, output text, input image, or input + * audio. + */ + @JsonDeserialize(using = EvalContentItem.Deserializer::class) + @JsonSerialize(using = EvalContentItem.Serializer::class) + class EvalContentItem private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, private val _json: JsonValue? = null, ) { @@ -4435,8 +4375,7 @@ private constructor( fun outputText(): Optional = Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -4448,7 +4387,7 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null @@ -4463,8 +4402,7 @@ private constructor( fun asOutputText(): OutputText = outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -4478,8 +4416,7 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) else -> visitor.unknown(_json) @@ -4487,7 +4424,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent7 = apply { + fun validate(): EvalContentItem = apply { if (validated) { return@apply } @@ -4506,10 +4443,8 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) { - evalItemInputImage.validate() + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() } override fun visitResponseInputAudio( @@ -4549,9 +4484,8 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage(inputImage: InputImage) = + inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio @@ -4566,11 +4500,11 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent7 && + return other is EvalContentItem && textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio } @@ -4579,28 +4513,21 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, ) override fun toString(): String = when { - textInput != null -> - "UnnamedSchemaWithArrayParent7{textInput=$textInput}" + textInput != null -> "EvalContentItem{textInput=$textInput}" responseInputText != null -> - "UnnamedSchemaWithArrayParent7{responseInputText=$responseInputText}" - outputText != null -> - "UnnamedSchemaWithArrayParent7{outputText=$outputText}" - evalItemInputImage != null -> - "UnnamedSchemaWithArrayParent7{evalItemInputImage=$evalItemInputImage}" + "EvalContentItem{responseInputText=$responseInputText}" + outputText != null -> "EvalContentItem{outputText=$outputText}" + inputImage != null -> "EvalContentItem{inputImage=$inputImage}" responseInputAudio != null -> - "UnnamedSchemaWithArrayParent7{responseInputAudio=$responseInputAudio}" - _json != null -> - "UnnamedSchemaWithArrayParent7{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent7" - ) + "EvalContentItem{responseInputAudio=$responseInputAudio}" + _json != null -> "EvalContentItem{_unknown=$_json}" + else -> throw IllegalStateException("Invalid EvalContentItem") } companion object { @@ -4608,38 +4535,32 @@ private constructor( /** A text input to the model. */ @JvmStatic fun ofTextInput(textInput: String) = - UnnamedSchemaWithArrayParent7(textInput = textInput) + EvalContentItem(textInput = textInput) /** A text input to the model. */ @JvmStatic fun ofResponseInputText(responseInputText: ResponseInputText) = - UnnamedSchemaWithArrayParent7( - responseInputText = responseInputText - ) + EvalContentItem(responseInputText = responseInputText) /** A text output from the model. */ @JvmStatic fun ofOutputText(outputText: OutputText) = - UnnamedSchemaWithArrayParent7(outputText = outputText) + EvalContentItem(outputText = outputText) /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = - UnnamedSchemaWithArrayParent7( - evalItemInputImage = evalItemInputImage - ) + fun ofInputImage(inputImage: InputImage) = + EvalContentItem(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic fun ofResponseInputAudio(responseInputAudio: ResponseInputAudio) = - UnnamedSchemaWithArrayParent7( - responseInputAudio = responseInputAudio - ) + EvalContentItem(responseInputAudio = responseInputAudio) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent7] to a value of type [T]. + * [EvalContentItem] to a value of type [T]. */ interface Visitor { @@ -4653,9 +4574,7 @@ private constructor( fun visitOutputText(outputText: OutputText): T /** An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -4663,32 +4582,30 @@ private constructor( ): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent7] to a - * value of type [T]. + * Maps an unknown variant of [EvalContentItem] to a value of type + * [T]. * - * An instance of [UnnamedSchemaWithArrayParent7] can contain an - * unknown variant if it was deserialized from data that doesn't - * match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants - * that the SDK is unaware of. + * An instance of [EvalContentItem] can contain an unknown variant + * if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the + * API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws OpenAIInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent7: $json" + "Unknown EvalContentItem: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent7::class - ) { + BaseDeserializer(EvalContentItem::class) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent7 { + ): EvalContentItem { val json = JsonValue.fromJsonNode(node) val bestMatches = @@ -4698,25 +4615,22 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent7( + EvalContentItem( responseInputText = it, _json = json, ) }, tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent7( + EvalContentItem( outputText = it, _json = json, ) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) + tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent7( - evalItemInputImage = it, + EvalContentItem( + inputImage = it, _json = json, ) }, @@ -4725,14 +4639,14 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent7( + EvalContentItem( responseInputAudio = it, _json = json, ) }, tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent7( + EvalContentItem( textInput = it, _json = json, ) @@ -4745,7 +4659,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. // deserializing from array). - 0 -> UnnamedSchemaWithArrayParent7(_json = json) + 0 -> EvalContentItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, // then use the first completely valid match, or simply the @@ -4758,12 +4672,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent7::class - ) { + BaseSerializer(EvalContentItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent7, + value: EvalContentItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -4774,15 +4686,13 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) value._json != null -> generator.writeObject(value._json) else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent7" - ) + throw IllegalStateException("Invalid EvalContentItem") } } } @@ -5015,7 +4925,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -5105,7 +5015,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EvalItemInputImage]. + * [InputImage]. * * The following fields are required: * ```java @@ -5115,7 +5025,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -5126,15 +5036,13 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(evalItemInputImage: EvalItemInputImage) = - apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail - additionalProperties = - evalItemInputImage.additionalProperties - .toMutableMap() - } + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail + additionalProperties = + inputImage.additionalProperties.toMutableMap() + } /** The URL of the image input. */ fun imageUrl(imageUrl: String) = @@ -5209,7 +5117,7 @@ private constructor( } /** - * Returns an immutable instance of [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -5221,8 +5129,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -5232,7 +5140,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -5276,7 +5184,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -5290,7 +5198,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt index edf60977..a202c89e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt @@ -26,6 +26,7 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatJsonObject import com.openai.models.ResponseFormatJsonSchema @@ -2881,12 +2882,9 @@ private constructor( fun content(outputText: Content.OutputText) = content(Content.ofOutputText(outputText)) - /** - * Alias for calling [content] with - * `Content.ofEvalItemInputImage(evalItemInputImage)`. - */ - fun content(evalItemInputImage: Content.EvalItemInputImage) = - content(Content.ofEvalItemInputImage(evalItemInputImage)) + /** Alias for calling [content] with `Content.ofInputImage(inputImage)`. */ + fun content(inputImage: Content.InputImage) = + content(Content.ofInputImage(inputImage)) /** * Alias for calling [content] with @@ -2896,18 +2894,10 @@ private constructor( content(Content.ofResponseInputAudio(responseInputAudio)) /** - * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. + * Alias for calling [content] with `Content.ofGraderInputs(graderInputs)`. */ - fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - content( - Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) - ) + fun contentOfGraderInputs(graderInputs: List) = + content(Content.ofGraderInputs(graderInputs)) /** * The role of the message input. One of `user`, `assistant`, `system`, or @@ -3025,11 +3015,9 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextOutputTextInputImageAndInputAudio: - List? = - null, + private val graderInputs: List? = null, private val _json: JsonValue? = null, ) { @@ -3044,8 +3032,7 @@ private constructor( fun outputText(): Optional = Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -3055,9 +3042,8 @@ private constructor( * A list of inputs, each of which may be either an input text, output text, * input image, or input audio object. */ - fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable(anArrayOfInputTextOutputTextInputImageAndInputAudio) + fun graderInputs(): Optional> = + Optional.ofNullable(graderInputs) fun isTextInput(): Boolean = textInput != null @@ -3065,12 +3051,11 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): Boolean = - anArrayOfInputTextOutputTextInputImageAndInputAudio != null + fun isGraderInputs(): Boolean = graderInputs != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -3083,8 +3068,7 @@ private constructor( fun asOutputText(): OutputText = outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -3094,11 +3078,8 @@ private constructor( * A list of inputs, each of which may be either an input text, output text, * input image, or input audio object. */ - fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - List = - anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextOutputTextInputImageAndInputAudio" - ) + fun asGraderInputs(): List = + graderInputs.getOrThrow("graderInputs") fun _json(): Optional = Optional.ofNullable(_json) @@ -3108,15 +3089,10 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> - visitor - .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + graderInputs != null -> visitor.visitGraderInputs(graderInputs) else -> visitor.unknown(_json) } @@ -3141,10 +3117,8 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) { - evalItemInputImage.validate() + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() } override fun visitResponseInputAudio( @@ -3153,12 +3127,10 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List + override fun visitGraderInputs( + graderInputs: List ) { - anArrayOfInputTextOutputTextInputImageAndInputAudio - .forEach { it.validate() } + graderInputs.forEach { it.validate() } } } ) @@ -3192,21 +3164,16 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage(inputImage: InputImage) = + inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - anArrayOfInputTextOutputTextInputImageAndInputAudio.sumOf { - it.validity().toInt() - } + override fun visitGraderInputs( + graderInputs: List + ) = graderInputs.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -3221,10 +3188,9 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextOutputTextInputImageAndInputAudio == - other.anArrayOfInputTextOutputTextInputImageAndInputAudio + graderInputs == other.graderInputs } override fun hashCode(): Int = @@ -3232,9 +3198,9 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, - anArrayOfInputTextOutputTextInputImageAndInputAudio, + graderInputs, ) override fun toString(): String = @@ -3243,12 +3209,10 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - evalItemInputImage != null -> - "Content{evalItemInputImage=$evalItemInputImage}" + inputImage != null -> "Content{inputImage=$inputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> - "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" + graderInputs != null -> "Content{graderInputs=$graderInputs}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -3271,8 +3235,8 @@ private constructor( /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = - Content(evalItemInputImage = evalItemInputImage) + fun ofInputImage(inputImage: InputImage) = + Content(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic @@ -3284,15 +3248,8 @@ private constructor( * text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - anArrayOfInputTextOutputTextInputImageAndInputAudio - .toImmutable() - ) + fun ofGraderInputs(graderInputs: List) = + Content(graderInputs = graderInputs.toImmutable()) } /** @@ -3311,7 +3268,7 @@ private constructor( fun visitOutputText(outputText: OutputText): T /** An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage(evalItemInputImage: EvalItemInputImage): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T @@ -3320,10 +3277,7 @@ private constructor( * A list of inputs, each of which may be either an input text, output * text, input image, or input audio object. */ - fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ): T + fun visitGraderInputs(graderInputs: List): T /** * Maps an unknown variant of [Content] to a value of type [T]. @@ -3356,13 +3310,8 @@ private constructor( }, tryDeserialize(node, jacksonTypeRef()) ?.let { Content(outputText = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Content(evalItemInputImage = it, _json = json) - }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Content(inputImage = it, _json = json) }, tryDeserialize( node, jacksonTypeRef(), @@ -3375,17 +3324,9 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef< - List - >(), + jacksonTypeRef>(), ) - ?.let { - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - it, - _json = json, - ) - }, + ?.let { Content(graderInputs = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -3419,16 +3360,12 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value.anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - generator.writeObject( - value - .anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + value.graderInputs != null -> + generator.writeObject(value.graderInputs) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") } @@ -3657,7 +3594,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -3747,7 +3684,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EvalItemInputImage]. + * [InputImage]. * * The following fields are required: * ```java @@ -3757,7 +3694,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -3767,12 +3704,12 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(evalItemInputImage: EvalItemInputImage) = apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail additionalProperties = - evalItemInputImage.additionalProperties.toMutableMap() + inputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -3844,7 +3781,7 @@ private constructor( } /** - * Returns an immutable instance of [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the returned * instance. @@ -3856,8 +3793,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -3867,7 +3804,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -3909,7 +3846,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -3923,18 +3860,21 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - /** A text input to the model. */ - @JsonDeserialize(using = UnnamedSchemaWithArrayParent2.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) - class UnnamedSchemaWithArrayParent2 + /** + * A single content item: input text, output text, input image, or input + * audio. + */ + @JsonDeserialize(using = EvalContentItem.Deserializer::class) + @JsonSerialize(using = EvalContentItem.Serializer::class) + class EvalContentItem private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, private val _json: JsonValue? = null, ) { @@ -3950,8 +3890,7 @@ private constructor( fun outputText(): Optional = Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -3963,7 +3902,7 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null @@ -3978,8 +3917,7 @@ private constructor( fun asOutputText(): OutputText = outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -3993,8 +3931,7 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) else -> visitor.unknown(_json) @@ -4002,7 +3939,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent2 = apply { + fun validate(): EvalContentItem = apply { if (validated) { return@apply } @@ -4021,10 +3958,8 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) { - evalItemInputImage.validate() + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() } override fun visitResponseInputAudio( @@ -4064,9 +3999,8 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage(inputImage: InputImage) = + inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio @@ -4081,11 +4015,11 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent2 && + return other is EvalContentItem && textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio } @@ -4094,28 +4028,21 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, ) override fun toString(): String = when { - textInput != null -> - "UnnamedSchemaWithArrayParent2{textInput=$textInput}" + textInput != null -> "EvalContentItem{textInput=$textInput}" responseInputText != null -> - "UnnamedSchemaWithArrayParent2{responseInputText=$responseInputText}" - outputText != null -> - "UnnamedSchemaWithArrayParent2{outputText=$outputText}" - evalItemInputImage != null -> - "UnnamedSchemaWithArrayParent2{evalItemInputImage=$evalItemInputImage}" + "EvalContentItem{responseInputText=$responseInputText}" + outputText != null -> "EvalContentItem{outputText=$outputText}" + inputImage != null -> "EvalContentItem{inputImage=$inputImage}" responseInputAudio != null -> - "UnnamedSchemaWithArrayParent2{responseInputAudio=$responseInputAudio}" - _json != null -> - "UnnamedSchemaWithArrayParent2{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent2" - ) + "EvalContentItem{responseInputAudio=$responseInputAudio}" + _json != null -> "EvalContentItem{_unknown=$_json}" + else -> throw IllegalStateException("Invalid EvalContentItem") } companion object { @@ -4123,38 +4050,32 @@ private constructor( /** A text input to the model. */ @JvmStatic fun ofTextInput(textInput: String) = - UnnamedSchemaWithArrayParent2(textInput = textInput) + EvalContentItem(textInput = textInput) /** A text input to the model. */ @JvmStatic fun ofResponseInputText(responseInputText: ResponseInputText) = - UnnamedSchemaWithArrayParent2( - responseInputText = responseInputText - ) + EvalContentItem(responseInputText = responseInputText) /** A text output from the model. */ @JvmStatic fun ofOutputText(outputText: OutputText) = - UnnamedSchemaWithArrayParent2(outputText = outputText) + EvalContentItem(outputText = outputText) /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = - UnnamedSchemaWithArrayParent2( - evalItemInputImage = evalItemInputImage - ) + fun ofInputImage(inputImage: InputImage) = + EvalContentItem(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic fun ofResponseInputAudio(responseInputAudio: ResponseInputAudio) = - UnnamedSchemaWithArrayParent2( - responseInputAudio = responseInputAudio - ) + EvalContentItem(responseInputAudio = responseInputAudio) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent2] to a value of type [T]. + * [EvalContentItem] to a value of type [T]. */ interface Visitor { @@ -4168,9 +4089,7 @@ private constructor( fun visitOutputText(outputText: OutputText): T /** An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -4178,32 +4097,30 @@ private constructor( ): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent2] to a - * value of type [T]. + * Maps an unknown variant of [EvalContentItem] to a value of type + * [T]. * - * An instance of [UnnamedSchemaWithArrayParent2] can contain an - * unknown variant if it was deserialized from data that doesn't - * match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants - * that the SDK is unaware of. + * An instance of [EvalContentItem] can contain an unknown variant + * if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the + * API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws OpenAIInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent2: $json" + "Unknown EvalContentItem: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent2::class - ) { + BaseDeserializer(EvalContentItem::class) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent2 { + ): EvalContentItem { val json = JsonValue.fromJsonNode(node) val bestMatches = @@ -4213,25 +4130,22 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent2( + EvalContentItem( responseInputText = it, _json = json, ) }, tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent2( + EvalContentItem( outputText = it, _json = json, ) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) + tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent2( - evalItemInputImage = it, + EvalContentItem( + inputImage = it, _json = json, ) }, @@ -4240,14 +4154,14 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent2( + EvalContentItem( responseInputAudio = it, _json = json, ) }, tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent2( + EvalContentItem( textInput = it, _json = json, ) @@ -4260,7 +4174,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. // deserializing from array). - 0 -> UnnamedSchemaWithArrayParent2(_json = json) + 0 -> EvalContentItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, // then use the first completely valid match, or simply the @@ -4273,12 +4187,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent2::class - ) { + BaseSerializer(EvalContentItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent2, + value: EvalContentItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -4289,15 +4201,13 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) value._json != null -> generator.writeObject(value._json) else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent2" - ) + throw IllegalStateException("Invalid EvalContentItem") } } } @@ -4530,7 +4440,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -4620,7 +4530,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EvalItemInputImage]. + * [InputImage]. * * The following fields are required: * ```java @@ -4630,7 +4540,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -4641,15 +4551,13 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(evalItemInputImage: EvalItemInputImage) = - apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail - additionalProperties = - evalItemInputImage.additionalProperties - .toMutableMap() - } + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail + additionalProperties = + inputImage.additionalProperties.toMutableMap() + } /** The URL of the image input. */ fun imageUrl(imageUrl: String) = @@ -4724,7 +4632,7 @@ private constructor( } /** - * Returns an immutable instance of [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -4736,8 +4644,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -4747,7 +4655,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -4791,7 +4699,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -4805,7 +4713,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt index 745aead0..a6af2f6b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt @@ -26,6 +26,7 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatJsonObject import com.openai.models.ResponseFormatText @@ -4375,10 +4376,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofEvalItemInputImage(evalItemInputImage)`. + * `Content.ofInputImage(inputImage)`. */ - fun content(evalItemInputImage: Content.EvalItemInputImage) = - content(Content.ofEvalItemInputImage(evalItemInputImage)) + fun content(inputImage: Content.InputImage) = + content(Content.ofInputImage(inputImage)) /** * Alias for calling [content] with @@ -4389,18 +4390,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. + * `Content.ofGraderInputs(graderInputs)`. */ - fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - content( - Content - .ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) - ) + fun contentOfGraderInputs(graderInputs: List) = + content(Content.ofGraderInputs(graderInputs)) /** * The role of the message input. One of `user`, `assistant`, @@ -4520,11 +4513,9 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextOutputTextInputImageAndInputAudio: - List? = - null, + private val graderInputs: List? = null, private val _json: JsonValue? = null, ) { @@ -4540,8 +4531,8 @@ private constructor( Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = + Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -4551,11 +4542,8 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + fun graderInputs(): Optional> = + Optional.ofNullable(graderInputs) fun isTextInput(): Boolean = textInput != null @@ -4563,13 +4551,11 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - Boolean = - anArrayOfInputTextOutputTextInputImageAndInputAudio != null + fun isGraderInputs(): Boolean = graderInputs != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -4582,8 +4568,7 @@ private constructor( fun asOutputText(): OutputText = outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -4593,11 +4578,8 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - List = - anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextOutputTextInputImageAndInputAudio" - ) + fun asGraderInputs(): List = + graderInputs.getOrThrow("graderInputs") fun _json(): Optional = Optional.ofNullable(_json) @@ -4607,16 +4589,11 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - visitor - .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + graderInputs != null -> + visitor.visitGraderInputs(graderInputs) else -> visitor.unknown(_json) } @@ -4641,10 +4618,8 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) { - evalItemInputImage.validate() + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() } override fun visitResponseInputAudio( @@ -4653,12 +4628,10 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List + override fun visitGraderInputs( + graderInputs: List ) { - anArrayOfInputTextOutputTextInputImageAndInputAudio - .forEach { it.validate() } + graderInputs.forEach { it.validate() } } } ) @@ -4692,20 +4665,16 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage(inputImage: InputImage) = + inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - anArrayOfInputTextOutputTextInputImageAndInputAudio - .sumOf { it.validity().toInt() } + override fun visitGraderInputs( + graderInputs: List + ) = graderInputs.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -4720,11 +4689,9 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextOutputTextInputImageAndInputAudio == - other - .anArrayOfInputTextOutputTextInputImageAndInputAudio + graderInputs == other.graderInputs } override fun hashCode(): Int = @@ -4732,9 +4699,9 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, - anArrayOfInputTextOutputTextInputImageAndInputAudio, + graderInputs, ) override fun toString(): String = @@ -4743,13 +4710,11 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - evalItemInputImage != null -> - "Content{evalItemInputImage=$evalItemInputImage}" + inputImage != null -> "Content{inputImage=$inputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" + graderInputs != null -> + "Content{graderInputs=$graderInputs}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -4773,9 +4738,8 @@ private constructor( /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = Content(evalItemInputImage = evalItemInputImage) + fun ofInputImage(inputImage: InputImage) = + Content(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic @@ -4788,15 +4752,8 @@ private constructor( * output text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - anArrayOfInputTextOutputTextInputImageAndInputAudio - .toImmutable() - ) + fun ofGraderInputs(graderInputs: List) = + Content(graderInputs = graderInputs.toImmutable()) } /** @@ -4817,9 +4774,7 @@ private constructor( fun visitOutputText(outputText: OutputText): T /** An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -4830,10 +4785,7 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ): T + fun visitGraderInputs(graderInputs: List): T /** * Maps an unknown variant of [Content] to a value of type [T]. @@ -4879,13 +4831,10 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - Content( - evalItemInputImage = it, - _json = json, - ) + Content(inputImage = it, _json = json) }, tryDeserialize( node, @@ -4903,16 +4852,10 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef< - List - >(), + jacksonTypeRef>(), ) ?.let { - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - it, - _json = json, - ) + Content(graderInputs = it, _json = json) }, ) .filterNotNull() @@ -4950,17 +4893,12 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value - .anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - generator.writeObject( - value - .anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + value.graderInputs != null -> + generator.writeObject(value.graderInputs) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") @@ -5206,7 +5144,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -5301,7 +5239,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EvalItemInputImage]. + * [InputImage]. * * The following fields are required: * ```java @@ -5311,7 +5249,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -5322,15 +5260,13 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(evalItemInputImage: EvalItemInputImage) = - apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail - additionalProperties = - evalItemInputImage.additionalProperties - .toMutableMap() - } + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail + additionalProperties = + inputImage.additionalProperties.toMutableMap() + } /** The URL of the image input. */ fun imageUrl(imageUrl: String) = @@ -5408,7 +5344,7 @@ private constructor( } /** - * Returns an immutable instance of [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -5421,8 +5357,8 @@ private constructor( * @throws IllegalStateException if any required field is * unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -5432,7 +5368,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -5476,7 +5412,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -5490,22 +5426,21 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - /** A text input to the model. */ - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent6.Deserializer::class - ) - @JsonSerialize( - using = UnnamedSchemaWithArrayParent6.Serializer::class - ) - class UnnamedSchemaWithArrayParent6 + /** + * A single content item: input text, output text, input image, or + * input audio. + */ + @JsonDeserialize(using = EvalContentItem.Deserializer::class) + @JsonSerialize(using = EvalContentItem.Serializer::class) + class EvalContentItem private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, private val _json: JsonValue? = null, ) { @@ -5523,8 +5458,8 @@ private constructor( Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = + Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -5536,7 +5471,7 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null @@ -5552,8 +5487,8 @@ private constructor( outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = + inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -5568,8 +5503,8 @@ private constructor( visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> + visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) else -> visitor.unknown(_json) @@ -5577,7 +5512,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent6 = apply { + fun validate(): EvalContentItem = apply { if (validated) { return@apply } @@ -5598,10 +5533,10 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage + override fun visitInputImage( + inputImage: InputImage ) { - evalItemInputImage.validate() + inputImage.validate() } override fun visitResponseInputAudio( @@ -5642,9 +5577,9 @@ private constructor( outputText: OutputText ) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage( + inputImage: InputImage + ) = inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio @@ -5659,11 +5594,11 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent6 && + return other is EvalContentItem && textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio } @@ -5672,27 +5607,26 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, ) override fun toString(): String = when { textInput != null -> - "UnnamedSchemaWithArrayParent6{textInput=$textInput}" + "EvalContentItem{textInput=$textInput}" responseInputText != null -> - "UnnamedSchemaWithArrayParent6{responseInputText=$responseInputText}" + "EvalContentItem{responseInputText=$responseInputText}" outputText != null -> - "UnnamedSchemaWithArrayParent6{outputText=$outputText}" - evalItemInputImage != null -> - "UnnamedSchemaWithArrayParent6{evalItemInputImage=$evalItemInputImage}" + "EvalContentItem{outputText=$outputText}" + inputImage != null -> + "EvalContentItem{inputImage=$inputImage}" responseInputAudio != null -> - "UnnamedSchemaWithArrayParent6{responseInputAudio=$responseInputAudio}" - _json != null -> - "UnnamedSchemaWithArrayParent6{_unknown=$_json}" + "EvalContentItem{responseInputAudio=$responseInputAudio}" + _json != null -> "EvalContentItem{_unknown=$_json}" else -> throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent6" + "Invalid EvalContentItem" ) } @@ -5701,46 +5635,36 @@ private constructor( /** A text input to the model. */ @JvmStatic fun ofTextInput(textInput: String) = - UnnamedSchemaWithArrayParent6(textInput = textInput) + EvalContentItem(textInput = textInput) /** A text input to the model. */ @JvmStatic fun ofResponseInputText( responseInputText: ResponseInputText - ) = - UnnamedSchemaWithArrayParent6( - responseInputText = responseInputText - ) + ) = EvalContentItem(responseInputText = responseInputText) /** A text output from the model. */ @JvmStatic fun ofOutputText(outputText: OutputText) = - UnnamedSchemaWithArrayParent6(outputText = outputText) + EvalContentItem(outputText = outputText) /** * An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = - UnnamedSchemaWithArrayParent6( - evalItemInputImage = evalItemInputImage - ) + fun ofInputImage(inputImage: InputImage) = + EvalContentItem(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic fun ofResponseInputAudio( responseInputAudio: ResponseInputAudio - ) = - UnnamedSchemaWithArrayParent6( - responseInputAudio = responseInputAudio - ) + ) = EvalContentItem(responseInputAudio = responseInputAudio) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent6] to a value of type [T]. + * [EvalContentItem] to a value of type [T]. */ interface Visitor { @@ -5758,9 +5682,7 @@ private constructor( /** * An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -5768,34 +5690,31 @@ private constructor( ): T /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent6] to a value of type [T]. + * Maps an unknown variant of [EvalContentItem] to a value + * of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent6] can - * contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the - * API may respond with new variants that the SDK is unaware - * of. + * An instance of [EvalContentItem] can contain an unknown + * variant if it was deserialized from data that doesn't + * match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws OpenAIInvalidDataException in the default * implementation. */ fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent6: $json" + "Unknown EvalContentItem: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent6::class - ) { + BaseDeserializer(EvalContentItem::class) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent6 { + ): EvalContentItem { val json = JsonValue.fromJsonNode(node) val bestMatches = @@ -5805,7 +5724,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent6( + EvalContentItem( responseInputText = it, _json = json, ) @@ -5815,18 +5734,18 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent6( + EvalContentItem( outputText = it, _json = json, ) }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent6( - evalItemInputImage = it, + EvalContentItem( + inputImage = it, _json = json, ) }, @@ -5835,7 +5754,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent6( + EvalContentItem( responseInputAudio = it, _json = json, ) @@ -5845,7 +5764,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent6( + EvalContentItem( textInput = it, _json = json, ) @@ -5858,7 +5777,7 @@ private constructor( // This can happen if what we're deserializing is // completely incompatible with all the possible // variants (e.g. deserializing from array). - 0 -> UnnamedSchemaWithArrayParent6(_json = json) + 0 -> EvalContentItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest // validity, then use the first completely valid @@ -5872,12 +5791,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent6::class - ) { + BaseSerializer(EvalContentItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent6, + value: EvalContentItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -5888,15 +5805,15 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent6" + "Invalid EvalContentItem" ) } } @@ -6147,7 +6064,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -6246,7 +6163,7 @@ private constructor( /** * Returns a mutable builder for constructing an - * instance of [EvalItemInputImage]. + * instance of [InputImage]. * * The following fields are required: * ```java @@ -6256,7 +6173,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -6268,15 +6185,12 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - evalItemInputImage: EvalItemInputImage - ) = apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail additionalProperties = - evalItemInputImage.additionalProperties - .toMutableMap() + inputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -6359,8 +6273,7 @@ private constructor( } /** - * Returns an immutable instance of - * [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -6373,8 +6286,8 @@ private constructor( * @throws IllegalStateException if any required field * is unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -6384,7 +6297,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -6429,7 +6342,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -6448,7 +6361,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt index 675dc8b5..d0d62e4d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt @@ -29,6 +29,7 @@ import com.openai.core.http.Headers import com.openai.core.http.QueryParams import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatJsonObject import com.openai.models.ResponseFormatText @@ -4260,10 +4261,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofEvalItemInputImage(evalItemInputImage)`. + * `Content.ofInputImage(inputImage)`. */ - fun content(evalItemInputImage: Content.EvalItemInputImage) = - content(Content.ofEvalItemInputImage(evalItemInputImage)) + fun content(inputImage: Content.InputImage) = + content(Content.ofInputImage(inputImage)) /** * Alias for calling [content] with @@ -4274,18 +4275,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. + * `Content.ofGraderInputs(graderInputs)`. */ - fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - content( - Content - .ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) - ) + fun contentOfGraderInputs(graderInputs: List) = + content(Content.ofGraderInputs(graderInputs)) /** * The role of the message input. One of `user`, `assistant`, @@ -4405,11 +4398,9 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextOutputTextInputImageAndInputAudio: - List? = - null, + private val graderInputs: List? = null, private val _json: JsonValue? = null, ) { @@ -4425,8 +4416,8 @@ private constructor( Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = + Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -4436,11 +4427,8 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + fun graderInputs(): Optional> = + Optional.ofNullable(graderInputs) fun isTextInput(): Boolean = textInput != null @@ -4448,13 +4436,11 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - Boolean = - anArrayOfInputTextOutputTextInputImageAndInputAudio != null + fun isGraderInputs(): Boolean = graderInputs != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -4467,8 +4453,7 @@ private constructor( fun asOutputText(): OutputText = outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -4478,11 +4463,8 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - List = - anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextOutputTextInputImageAndInputAudio" - ) + fun asGraderInputs(): List = + graderInputs.getOrThrow("graderInputs") fun _json(): Optional = Optional.ofNullable(_json) @@ -4492,16 +4474,11 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - visitor - .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + graderInputs != null -> + visitor.visitGraderInputs(graderInputs) else -> visitor.unknown(_json) } @@ -4526,10 +4503,8 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) { - evalItemInputImage.validate() + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() } override fun visitResponseInputAudio( @@ -4538,12 +4513,10 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List + override fun visitGraderInputs( + graderInputs: List ) { - anArrayOfInputTextOutputTextInputImageAndInputAudio - .forEach { it.validate() } + graderInputs.forEach { it.validate() } } } ) @@ -4577,20 +4550,16 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage(inputImage: InputImage) = + inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - anArrayOfInputTextOutputTextInputImageAndInputAudio - .sumOf { it.validity().toInt() } + override fun visitGraderInputs( + graderInputs: List + ) = graderInputs.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -4605,11 +4574,9 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextOutputTextInputImageAndInputAudio == - other - .anArrayOfInputTextOutputTextInputImageAndInputAudio + graderInputs == other.graderInputs } override fun hashCode(): Int = @@ -4617,9 +4584,9 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, - anArrayOfInputTextOutputTextInputImageAndInputAudio, + graderInputs, ) override fun toString(): String = @@ -4628,13 +4595,11 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - evalItemInputImage != null -> - "Content{evalItemInputImage=$evalItemInputImage}" + inputImage != null -> "Content{inputImage=$inputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" + graderInputs != null -> + "Content{graderInputs=$graderInputs}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -4658,9 +4623,8 @@ private constructor( /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = Content(evalItemInputImage = evalItemInputImage) + fun ofInputImage(inputImage: InputImage) = + Content(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic @@ -4673,15 +4637,8 @@ private constructor( * output text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - anArrayOfInputTextOutputTextInputImageAndInputAudio - .toImmutable() - ) + fun ofGraderInputs(graderInputs: List) = + Content(graderInputs = graderInputs.toImmutable()) } /** @@ -4702,9 +4659,7 @@ private constructor( fun visitOutputText(outputText: OutputText): T /** An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -4715,10 +4670,7 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ): T + fun visitGraderInputs(graderInputs: List): T /** * Maps an unknown variant of [Content] to a value of type [T]. @@ -4764,13 +4716,10 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - Content( - evalItemInputImage = it, - _json = json, - ) + Content(inputImage = it, _json = json) }, tryDeserialize( node, @@ -4788,16 +4737,10 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef< - List - >(), + jacksonTypeRef>(), ) ?.let { - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - it, - _json = json, - ) + Content(graderInputs = it, _json = json) }, ) .filterNotNull() @@ -4835,17 +4778,12 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value - .anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - generator.writeObject( - value - .anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + value.graderInputs != null -> + generator.writeObject(value.graderInputs) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") @@ -5091,7 +5029,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -5186,7 +5124,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EvalItemInputImage]. + * [InputImage]. * * The following fields are required: * ```java @@ -5196,7 +5134,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -5207,15 +5145,13 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(evalItemInputImage: EvalItemInputImage) = - apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail - additionalProperties = - evalItemInputImage.additionalProperties - .toMutableMap() - } + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail + additionalProperties = + inputImage.additionalProperties.toMutableMap() + } /** The URL of the image input. */ fun imageUrl(imageUrl: String) = @@ -5293,7 +5229,7 @@ private constructor( } /** - * Returns an immutable instance of [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -5306,8 +5242,8 @@ private constructor( * @throws IllegalStateException if any required field is * unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -5317,7 +5253,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -5361,7 +5297,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -5375,22 +5311,21 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - /** A text input to the model. */ - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent8.Deserializer::class - ) - @JsonSerialize( - using = UnnamedSchemaWithArrayParent8.Serializer::class - ) - class UnnamedSchemaWithArrayParent8 + /** + * A single content item: input text, output text, input image, or + * input audio. + */ + @JsonDeserialize(using = EvalContentItem.Deserializer::class) + @JsonSerialize(using = EvalContentItem.Serializer::class) + class EvalContentItem private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, private val _json: JsonValue? = null, ) { @@ -5408,8 +5343,8 @@ private constructor( Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = + Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -5421,7 +5356,7 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null @@ -5437,8 +5372,8 @@ private constructor( outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = + inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -5453,8 +5388,8 @@ private constructor( visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> + visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) else -> visitor.unknown(_json) @@ -5462,7 +5397,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent8 = apply { + fun validate(): EvalContentItem = apply { if (validated) { return@apply } @@ -5483,10 +5418,10 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage + override fun visitInputImage( + inputImage: InputImage ) { - evalItemInputImage.validate() + inputImage.validate() } override fun visitResponseInputAudio( @@ -5527,9 +5462,9 @@ private constructor( outputText: OutputText ) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage( + inputImage: InputImage + ) = inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio @@ -5544,11 +5479,11 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent8 && + return other is EvalContentItem && textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio } @@ -5557,27 +5492,26 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, ) override fun toString(): String = when { textInput != null -> - "UnnamedSchemaWithArrayParent8{textInput=$textInput}" + "EvalContentItem{textInput=$textInput}" responseInputText != null -> - "UnnamedSchemaWithArrayParent8{responseInputText=$responseInputText}" + "EvalContentItem{responseInputText=$responseInputText}" outputText != null -> - "UnnamedSchemaWithArrayParent8{outputText=$outputText}" - evalItemInputImage != null -> - "UnnamedSchemaWithArrayParent8{evalItemInputImage=$evalItemInputImage}" + "EvalContentItem{outputText=$outputText}" + inputImage != null -> + "EvalContentItem{inputImage=$inputImage}" responseInputAudio != null -> - "UnnamedSchemaWithArrayParent8{responseInputAudio=$responseInputAudio}" - _json != null -> - "UnnamedSchemaWithArrayParent8{_unknown=$_json}" + "EvalContentItem{responseInputAudio=$responseInputAudio}" + _json != null -> "EvalContentItem{_unknown=$_json}" else -> throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent8" + "Invalid EvalContentItem" ) } @@ -5586,46 +5520,36 @@ private constructor( /** A text input to the model. */ @JvmStatic fun ofTextInput(textInput: String) = - UnnamedSchemaWithArrayParent8(textInput = textInput) + EvalContentItem(textInput = textInput) /** A text input to the model. */ @JvmStatic fun ofResponseInputText( responseInputText: ResponseInputText - ) = - UnnamedSchemaWithArrayParent8( - responseInputText = responseInputText - ) + ) = EvalContentItem(responseInputText = responseInputText) /** A text output from the model. */ @JvmStatic fun ofOutputText(outputText: OutputText) = - UnnamedSchemaWithArrayParent8(outputText = outputText) + EvalContentItem(outputText = outputText) /** * An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = - UnnamedSchemaWithArrayParent8( - evalItemInputImage = evalItemInputImage - ) + fun ofInputImage(inputImage: InputImage) = + EvalContentItem(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic fun ofResponseInputAudio( responseInputAudio: ResponseInputAudio - ) = - UnnamedSchemaWithArrayParent8( - responseInputAudio = responseInputAudio - ) + ) = EvalContentItem(responseInputAudio = responseInputAudio) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent8] to a value of type [T]. + * [EvalContentItem] to a value of type [T]. */ interface Visitor { @@ -5643,9 +5567,7 @@ private constructor( /** * An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -5653,34 +5575,31 @@ private constructor( ): T /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent8] to a value of type [T]. + * Maps an unknown variant of [EvalContentItem] to a value + * of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent8] can - * contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the - * API may respond with new variants that the SDK is unaware - * of. + * An instance of [EvalContentItem] can contain an unknown + * variant if it was deserialized from data that doesn't + * match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws OpenAIInvalidDataException in the default * implementation. */ fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent8: $json" + "Unknown EvalContentItem: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent8::class - ) { + BaseDeserializer(EvalContentItem::class) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent8 { + ): EvalContentItem { val json = JsonValue.fromJsonNode(node) val bestMatches = @@ -5690,7 +5609,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent8( + EvalContentItem( responseInputText = it, _json = json, ) @@ -5700,18 +5619,18 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent8( + EvalContentItem( outputText = it, _json = json, ) }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent8( - evalItemInputImage = it, + EvalContentItem( + inputImage = it, _json = json, ) }, @@ -5720,7 +5639,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent8( + EvalContentItem( responseInputAudio = it, _json = json, ) @@ -5730,7 +5649,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent8( + EvalContentItem( textInput = it, _json = json, ) @@ -5743,7 +5662,7 @@ private constructor( // This can happen if what we're deserializing is // completely incompatible with all the possible // variants (e.g. deserializing from array). - 0 -> UnnamedSchemaWithArrayParent8(_json = json) + 0 -> EvalContentItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest // validity, then use the first completely valid @@ -5757,12 +5676,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent8::class - ) { + BaseSerializer(EvalContentItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent8, + value: EvalContentItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -5773,15 +5690,15 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent8" + "Invalid EvalContentItem" ) } } @@ -6032,7 +5949,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -6131,7 +6048,7 @@ private constructor( /** * Returns a mutable builder for constructing an - * instance of [EvalItemInputImage]. + * instance of [InputImage]. * * The following fields are required: * ```java @@ -6141,7 +6058,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -6153,15 +6070,12 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - evalItemInputImage: EvalItemInputImage - ) = apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail additionalProperties = - evalItemInputImage.additionalProperties - .toMutableMap() + inputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -6244,8 +6158,7 @@ private constructor( } /** - * Returns an immutable instance of - * [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -6258,8 +6171,8 @@ private constructor( * @throws IllegalStateException if any required field * is unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -6269,7 +6182,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -6314,7 +6227,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -6333,7 +6246,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt index 128f79fa..85a0acc4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt @@ -26,6 +26,7 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatJsonObject import com.openai.models.ResponseFormatText @@ -4375,10 +4376,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofEvalItemInputImage(evalItemInputImage)`. + * `Content.ofInputImage(inputImage)`. */ - fun content(evalItemInputImage: Content.EvalItemInputImage) = - content(Content.ofEvalItemInputImage(evalItemInputImage)) + fun content(inputImage: Content.InputImage) = + content(Content.ofInputImage(inputImage)) /** * Alias for calling [content] with @@ -4389,18 +4390,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. + * `Content.ofGraderInputs(graderInputs)`. */ - fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - content( - Content - .ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) - ) + fun contentOfGraderInputs(graderInputs: List) = + content(Content.ofGraderInputs(graderInputs)) /** * The role of the message input. One of `user`, `assistant`, @@ -4520,11 +4513,9 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextOutputTextInputImageAndInputAudio: - List? = - null, + private val graderInputs: List? = null, private val _json: JsonValue? = null, ) { @@ -4540,8 +4531,8 @@ private constructor( Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = + Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -4551,11 +4542,8 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + fun graderInputs(): Optional> = + Optional.ofNullable(graderInputs) fun isTextInput(): Boolean = textInput != null @@ -4563,13 +4551,11 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - Boolean = - anArrayOfInputTextOutputTextInputImageAndInputAudio != null + fun isGraderInputs(): Boolean = graderInputs != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -4582,8 +4568,7 @@ private constructor( fun asOutputText(): OutputText = outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -4593,11 +4578,8 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - List = - anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextOutputTextInputImageAndInputAudio" - ) + fun asGraderInputs(): List = + graderInputs.getOrThrow("graderInputs") fun _json(): Optional = Optional.ofNullable(_json) @@ -4607,16 +4589,11 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - visitor - .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + graderInputs != null -> + visitor.visitGraderInputs(graderInputs) else -> visitor.unknown(_json) } @@ -4641,10 +4618,8 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) { - evalItemInputImage.validate() + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() } override fun visitResponseInputAudio( @@ -4653,12 +4628,10 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List + override fun visitGraderInputs( + graderInputs: List ) { - anArrayOfInputTextOutputTextInputImageAndInputAudio - .forEach { it.validate() } + graderInputs.forEach { it.validate() } } } ) @@ -4692,20 +4665,16 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage(inputImage: InputImage) = + inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - anArrayOfInputTextOutputTextInputImageAndInputAudio - .sumOf { it.validity().toInt() } + override fun visitGraderInputs( + graderInputs: List + ) = graderInputs.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -4720,11 +4689,9 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextOutputTextInputImageAndInputAudio == - other - .anArrayOfInputTextOutputTextInputImageAndInputAudio + graderInputs == other.graderInputs } override fun hashCode(): Int = @@ -4732,9 +4699,9 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, - anArrayOfInputTextOutputTextInputImageAndInputAudio, + graderInputs, ) override fun toString(): String = @@ -4743,13 +4710,11 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - evalItemInputImage != null -> - "Content{evalItemInputImage=$evalItemInputImage}" + inputImage != null -> "Content{inputImage=$inputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" + graderInputs != null -> + "Content{graderInputs=$graderInputs}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -4773,9 +4738,8 @@ private constructor( /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = Content(evalItemInputImage = evalItemInputImage) + fun ofInputImage(inputImage: InputImage) = + Content(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic @@ -4788,15 +4752,8 @@ private constructor( * output text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - anArrayOfInputTextOutputTextInputImageAndInputAudio - .toImmutable() - ) + fun ofGraderInputs(graderInputs: List) = + Content(graderInputs = graderInputs.toImmutable()) } /** @@ -4817,9 +4774,7 @@ private constructor( fun visitOutputText(outputText: OutputText): T /** An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -4830,10 +4785,7 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ): T + fun visitGraderInputs(graderInputs: List): T /** * Maps an unknown variant of [Content] to a value of type [T]. @@ -4879,13 +4831,10 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - Content( - evalItemInputImage = it, - _json = json, - ) + Content(inputImage = it, _json = json) }, tryDeserialize( node, @@ -4903,16 +4852,10 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef< - List - >(), + jacksonTypeRef>(), ) ?.let { - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - it, - _json = json, - ) + Content(graderInputs = it, _json = json) }, ) .filterNotNull() @@ -4950,17 +4893,12 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value - .anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - generator.writeObject( - value - .anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + value.graderInputs != null -> + generator.writeObject(value.graderInputs) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") @@ -5206,7 +5144,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -5301,7 +5239,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EvalItemInputImage]. + * [InputImage]. * * The following fields are required: * ```java @@ -5311,7 +5249,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -5322,15 +5260,13 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(evalItemInputImage: EvalItemInputImage) = - apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail - additionalProperties = - evalItemInputImage.additionalProperties - .toMutableMap() - } + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail + additionalProperties = + inputImage.additionalProperties.toMutableMap() + } /** The URL of the image input. */ fun imageUrl(imageUrl: String) = @@ -5408,7 +5344,7 @@ private constructor( } /** - * Returns an immutable instance of [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -5421,8 +5357,8 @@ private constructor( * @throws IllegalStateException if any required field is * unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -5432,7 +5368,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -5476,7 +5412,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -5490,22 +5426,21 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - /** A text input to the model. */ - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent3.Deserializer::class - ) - @JsonSerialize( - using = UnnamedSchemaWithArrayParent3.Serializer::class - ) - class UnnamedSchemaWithArrayParent3 + /** + * A single content item: input text, output text, input image, or + * input audio. + */ + @JsonDeserialize(using = EvalContentItem.Deserializer::class) + @JsonSerialize(using = EvalContentItem.Serializer::class) + class EvalContentItem private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, private val _json: JsonValue? = null, ) { @@ -5523,8 +5458,8 @@ private constructor( Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = + Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -5536,7 +5471,7 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null @@ -5552,8 +5487,8 @@ private constructor( outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = + inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -5568,8 +5503,8 @@ private constructor( visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> + visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) else -> visitor.unknown(_json) @@ -5577,7 +5512,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent3 = apply { + fun validate(): EvalContentItem = apply { if (validated) { return@apply } @@ -5598,10 +5533,10 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage + override fun visitInputImage( + inputImage: InputImage ) { - evalItemInputImage.validate() + inputImage.validate() } override fun visitResponseInputAudio( @@ -5642,9 +5577,9 @@ private constructor( outputText: OutputText ) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage( + inputImage: InputImage + ) = inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio @@ -5659,11 +5594,11 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent3 && + return other is EvalContentItem && textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio } @@ -5672,27 +5607,26 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, ) override fun toString(): String = when { textInput != null -> - "UnnamedSchemaWithArrayParent3{textInput=$textInput}" + "EvalContentItem{textInput=$textInput}" responseInputText != null -> - "UnnamedSchemaWithArrayParent3{responseInputText=$responseInputText}" + "EvalContentItem{responseInputText=$responseInputText}" outputText != null -> - "UnnamedSchemaWithArrayParent3{outputText=$outputText}" - evalItemInputImage != null -> - "UnnamedSchemaWithArrayParent3{evalItemInputImage=$evalItemInputImage}" + "EvalContentItem{outputText=$outputText}" + inputImage != null -> + "EvalContentItem{inputImage=$inputImage}" responseInputAudio != null -> - "UnnamedSchemaWithArrayParent3{responseInputAudio=$responseInputAudio}" - _json != null -> - "UnnamedSchemaWithArrayParent3{_unknown=$_json}" + "EvalContentItem{responseInputAudio=$responseInputAudio}" + _json != null -> "EvalContentItem{_unknown=$_json}" else -> throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent3" + "Invalid EvalContentItem" ) } @@ -5701,46 +5635,36 @@ private constructor( /** A text input to the model. */ @JvmStatic fun ofTextInput(textInput: String) = - UnnamedSchemaWithArrayParent3(textInput = textInput) + EvalContentItem(textInput = textInput) /** A text input to the model. */ @JvmStatic fun ofResponseInputText( responseInputText: ResponseInputText - ) = - UnnamedSchemaWithArrayParent3( - responseInputText = responseInputText - ) + ) = EvalContentItem(responseInputText = responseInputText) /** A text output from the model. */ @JvmStatic fun ofOutputText(outputText: OutputText) = - UnnamedSchemaWithArrayParent3(outputText = outputText) + EvalContentItem(outputText = outputText) /** * An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = - UnnamedSchemaWithArrayParent3( - evalItemInputImage = evalItemInputImage - ) + fun ofInputImage(inputImage: InputImage) = + EvalContentItem(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic fun ofResponseInputAudio( responseInputAudio: ResponseInputAudio - ) = - UnnamedSchemaWithArrayParent3( - responseInputAudio = responseInputAudio - ) + ) = EvalContentItem(responseInputAudio = responseInputAudio) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent3] to a value of type [T]. + * [EvalContentItem] to a value of type [T]. */ interface Visitor { @@ -5758,9 +5682,7 @@ private constructor( /** * An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -5768,34 +5690,31 @@ private constructor( ): T /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent3] to a value of type [T]. + * Maps an unknown variant of [EvalContentItem] to a value + * of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent3] can - * contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the - * API may respond with new variants that the SDK is unaware - * of. + * An instance of [EvalContentItem] can contain an unknown + * variant if it was deserialized from data that doesn't + * match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws OpenAIInvalidDataException in the default * implementation. */ fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent3: $json" + "Unknown EvalContentItem: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent3::class - ) { + BaseDeserializer(EvalContentItem::class) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent3 { + ): EvalContentItem { val json = JsonValue.fromJsonNode(node) val bestMatches = @@ -5805,7 +5724,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent3( + EvalContentItem( responseInputText = it, _json = json, ) @@ -5815,18 +5734,18 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent3( + EvalContentItem( outputText = it, _json = json, ) }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent3( - evalItemInputImage = it, + EvalContentItem( + inputImage = it, _json = json, ) }, @@ -5835,7 +5754,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent3( + EvalContentItem( responseInputAudio = it, _json = json, ) @@ -5845,7 +5764,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent3( + EvalContentItem( textInput = it, _json = json, ) @@ -5858,7 +5777,7 @@ private constructor( // This can happen if what we're deserializing is // completely incompatible with all the possible // variants (e.g. deserializing from array). - 0 -> UnnamedSchemaWithArrayParent3(_json = json) + 0 -> EvalContentItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest // validity, then use the first completely valid @@ -5872,12 +5791,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent3::class - ) { + BaseSerializer(EvalContentItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent3, + value: EvalContentItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -5888,15 +5805,15 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent3" + "Invalid EvalContentItem" ) } } @@ -6147,7 +6064,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -6246,7 +6163,7 @@ private constructor( /** * Returns a mutable builder for constructing an - * instance of [EvalItemInputImage]. + * instance of [InputImage]. * * The following fields are required: * ```java @@ -6256,7 +6173,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -6268,15 +6185,12 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - evalItemInputImage: EvalItemInputImage - ) = apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail additionalProperties = - evalItemInputImage.additionalProperties - .toMutableMap() + inputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -6359,8 +6273,7 @@ private constructor( } /** - * Returns an immutable instance of - * [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -6373,8 +6286,8 @@ private constructor( * @throws IllegalStateException if any required field * is unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -6384,7 +6297,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -6429,7 +6342,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -6448,7 +6361,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt index c6196956..8c99b115 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt @@ -26,6 +26,7 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatJsonObject import com.openai.models.ResponseFormatText @@ -4375,10 +4376,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofEvalItemInputImage(evalItemInputImage)`. + * `Content.ofInputImage(inputImage)`. */ - fun content(evalItemInputImage: Content.EvalItemInputImage) = - content(Content.ofEvalItemInputImage(evalItemInputImage)) + fun content(inputImage: Content.InputImage) = + content(Content.ofInputImage(inputImage)) /** * Alias for calling [content] with @@ -4389,18 +4390,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. + * `Content.ofGraderInputs(graderInputs)`. */ - fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - content( - Content - .ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) - ) + fun contentOfGraderInputs(graderInputs: List) = + content(Content.ofGraderInputs(graderInputs)) /** * The role of the message input. One of `user`, `assistant`, @@ -4520,11 +4513,9 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextOutputTextInputImageAndInputAudio: - List? = - null, + private val graderInputs: List? = null, private val _json: JsonValue? = null, ) { @@ -4540,8 +4531,8 @@ private constructor( Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = + Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -4551,11 +4542,8 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + fun graderInputs(): Optional> = + Optional.ofNullable(graderInputs) fun isTextInput(): Boolean = textInput != null @@ -4563,13 +4551,11 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - Boolean = - anArrayOfInputTextOutputTextInputImageAndInputAudio != null + fun isGraderInputs(): Boolean = graderInputs != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -4582,8 +4568,7 @@ private constructor( fun asOutputText(): OutputText = outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -4593,11 +4578,8 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - List = - anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextOutputTextInputImageAndInputAudio" - ) + fun asGraderInputs(): List = + graderInputs.getOrThrow("graderInputs") fun _json(): Optional = Optional.ofNullable(_json) @@ -4607,16 +4589,11 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - visitor - .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + graderInputs != null -> + visitor.visitGraderInputs(graderInputs) else -> visitor.unknown(_json) } @@ -4641,10 +4618,8 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) { - evalItemInputImage.validate() + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() } override fun visitResponseInputAudio( @@ -4653,12 +4628,10 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List + override fun visitGraderInputs( + graderInputs: List ) { - anArrayOfInputTextOutputTextInputImageAndInputAudio - .forEach { it.validate() } + graderInputs.forEach { it.validate() } } } ) @@ -4692,20 +4665,16 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage(inputImage: InputImage) = + inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - anArrayOfInputTextOutputTextInputImageAndInputAudio - .sumOf { it.validity().toInt() } + override fun visitGraderInputs( + graderInputs: List + ) = graderInputs.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -4720,11 +4689,9 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextOutputTextInputImageAndInputAudio == - other - .anArrayOfInputTextOutputTextInputImageAndInputAudio + graderInputs == other.graderInputs } override fun hashCode(): Int = @@ -4732,9 +4699,9 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, - anArrayOfInputTextOutputTextInputImageAndInputAudio, + graderInputs, ) override fun toString(): String = @@ -4743,13 +4710,11 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - evalItemInputImage != null -> - "Content{evalItemInputImage=$evalItemInputImage}" + inputImage != null -> "Content{inputImage=$inputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" + graderInputs != null -> + "Content{graderInputs=$graderInputs}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -4773,9 +4738,8 @@ private constructor( /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = Content(evalItemInputImage = evalItemInputImage) + fun ofInputImage(inputImage: InputImage) = + Content(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic @@ -4788,15 +4752,8 @@ private constructor( * output text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - anArrayOfInputTextOutputTextInputImageAndInputAudio - .toImmutable() - ) + fun ofGraderInputs(graderInputs: List) = + Content(graderInputs = graderInputs.toImmutable()) } /** @@ -4817,9 +4774,7 @@ private constructor( fun visitOutputText(outputText: OutputText): T /** An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -4830,10 +4785,7 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ): T + fun visitGraderInputs(graderInputs: List): T /** * Maps an unknown variant of [Content] to a value of type [T]. @@ -4879,13 +4831,10 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - Content( - evalItemInputImage = it, - _json = json, - ) + Content(inputImage = it, _json = json) }, tryDeserialize( node, @@ -4903,16 +4852,10 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef< - List - >(), + jacksonTypeRef>(), ) ?.let { - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - it, - _json = json, - ) + Content(graderInputs = it, _json = json) }, ) .filterNotNull() @@ -4950,17 +4893,12 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value - .anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - generator.writeObject( - value - .anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + value.graderInputs != null -> + generator.writeObject(value.graderInputs) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") @@ -5206,7 +5144,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -5301,7 +5239,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EvalItemInputImage]. + * [InputImage]. * * The following fields are required: * ```java @@ -5311,7 +5249,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -5322,15 +5260,13 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(evalItemInputImage: EvalItemInputImage) = - apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail - additionalProperties = - evalItemInputImage.additionalProperties - .toMutableMap() - } + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail + additionalProperties = + inputImage.additionalProperties.toMutableMap() + } /** The URL of the image input. */ fun imageUrl(imageUrl: String) = @@ -5408,7 +5344,7 @@ private constructor( } /** - * Returns an immutable instance of [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -5421,8 +5357,8 @@ private constructor( * @throws IllegalStateException if any required field is * unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -5432,7 +5368,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -5476,7 +5412,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -5490,22 +5426,21 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - /** A text input to the model. */ - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent5.Deserializer::class - ) - @JsonSerialize( - using = UnnamedSchemaWithArrayParent5.Serializer::class - ) - class UnnamedSchemaWithArrayParent5 + /** + * A single content item: input text, output text, input image, or + * input audio. + */ + @JsonDeserialize(using = EvalContentItem.Deserializer::class) + @JsonSerialize(using = EvalContentItem.Serializer::class) + class EvalContentItem private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, private val _json: JsonValue? = null, ) { @@ -5523,8 +5458,8 @@ private constructor( Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = + Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -5536,7 +5471,7 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null @@ -5552,8 +5487,8 @@ private constructor( outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = + inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -5568,8 +5503,8 @@ private constructor( visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> + visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) else -> visitor.unknown(_json) @@ -5577,7 +5512,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent5 = apply { + fun validate(): EvalContentItem = apply { if (validated) { return@apply } @@ -5598,10 +5533,10 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage + override fun visitInputImage( + inputImage: InputImage ) { - evalItemInputImage.validate() + inputImage.validate() } override fun visitResponseInputAudio( @@ -5642,9 +5577,9 @@ private constructor( outputText: OutputText ) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage( + inputImage: InputImage + ) = inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio @@ -5659,11 +5594,11 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent5 && + return other is EvalContentItem && textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio } @@ -5672,27 +5607,26 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, ) override fun toString(): String = when { textInput != null -> - "UnnamedSchemaWithArrayParent5{textInput=$textInput}" + "EvalContentItem{textInput=$textInput}" responseInputText != null -> - "UnnamedSchemaWithArrayParent5{responseInputText=$responseInputText}" + "EvalContentItem{responseInputText=$responseInputText}" outputText != null -> - "UnnamedSchemaWithArrayParent5{outputText=$outputText}" - evalItemInputImage != null -> - "UnnamedSchemaWithArrayParent5{evalItemInputImage=$evalItemInputImage}" + "EvalContentItem{outputText=$outputText}" + inputImage != null -> + "EvalContentItem{inputImage=$inputImage}" responseInputAudio != null -> - "UnnamedSchemaWithArrayParent5{responseInputAudio=$responseInputAudio}" - _json != null -> - "UnnamedSchemaWithArrayParent5{_unknown=$_json}" + "EvalContentItem{responseInputAudio=$responseInputAudio}" + _json != null -> "EvalContentItem{_unknown=$_json}" else -> throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent5" + "Invalid EvalContentItem" ) } @@ -5701,46 +5635,36 @@ private constructor( /** A text input to the model. */ @JvmStatic fun ofTextInput(textInput: String) = - UnnamedSchemaWithArrayParent5(textInput = textInput) + EvalContentItem(textInput = textInput) /** A text input to the model. */ @JvmStatic fun ofResponseInputText( responseInputText: ResponseInputText - ) = - UnnamedSchemaWithArrayParent5( - responseInputText = responseInputText - ) + ) = EvalContentItem(responseInputText = responseInputText) /** A text output from the model. */ @JvmStatic fun ofOutputText(outputText: OutputText) = - UnnamedSchemaWithArrayParent5(outputText = outputText) + EvalContentItem(outputText = outputText) /** * An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = - UnnamedSchemaWithArrayParent5( - evalItemInputImage = evalItemInputImage - ) + fun ofInputImage(inputImage: InputImage) = + EvalContentItem(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic fun ofResponseInputAudio( responseInputAudio: ResponseInputAudio - ) = - UnnamedSchemaWithArrayParent5( - responseInputAudio = responseInputAudio - ) + ) = EvalContentItem(responseInputAudio = responseInputAudio) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent5] to a value of type [T]. + * [EvalContentItem] to a value of type [T]. */ interface Visitor { @@ -5758,9 +5682,7 @@ private constructor( /** * An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -5768,34 +5690,31 @@ private constructor( ): T /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent5] to a value of type [T]. + * Maps an unknown variant of [EvalContentItem] to a value + * of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent5] can - * contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the - * API may respond with new variants that the SDK is unaware - * of. + * An instance of [EvalContentItem] can contain an unknown + * variant if it was deserialized from data that doesn't + * match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws OpenAIInvalidDataException in the default * implementation. */ fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent5: $json" + "Unknown EvalContentItem: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent5::class - ) { + BaseDeserializer(EvalContentItem::class) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent5 { + ): EvalContentItem { val json = JsonValue.fromJsonNode(node) val bestMatches = @@ -5805,7 +5724,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent5( + EvalContentItem( responseInputText = it, _json = json, ) @@ -5815,18 +5734,18 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent5( + EvalContentItem( outputText = it, _json = json, ) }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent5( - evalItemInputImage = it, + EvalContentItem( + inputImage = it, _json = json, ) }, @@ -5835,7 +5754,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent5( + EvalContentItem( responseInputAudio = it, _json = json, ) @@ -5845,7 +5764,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent5( + EvalContentItem( textInput = it, _json = json, ) @@ -5858,7 +5777,7 @@ private constructor( // This can happen if what we're deserializing is // completely incompatible with all the possible // variants (e.g. deserializing from array). - 0 -> UnnamedSchemaWithArrayParent5(_json = json) + 0 -> EvalContentItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest // validity, then use the first completely valid @@ -5872,12 +5791,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent5::class - ) { + BaseSerializer(EvalContentItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent5, + value: EvalContentItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -5888,15 +5805,15 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent5" + "Invalid EvalContentItem" ) } } @@ -6147,7 +6064,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -6246,7 +6163,7 @@ private constructor( /** * Returns a mutable builder for constructing an - * instance of [EvalItemInputImage]. + * instance of [InputImage]. * * The following fields are required: * ```java @@ -6256,7 +6173,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -6268,15 +6185,12 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - evalItemInputImage: EvalItemInputImage - ) = apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail additionalProperties = - evalItemInputImage.additionalProperties - .toMutableMap() + inputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -6359,8 +6273,7 @@ private constructor( } /** - * Returns an immutable instance of - * [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -6373,8 +6286,8 @@ private constructor( * @throws IllegalStateException if any required field * is unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -6384,7 +6297,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -6429,7 +6342,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -6448,7 +6361,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt index f6b4e58b..caae91ca 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt @@ -26,6 +26,7 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatJsonObject import com.openai.models.ResponseFormatText @@ -4375,10 +4376,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofEvalItemInputImage(evalItemInputImage)`. + * `Content.ofInputImage(inputImage)`. */ - fun content(evalItemInputImage: Content.EvalItemInputImage) = - content(Content.ofEvalItemInputImage(evalItemInputImage)) + fun content(inputImage: Content.InputImage) = + content(Content.ofInputImage(inputImage)) /** * Alias for calling [content] with @@ -4389,18 +4390,10 @@ private constructor( /** * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. + * `Content.ofGraderInputs(graderInputs)`. */ - fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - content( - Content - .ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) - ) + fun contentOfGraderInputs(graderInputs: List) = + content(Content.ofGraderInputs(graderInputs)) /** * The role of the message input. One of `user`, `assistant`, @@ -4520,11 +4513,9 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextOutputTextInputImageAndInputAudio: - List? = - null, + private val graderInputs: List? = null, private val _json: JsonValue? = null, ) { @@ -4540,8 +4531,8 @@ private constructor( Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = + Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -4551,11 +4542,8 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + fun graderInputs(): Optional> = + Optional.ofNullable(graderInputs) fun isTextInput(): Boolean = textInput != null @@ -4563,13 +4551,11 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - Boolean = - anArrayOfInputTextOutputTextInputImageAndInputAudio != null + fun isGraderInputs(): Boolean = graderInputs != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -4582,8 +4568,7 @@ private constructor( fun asOutputText(): OutputText = outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -4593,11 +4578,8 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - List = - anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextOutputTextInputImageAndInputAudio" - ) + fun asGraderInputs(): List = + graderInputs.getOrThrow("graderInputs") fun _json(): Optional = Optional.ofNullable(_json) @@ -4607,16 +4589,11 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - visitor - .visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + graderInputs != null -> + visitor.visitGraderInputs(graderInputs) else -> visitor.unknown(_json) } @@ -4641,10 +4618,8 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) { - evalItemInputImage.validate() + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() } override fun visitResponseInputAudio( @@ -4653,12 +4628,10 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List + override fun visitGraderInputs( + graderInputs: List ) { - anArrayOfInputTextOutputTextInputImageAndInputAudio - .forEach { it.validate() } + graderInputs.forEach { it.validate() } } } ) @@ -4692,20 +4665,16 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage(inputImage: InputImage) = + inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - anArrayOfInputTextOutputTextInputImageAndInputAudio - .sumOf { it.validity().toInt() } + override fun visitGraderInputs( + graderInputs: List + ) = graderInputs.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -4720,11 +4689,9 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextOutputTextInputImageAndInputAudio == - other - .anArrayOfInputTextOutputTextInputImageAndInputAudio + graderInputs == other.graderInputs } override fun hashCode(): Int = @@ -4732,9 +4699,9 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, - anArrayOfInputTextOutputTextInputImageAndInputAudio, + graderInputs, ) override fun toString(): String = @@ -4743,13 +4710,11 @@ private constructor( responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - evalItemInputImage != null -> - "Content{evalItemInputImage=$evalItemInputImage}" + inputImage != null -> "Content{inputImage=$inputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" + graderInputs != null -> + "Content{graderInputs=$graderInputs}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -4773,9 +4738,8 @@ private constructor( /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = Content(evalItemInputImage = evalItemInputImage) + fun ofInputImage(inputImage: InputImage) = + Content(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic @@ -4788,15 +4752,8 @@ private constructor( * output text, input image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - anArrayOfInputTextOutputTextInputImageAndInputAudio - .toImmutable() - ) + fun ofGraderInputs(graderInputs: List) = + Content(graderInputs = graderInputs.toImmutable()) } /** @@ -4817,9 +4774,7 @@ private constructor( fun visitOutputText(outputText: OutputText): T /** An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -4830,10 +4785,7 @@ private constructor( * A list of inputs, each of which may be either an input text, * output text, input image, or input audio object. */ - fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ): T + fun visitGraderInputs(graderInputs: List): T /** * Maps an unknown variant of [Content] to a value of type [T]. @@ -4879,13 +4831,10 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - Content( - evalItemInputImage = it, - _json = json, - ) + Content(inputImage = it, _json = json) }, tryDeserialize( node, @@ -4903,16 +4852,10 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef< - List - >(), + jacksonTypeRef>(), ) ?.let { - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - it, - _json = json, - ) + Content(graderInputs = it, _json = json) }, ) .filterNotNull() @@ -4950,17 +4893,12 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value - .anArrayOfInputTextOutputTextInputImageAndInputAudio != - null -> - generator.writeObject( - value - .anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + value.graderInputs != null -> + generator.writeObject(value.graderInputs) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") @@ -5206,7 +5144,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -5301,7 +5239,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EvalItemInputImage]. + * [InputImage]. * * The following fields are required: * ```java @@ -5311,7 +5249,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -5322,15 +5260,13 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(evalItemInputImage: EvalItemInputImage) = - apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail - additionalProperties = - evalItemInputImage.additionalProperties - .toMutableMap() - } + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail + additionalProperties = + inputImage.additionalProperties.toMutableMap() + } /** The URL of the image input. */ fun imageUrl(imageUrl: String) = @@ -5408,7 +5344,7 @@ private constructor( } /** - * Returns an immutable instance of [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -5421,8 +5357,8 @@ private constructor( * @throws IllegalStateException if any required field is * unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -5432,7 +5368,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -5476,7 +5412,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -5490,22 +5426,21 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - /** A text input to the model. */ - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent4.Deserializer::class - ) - @JsonSerialize( - using = UnnamedSchemaWithArrayParent4.Serializer::class - ) - class UnnamedSchemaWithArrayParent4 + /** + * A single content item: input text, output text, input image, or + * input audio. + */ + @JsonDeserialize(using = EvalContentItem.Deserializer::class) + @JsonSerialize(using = EvalContentItem.Serializer::class) + class EvalContentItem private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, private val _json: JsonValue? = null, ) { @@ -5523,8 +5458,8 @@ private constructor( Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = + Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -5536,7 +5471,7 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null @@ -5552,8 +5487,8 @@ private constructor( outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = + inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -5568,8 +5503,8 @@ private constructor( visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> + visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) else -> visitor.unknown(_json) @@ -5577,7 +5512,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent4 = apply { + fun validate(): EvalContentItem = apply { if (validated) { return@apply } @@ -5598,10 +5533,10 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage + override fun visitInputImage( + inputImage: InputImage ) { - evalItemInputImage.validate() + inputImage.validate() } override fun visitResponseInputAudio( @@ -5642,9 +5577,9 @@ private constructor( outputText: OutputText ) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage( + inputImage: InputImage + ) = inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio @@ -5659,11 +5594,11 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent4 && + return other is EvalContentItem && textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio } @@ -5672,27 +5607,26 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, ) override fun toString(): String = when { textInput != null -> - "UnnamedSchemaWithArrayParent4{textInput=$textInput}" + "EvalContentItem{textInput=$textInput}" responseInputText != null -> - "UnnamedSchemaWithArrayParent4{responseInputText=$responseInputText}" + "EvalContentItem{responseInputText=$responseInputText}" outputText != null -> - "UnnamedSchemaWithArrayParent4{outputText=$outputText}" - evalItemInputImage != null -> - "UnnamedSchemaWithArrayParent4{evalItemInputImage=$evalItemInputImage}" + "EvalContentItem{outputText=$outputText}" + inputImage != null -> + "EvalContentItem{inputImage=$inputImage}" responseInputAudio != null -> - "UnnamedSchemaWithArrayParent4{responseInputAudio=$responseInputAudio}" - _json != null -> - "UnnamedSchemaWithArrayParent4{_unknown=$_json}" + "EvalContentItem{responseInputAudio=$responseInputAudio}" + _json != null -> "EvalContentItem{_unknown=$_json}" else -> throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent4" + "Invalid EvalContentItem" ) } @@ -5701,46 +5635,36 @@ private constructor( /** A text input to the model. */ @JvmStatic fun ofTextInput(textInput: String) = - UnnamedSchemaWithArrayParent4(textInput = textInput) + EvalContentItem(textInput = textInput) /** A text input to the model. */ @JvmStatic fun ofResponseInputText( responseInputText: ResponseInputText - ) = - UnnamedSchemaWithArrayParent4( - responseInputText = responseInputText - ) + ) = EvalContentItem(responseInputText = responseInputText) /** A text output from the model. */ @JvmStatic fun ofOutputText(outputText: OutputText) = - UnnamedSchemaWithArrayParent4(outputText = outputText) + EvalContentItem(outputText = outputText) /** * An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = - UnnamedSchemaWithArrayParent4( - evalItemInputImage = evalItemInputImage - ) + fun ofInputImage(inputImage: InputImage) = + EvalContentItem(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic fun ofResponseInputAudio( responseInputAudio: ResponseInputAudio - ) = - UnnamedSchemaWithArrayParent4( - responseInputAudio = responseInputAudio - ) + ) = EvalContentItem(responseInputAudio = responseInputAudio) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent4] to a value of type [T]. + * [EvalContentItem] to a value of type [T]. */ interface Visitor { @@ -5758,9 +5682,7 @@ private constructor( /** * An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio( @@ -5768,34 +5690,31 @@ private constructor( ): T /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent4] to a value of type [T]. + * Maps an unknown variant of [EvalContentItem] to a value + * of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent4] can - * contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the - * API may respond with new variants that the SDK is unaware - * of. + * An instance of [EvalContentItem] can contain an unknown + * variant if it was deserialized from data that doesn't + * match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws OpenAIInvalidDataException in the default * implementation. */ fun unknown(json: JsonValue?): T { throw OpenAIInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent4: $json" + "Unknown EvalContentItem: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent4::class - ) { + BaseDeserializer(EvalContentItem::class) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent4 { + ): EvalContentItem { val json = JsonValue.fromJsonNode(node) val bestMatches = @@ -5805,7 +5724,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent4( + EvalContentItem( responseInputText = it, _json = json, ) @@ -5815,18 +5734,18 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent4( + EvalContentItem( outputText = it, _json = json, ) }, tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent4( - evalItemInputImage = it, + EvalContentItem( + inputImage = it, _json = json, ) }, @@ -5835,7 +5754,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent4( + EvalContentItem( responseInputAudio = it, _json = json, ) @@ -5845,7 +5764,7 @@ private constructor( jacksonTypeRef(), ) ?.let { - UnnamedSchemaWithArrayParent4( + EvalContentItem( textInput = it, _json = json, ) @@ -5858,7 +5777,7 @@ private constructor( // This can happen if what we're deserializing is // completely incompatible with all the possible // variants (e.g. deserializing from array). - 0 -> UnnamedSchemaWithArrayParent4(_json = json) + 0 -> EvalContentItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest // validity, then use the first completely valid @@ -5872,12 +5791,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent4::class - ) { + BaseSerializer(EvalContentItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent4, + value: EvalContentItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -5888,15 +5805,15 @@ private constructor( generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> + generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent4" + "Invalid EvalContentItem" ) } } @@ -6147,7 +6064,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -6246,7 +6163,7 @@ private constructor( /** * Returns a mutable builder for constructing an - * instance of [EvalItemInputImage]. + * instance of [InputImage]. * * The following fields are required: * ```java @@ -6256,7 +6173,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -6268,15 +6185,12 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - evalItemInputImage: EvalItemInputImage - ) = apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail additionalProperties = - evalItemInputImage.additionalProperties - .toMutableMap() + inputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -6359,8 +6273,7 @@ private constructor( } /** - * Returns an immutable instance of - * [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the * returned instance. @@ -6373,8 +6286,8 @@ private constructor( * @throws IllegalStateException if any required field * is unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -6384,7 +6297,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -6429,7 +6342,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -6448,7 +6361,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt index f03a2a81..48fad67e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt @@ -26,6 +26,7 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.EvalContentItem import com.openai.models.responses.ResponseInputAudio import com.openai.models.responses.ResponseInputText import java.util.Collections @@ -536,11 +537,8 @@ private constructor( /** Alias for calling [content] with `Content.ofOutputText(outputText)`. */ fun content(outputText: Content.OutputText) = content(Content.ofOutputText(outputText)) - /** - * Alias for calling [content] with `Content.ofEvalItemInputImage(evalItemInputImage)`. - */ - fun content(evalItemInputImage: Content.EvalItemInputImage) = - content(Content.ofEvalItemInputImage(evalItemInputImage)) + /** Alias for calling [content] with `Content.ofInputImage(inputImage)`. */ + fun content(inputImage: Content.InputImage) = content(Content.ofInputImage(inputImage)) /** * Alias for calling [content] with `Content.ofResponseInputAudio(responseInputAudio)`. @@ -548,19 +546,9 @@ private constructor( fun content(responseInputAudio: ResponseInputAudio) = content(Content.ofResponseInputAudio(responseInputAudio)) - /** - * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. - */ - fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - content( - Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) - ) + /** Alias for calling [content] with `Content.ofGraderInputs(graderInputs)`. */ + fun contentOfGraderInputs(graderInputs: List) = + content(Content.ofGraderInputs(graderInputs)) /** * The role of the message input. One of `user`, `assistant`, `system`, or `developer`. @@ -673,11 +661,9 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextOutputTextInputImageAndInputAudio: - List? = - null, + private val graderInputs: List? = null, private val _json: JsonValue? = null, ) { @@ -692,8 +678,7 @@ private constructor( fun outputText(): Optional = Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -703,9 +688,7 @@ private constructor( * A list of inputs, each of which may be either an input text, output text, input * image, or input audio object. */ - fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable(anArrayOfInputTextOutputTextInputImageAndInputAudio) + fun graderInputs(): Optional> = Optional.ofNullable(graderInputs) fun isTextInput(): Boolean = textInput != null @@ -713,12 +696,11 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): Boolean = - anArrayOfInputTextOutputTextInputImageAndInputAudio != null + fun isGraderInputs(): Boolean = graderInputs != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -731,8 +713,7 @@ private constructor( fun asOutputText(): OutputText = outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -742,11 +723,7 @@ private constructor( * A list of inputs, each of which may be either an input text, output text, input * image, or input audio object. */ - fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - List = - anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextOutputTextInputImageAndInputAudio" - ) + fun asGraderInputs(): List = graderInputs.getOrThrow("graderInputs") fun _json(): Optional = Optional.ofNullable(_json) @@ -755,14 +732,10 @@ private constructor( textInput != null -> visitor.visitTextInput(textInput) responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> - visitor.visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + graderInputs != null -> visitor.visitGraderInputs(graderInputs) else -> visitor.unknown(_json) } @@ -785,10 +758,8 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) { - evalItemInputImage.validate() + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() } override fun visitResponseInputAudio( @@ -797,13 +768,8 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) { - anArrayOfInputTextOutputTextInputImageAndInputAudio.forEach { - it.validate() - } + override fun visitGraderInputs(graderInputs: List) { + graderInputs.forEach { it.validate() } } } ) @@ -835,21 +801,14 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage(inputImage: InputImage) = inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - anArrayOfInputTextOutputTextInputImageAndInputAudio.sumOf { - it.validity().toInt() - } + override fun visitGraderInputs(graderInputs: List) = + graderInputs.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -864,10 +823,9 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextOutputTextInputImageAndInputAudio == - other.anArrayOfInputTextOutputTextInputImageAndInputAudio + graderInputs == other.graderInputs } override fun hashCode(): Int = @@ -875,9 +833,9 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, - anArrayOfInputTextOutputTextInputImageAndInputAudio, + graderInputs, ) override fun toString(): String = @@ -885,10 +843,9 @@ private constructor( textInput != null -> "Content{textInput=$textInput}" responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - evalItemInputImage != null -> "Content{evalItemInputImage=$evalItemInputImage}" + inputImage != null -> "Content{inputImage=$inputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> - "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" + graderInputs != null -> "Content{graderInputs=$graderInputs}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -909,8 +866,7 @@ private constructor( /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = - Content(evalItemInputImage = evalItemInputImage) + fun ofInputImage(inputImage: InputImage) = Content(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic @@ -922,14 +878,8 @@ private constructor( * image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - anArrayOfInputTextOutputTextInputImageAndInputAudio.toImmutable() - ) + fun ofGraderInputs(graderInputs: List) = + Content(graderInputs = graderInputs.toImmutable()) } /** @@ -948,7 +898,7 @@ private constructor( fun visitOutputText(outputText: OutputText): T /** An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage(evalItemInputImage: EvalItemInputImage): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T @@ -957,10 +907,7 @@ private constructor( * A list of inputs, each of which may be either an input text, output text, input * image, or input audio object. */ - fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ): T + fun visitGraderInputs(graderInputs: List): T /** * Maps an unknown variant of [Content] to a value of type [T]. @@ -990,8 +937,8 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Content(outputText = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Content(evalItemInputImage = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Content(inputImage = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { Content(responseInputAudio = it, _json = json) @@ -999,17 +946,9 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Content(textInput = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef>(), - ) - ?.let { - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - it, - _json = json, - ) - }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Content(graderInputs = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1039,14 +978,10 @@ private constructor( value.responseInputText != null -> generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value.anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> - generator.writeObject( - value.anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + value.graderInputs != null -> generator.writeObject(value.graderInputs) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") } @@ -1262,7 +1197,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -1346,8 +1281,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [EvalItemInputImage]. + * Returns a mutable builder for constructing an instance of [InputImage]. * * The following fields are required: * ```java @@ -1357,7 +1291,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -1366,12 +1300,11 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(evalItemInputImage: EvalItemInputImage) = apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail - additionalProperties = - evalItemInputImage.additionalProperties.toMutableMap() + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail + additionalProperties = inputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -1438,7 +1371,7 @@ private constructor( } /** - * Returns an immutable instance of [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -1449,8 +1382,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -1460,7 +1393,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -1500,7 +1433,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -1514,18 +1447,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - /** A text input to the model. */ - @JsonDeserialize(using = UnnamedSchemaWithArrayParent0.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent0.Serializer::class) - class UnnamedSchemaWithArrayParent0 + /** A single content item: input text, output text, input image, or input audio. */ + @JsonDeserialize(using = EvalContentItem.Deserializer::class) + @JsonSerialize(using = EvalContentItem.Serializer::class) + class EvalContentItem private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, private val _json: JsonValue? = null, ) { @@ -1541,8 +1474,7 @@ private constructor( fun outputText(): Optional = Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -1554,7 +1486,7 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null @@ -1569,8 +1501,7 @@ private constructor( fun asOutputText(): OutputText = outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -1584,8 +1515,7 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) else -> visitor.unknown(_json) @@ -1593,7 +1523,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent0 = apply { + fun validate(): EvalContentItem = apply { if (validated) { return@apply } @@ -1612,10 +1542,8 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) { - evalItemInputImage.validate() + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() } override fun visitResponseInputAudio( @@ -1655,9 +1583,8 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage(inputImage: InputImage) = + inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio @@ -1672,11 +1599,11 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent0 && + return other is EvalContentItem && textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio } @@ -1685,56 +1612,53 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, ) override fun toString(): String = when { - textInput != null -> "UnnamedSchemaWithArrayParent0{textInput=$textInput}" + textInput != null -> "EvalContentItem{textInput=$textInput}" responseInputText != null -> - "UnnamedSchemaWithArrayParent0{responseInputText=$responseInputText}" - outputText != null -> - "UnnamedSchemaWithArrayParent0{outputText=$outputText}" - evalItemInputImage != null -> - "UnnamedSchemaWithArrayParent0{evalItemInputImage=$evalItemInputImage}" + "EvalContentItem{responseInputText=$responseInputText}" + outputText != null -> "EvalContentItem{outputText=$outputText}" + inputImage != null -> "EvalContentItem{inputImage=$inputImage}" responseInputAudio != null -> - "UnnamedSchemaWithArrayParent0{responseInputAudio=$responseInputAudio}" - _json != null -> "UnnamedSchemaWithArrayParent0{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent0") + "EvalContentItem{responseInputAudio=$responseInputAudio}" + _json != null -> "EvalContentItem{_unknown=$_json}" + else -> throw IllegalStateException("Invalid EvalContentItem") } companion object { /** A text input to the model. */ @JvmStatic - fun ofTextInput(textInput: String) = - UnnamedSchemaWithArrayParent0(textInput = textInput) + fun ofTextInput(textInput: String) = EvalContentItem(textInput = textInput) /** A text input to the model. */ @JvmStatic fun ofResponseInputText(responseInputText: ResponseInputText) = - UnnamedSchemaWithArrayParent0(responseInputText = responseInputText) + EvalContentItem(responseInputText = responseInputText) /** A text output from the model. */ @JvmStatic fun ofOutputText(outputText: OutputText) = - UnnamedSchemaWithArrayParent0(outputText = outputText) + EvalContentItem(outputText = outputText) /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = - UnnamedSchemaWithArrayParent0(evalItemInputImage = evalItemInputImage) + fun ofInputImage(inputImage: InputImage) = + EvalContentItem(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic fun ofResponseInputAudio(responseInputAudio: ResponseInputAudio) = - UnnamedSchemaWithArrayParent0(responseInputAudio = responseInputAudio) + EvalContentItem(responseInputAudio = responseInputAudio) } /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent0] to a value of type [T]. + * An interface that defines how to map each variant of [EvalContentItem] to a value + * of type [T]. */ interface Visitor { @@ -1748,66 +1672,49 @@ private constructor( fun visitOutputText(outputText: OutputText): T /** An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage(evalItemInputImage: EvalItemInputImage): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent0] to a value of type - * [T]. + * Maps an unknown variant of [EvalContentItem] to a value of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent0] can contain an unknown variant - * if it was deserialized from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new variants that the SDK is unaware of. + * An instance of [EvalContentItem] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws OpenAIInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw OpenAIInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent0: $json" - ) + throw OpenAIInvalidDataException("Unknown EvalContentItem: $json") } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent0::class - ) { + BaseDeserializer(EvalContentItem::class) { - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent0 { + override fun ObjectCodec.deserialize(node: JsonNode): EvalContentItem { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent0( - responseInputText = it, - _json = json, - ) + EvalContentItem(responseInputText = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent0(outputText = it, _json = json) + EvalContentItem(outputText = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + EvalContentItem(inputImage = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - UnnamedSchemaWithArrayParent0( - evalItemInputImage = it, - _json = json, - ) - }, tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent0( - responseInputAudio = it, - _json = json, - ) + EvalContentItem(responseInputAudio = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent0(textInput = it, _json = json) + EvalContentItem(textInput = it, _json = json) }, ) .filterNotNull() @@ -1817,7 +1724,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // array). - 0 -> UnnamedSchemaWithArrayParent0(_json = json) + 0 -> EvalContentItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -1828,12 +1735,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent0::class - ) { + BaseSerializer(EvalContentItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent0, + value: EvalContentItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -1842,13 +1747,11 @@ private constructor( value.responseInputText != null -> generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent0") + else -> throw IllegalStateException("Invalid EvalContentItem") } } } @@ -2065,7 +1968,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -2151,8 +2054,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [EvalItemInputImage]. + * Returns a mutable builder for constructing an instance of [InputImage]. * * The following fields are required: * ```java @@ -2162,7 +2064,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -2172,12 +2074,11 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(evalItemInputImage: EvalItemInputImage) = apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail - additionalProperties = - evalItemInputImage.additionalProperties.toMutableMap() + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail + additionalProperties = inputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -2246,7 +2147,7 @@ private constructor( } /** - * Returns an immutable instance of [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2257,8 +2158,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -2268,7 +2169,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -2308,7 +2209,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -2322,7 +2223,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt index 690bdcc6..a9ad8ead 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt @@ -26,6 +26,7 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.responses.ResponseInputAudio import com.openai.models.responses.ResponseInputText @@ -529,11 +530,8 @@ private constructor( /** Alias for calling [content] with `Content.ofOutputText(outputText)`. */ fun content(outputText: Content.OutputText) = content(Content.ofOutputText(outputText)) - /** - * Alias for calling [content] with `Content.ofEvalItemInputImage(evalItemInputImage)`. - */ - fun content(evalItemInputImage: Content.EvalItemInputImage) = - content(Content.ofEvalItemInputImage(evalItemInputImage)) + /** Alias for calling [content] with `Content.ofInputImage(inputImage)`. */ + fun content(inputImage: Content.InputImage) = content(Content.ofInputImage(inputImage)) /** * Alias for calling [content] with `Content.ofResponseInputAudio(responseInputAudio)`. @@ -541,19 +539,9 @@ private constructor( fun content(responseInputAudio: ResponseInputAudio) = content(Content.ofResponseInputAudio(responseInputAudio)) - /** - * Alias for calling [content] with - * `Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio(anArrayOfInputTextOutputTextInputImageAndInputAudio)`. - */ - fun contentOfAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - content( - Content.ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) - ) + /** Alias for calling [content] with `Content.ofGraderInputs(graderInputs)`. */ + fun contentOfGraderInputs(graderInputs: List) = + content(Content.ofGraderInputs(graderInputs)) /** * The role of the message input. One of `user`, `assistant`, `system`, or `developer`. @@ -666,11 +654,9 @@ private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, - private val anArrayOfInputTextOutputTextInputImageAndInputAudio: - List? = - null, + private val graderInputs: List? = null, private val _json: JsonValue? = null, ) { @@ -685,8 +671,7 @@ private constructor( fun outputText(): Optional = Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -696,9 +681,7 @@ private constructor( * A list of inputs, each of which may be either an input text, output text, input * image, or input audio object. */ - fun anArrayOfInputTextOutputTextInputImageAndInputAudio(): - Optional> = - Optional.ofNullable(anArrayOfInputTextOutputTextInputImageAndInputAudio) + fun graderInputs(): Optional> = Optional.ofNullable(graderInputs) fun isTextInput(): Boolean = textInput != null @@ -706,12 +689,11 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null - fun isAnArrayOfInputTextOutputTextInputImageAndInputAudio(): Boolean = - anArrayOfInputTextOutputTextInputImageAndInputAudio != null + fun isGraderInputs(): Boolean = graderInputs != null /** A text input to the model. */ fun asTextInput(): String = textInput.getOrThrow("textInput") @@ -724,8 +706,7 @@ private constructor( fun asOutputText(): OutputText = outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -735,11 +716,7 @@ private constructor( * A list of inputs, each of which may be either an input text, output text, input * image, or input audio object. */ - fun asAnArrayOfInputTextOutputTextInputImageAndInputAudio(): - List = - anArrayOfInputTextOutputTextInputImageAndInputAudio.getOrThrow( - "anArrayOfInputTextOutputTextInputImageAndInputAudio" - ) + fun asGraderInputs(): List = graderInputs.getOrThrow("graderInputs") fun _json(): Optional = Optional.ofNullable(_json) @@ -748,14 +725,10 @@ private constructor( textInput != null -> visitor.visitTextInput(textInput) responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) - anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> - visitor.visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + graderInputs != null -> visitor.visitGraderInputs(graderInputs) else -> visitor.unknown(_json) } @@ -778,10 +751,8 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) { - evalItemInputImage.validate() + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() } override fun visitResponseInputAudio( @@ -790,13 +761,8 @@ private constructor( responseInputAudio.validate() } - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) { - anArrayOfInputTextOutputTextInputImageAndInputAudio.forEach { - it.validate() - } + override fun visitGraderInputs(graderInputs: List) { + graderInputs.forEach { it.validate() } } } ) @@ -828,21 +794,14 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage(inputImage: InputImage) = inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio ) = responseInputAudio.validity() - override fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - anArrayOfInputTextOutputTextInputImageAndInputAudio.sumOf { - it.validity().toInt() - } + override fun visitGraderInputs(graderInputs: List) = + graderInputs.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -857,10 +816,9 @@ private constructor( textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio && - anArrayOfInputTextOutputTextInputImageAndInputAudio == - other.anArrayOfInputTextOutputTextInputImageAndInputAudio + graderInputs == other.graderInputs } override fun hashCode(): Int = @@ -868,9 +826,9 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, - anArrayOfInputTextOutputTextInputImageAndInputAudio, + graderInputs, ) override fun toString(): String = @@ -878,10 +836,9 @@ private constructor( textInput != null -> "Content{textInput=$textInput}" responseInputText != null -> "Content{responseInputText=$responseInputText}" outputText != null -> "Content{outputText=$outputText}" - evalItemInputImage != null -> "Content{evalItemInputImage=$evalItemInputImage}" + inputImage != null -> "Content{inputImage=$inputImage}" responseInputAudio != null -> "Content{responseInputAudio=$responseInputAudio}" - anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> - "Content{anArrayOfInputTextOutputTextInputImageAndInputAudio=$anArrayOfInputTextOutputTextInputImageAndInputAudio}" + graderInputs != null -> "Content{graderInputs=$graderInputs}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -902,8 +859,7 @@ private constructor( /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = - Content(evalItemInputImage = evalItemInputImage) + fun ofInputImage(inputImage: InputImage) = Content(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic @@ -915,14 +871,8 @@ private constructor( * image, or input audio object. */ @JvmStatic - fun ofAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ) = - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - anArrayOfInputTextOutputTextInputImageAndInputAudio.toImmutable() - ) + fun ofGraderInputs(graderInputs: List) = + Content(graderInputs = graderInputs.toImmutable()) } /** @@ -941,7 +891,7 @@ private constructor( fun visitOutputText(outputText: OutputText): T /** An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage(evalItemInputImage: EvalItemInputImage): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T @@ -950,10 +900,7 @@ private constructor( * A list of inputs, each of which may be either an input text, output text, input * image, or input audio object. */ - fun visitAnArrayOfInputTextOutputTextInputImageAndInputAudio( - anArrayOfInputTextOutputTextInputImageAndInputAudio: - List - ): T + fun visitGraderInputs(graderInputs: List): T /** * Maps an unknown variant of [Content] to a value of type [T]. @@ -983,8 +930,8 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Content(outputText = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Content(evalItemInputImage = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Content(inputImage = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { Content(responseInputAudio = it, _json = json) @@ -992,17 +939,9 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Content(textInput = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef>(), - ) - ?.let { - Content( - anArrayOfInputTextOutputTextInputImageAndInputAudio = - it, - _json = json, - ) - }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Content(graderInputs = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1032,14 +971,10 @@ private constructor( value.responseInputText != null -> generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) - value.anArrayOfInputTextOutputTextInputImageAndInputAudio != null -> - generator.writeObject( - value.anArrayOfInputTextOutputTextInputImageAndInputAudio - ) + value.graderInputs != null -> generator.writeObject(value.graderInputs) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") } @@ -1255,7 +1190,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -1339,8 +1274,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [EvalItemInputImage]. + * Returns a mutable builder for constructing an instance of [InputImage]. * * The following fields are required: * ```java @@ -1350,7 +1284,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -1359,12 +1293,11 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(evalItemInputImage: EvalItemInputImage) = apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail - additionalProperties = - evalItemInputImage.additionalProperties.toMutableMap() + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail + additionalProperties = inputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -1431,7 +1364,7 @@ private constructor( } /** - * Returns an immutable instance of [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -1442,8 +1375,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -1453,7 +1386,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -1493,7 +1426,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -1507,18 +1440,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - /** A text input to the model. */ - @JsonDeserialize(using = UnnamedSchemaWithArrayParent1.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) - class UnnamedSchemaWithArrayParent1 + /** A single content item: input text, output text, input image, or input audio. */ + @JsonDeserialize(using = EvalContentItem.Deserializer::class) + @JsonSerialize(using = EvalContentItem.Serializer::class) + class EvalContentItem private constructor( private val textInput: String? = null, private val responseInputText: ResponseInputText? = null, private val outputText: OutputText? = null, - private val evalItemInputImage: EvalItemInputImage? = null, + private val inputImage: InputImage? = null, private val responseInputAudio: ResponseInputAudio? = null, private val _json: JsonValue? = null, ) { @@ -1534,8 +1467,7 @@ private constructor( fun outputText(): Optional = Optional.ofNullable(outputText) /** An image input block used within EvalItem content arrays. */ - fun evalItemInputImage(): Optional = - Optional.ofNullable(evalItemInputImage) + fun inputImage(): Optional = Optional.ofNullable(inputImage) /** An audio input to the model. */ fun responseInputAudio(): Optional = @@ -1547,7 +1479,7 @@ private constructor( fun isOutputText(): Boolean = outputText != null - fun isEvalItemInputImage(): Boolean = evalItemInputImage != null + fun isInputImage(): Boolean = inputImage != null fun isResponseInputAudio(): Boolean = responseInputAudio != null @@ -1562,8 +1494,7 @@ private constructor( fun asOutputText(): OutputText = outputText.getOrThrow("outputText") /** An image input block used within EvalItem content arrays. */ - fun asEvalItemInputImage(): EvalItemInputImage = - evalItemInputImage.getOrThrow("evalItemInputImage") + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") /** An audio input to the model. */ fun asResponseInputAudio(): ResponseInputAudio = @@ -1577,8 +1508,7 @@ private constructor( responseInputText != null -> visitor.visitResponseInputText(responseInputText) outputText != null -> visitor.visitOutputText(outputText) - evalItemInputImage != null -> - visitor.visitEvalItemInputImage(evalItemInputImage) + inputImage != null -> visitor.visitInputImage(inputImage) responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) else -> visitor.unknown(_json) @@ -1586,7 +1516,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent1 = apply { + fun validate(): EvalContentItem = apply { if (validated) { return@apply } @@ -1605,10 +1535,8 @@ private constructor( outputText.validate() } - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) { - evalItemInputImage.validate() + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() } override fun visitResponseInputAudio( @@ -1648,9 +1576,8 @@ private constructor( override fun visitOutputText(outputText: OutputText) = outputText.validity() - override fun visitEvalItemInputImage( - evalItemInputImage: EvalItemInputImage - ) = evalItemInputImage.validity() + override fun visitInputImage(inputImage: InputImage) = + inputImage.validity() override fun visitResponseInputAudio( responseInputAudio: ResponseInputAudio @@ -1665,11 +1592,11 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent1 && + return other is EvalContentItem && textInput == other.textInput && responseInputText == other.responseInputText && outputText == other.outputText && - evalItemInputImage == other.evalItemInputImage && + inputImage == other.inputImage && responseInputAudio == other.responseInputAudio } @@ -1678,56 +1605,53 @@ private constructor( textInput, responseInputText, outputText, - evalItemInputImage, + inputImage, responseInputAudio, ) override fun toString(): String = when { - textInput != null -> "UnnamedSchemaWithArrayParent1{textInput=$textInput}" + textInput != null -> "EvalContentItem{textInput=$textInput}" responseInputText != null -> - "UnnamedSchemaWithArrayParent1{responseInputText=$responseInputText}" - outputText != null -> - "UnnamedSchemaWithArrayParent1{outputText=$outputText}" - evalItemInputImage != null -> - "UnnamedSchemaWithArrayParent1{evalItemInputImage=$evalItemInputImage}" + "EvalContentItem{responseInputText=$responseInputText}" + outputText != null -> "EvalContentItem{outputText=$outputText}" + inputImage != null -> "EvalContentItem{inputImage=$inputImage}" responseInputAudio != null -> - "UnnamedSchemaWithArrayParent1{responseInputAudio=$responseInputAudio}" - _json != null -> "UnnamedSchemaWithArrayParent1{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + "EvalContentItem{responseInputAudio=$responseInputAudio}" + _json != null -> "EvalContentItem{_unknown=$_json}" + else -> throw IllegalStateException("Invalid EvalContentItem") } companion object { /** A text input to the model. */ @JvmStatic - fun ofTextInput(textInput: String) = - UnnamedSchemaWithArrayParent1(textInput = textInput) + fun ofTextInput(textInput: String) = EvalContentItem(textInput = textInput) /** A text input to the model. */ @JvmStatic fun ofResponseInputText(responseInputText: ResponseInputText) = - UnnamedSchemaWithArrayParent1(responseInputText = responseInputText) + EvalContentItem(responseInputText = responseInputText) /** A text output from the model. */ @JvmStatic fun ofOutputText(outputText: OutputText) = - UnnamedSchemaWithArrayParent1(outputText = outputText) + EvalContentItem(outputText = outputText) /** An image input block used within EvalItem content arrays. */ @JvmStatic - fun ofEvalItemInputImage(evalItemInputImage: EvalItemInputImage) = - UnnamedSchemaWithArrayParent1(evalItemInputImage = evalItemInputImage) + fun ofInputImage(inputImage: InputImage) = + EvalContentItem(inputImage = inputImage) /** An audio input to the model. */ @JvmStatic fun ofResponseInputAudio(responseInputAudio: ResponseInputAudio) = - UnnamedSchemaWithArrayParent1(responseInputAudio = responseInputAudio) + EvalContentItem(responseInputAudio = responseInputAudio) } /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent1] to a value of type [T]. + * An interface that defines how to map each variant of [EvalContentItem] to a value + * of type [T]. */ interface Visitor { @@ -1741,66 +1665,49 @@ private constructor( fun visitOutputText(outputText: OutputText): T /** An image input block used within EvalItem content arrays. */ - fun visitEvalItemInputImage(evalItemInputImage: EvalItemInputImage): T + fun visitInputImage(inputImage: InputImage): T /** An audio input to the model. */ fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of type - * [T]. + * Maps an unknown variant of [EvalContentItem] to a value of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent1] can contain an unknown variant - * if it was deserialized from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new variants that the SDK is unaware of. + * An instance of [EvalContentItem] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws OpenAIInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw OpenAIInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent1: $json" - ) + throw OpenAIInvalidDataException("Unknown EvalContentItem: $json") } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent1::class - ) { + BaseDeserializer(EvalContentItem::class) { - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent1 { + override fun ObjectCodec.deserialize(node: JsonNode): EvalContentItem { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1( - responseInputText = it, - _json = json, - ) + EvalContentItem(responseInputText = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(outputText = it, _json = json) + EvalContentItem(outputText = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + EvalContentItem(inputImage = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - UnnamedSchemaWithArrayParent1( - evalItemInputImage = it, - _json = json, - ) - }, tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent1( - responseInputAudio = it, - _json = json, - ) + EvalContentItem(responseInputAudio = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(textInput = it, _json = json) + EvalContentItem(textInput = it, _json = json) }, ) .filterNotNull() @@ -1810,7 +1717,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // array). - 0 -> UnnamedSchemaWithArrayParent1(_json = json) + 0 -> EvalContentItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -1821,12 +1728,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent1::class - ) { + BaseSerializer(EvalContentItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent1, + value: EvalContentItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -1835,13 +1740,11 @@ private constructor( value.responseInputText != null -> generator.writeObject(value.responseInputText) value.outputText != null -> generator.writeObject(value.outputText) - value.evalItemInputImage != null -> - generator.writeObject(value.evalItemInputImage) + value.inputImage != null -> generator.writeObject(value.inputImage) value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + else -> throw IllegalStateException("Invalid EvalContentItem") } } } @@ -2058,7 +1961,7 @@ private constructor( } /** An image input block used within EvalItem content arrays. */ - class EvalItemInputImage + class InputImage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val imageUrl: JsonField, @@ -2144,8 +2047,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [EvalItemInputImage]. + * Returns a mutable builder for constructing an instance of [InputImage]. * * The following fields are required: * ```java @@ -2155,7 +2057,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalItemInputImage]. */ + /** A builder for [InputImage]. */ class Builder internal constructor() { private var imageUrl: JsonField? = null @@ -2165,12 +2067,11 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(evalItemInputImage: EvalItemInputImage) = apply { - imageUrl = evalItemInputImage.imageUrl - type = evalItemInputImage.type - detail = evalItemInputImage.detail - additionalProperties = - evalItemInputImage.additionalProperties.toMutableMap() + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail + additionalProperties = inputImage.additionalProperties.toMutableMap() } /** The URL of the image input. */ @@ -2239,7 +2140,7 @@ private constructor( } /** - * Returns an immutable instance of [EvalItemInputImage]. + * Returns an immutable instance of [InputImage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2250,8 +2151,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): EvalItemInputImage = - EvalItemInputImage( + fun build(): InputImage = + InputImage( checkRequired("imageUrl", imageUrl), type, detail, @@ -2261,7 +2162,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalItemInputImage = apply { + fun validate(): InputImage = apply { if (validated) { return@apply } @@ -2301,7 +2202,7 @@ private constructor( return true } - return other is EvalItemInputImage && + return other is InputImage && imageUrl == other.imageUrl && type == other.type && detail == other.detail && @@ -2315,7 +2216,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalItemInputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } } } From ffd07a2ad1ae064e65f4564c663502fe3901c21e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 15 Dec 2025 17:42:30 +0000 Subject: [PATCH 3/4] feat(api): manual updates for java --- .stats.yml | 2 +- .../openai/models/evals/EvalCreateParams.kt | 856 +--------------- .../CreateEvalCompletionsRunDataSource.kt | 856 +--------------- .../models/evals/runs/RunCancelResponse.kt | 938 +----------------- .../models/evals/runs/RunCreateParams.kt | 938 +----------------- .../models/evals/runs/RunCreateResponse.kt | 938 +----------------- .../models/evals/runs/RunListResponse.kt | 938 +----------------- .../models/evals/runs/RunRetrieveResponse.kt | 938 +----------------- .../graders/gradermodels/EvalContentItem.kt | 746 ++++++++++++++ .../graders/gradermodels/LabelModelGrader.kt | 778 --------------- .../graders/gradermodels/ScoreModelGrader.kt | 778 --------------- .../gradermodels/EvalContentItemTest.kt | 184 ++++ 12 files changed, 938 insertions(+), 7952 deletions(-) create mode 100644 openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/EvalContentItem.kt create mode 100644 openai-java-core/src/test/kotlin/com/openai/models/graders/gradermodels/EvalContentItemTest.kt diff --git a/.stats.yml b/.stats.yml index a6811613..0d142a9e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 136 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-fe8e67bdc351a518b113ab48e775750190e207807903d6b03ab22c438c38a588.yml openapi_spec_hash: 8af972190647ffb9dcec516e19d8761a -config_hash: 856bee50ee3617e85a9bc9274db01dbb +config_hash: d013f4fdd4dd59c6f376a9ca482b7f9e diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt index 1974483f..b8b252e0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt @@ -29,7 +29,7 @@ import com.openai.core.http.Headers import com.openai.core.http.QueryParams import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException -import com.openai.models.EvalContentItem +import com.openai.models.graders.gradermodels.EvalContentItem import com.openai.models.graders.gradermodels.PythonGrader import com.openai.models.graders.gradermodels.ScoreModelGrader import com.openai.models.graders.gradermodels.StringCheckGrader @@ -4347,860 +4347,6 @@ private constructor( override fun toString() = "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - - /** - * A single content item: input text, output text, input image, or input - * audio. - */ - @JsonDeserialize(using = EvalContentItem.Deserializer::class) - @JsonSerialize(using = EvalContentItem.Serializer::class) - class EvalContentItem - private constructor( - private val textInput: String? = null, - private val responseInputText: ResponseInputText? = null, - private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, - private val responseInputAudio: ResponseInputAudio? = null, - private val _json: JsonValue? = null, - ) { - - /** A text input to the model. */ - fun textInput(): Optional = Optional.ofNullable(textInput) - - /** A text input to the model. */ - fun responseInputText(): Optional = - Optional.ofNullable(responseInputText) - - /** A text output from the model. */ - fun outputText(): Optional = Optional.ofNullable(outputText) - - /** An image input block used within EvalItem content arrays. */ - fun inputImage(): Optional = Optional.ofNullable(inputImage) - - /** An audio input to the model. */ - fun responseInputAudio(): Optional = - Optional.ofNullable(responseInputAudio) - - fun isTextInput(): Boolean = textInput != null - - fun isResponseInputText(): Boolean = responseInputText != null - - fun isOutputText(): Boolean = outputText != null - - fun isInputImage(): Boolean = inputImage != null - - fun isResponseInputAudio(): Boolean = responseInputAudio != null - - /** A text input to the model. */ - fun asTextInput(): String = textInput.getOrThrow("textInput") - - /** A text input to the model. */ - fun asResponseInputText(): ResponseInputText = - responseInputText.getOrThrow("responseInputText") - - /** A text output from the model. */ - fun asOutputText(): OutputText = outputText.getOrThrow("outputText") - - /** An image input block used within EvalItem content arrays. */ - fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") - - /** An audio input to the model. */ - fun asResponseInputAudio(): ResponseInputAudio = - responseInputAudio.getOrThrow("responseInputAudio") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - textInput != null -> visitor.visitTextInput(textInput) - responseInputText != null -> - visitor.visitResponseInputText(responseInputText) - outputText != null -> visitor.visitOutputText(outputText) - inputImage != null -> visitor.visitInputImage(inputImage) - responseInputAudio != null -> - visitor.visitResponseInputAudio(responseInputAudio) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): EvalContentItem = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitTextInput(textInput: String) {} - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) { - responseInputText.validate() - } - - override fun visitOutputText(outputText: OutputText) { - outputText.validate() - } - - override fun visitInputImage(inputImage: InputImage) { - inputImage.validate() - } - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) { - responseInputAudio.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTextInput(textInput: String) = 1 - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) = responseInputText.validity() - - override fun visitOutputText(outputText: OutputText) = - outputText.validity() - - override fun visitInputImage(inputImage: InputImage) = - inputImage.validity() - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = responseInputAudio.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EvalContentItem && - textInput == other.textInput && - responseInputText == other.responseInputText && - outputText == other.outputText && - inputImage == other.inputImage && - responseInputAudio == other.responseInputAudio - } - - override fun hashCode(): Int = - Objects.hash( - textInput, - responseInputText, - outputText, - inputImage, - responseInputAudio, - ) - - override fun toString(): String = - when { - textInput != null -> "EvalContentItem{textInput=$textInput}" - responseInputText != null -> - "EvalContentItem{responseInputText=$responseInputText}" - outputText != null -> "EvalContentItem{outputText=$outputText}" - inputImage != null -> "EvalContentItem{inputImage=$inputImage}" - responseInputAudio != null -> - "EvalContentItem{responseInputAudio=$responseInputAudio}" - _json != null -> "EvalContentItem{_unknown=$_json}" - else -> throw IllegalStateException("Invalid EvalContentItem") - } - - companion object { - - /** A text input to the model. */ - @JvmStatic - fun ofTextInput(textInput: String) = - EvalContentItem(textInput = textInput) - - /** A text input to the model. */ - @JvmStatic - fun ofResponseInputText(responseInputText: ResponseInputText) = - EvalContentItem(responseInputText = responseInputText) - - /** A text output from the model. */ - @JvmStatic - fun ofOutputText(outputText: OutputText) = - EvalContentItem(outputText = outputText) - - /** An image input block used within EvalItem content arrays. */ - @JvmStatic - fun ofInputImage(inputImage: InputImage) = - EvalContentItem(inputImage = inputImage) - - /** An audio input to the model. */ - @JvmStatic - fun ofResponseInputAudio(responseInputAudio: ResponseInputAudio) = - EvalContentItem(responseInputAudio = responseInputAudio) - } - - /** - * An interface that defines how to map each variant of - * [EvalContentItem] to a value of type [T]. - */ - interface Visitor { - - /** A text input to the model. */ - fun visitTextInput(textInput: String): T - - /** A text input to the model. */ - fun visitResponseInputText(responseInputText: ResponseInputText): T - - /** A text output from the model. */ - fun visitOutputText(outputText: OutputText): T - - /** An image input block used within EvalItem content arrays. */ - fun visitInputImage(inputImage: InputImage): T - - /** An audio input to the model. */ - fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ): T - - /** - * Maps an unknown variant of [EvalContentItem] to a value of type - * [T]. - * - * An instance of [EvalContentItem] can contain an unknown variant - * if it was deserialized from data that doesn't match any known - * variant. For example, if the SDK is on an older version than the - * API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OpenAIInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OpenAIInvalidDataException( - "Unknown EvalContentItem: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer(EvalContentItem::class) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): EvalContentItem { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputText = it, - _json = json, - ) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - EvalContentItem( - outputText = it, - _json = json, - ) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - EvalContentItem( - inputImage = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputAudio = it, - _json = json, - ) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - EvalContentItem( - textInput = it, - _json = json, - ) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. - // deserializing from array). - 0 -> EvalContentItem(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, - // then use the first completely valid match, or simply the - // first match if none are completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(EvalContentItem::class) { - - override fun serialize( - value: EvalContentItem, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.textInput != null -> - generator.writeObject(value.textInput) - value.responseInputText != null -> - generator.writeObject(value.responseInputText) - value.outputText != null -> - generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) - value.responseInputAudio != null -> - generator.writeObject(value.responseInputAudio) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid EvalContentItem") - } - } - } - - /** A text output from the model. */ - class OutputText - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val text: JsonField, - private val type: JsonValue, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("text") - @ExcludeMissing - text: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - ) : this(text, type, mutableMapOf()) - - /** - * The text output from the model. - * - * @throws OpenAIInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). - */ - fun text(): String = text.getRequired("text") - - /** - * The type of the output text. Always `output_text`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * However, this method can be useful for debugging and logging - * (e.g. if the server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Returns the raw JSON value of [text]. - * - * Unlike [text], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("text") - @ExcludeMissing - fun _text(): JsonField = text - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [OutputText]. - * - * The following fields are required: - * ```java - * .text() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OutputText]. */ - class Builder internal constructor() { - - private var text: JsonField? = null - private var type: JsonValue = JsonValue.from("output_text") - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(outputText: OutputText) = apply { - text = outputText.text - type = outputText.type - additionalProperties = - outputText.additionalProperties.toMutableMap() - } - - /** The text output from the model. */ - fun text(text: String) = text(JsonField.of(text)) - - /** - * Sets [Builder.text] to an arbitrary JSON value. - * - * You should usually call [Builder.text] with a well-typed - * [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun text(text: JsonField) = apply { this.text = text } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the - * field defaults to the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OutputText]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .text() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): OutputText = - OutputText( - checkRequired("text", text), - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OutputText = apply { - if (validated) { - return@apply - } - - text() - _type().let { - if (it != JsonValue.from("output_text")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (text.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("output_text")) 1 else 0 - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OutputText && - text == other.text && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(text, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" - } - - /** An image input block used within EvalItem content arrays. */ - class InputImage - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val imageUrl: JsonField, - private val type: JsonValue, - private val detail: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("image_url") - @ExcludeMissing - imageUrl: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - @JsonProperty("detail") - @ExcludeMissing - detail: JsonField = JsonMissing.of(), - ) : this(imageUrl, type, detail, mutableMapOf()) - - /** - * The URL of the image input. - * - * @throws OpenAIInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). - */ - fun imageUrl(): String = imageUrl.getRequired("image_url") - - /** - * The type of the image input. Always `input_image`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * However, this method can be useful for debugging and logging - * (e.g. if the server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * The detail level of the image to be sent to the model. One of - * `high`, `low`, or `auto`. Defaults to `auto`. - * - * @throws OpenAIInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an - * unexpected value). - */ - fun detail(): Optional = detail.getOptional("detail") - - /** - * Returns the raw JSON value of [imageUrl]. - * - * Unlike [imageUrl], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl(): JsonField = imageUrl - - /** - * Returns the raw JSON value of [detail]. - * - * Unlike [detail], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("detail") - @ExcludeMissing - fun _detail(): JsonField = detail - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InputImage]. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InputImage]. */ - class Builder internal constructor() { - - private var imageUrl: JsonField? = null - private var type: JsonValue = JsonValue.from("input_image") - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = - inputImage.additionalProperties.toMutableMap() - } - - /** The URL of the image input. */ - fun imageUrl(imageUrl: String) = - imageUrl(JsonField.of(imageUrl)) - - /** - * Sets [Builder.imageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.imageUrl] with a well-typed - * [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the - * field defaults to the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * The detail level of the image to be sent to the model. One of - * `high`, `low`, or `auto`. Defaults to `auto`. - */ - fun detail(detail: String) = detail(JsonField.of(detail)) - - /** - * Sets [Builder.detail] to an arbitrary JSON value. - * - * You should usually call [Builder.detail] with a well-typed - * [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun detail(detail: JsonField) = apply { - this.detail = detail - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InputImage]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InputImage = - InputImage( - checkRequired("imageUrl", imageUrl), - type, - detail, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InputImage = apply { - if (validated) { - return@apply - } - - imageUrl() - _type().let { - if (it != JsonValue.from("input_image")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - detail() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (imageUrl.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("input_image")) 1 else 0 - } + - (if (detail.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InputImage && - imageUrl == other.imageUrl && - type == other.type && - detail == other.detail && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(imageUrl, type, detail, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" - } - } } /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt index a202c89e..bb608831 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt @@ -26,12 +26,12 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException -import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatJsonObject import com.openai.models.ResponseFormatJsonSchema import com.openai.models.ResponseFormatText import com.openai.models.chat.completions.ChatCompletionFunctionTool +import com.openai.models.graders.gradermodels.EvalContentItem import com.openai.models.responses.EasyInputMessage import com.openai.models.responses.ResponseInputAudio import com.openai.models.responses.ResponseInputText @@ -3862,860 +3862,6 @@ private constructor( override fun toString() = "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - - /** - * A single content item: input text, output text, input image, or input - * audio. - */ - @JsonDeserialize(using = EvalContentItem.Deserializer::class) - @JsonSerialize(using = EvalContentItem.Serializer::class) - class EvalContentItem - private constructor( - private val textInput: String? = null, - private val responseInputText: ResponseInputText? = null, - private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, - private val responseInputAudio: ResponseInputAudio? = null, - private val _json: JsonValue? = null, - ) { - - /** A text input to the model. */ - fun textInput(): Optional = Optional.ofNullable(textInput) - - /** A text input to the model. */ - fun responseInputText(): Optional = - Optional.ofNullable(responseInputText) - - /** A text output from the model. */ - fun outputText(): Optional = Optional.ofNullable(outputText) - - /** An image input block used within EvalItem content arrays. */ - fun inputImage(): Optional = Optional.ofNullable(inputImage) - - /** An audio input to the model. */ - fun responseInputAudio(): Optional = - Optional.ofNullable(responseInputAudio) - - fun isTextInput(): Boolean = textInput != null - - fun isResponseInputText(): Boolean = responseInputText != null - - fun isOutputText(): Boolean = outputText != null - - fun isInputImage(): Boolean = inputImage != null - - fun isResponseInputAudio(): Boolean = responseInputAudio != null - - /** A text input to the model. */ - fun asTextInput(): String = textInput.getOrThrow("textInput") - - /** A text input to the model. */ - fun asResponseInputText(): ResponseInputText = - responseInputText.getOrThrow("responseInputText") - - /** A text output from the model. */ - fun asOutputText(): OutputText = outputText.getOrThrow("outputText") - - /** An image input block used within EvalItem content arrays. */ - fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") - - /** An audio input to the model. */ - fun asResponseInputAudio(): ResponseInputAudio = - responseInputAudio.getOrThrow("responseInputAudio") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - textInput != null -> visitor.visitTextInput(textInput) - responseInputText != null -> - visitor.visitResponseInputText(responseInputText) - outputText != null -> visitor.visitOutputText(outputText) - inputImage != null -> visitor.visitInputImage(inputImage) - responseInputAudio != null -> - visitor.visitResponseInputAudio(responseInputAudio) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): EvalContentItem = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitTextInput(textInput: String) {} - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) { - responseInputText.validate() - } - - override fun visitOutputText(outputText: OutputText) { - outputText.validate() - } - - override fun visitInputImage(inputImage: InputImage) { - inputImage.validate() - } - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) { - responseInputAudio.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTextInput(textInput: String) = 1 - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) = responseInputText.validity() - - override fun visitOutputText(outputText: OutputText) = - outputText.validity() - - override fun visitInputImage(inputImage: InputImage) = - inputImage.validity() - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = responseInputAudio.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EvalContentItem && - textInput == other.textInput && - responseInputText == other.responseInputText && - outputText == other.outputText && - inputImage == other.inputImage && - responseInputAudio == other.responseInputAudio - } - - override fun hashCode(): Int = - Objects.hash( - textInput, - responseInputText, - outputText, - inputImage, - responseInputAudio, - ) - - override fun toString(): String = - when { - textInput != null -> "EvalContentItem{textInput=$textInput}" - responseInputText != null -> - "EvalContentItem{responseInputText=$responseInputText}" - outputText != null -> "EvalContentItem{outputText=$outputText}" - inputImage != null -> "EvalContentItem{inputImage=$inputImage}" - responseInputAudio != null -> - "EvalContentItem{responseInputAudio=$responseInputAudio}" - _json != null -> "EvalContentItem{_unknown=$_json}" - else -> throw IllegalStateException("Invalid EvalContentItem") - } - - companion object { - - /** A text input to the model. */ - @JvmStatic - fun ofTextInput(textInput: String) = - EvalContentItem(textInput = textInput) - - /** A text input to the model. */ - @JvmStatic - fun ofResponseInputText(responseInputText: ResponseInputText) = - EvalContentItem(responseInputText = responseInputText) - - /** A text output from the model. */ - @JvmStatic - fun ofOutputText(outputText: OutputText) = - EvalContentItem(outputText = outputText) - - /** An image input block used within EvalItem content arrays. */ - @JvmStatic - fun ofInputImage(inputImage: InputImage) = - EvalContentItem(inputImage = inputImage) - - /** An audio input to the model. */ - @JvmStatic - fun ofResponseInputAudio(responseInputAudio: ResponseInputAudio) = - EvalContentItem(responseInputAudio = responseInputAudio) - } - - /** - * An interface that defines how to map each variant of - * [EvalContentItem] to a value of type [T]. - */ - interface Visitor { - - /** A text input to the model. */ - fun visitTextInput(textInput: String): T - - /** A text input to the model. */ - fun visitResponseInputText(responseInputText: ResponseInputText): T - - /** A text output from the model. */ - fun visitOutputText(outputText: OutputText): T - - /** An image input block used within EvalItem content arrays. */ - fun visitInputImage(inputImage: InputImage): T - - /** An audio input to the model. */ - fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ): T - - /** - * Maps an unknown variant of [EvalContentItem] to a value of type - * [T]. - * - * An instance of [EvalContentItem] can contain an unknown variant - * if it was deserialized from data that doesn't match any known - * variant. For example, if the SDK is on an older version than the - * API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws OpenAIInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OpenAIInvalidDataException( - "Unknown EvalContentItem: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer(EvalContentItem::class) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): EvalContentItem { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputText = it, - _json = json, - ) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - EvalContentItem( - outputText = it, - _json = json, - ) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - EvalContentItem( - inputImage = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputAudio = it, - _json = json, - ) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - EvalContentItem( - textInput = it, - _json = json, - ) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. - // deserializing from array). - 0 -> EvalContentItem(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, - // then use the first completely valid match, or simply the - // first match if none are completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(EvalContentItem::class) { - - override fun serialize( - value: EvalContentItem, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.textInput != null -> - generator.writeObject(value.textInput) - value.responseInputText != null -> - generator.writeObject(value.responseInputText) - value.outputText != null -> - generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) - value.responseInputAudio != null -> - generator.writeObject(value.responseInputAudio) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid EvalContentItem") - } - } - } - - /** A text output from the model. */ - class OutputText - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val text: JsonField, - private val type: JsonValue, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("text") - @ExcludeMissing - text: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - ) : this(text, type, mutableMapOf()) - - /** - * The text output from the model. - * - * @throws OpenAIInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). - */ - fun text(): String = text.getRequired("text") - - /** - * The type of the output text. Always `output_text`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * However, this method can be useful for debugging and logging - * (e.g. if the server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Returns the raw JSON value of [text]. - * - * Unlike [text], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("text") - @ExcludeMissing - fun _text(): JsonField = text - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [OutputText]. - * - * The following fields are required: - * ```java - * .text() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OutputText]. */ - class Builder internal constructor() { - - private var text: JsonField? = null - private var type: JsonValue = JsonValue.from("output_text") - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(outputText: OutputText) = apply { - text = outputText.text - type = outputText.type - additionalProperties = - outputText.additionalProperties.toMutableMap() - } - - /** The text output from the model. */ - fun text(text: String) = text(JsonField.of(text)) - - /** - * Sets [Builder.text] to an arbitrary JSON value. - * - * You should usually call [Builder.text] with a well-typed - * [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun text(text: JsonField) = apply { this.text = text } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the - * field defaults to the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OutputText]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .text() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): OutputText = - OutputText( - checkRequired("text", text), - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OutputText = apply { - if (validated) { - return@apply - } - - text() - _type().let { - if (it != JsonValue.from("output_text")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (text.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("output_text")) 1 else 0 - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OutputText && - text == other.text && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(text, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" - } - - /** An image input block used within EvalItem content arrays. */ - class InputImage - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val imageUrl: JsonField, - private val type: JsonValue, - private val detail: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("image_url") - @ExcludeMissing - imageUrl: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - @JsonProperty("detail") - @ExcludeMissing - detail: JsonField = JsonMissing.of(), - ) : this(imageUrl, type, detail, mutableMapOf()) - - /** - * The URL of the image input. - * - * @throws OpenAIInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). - */ - fun imageUrl(): String = imageUrl.getRequired("image_url") - - /** - * The type of the image input. Always `input_image`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * However, this method can be useful for debugging and logging - * (e.g. if the server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * The detail level of the image to be sent to the model. One of - * `high`, `low`, or `auto`. Defaults to `auto`. - * - * @throws OpenAIInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an - * unexpected value). - */ - fun detail(): Optional = detail.getOptional("detail") - - /** - * Returns the raw JSON value of [imageUrl]. - * - * Unlike [imageUrl], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl(): JsonField = imageUrl - - /** - * Returns the raw JSON value of [detail]. - * - * Unlike [detail], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("detail") - @ExcludeMissing - fun _detail(): JsonField = detail - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InputImage]. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InputImage]. */ - class Builder internal constructor() { - - private var imageUrl: JsonField? = null - private var type: JsonValue = JsonValue.from("input_image") - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = - inputImage.additionalProperties.toMutableMap() - } - - /** The URL of the image input. */ - fun imageUrl(imageUrl: String) = - imageUrl(JsonField.of(imageUrl)) - - /** - * Sets [Builder.imageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.imageUrl] with a well-typed - * [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the - * field defaults to the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * The detail level of the image to be sent to the model. One of - * `high`, `low`, or `auto`. Defaults to `auto`. - */ - fun detail(detail: String) = detail(JsonField.of(detail)) - - /** - * Sets [Builder.detail] to an arbitrary JSON value. - * - * You should usually call [Builder.detail] with a well-typed - * [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun detail(detail: JsonField) = apply { - this.detail = detail - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InputImage]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InputImage = - InputImage( - checkRequired("imageUrl", imageUrl), - type, - detail, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InputImage = apply { - if (validated) { - return@apply - } - - imageUrl() - _type().let { - if (it != JsonValue.from("input_image")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - detail() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (imageUrl.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("input_image")) 1 else 0 - } + - (if (detail.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InputImage && - imageUrl == other.imageUrl && - type == other.type && - detail == other.detail && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(imageUrl, type, detail, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" - } - } } /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt index a6af2f6b..f3c3ed86 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt @@ -26,10 +26,10 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException -import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatJsonObject import com.openai.models.ResponseFormatText +import com.openai.models.graders.gradermodels.EvalContentItem import com.openai.models.responses.ApplyPatchTool import com.openai.models.responses.ComputerTool import com.openai.models.responses.CustomTool @@ -5428,942 +5428,6 @@ private constructor( override fun toString() = "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - - /** - * A single content item: input text, output text, input image, or - * input audio. - */ - @JsonDeserialize(using = EvalContentItem.Deserializer::class) - @JsonSerialize(using = EvalContentItem.Serializer::class) - class EvalContentItem - private constructor( - private val textInput: String? = null, - private val responseInputText: ResponseInputText? = null, - private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, - private val responseInputAudio: ResponseInputAudio? = null, - private val _json: JsonValue? = null, - ) { - - /** A text input to the model. */ - fun textInput(): Optional = - Optional.ofNullable(textInput) - - /** A text input to the model. */ - fun responseInputText(): Optional = - Optional.ofNullable(responseInputText) - - /** A text output from the model. */ - fun outputText(): Optional = - Optional.ofNullable(outputText) - - /** An image input block used within EvalItem content arrays. */ - fun inputImage(): Optional = - Optional.ofNullable(inputImage) - - /** An audio input to the model. */ - fun responseInputAudio(): Optional = - Optional.ofNullable(responseInputAudio) - - fun isTextInput(): Boolean = textInput != null - - fun isResponseInputText(): Boolean = responseInputText != null - - fun isOutputText(): Boolean = outputText != null - - fun isInputImage(): Boolean = inputImage != null - - fun isResponseInputAudio(): Boolean = responseInputAudio != null - - /** A text input to the model. */ - fun asTextInput(): String = textInput.getOrThrow("textInput") - - /** A text input to the model. */ - fun asResponseInputText(): ResponseInputText = - responseInputText.getOrThrow("responseInputText") - - /** A text output from the model. */ - fun asOutputText(): OutputText = - outputText.getOrThrow("outputText") - - /** An image input block used within EvalItem content arrays. */ - fun asInputImage(): InputImage = - inputImage.getOrThrow("inputImage") - - /** An audio input to the model. */ - fun asResponseInputAudio(): ResponseInputAudio = - responseInputAudio.getOrThrow("responseInputAudio") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - textInput != null -> visitor.visitTextInput(textInput) - responseInputText != null -> - visitor.visitResponseInputText(responseInputText) - outputText != null -> - visitor.visitOutputText(outputText) - inputImage != null -> - visitor.visitInputImage(inputImage) - responseInputAudio != null -> - visitor.visitResponseInputAudio(responseInputAudio) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): EvalContentItem = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitTextInput(textInput: String) {} - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) { - responseInputText.validate() - } - - override fun visitOutputText( - outputText: OutputText - ) { - outputText.validate() - } - - override fun visitInputImage( - inputImage: InputImage - ) { - inputImage.validate() - } - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) { - responseInputAudio.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTextInput(textInput: String) = 1 - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) = responseInputText.validity() - - override fun visitOutputText( - outputText: OutputText - ) = outputText.validity() - - override fun visitInputImage( - inputImage: InputImage - ) = inputImage.validity() - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = responseInputAudio.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EvalContentItem && - textInput == other.textInput && - responseInputText == other.responseInputText && - outputText == other.outputText && - inputImage == other.inputImage && - responseInputAudio == other.responseInputAudio - } - - override fun hashCode(): Int = - Objects.hash( - textInput, - responseInputText, - outputText, - inputImage, - responseInputAudio, - ) - - override fun toString(): String = - when { - textInput != null -> - "EvalContentItem{textInput=$textInput}" - responseInputText != null -> - "EvalContentItem{responseInputText=$responseInputText}" - outputText != null -> - "EvalContentItem{outputText=$outputText}" - inputImage != null -> - "EvalContentItem{inputImage=$inputImage}" - responseInputAudio != null -> - "EvalContentItem{responseInputAudio=$responseInputAudio}" - _json != null -> "EvalContentItem{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid EvalContentItem" - ) - } - - companion object { - - /** A text input to the model. */ - @JvmStatic - fun ofTextInput(textInput: String) = - EvalContentItem(textInput = textInput) - - /** A text input to the model. */ - @JvmStatic - fun ofResponseInputText( - responseInputText: ResponseInputText - ) = EvalContentItem(responseInputText = responseInputText) - - /** A text output from the model. */ - @JvmStatic - fun ofOutputText(outputText: OutputText) = - EvalContentItem(outputText = outputText) - - /** - * An image input block used within EvalItem content arrays. - */ - @JvmStatic - fun ofInputImage(inputImage: InputImage) = - EvalContentItem(inputImage = inputImage) - - /** An audio input to the model. */ - @JvmStatic - fun ofResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = EvalContentItem(responseInputAudio = responseInputAudio) - } - - /** - * An interface that defines how to map each variant of - * [EvalContentItem] to a value of type [T]. - */ - interface Visitor { - - /** A text input to the model. */ - fun visitTextInput(textInput: String): T - - /** A text input to the model. */ - fun visitResponseInputText( - responseInputText: ResponseInputText - ): T - - /** A text output from the model. */ - fun visitOutputText(outputText: OutputText): T - - /** - * An image input block used within EvalItem content arrays. - */ - fun visitInputImage(inputImage: InputImage): T - - /** An audio input to the model. */ - fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ): T - - /** - * Maps an unknown variant of [EvalContentItem] to a value - * of type [T]. - * - * An instance of [EvalContentItem] can contain an unknown - * variant if it was deserialized from data that doesn't - * match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws OpenAIInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw OpenAIInvalidDataException( - "Unknown EvalContentItem: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer(EvalContentItem::class) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): EvalContentItem { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputText = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - outputText = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - inputImage = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputAudio = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - textInput = it, - _json = json, - ) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is - // completely incompatible with all the possible - // variants (e.g. deserializing from array). - 0 -> EvalContentItem(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest - // validity, then use the first completely valid - // match, or simply the first match if none are - // completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(EvalContentItem::class) { - - override fun serialize( - value: EvalContentItem, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.textInput != null -> - generator.writeObject(value.textInput) - value.responseInputText != null -> - generator.writeObject(value.responseInputText) - value.outputText != null -> - generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) - value.responseInputAudio != null -> - generator.writeObject(value.responseInputAudio) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid EvalContentItem" - ) - } - } - } - - /** A text output from the model. */ - class OutputText - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val text: JsonField, - private val type: JsonValue, - private val additionalProperties: - MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("text") - @ExcludeMissing - text: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - ) : this(text, type, mutableMapOf()) - - /** - * The text output from the model. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type or is unexpectedly missing or null - * (e.g. if the server responded with an unexpected - * value). - */ - fun text(): String = text.getRequired("text") - - /** - * The type of the output text. Always `output_text`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * However, this method can be useful for debugging and - * logging (e.g. if the server responded with an unexpected - * value). - */ - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonValue = type - - /** - * Returns the raw JSON value of [text]. - * - * Unlike [text], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("text") - @ExcludeMissing - fun _text(): JsonField = text - - @JsonAnySetter - private fun putAdditionalProperty( - key: String, - value: JsonValue, - ) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an - * instance of [OutputText]. - * - * The following fields are required: - * ```java - * .text() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OutputText]. */ - class Builder internal constructor() { - - private var text: JsonField? = null - private var type: JsonValue = - JsonValue.from("output_text") - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(outputText: OutputText) = apply { - text = outputText.text - type = outputText.type - additionalProperties = - outputText.additionalProperties.toMutableMap() - } - - /** The text output from the model. */ - fun text(text: String) = text(JsonField.of(text)) - - /** - * Sets [Builder.text] to an arbitrary JSON value. - * - * You should usually call [Builder.text] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun text(text: JsonField) = apply { - this.text = text - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because - * the field defaults to the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty( - key: String, - value: JsonValue, - ) = apply { additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OutputText]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .text() - * ``` - * - * @throws IllegalStateException if any required field - * is unset. - */ - fun build(): OutputText = - OutputText( - checkRequired("text", text), - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OutputText = apply { - if (validated) { - return@apply - } - - text() - _type().let { - if (it != JsonValue.from("output_text")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (text.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("output_text")) 1 - else 0 - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OutputText && - text == other.text && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(text, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" - } - - /** An image input block used within EvalItem content arrays. */ - class InputImage - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val imageUrl: JsonField, - private val type: JsonValue, - private val detail: JsonField, - private val additionalProperties: - MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("image_url") - @ExcludeMissing - imageUrl: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - @JsonProperty("detail") - @ExcludeMissing - detail: JsonField = JsonMissing.of(), - ) : this(imageUrl, type, detail, mutableMapOf()) - - /** - * The URL of the image input. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type or is unexpectedly missing or null - * (e.g. if the server responded with an unexpected - * value). - */ - fun imageUrl(): String = imageUrl.getRequired("image_url") - - /** - * The type of the image input. Always `input_image`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * However, this method can be useful for debugging and - * logging (e.g. if the server responded with an unexpected - * value). - */ - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonValue = type - - /** - * The detail level of the image to be sent to the model. - * One of `high`, `low`, or `auto`. Defaults to `auto`. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type (e.g. if the server responded with - * an unexpected value). - */ - fun detail(): Optional = - detail.getOptional("detail") - - /** - * Returns the raw JSON value of [imageUrl]. - * - * Unlike [imageUrl], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl(): JsonField = imageUrl - - /** - * Returns the raw JSON value of [detail]. - * - * Unlike [detail], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("detail") - @ExcludeMissing - fun _detail(): JsonField = detail - - @JsonAnySetter - private fun putAdditionalProperty( - key: String, - value: JsonValue, - ) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an - * instance of [InputImage]. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InputImage]. */ - class Builder internal constructor() { - - private var imageUrl: JsonField? = null - private var type: JsonValue = - JsonValue.from("input_image") - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = - inputImage.additionalProperties.toMutableMap() - } - - /** The URL of the image input. */ - fun imageUrl(imageUrl: String) = - imageUrl(JsonField.of(imageUrl)) - - /** - * Sets [Builder.imageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.imageUrl] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because - * the field defaults to the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * The detail level of the image to be sent to the - * model. One of `high`, `low`, or `auto`. Defaults to - * `auto`. - */ - fun detail(detail: String) = - detail(JsonField.of(detail)) - - /** - * Sets [Builder.detail] to an arbitrary JSON value. - * - * You should usually call [Builder.detail] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun detail(detail: JsonField) = apply { - this.detail = detail - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty( - key: String, - value: JsonValue, - ) = apply { additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InputImage]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - * - * @throws IllegalStateException if any required field - * is unset. - */ - fun build(): InputImage = - InputImage( - checkRequired("imageUrl", imageUrl), - type, - detail, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InputImage = apply { - if (validated) { - return@apply - } - - imageUrl() - _type().let { - if (it != JsonValue.from("input_image")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - detail() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (imageUrl.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("input_image")) 1 - else 0 - } + - (if (detail.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InputImage && - imageUrl == other.imageUrl && - type == other.type && - detail == other.detail && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - imageUrl, - type, - detail, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" - } - } } /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt index d0d62e4d..59ee2f6f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt @@ -29,10 +29,10 @@ import com.openai.core.http.Headers import com.openai.core.http.QueryParams import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException -import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatJsonObject import com.openai.models.ResponseFormatText +import com.openai.models.graders.gradermodels.EvalContentItem import com.openai.models.responses.ApplyPatchTool import com.openai.models.responses.ComputerTool import com.openai.models.responses.CustomTool @@ -5313,942 +5313,6 @@ private constructor( override fun toString() = "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - - /** - * A single content item: input text, output text, input image, or - * input audio. - */ - @JsonDeserialize(using = EvalContentItem.Deserializer::class) - @JsonSerialize(using = EvalContentItem.Serializer::class) - class EvalContentItem - private constructor( - private val textInput: String? = null, - private val responseInputText: ResponseInputText? = null, - private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, - private val responseInputAudio: ResponseInputAudio? = null, - private val _json: JsonValue? = null, - ) { - - /** A text input to the model. */ - fun textInput(): Optional = - Optional.ofNullable(textInput) - - /** A text input to the model. */ - fun responseInputText(): Optional = - Optional.ofNullable(responseInputText) - - /** A text output from the model. */ - fun outputText(): Optional = - Optional.ofNullable(outputText) - - /** An image input block used within EvalItem content arrays. */ - fun inputImage(): Optional = - Optional.ofNullable(inputImage) - - /** An audio input to the model. */ - fun responseInputAudio(): Optional = - Optional.ofNullable(responseInputAudio) - - fun isTextInput(): Boolean = textInput != null - - fun isResponseInputText(): Boolean = responseInputText != null - - fun isOutputText(): Boolean = outputText != null - - fun isInputImage(): Boolean = inputImage != null - - fun isResponseInputAudio(): Boolean = responseInputAudio != null - - /** A text input to the model. */ - fun asTextInput(): String = textInput.getOrThrow("textInput") - - /** A text input to the model. */ - fun asResponseInputText(): ResponseInputText = - responseInputText.getOrThrow("responseInputText") - - /** A text output from the model. */ - fun asOutputText(): OutputText = - outputText.getOrThrow("outputText") - - /** An image input block used within EvalItem content arrays. */ - fun asInputImage(): InputImage = - inputImage.getOrThrow("inputImage") - - /** An audio input to the model. */ - fun asResponseInputAudio(): ResponseInputAudio = - responseInputAudio.getOrThrow("responseInputAudio") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - textInput != null -> visitor.visitTextInput(textInput) - responseInputText != null -> - visitor.visitResponseInputText(responseInputText) - outputText != null -> - visitor.visitOutputText(outputText) - inputImage != null -> - visitor.visitInputImage(inputImage) - responseInputAudio != null -> - visitor.visitResponseInputAudio(responseInputAudio) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): EvalContentItem = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitTextInput(textInput: String) {} - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) { - responseInputText.validate() - } - - override fun visitOutputText( - outputText: OutputText - ) { - outputText.validate() - } - - override fun visitInputImage( - inputImage: InputImage - ) { - inputImage.validate() - } - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) { - responseInputAudio.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTextInput(textInput: String) = 1 - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) = responseInputText.validity() - - override fun visitOutputText( - outputText: OutputText - ) = outputText.validity() - - override fun visitInputImage( - inputImage: InputImage - ) = inputImage.validity() - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = responseInputAudio.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EvalContentItem && - textInput == other.textInput && - responseInputText == other.responseInputText && - outputText == other.outputText && - inputImage == other.inputImage && - responseInputAudio == other.responseInputAudio - } - - override fun hashCode(): Int = - Objects.hash( - textInput, - responseInputText, - outputText, - inputImage, - responseInputAudio, - ) - - override fun toString(): String = - when { - textInput != null -> - "EvalContentItem{textInput=$textInput}" - responseInputText != null -> - "EvalContentItem{responseInputText=$responseInputText}" - outputText != null -> - "EvalContentItem{outputText=$outputText}" - inputImage != null -> - "EvalContentItem{inputImage=$inputImage}" - responseInputAudio != null -> - "EvalContentItem{responseInputAudio=$responseInputAudio}" - _json != null -> "EvalContentItem{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid EvalContentItem" - ) - } - - companion object { - - /** A text input to the model. */ - @JvmStatic - fun ofTextInput(textInput: String) = - EvalContentItem(textInput = textInput) - - /** A text input to the model. */ - @JvmStatic - fun ofResponseInputText( - responseInputText: ResponseInputText - ) = EvalContentItem(responseInputText = responseInputText) - - /** A text output from the model. */ - @JvmStatic - fun ofOutputText(outputText: OutputText) = - EvalContentItem(outputText = outputText) - - /** - * An image input block used within EvalItem content arrays. - */ - @JvmStatic - fun ofInputImage(inputImage: InputImage) = - EvalContentItem(inputImage = inputImage) - - /** An audio input to the model. */ - @JvmStatic - fun ofResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = EvalContentItem(responseInputAudio = responseInputAudio) - } - - /** - * An interface that defines how to map each variant of - * [EvalContentItem] to a value of type [T]. - */ - interface Visitor { - - /** A text input to the model. */ - fun visitTextInput(textInput: String): T - - /** A text input to the model. */ - fun visitResponseInputText( - responseInputText: ResponseInputText - ): T - - /** A text output from the model. */ - fun visitOutputText(outputText: OutputText): T - - /** - * An image input block used within EvalItem content arrays. - */ - fun visitInputImage(inputImage: InputImage): T - - /** An audio input to the model. */ - fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ): T - - /** - * Maps an unknown variant of [EvalContentItem] to a value - * of type [T]. - * - * An instance of [EvalContentItem] can contain an unknown - * variant if it was deserialized from data that doesn't - * match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws OpenAIInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw OpenAIInvalidDataException( - "Unknown EvalContentItem: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer(EvalContentItem::class) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): EvalContentItem { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputText = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - outputText = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - inputImage = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputAudio = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - textInput = it, - _json = json, - ) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is - // completely incompatible with all the possible - // variants (e.g. deserializing from array). - 0 -> EvalContentItem(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest - // validity, then use the first completely valid - // match, or simply the first match if none are - // completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(EvalContentItem::class) { - - override fun serialize( - value: EvalContentItem, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.textInput != null -> - generator.writeObject(value.textInput) - value.responseInputText != null -> - generator.writeObject(value.responseInputText) - value.outputText != null -> - generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) - value.responseInputAudio != null -> - generator.writeObject(value.responseInputAudio) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid EvalContentItem" - ) - } - } - } - - /** A text output from the model. */ - class OutputText - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val text: JsonField, - private val type: JsonValue, - private val additionalProperties: - MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("text") - @ExcludeMissing - text: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - ) : this(text, type, mutableMapOf()) - - /** - * The text output from the model. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type or is unexpectedly missing or null - * (e.g. if the server responded with an unexpected - * value). - */ - fun text(): String = text.getRequired("text") - - /** - * The type of the output text. Always `output_text`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * However, this method can be useful for debugging and - * logging (e.g. if the server responded with an unexpected - * value). - */ - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonValue = type - - /** - * Returns the raw JSON value of [text]. - * - * Unlike [text], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("text") - @ExcludeMissing - fun _text(): JsonField = text - - @JsonAnySetter - private fun putAdditionalProperty( - key: String, - value: JsonValue, - ) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an - * instance of [OutputText]. - * - * The following fields are required: - * ```java - * .text() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OutputText]. */ - class Builder internal constructor() { - - private var text: JsonField? = null - private var type: JsonValue = - JsonValue.from("output_text") - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(outputText: OutputText) = apply { - text = outputText.text - type = outputText.type - additionalProperties = - outputText.additionalProperties.toMutableMap() - } - - /** The text output from the model. */ - fun text(text: String) = text(JsonField.of(text)) - - /** - * Sets [Builder.text] to an arbitrary JSON value. - * - * You should usually call [Builder.text] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun text(text: JsonField) = apply { - this.text = text - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because - * the field defaults to the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty( - key: String, - value: JsonValue, - ) = apply { additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OutputText]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .text() - * ``` - * - * @throws IllegalStateException if any required field - * is unset. - */ - fun build(): OutputText = - OutputText( - checkRequired("text", text), - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OutputText = apply { - if (validated) { - return@apply - } - - text() - _type().let { - if (it != JsonValue.from("output_text")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (text.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("output_text")) 1 - else 0 - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OutputText && - text == other.text && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(text, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" - } - - /** An image input block used within EvalItem content arrays. */ - class InputImage - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val imageUrl: JsonField, - private val type: JsonValue, - private val detail: JsonField, - private val additionalProperties: - MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("image_url") - @ExcludeMissing - imageUrl: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - @JsonProperty("detail") - @ExcludeMissing - detail: JsonField = JsonMissing.of(), - ) : this(imageUrl, type, detail, mutableMapOf()) - - /** - * The URL of the image input. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type or is unexpectedly missing or null - * (e.g. if the server responded with an unexpected - * value). - */ - fun imageUrl(): String = imageUrl.getRequired("image_url") - - /** - * The type of the image input. Always `input_image`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * However, this method can be useful for debugging and - * logging (e.g. if the server responded with an unexpected - * value). - */ - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonValue = type - - /** - * The detail level of the image to be sent to the model. - * One of `high`, `low`, or `auto`. Defaults to `auto`. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type (e.g. if the server responded with - * an unexpected value). - */ - fun detail(): Optional = - detail.getOptional("detail") - - /** - * Returns the raw JSON value of [imageUrl]. - * - * Unlike [imageUrl], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl(): JsonField = imageUrl - - /** - * Returns the raw JSON value of [detail]. - * - * Unlike [detail], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("detail") - @ExcludeMissing - fun _detail(): JsonField = detail - - @JsonAnySetter - private fun putAdditionalProperty( - key: String, - value: JsonValue, - ) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an - * instance of [InputImage]. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InputImage]. */ - class Builder internal constructor() { - - private var imageUrl: JsonField? = null - private var type: JsonValue = - JsonValue.from("input_image") - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = - inputImage.additionalProperties.toMutableMap() - } - - /** The URL of the image input. */ - fun imageUrl(imageUrl: String) = - imageUrl(JsonField.of(imageUrl)) - - /** - * Sets [Builder.imageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.imageUrl] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because - * the field defaults to the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * The detail level of the image to be sent to the - * model. One of `high`, `low`, or `auto`. Defaults to - * `auto`. - */ - fun detail(detail: String) = - detail(JsonField.of(detail)) - - /** - * Sets [Builder.detail] to an arbitrary JSON value. - * - * You should usually call [Builder.detail] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun detail(detail: JsonField) = apply { - this.detail = detail - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty( - key: String, - value: JsonValue, - ) = apply { additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InputImage]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - * - * @throws IllegalStateException if any required field - * is unset. - */ - fun build(): InputImage = - InputImage( - checkRequired("imageUrl", imageUrl), - type, - detail, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InputImage = apply { - if (validated) { - return@apply - } - - imageUrl() - _type().let { - if (it != JsonValue.from("input_image")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - detail() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (imageUrl.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("input_image")) 1 - else 0 - } + - (if (detail.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InputImage && - imageUrl == other.imageUrl && - type == other.type && - detail == other.detail && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - imageUrl, - type, - detail, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" - } - } } /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt index 85a0acc4..858b0d4c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt @@ -26,10 +26,10 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException -import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatJsonObject import com.openai.models.ResponseFormatText +import com.openai.models.graders.gradermodels.EvalContentItem import com.openai.models.responses.ApplyPatchTool import com.openai.models.responses.ComputerTool import com.openai.models.responses.CustomTool @@ -5428,942 +5428,6 @@ private constructor( override fun toString() = "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - - /** - * A single content item: input text, output text, input image, or - * input audio. - */ - @JsonDeserialize(using = EvalContentItem.Deserializer::class) - @JsonSerialize(using = EvalContentItem.Serializer::class) - class EvalContentItem - private constructor( - private val textInput: String? = null, - private val responseInputText: ResponseInputText? = null, - private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, - private val responseInputAudio: ResponseInputAudio? = null, - private val _json: JsonValue? = null, - ) { - - /** A text input to the model. */ - fun textInput(): Optional = - Optional.ofNullable(textInput) - - /** A text input to the model. */ - fun responseInputText(): Optional = - Optional.ofNullable(responseInputText) - - /** A text output from the model. */ - fun outputText(): Optional = - Optional.ofNullable(outputText) - - /** An image input block used within EvalItem content arrays. */ - fun inputImage(): Optional = - Optional.ofNullable(inputImage) - - /** An audio input to the model. */ - fun responseInputAudio(): Optional = - Optional.ofNullable(responseInputAudio) - - fun isTextInput(): Boolean = textInput != null - - fun isResponseInputText(): Boolean = responseInputText != null - - fun isOutputText(): Boolean = outputText != null - - fun isInputImage(): Boolean = inputImage != null - - fun isResponseInputAudio(): Boolean = responseInputAudio != null - - /** A text input to the model. */ - fun asTextInput(): String = textInput.getOrThrow("textInput") - - /** A text input to the model. */ - fun asResponseInputText(): ResponseInputText = - responseInputText.getOrThrow("responseInputText") - - /** A text output from the model. */ - fun asOutputText(): OutputText = - outputText.getOrThrow("outputText") - - /** An image input block used within EvalItem content arrays. */ - fun asInputImage(): InputImage = - inputImage.getOrThrow("inputImage") - - /** An audio input to the model. */ - fun asResponseInputAudio(): ResponseInputAudio = - responseInputAudio.getOrThrow("responseInputAudio") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - textInput != null -> visitor.visitTextInput(textInput) - responseInputText != null -> - visitor.visitResponseInputText(responseInputText) - outputText != null -> - visitor.visitOutputText(outputText) - inputImage != null -> - visitor.visitInputImage(inputImage) - responseInputAudio != null -> - visitor.visitResponseInputAudio(responseInputAudio) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): EvalContentItem = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitTextInput(textInput: String) {} - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) { - responseInputText.validate() - } - - override fun visitOutputText( - outputText: OutputText - ) { - outputText.validate() - } - - override fun visitInputImage( - inputImage: InputImage - ) { - inputImage.validate() - } - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) { - responseInputAudio.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTextInput(textInput: String) = 1 - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) = responseInputText.validity() - - override fun visitOutputText( - outputText: OutputText - ) = outputText.validity() - - override fun visitInputImage( - inputImage: InputImage - ) = inputImage.validity() - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = responseInputAudio.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EvalContentItem && - textInput == other.textInput && - responseInputText == other.responseInputText && - outputText == other.outputText && - inputImage == other.inputImage && - responseInputAudio == other.responseInputAudio - } - - override fun hashCode(): Int = - Objects.hash( - textInput, - responseInputText, - outputText, - inputImage, - responseInputAudio, - ) - - override fun toString(): String = - when { - textInput != null -> - "EvalContentItem{textInput=$textInput}" - responseInputText != null -> - "EvalContentItem{responseInputText=$responseInputText}" - outputText != null -> - "EvalContentItem{outputText=$outputText}" - inputImage != null -> - "EvalContentItem{inputImage=$inputImage}" - responseInputAudio != null -> - "EvalContentItem{responseInputAudio=$responseInputAudio}" - _json != null -> "EvalContentItem{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid EvalContentItem" - ) - } - - companion object { - - /** A text input to the model. */ - @JvmStatic - fun ofTextInput(textInput: String) = - EvalContentItem(textInput = textInput) - - /** A text input to the model. */ - @JvmStatic - fun ofResponseInputText( - responseInputText: ResponseInputText - ) = EvalContentItem(responseInputText = responseInputText) - - /** A text output from the model. */ - @JvmStatic - fun ofOutputText(outputText: OutputText) = - EvalContentItem(outputText = outputText) - - /** - * An image input block used within EvalItem content arrays. - */ - @JvmStatic - fun ofInputImage(inputImage: InputImage) = - EvalContentItem(inputImage = inputImage) - - /** An audio input to the model. */ - @JvmStatic - fun ofResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = EvalContentItem(responseInputAudio = responseInputAudio) - } - - /** - * An interface that defines how to map each variant of - * [EvalContentItem] to a value of type [T]. - */ - interface Visitor { - - /** A text input to the model. */ - fun visitTextInput(textInput: String): T - - /** A text input to the model. */ - fun visitResponseInputText( - responseInputText: ResponseInputText - ): T - - /** A text output from the model. */ - fun visitOutputText(outputText: OutputText): T - - /** - * An image input block used within EvalItem content arrays. - */ - fun visitInputImage(inputImage: InputImage): T - - /** An audio input to the model. */ - fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ): T - - /** - * Maps an unknown variant of [EvalContentItem] to a value - * of type [T]. - * - * An instance of [EvalContentItem] can contain an unknown - * variant if it was deserialized from data that doesn't - * match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws OpenAIInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw OpenAIInvalidDataException( - "Unknown EvalContentItem: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer(EvalContentItem::class) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): EvalContentItem { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputText = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - outputText = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - inputImage = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputAudio = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - textInput = it, - _json = json, - ) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is - // completely incompatible with all the possible - // variants (e.g. deserializing from array). - 0 -> EvalContentItem(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest - // validity, then use the first completely valid - // match, or simply the first match if none are - // completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(EvalContentItem::class) { - - override fun serialize( - value: EvalContentItem, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.textInput != null -> - generator.writeObject(value.textInput) - value.responseInputText != null -> - generator.writeObject(value.responseInputText) - value.outputText != null -> - generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) - value.responseInputAudio != null -> - generator.writeObject(value.responseInputAudio) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid EvalContentItem" - ) - } - } - } - - /** A text output from the model. */ - class OutputText - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val text: JsonField, - private val type: JsonValue, - private val additionalProperties: - MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("text") - @ExcludeMissing - text: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - ) : this(text, type, mutableMapOf()) - - /** - * The text output from the model. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type or is unexpectedly missing or null - * (e.g. if the server responded with an unexpected - * value). - */ - fun text(): String = text.getRequired("text") - - /** - * The type of the output text. Always `output_text`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * However, this method can be useful for debugging and - * logging (e.g. if the server responded with an unexpected - * value). - */ - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonValue = type - - /** - * Returns the raw JSON value of [text]. - * - * Unlike [text], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("text") - @ExcludeMissing - fun _text(): JsonField = text - - @JsonAnySetter - private fun putAdditionalProperty( - key: String, - value: JsonValue, - ) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an - * instance of [OutputText]. - * - * The following fields are required: - * ```java - * .text() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OutputText]. */ - class Builder internal constructor() { - - private var text: JsonField? = null - private var type: JsonValue = - JsonValue.from("output_text") - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(outputText: OutputText) = apply { - text = outputText.text - type = outputText.type - additionalProperties = - outputText.additionalProperties.toMutableMap() - } - - /** The text output from the model. */ - fun text(text: String) = text(JsonField.of(text)) - - /** - * Sets [Builder.text] to an arbitrary JSON value. - * - * You should usually call [Builder.text] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun text(text: JsonField) = apply { - this.text = text - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because - * the field defaults to the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty( - key: String, - value: JsonValue, - ) = apply { additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OutputText]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .text() - * ``` - * - * @throws IllegalStateException if any required field - * is unset. - */ - fun build(): OutputText = - OutputText( - checkRequired("text", text), - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OutputText = apply { - if (validated) { - return@apply - } - - text() - _type().let { - if (it != JsonValue.from("output_text")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (text.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("output_text")) 1 - else 0 - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OutputText && - text == other.text && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(text, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" - } - - /** An image input block used within EvalItem content arrays. */ - class InputImage - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val imageUrl: JsonField, - private val type: JsonValue, - private val detail: JsonField, - private val additionalProperties: - MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("image_url") - @ExcludeMissing - imageUrl: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - @JsonProperty("detail") - @ExcludeMissing - detail: JsonField = JsonMissing.of(), - ) : this(imageUrl, type, detail, mutableMapOf()) - - /** - * The URL of the image input. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type or is unexpectedly missing or null - * (e.g. if the server responded with an unexpected - * value). - */ - fun imageUrl(): String = imageUrl.getRequired("image_url") - - /** - * The type of the image input. Always `input_image`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * However, this method can be useful for debugging and - * logging (e.g. if the server responded with an unexpected - * value). - */ - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonValue = type - - /** - * The detail level of the image to be sent to the model. - * One of `high`, `low`, or `auto`. Defaults to `auto`. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type (e.g. if the server responded with - * an unexpected value). - */ - fun detail(): Optional = - detail.getOptional("detail") - - /** - * Returns the raw JSON value of [imageUrl]. - * - * Unlike [imageUrl], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl(): JsonField = imageUrl - - /** - * Returns the raw JSON value of [detail]. - * - * Unlike [detail], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("detail") - @ExcludeMissing - fun _detail(): JsonField = detail - - @JsonAnySetter - private fun putAdditionalProperty( - key: String, - value: JsonValue, - ) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an - * instance of [InputImage]. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InputImage]. */ - class Builder internal constructor() { - - private var imageUrl: JsonField? = null - private var type: JsonValue = - JsonValue.from("input_image") - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = - inputImage.additionalProperties.toMutableMap() - } - - /** The URL of the image input. */ - fun imageUrl(imageUrl: String) = - imageUrl(JsonField.of(imageUrl)) - - /** - * Sets [Builder.imageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.imageUrl] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because - * the field defaults to the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * The detail level of the image to be sent to the - * model. One of `high`, `low`, or `auto`. Defaults to - * `auto`. - */ - fun detail(detail: String) = - detail(JsonField.of(detail)) - - /** - * Sets [Builder.detail] to an arbitrary JSON value. - * - * You should usually call [Builder.detail] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun detail(detail: JsonField) = apply { - this.detail = detail - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty( - key: String, - value: JsonValue, - ) = apply { additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InputImage]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - * - * @throws IllegalStateException if any required field - * is unset. - */ - fun build(): InputImage = - InputImage( - checkRequired("imageUrl", imageUrl), - type, - detail, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InputImage = apply { - if (validated) { - return@apply - } - - imageUrl() - _type().let { - if (it != JsonValue.from("input_image")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - detail() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (imageUrl.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("input_image")) 1 - else 0 - } + - (if (detail.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InputImage && - imageUrl == other.imageUrl && - type == other.type && - detail == other.detail && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - imageUrl, - type, - detail, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" - } - } } /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt index 8c99b115..9241e11c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt @@ -26,10 +26,10 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException -import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatJsonObject import com.openai.models.ResponseFormatText +import com.openai.models.graders.gradermodels.EvalContentItem import com.openai.models.responses.ApplyPatchTool import com.openai.models.responses.ComputerTool import com.openai.models.responses.CustomTool @@ -5428,942 +5428,6 @@ private constructor( override fun toString() = "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - - /** - * A single content item: input text, output text, input image, or - * input audio. - */ - @JsonDeserialize(using = EvalContentItem.Deserializer::class) - @JsonSerialize(using = EvalContentItem.Serializer::class) - class EvalContentItem - private constructor( - private val textInput: String? = null, - private val responseInputText: ResponseInputText? = null, - private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, - private val responseInputAudio: ResponseInputAudio? = null, - private val _json: JsonValue? = null, - ) { - - /** A text input to the model. */ - fun textInput(): Optional = - Optional.ofNullable(textInput) - - /** A text input to the model. */ - fun responseInputText(): Optional = - Optional.ofNullable(responseInputText) - - /** A text output from the model. */ - fun outputText(): Optional = - Optional.ofNullable(outputText) - - /** An image input block used within EvalItem content arrays. */ - fun inputImage(): Optional = - Optional.ofNullable(inputImage) - - /** An audio input to the model. */ - fun responseInputAudio(): Optional = - Optional.ofNullable(responseInputAudio) - - fun isTextInput(): Boolean = textInput != null - - fun isResponseInputText(): Boolean = responseInputText != null - - fun isOutputText(): Boolean = outputText != null - - fun isInputImage(): Boolean = inputImage != null - - fun isResponseInputAudio(): Boolean = responseInputAudio != null - - /** A text input to the model. */ - fun asTextInput(): String = textInput.getOrThrow("textInput") - - /** A text input to the model. */ - fun asResponseInputText(): ResponseInputText = - responseInputText.getOrThrow("responseInputText") - - /** A text output from the model. */ - fun asOutputText(): OutputText = - outputText.getOrThrow("outputText") - - /** An image input block used within EvalItem content arrays. */ - fun asInputImage(): InputImage = - inputImage.getOrThrow("inputImage") - - /** An audio input to the model. */ - fun asResponseInputAudio(): ResponseInputAudio = - responseInputAudio.getOrThrow("responseInputAudio") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - textInput != null -> visitor.visitTextInput(textInput) - responseInputText != null -> - visitor.visitResponseInputText(responseInputText) - outputText != null -> - visitor.visitOutputText(outputText) - inputImage != null -> - visitor.visitInputImage(inputImage) - responseInputAudio != null -> - visitor.visitResponseInputAudio(responseInputAudio) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): EvalContentItem = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitTextInput(textInput: String) {} - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) { - responseInputText.validate() - } - - override fun visitOutputText( - outputText: OutputText - ) { - outputText.validate() - } - - override fun visitInputImage( - inputImage: InputImage - ) { - inputImage.validate() - } - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) { - responseInputAudio.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTextInput(textInput: String) = 1 - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) = responseInputText.validity() - - override fun visitOutputText( - outputText: OutputText - ) = outputText.validity() - - override fun visitInputImage( - inputImage: InputImage - ) = inputImage.validity() - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = responseInputAudio.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EvalContentItem && - textInput == other.textInput && - responseInputText == other.responseInputText && - outputText == other.outputText && - inputImage == other.inputImage && - responseInputAudio == other.responseInputAudio - } - - override fun hashCode(): Int = - Objects.hash( - textInput, - responseInputText, - outputText, - inputImage, - responseInputAudio, - ) - - override fun toString(): String = - when { - textInput != null -> - "EvalContentItem{textInput=$textInput}" - responseInputText != null -> - "EvalContentItem{responseInputText=$responseInputText}" - outputText != null -> - "EvalContentItem{outputText=$outputText}" - inputImage != null -> - "EvalContentItem{inputImage=$inputImage}" - responseInputAudio != null -> - "EvalContentItem{responseInputAudio=$responseInputAudio}" - _json != null -> "EvalContentItem{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid EvalContentItem" - ) - } - - companion object { - - /** A text input to the model. */ - @JvmStatic - fun ofTextInput(textInput: String) = - EvalContentItem(textInput = textInput) - - /** A text input to the model. */ - @JvmStatic - fun ofResponseInputText( - responseInputText: ResponseInputText - ) = EvalContentItem(responseInputText = responseInputText) - - /** A text output from the model. */ - @JvmStatic - fun ofOutputText(outputText: OutputText) = - EvalContentItem(outputText = outputText) - - /** - * An image input block used within EvalItem content arrays. - */ - @JvmStatic - fun ofInputImage(inputImage: InputImage) = - EvalContentItem(inputImage = inputImage) - - /** An audio input to the model. */ - @JvmStatic - fun ofResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = EvalContentItem(responseInputAudio = responseInputAudio) - } - - /** - * An interface that defines how to map each variant of - * [EvalContentItem] to a value of type [T]. - */ - interface Visitor { - - /** A text input to the model. */ - fun visitTextInput(textInput: String): T - - /** A text input to the model. */ - fun visitResponseInputText( - responseInputText: ResponseInputText - ): T - - /** A text output from the model. */ - fun visitOutputText(outputText: OutputText): T - - /** - * An image input block used within EvalItem content arrays. - */ - fun visitInputImage(inputImage: InputImage): T - - /** An audio input to the model. */ - fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ): T - - /** - * Maps an unknown variant of [EvalContentItem] to a value - * of type [T]. - * - * An instance of [EvalContentItem] can contain an unknown - * variant if it was deserialized from data that doesn't - * match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws OpenAIInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw OpenAIInvalidDataException( - "Unknown EvalContentItem: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer(EvalContentItem::class) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): EvalContentItem { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputText = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - outputText = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - inputImage = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputAudio = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - textInput = it, - _json = json, - ) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is - // completely incompatible with all the possible - // variants (e.g. deserializing from array). - 0 -> EvalContentItem(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest - // validity, then use the first completely valid - // match, or simply the first match if none are - // completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(EvalContentItem::class) { - - override fun serialize( - value: EvalContentItem, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.textInput != null -> - generator.writeObject(value.textInput) - value.responseInputText != null -> - generator.writeObject(value.responseInputText) - value.outputText != null -> - generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) - value.responseInputAudio != null -> - generator.writeObject(value.responseInputAudio) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid EvalContentItem" - ) - } - } - } - - /** A text output from the model. */ - class OutputText - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val text: JsonField, - private val type: JsonValue, - private val additionalProperties: - MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("text") - @ExcludeMissing - text: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - ) : this(text, type, mutableMapOf()) - - /** - * The text output from the model. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type or is unexpectedly missing or null - * (e.g. if the server responded with an unexpected - * value). - */ - fun text(): String = text.getRequired("text") - - /** - * The type of the output text. Always `output_text`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * However, this method can be useful for debugging and - * logging (e.g. if the server responded with an unexpected - * value). - */ - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonValue = type - - /** - * Returns the raw JSON value of [text]. - * - * Unlike [text], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("text") - @ExcludeMissing - fun _text(): JsonField = text - - @JsonAnySetter - private fun putAdditionalProperty( - key: String, - value: JsonValue, - ) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an - * instance of [OutputText]. - * - * The following fields are required: - * ```java - * .text() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OutputText]. */ - class Builder internal constructor() { - - private var text: JsonField? = null - private var type: JsonValue = - JsonValue.from("output_text") - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(outputText: OutputText) = apply { - text = outputText.text - type = outputText.type - additionalProperties = - outputText.additionalProperties.toMutableMap() - } - - /** The text output from the model. */ - fun text(text: String) = text(JsonField.of(text)) - - /** - * Sets [Builder.text] to an arbitrary JSON value. - * - * You should usually call [Builder.text] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun text(text: JsonField) = apply { - this.text = text - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because - * the field defaults to the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty( - key: String, - value: JsonValue, - ) = apply { additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OutputText]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .text() - * ``` - * - * @throws IllegalStateException if any required field - * is unset. - */ - fun build(): OutputText = - OutputText( - checkRequired("text", text), - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OutputText = apply { - if (validated) { - return@apply - } - - text() - _type().let { - if (it != JsonValue.from("output_text")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (text.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("output_text")) 1 - else 0 - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OutputText && - text == other.text && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(text, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" - } - - /** An image input block used within EvalItem content arrays. */ - class InputImage - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val imageUrl: JsonField, - private val type: JsonValue, - private val detail: JsonField, - private val additionalProperties: - MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("image_url") - @ExcludeMissing - imageUrl: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - @JsonProperty("detail") - @ExcludeMissing - detail: JsonField = JsonMissing.of(), - ) : this(imageUrl, type, detail, mutableMapOf()) - - /** - * The URL of the image input. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type or is unexpectedly missing or null - * (e.g. if the server responded with an unexpected - * value). - */ - fun imageUrl(): String = imageUrl.getRequired("image_url") - - /** - * The type of the image input. Always `input_image`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * However, this method can be useful for debugging and - * logging (e.g. if the server responded with an unexpected - * value). - */ - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonValue = type - - /** - * The detail level of the image to be sent to the model. - * One of `high`, `low`, or `auto`. Defaults to `auto`. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type (e.g. if the server responded with - * an unexpected value). - */ - fun detail(): Optional = - detail.getOptional("detail") - - /** - * Returns the raw JSON value of [imageUrl]. - * - * Unlike [imageUrl], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl(): JsonField = imageUrl - - /** - * Returns the raw JSON value of [detail]. - * - * Unlike [detail], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("detail") - @ExcludeMissing - fun _detail(): JsonField = detail - - @JsonAnySetter - private fun putAdditionalProperty( - key: String, - value: JsonValue, - ) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an - * instance of [InputImage]. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InputImage]. */ - class Builder internal constructor() { - - private var imageUrl: JsonField? = null - private var type: JsonValue = - JsonValue.from("input_image") - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = - inputImage.additionalProperties.toMutableMap() - } - - /** The URL of the image input. */ - fun imageUrl(imageUrl: String) = - imageUrl(JsonField.of(imageUrl)) - - /** - * Sets [Builder.imageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.imageUrl] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because - * the field defaults to the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * The detail level of the image to be sent to the - * model. One of `high`, `low`, or `auto`. Defaults to - * `auto`. - */ - fun detail(detail: String) = - detail(JsonField.of(detail)) - - /** - * Sets [Builder.detail] to an arbitrary JSON value. - * - * You should usually call [Builder.detail] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun detail(detail: JsonField) = apply { - this.detail = detail - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty( - key: String, - value: JsonValue, - ) = apply { additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InputImage]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - * - * @throws IllegalStateException if any required field - * is unset. - */ - fun build(): InputImage = - InputImage( - checkRequired("imageUrl", imageUrl), - type, - detail, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InputImage = apply { - if (validated) { - return@apply - } - - imageUrl() - _type().let { - if (it != JsonValue.from("input_image")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - detail() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (imageUrl.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("input_image")) 1 - else 0 - } + - (if (detail.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InputImage && - imageUrl == other.imageUrl && - type == other.type && - detail == other.detail && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - imageUrl, - type, - detail, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" - } - } } /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt index caae91ca..fc897e4a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt @@ -26,10 +26,10 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException -import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.ResponseFormatJsonObject import com.openai.models.ResponseFormatText +import com.openai.models.graders.gradermodels.EvalContentItem import com.openai.models.responses.ApplyPatchTool import com.openai.models.responses.ComputerTool import com.openai.models.responses.CustomTool @@ -5428,942 +5428,6 @@ private constructor( override fun toString() = "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - - /** - * A single content item: input text, output text, input image, or - * input audio. - */ - @JsonDeserialize(using = EvalContentItem.Deserializer::class) - @JsonSerialize(using = EvalContentItem.Serializer::class) - class EvalContentItem - private constructor( - private val textInput: String? = null, - private val responseInputText: ResponseInputText? = null, - private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, - private val responseInputAudio: ResponseInputAudio? = null, - private val _json: JsonValue? = null, - ) { - - /** A text input to the model. */ - fun textInput(): Optional = - Optional.ofNullable(textInput) - - /** A text input to the model. */ - fun responseInputText(): Optional = - Optional.ofNullable(responseInputText) - - /** A text output from the model. */ - fun outputText(): Optional = - Optional.ofNullable(outputText) - - /** An image input block used within EvalItem content arrays. */ - fun inputImage(): Optional = - Optional.ofNullable(inputImage) - - /** An audio input to the model. */ - fun responseInputAudio(): Optional = - Optional.ofNullable(responseInputAudio) - - fun isTextInput(): Boolean = textInput != null - - fun isResponseInputText(): Boolean = responseInputText != null - - fun isOutputText(): Boolean = outputText != null - - fun isInputImage(): Boolean = inputImage != null - - fun isResponseInputAudio(): Boolean = responseInputAudio != null - - /** A text input to the model. */ - fun asTextInput(): String = textInput.getOrThrow("textInput") - - /** A text input to the model. */ - fun asResponseInputText(): ResponseInputText = - responseInputText.getOrThrow("responseInputText") - - /** A text output from the model. */ - fun asOutputText(): OutputText = - outputText.getOrThrow("outputText") - - /** An image input block used within EvalItem content arrays. */ - fun asInputImage(): InputImage = - inputImage.getOrThrow("inputImage") - - /** An audio input to the model. */ - fun asResponseInputAudio(): ResponseInputAudio = - responseInputAudio.getOrThrow("responseInputAudio") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - textInput != null -> visitor.visitTextInput(textInput) - responseInputText != null -> - visitor.visitResponseInputText(responseInputText) - outputText != null -> - visitor.visitOutputText(outputText) - inputImage != null -> - visitor.visitInputImage(inputImage) - responseInputAudio != null -> - visitor.visitResponseInputAudio(responseInputAudio) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): EvalContentItem = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitTextInput(textInput: String) {} - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) { - responseInputText.validate() - } - - override fun visitOutputText( - outputText: OutputText - ) { - outputText.validate() - } - - override fun visitInputImage( - inputImage: InputImage - ) { - inputImage.validate() - } - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) { - responseInputAudio.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTextInput(textInput: String) = 1 - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) = responseInputText.validity() - - override fun visitOutputText( - outputText: OutputText - ) = outputText.validity() - - override fun visitInputImage( - inputImage: InputImage - ) = inputImage.validity() - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = responseInputAudio.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EvalContentItem && - textInput == other.textInput && - responseInputText == other.responseInputText && - outputText == other.outputText && - inputImage == other.inputImage && - responseInputAudio == other.responseInputAudio - } - - override fun hashCode(): Int = - Objects.hash( - textInput, - responseInputText, - outputText, - inputImage, - responseInputAudio, - ) - - override fun toString(): String = - when { - textInput != null -> - "EvalContentItem{textInput=$textInput}" - responseInputText != null -> - "EvalContentItem{responseInputText=$responseInputText}" - outputText != null -> - "EvalContentItem{outputText=$outputText}" - inputImage != null -> - "EvalContentItem{inputImage=$inputImage}" - responseInputAudio != null -> - "EvalContentItem{responseInputAudio=$responseInputAudio}" - _json != null -> "EvalContentItem{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid EvalContentItem" - ) - } - - companion object { - - /** A text input to the model. */ - @JvmStatic - fun ofTextInput(textInput: String) = - EvalContentItem(textInput = textInput) - - /** A text input to the model. */ - @JvmStatic - fun ofResponseInputText( - responseInputText: ResponseInputText - ) = EvalContentItem(responseInputText = responseInputText) - - /** A text output from the model. */ - @JvmStatic - fun ofOutputText(outputText: OutputText) = - EvalContentItem(outputText = outputText) - - /** - * An image input block used within EvalItem content arrays. - */ - @JvmStatic - fun ofInputImage(inputImage: InputImage) = - EvalContentItem(inputImage = inputImage) - - /** An audio input to the model. */ - @JvmStatic - fun ofResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = EvalContentItem(responseInputAudio = responseInputAudio) - } - - /** - * An interface that defines how to map each variant of - * [EvalContentItem] to a value of type [T]. - */ - interface Visitor { - - /** A text input to the model. */ - fun visitTextInput(textInput: String): T - - /** A text input to the model. */ - fun visitResponseInputText( - responseInputText: ResponseInputText - ): T - - /** A text output from the model. */ - fun visitOutputText(outputText: OutputText): T - - /** - * An image input block used within EvalItem content arrays. - */ - fun visitInputImage(inputImage: InputImage): T - - /** An audio input to the model. */ - fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ): T - - /** - * Maps an unknown variant of [EvalContentItem] to a value - * of type [T]. - * - * An instance of [EvalContentItem] can contain an unknown - * variant if it was deserialized from data that doesn't - * match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws OpenAIInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw OpenAIInvalidDataException( - "Unknown EvalContentItem: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer(EvalContentItem::class) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): EvalContentItem { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputText = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - outputText = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - inputImage = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - responseInputAudio = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - EvalContentItem( - textInput = it, - _json = json, - ) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is - // completely incompatible with all the possible - // variants (e.g. deserializing from array). - 0 -> EvalContentItem(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest - // validity, then use the first completely valid - // match, or simply the first match if none are - // completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(EvalContentItem::class) { - - override fun serialize( - value: EvalContentItem, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.textInput != null -> - generator.writeObject(value.textInput) - value.responseInputText != null -> - generator.writeObject(value.responseInputText) - value.outputText != null -> - generator.writeObject(value.outputText) - value.inputImage != null -> - generator.writeObject(value.inputImage) - value.responseInputAudio != null -> - generator.writeObject(value.responseInputAudio) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid EvalContentItem" - ) - } - } - } - - /** A text output from the model. */ - class OutputText - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val text: JsonField, - private val type: JsonValue, - private val additionalProperties: - MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("text") - @ExcludeMissing - text: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - ) : this(text, type, mutableMapOf()) - - /** - * The text output from the model. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type or is unexpectedly missing or null - * (e.g. if the server responded with an unexpected - * value). - */ - fun text(): String = text.getRequired("text") - - /** - * The type of the output text. Always `output_text`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * However, this method can be useful for debugging and - * logging (e.g. if the server responded with an unexpected - * value). - */ - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonValue = type - - /** - * Returns the raw JSON value of [text]. - * - * Unlike [text], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("text") - @ExcludeMissing - fun _text(): JsonField = text - - @JsonAnySetter - private fun putAdditionalProperty( - key: String, - value: JsonValue, - ) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an - * instance of [OutputText]. - * - * The following fields are required: - * ```java - * .text() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OutputText]. */ - class Builder internal constructor() { - - private var text: JsonField? = null - private var type: JsonValue = - JsonValue.from("output_text") - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(outputText: OutputText) = apply { - text = outputText.text - type = outputText.type - additionalProperties = - outputText.additionalProperties.toMutableMap() - } - - /** The text output from the model. */ - fun text(text: String) = text(JsonField.of(text)) - - /** - * Sets [Builder.text] to an arbitrary JSON value. - * - * You should usually call [Builder.text] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun text(text: JsonField) = apply { - this.text = text - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because - * the field defaults to the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty( - key: String, - value: JsonValue, - ) = apply { additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OutputText]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .text() - * ``` - * - * @throws IllegalStateException if any required field - * is unset. - */ - fun build(): OutputText = - OutputText( - checkRequired("text", text), - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OutputText = apply { - if (validated) { - return@apply - } - - text() - _type().let { - if (it != JsonValue.from("output_text")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (text.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("output_text")) 1 - else 0 - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OutputText && - text == other.text && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(text, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" - } - - /** An image input block used within EvalItem content arrays. */ - class InputImage - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val imageUrl: JsonField, - private val type: JsonValue, - private val detail: JsonField, - private val additionalProperties: - MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("image_url") - @ExcludeMissing - imageUrl: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - @JsonProperty("detail") - @ExcludeMissing - detail: JsonField = JsonMissing.of(), - ) : this(imageUrl, type, detail, mutableMapOf()) - - /** - * The URL of the image input. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type or is unexpectedly missing or null - * (e.g. if the server responded with an unexpected - * value). - */ - fun imageUrl(): String = imageUrl.getRequired("image_url") - - /** - * The type of the image input. Always `input_image`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * However, this method can be useful for debugging and - * logging (e.g. if the server responded with an unexpected - * value). - */ - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonValue = type - - /** - * The detail level of the image to be sent to the model. - * One of `high`, `low`, or `auto`. Defaults to `auto`. - * - * @throws OpenAIInvalidDataException if the JSON field has - * an unexpected type (e.g. if the server responded with - * an unexpected value). - */ - fun detail(): Optional = - detail.getOptional("detail") - - /** - * Returns the raw JSON value of [imageUrl]. - * - * Unlike [imageUrl], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl(): JsonField = imageUrl - - /** - * Returns the raw JSON value of [detail]. - * - * Unlike [detail], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("detail") - @ExcludeMissing - fun _detail(): JsonField = detail - - @JsonAnySetter - private fun putAdditionalProperty( - key: String, - value: JsonValue, - ) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an - * instance of [InputImage]. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InputImage]. */ - class Builder internal constructor() { - - private var imageUrl: JsonField? = null - private var type: JsonValue = - JsonValue.from("input_image") - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = - inputImage.additionalProperties.toMutableMap() - } - - /** The URL of the image input. */ - fun imageUrl(imageUrl: String) = - imageUrl(JsonField.of(imageUrl)) - - /** - * Sets [Builder.imageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.imageUrl] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because - * the field defaults to the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * The detail level of the image to be sent to the - * model. One of `high`, `low`, or `auto`. Defaults to - * `auto`. - */ - fun detail(detail: String) = - detail(JsonField.of(detail)) - - /** - * Sets [Builder.detail] to an arbitrary JSON value. - * - * You should usually call [Builder.detail] with a - * well-typed [String] value instead. This method is - * primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun detail(detail: JsonField) = apply { - this.detail = detail - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty( - key: String, - value: JsonValue, - ) = apply { additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll( - additionalProperties - ) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InputImage]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - * - * @throws IllegalStateException if any required field - * is unset. - */ - fun build(): InputImage = - InputImage( - checkRequired("imageUrl", imageUrl), - type, - detail, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InputImage = apply { - if (validated) { - return@apply - } - - imageUrl() - _type().let { - if (it != JsonValue.from("input_image")) { - throw OpenAIInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - detail() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (imageUrl.asKnown().isPresent) 1 else 0) + - type.let { - if (it == JsonValue.from("input_image")) 1 - else 0 - } + - (if (detail.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InputImage && - imageUrl == other.imageUrl && - type == other.type && - detail == other.detail && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - imageUrl, - type, - detail, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" - } - } } /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/EvalContentItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/EvalContentItem.kt new file mode 100644 index 00000000..c55e34ee --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/EvalContentItem.kt @@ -0,0 +1,746 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.graders.gradermodels + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.BaseDeserializer +import com.openai.core.BaseSerializer +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.allMaxBy +import com.openai.core.checkRequired +import com.openai.core.getOrThrow +import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.responses.ResponseInputAudio +import com.openai.models.responses.ResponseInputText +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** A single content item: input text, output text, input image, or input audio. */ +@JsonDeserialize(using = EvalContentItem.Deserializer::class) +@JsonSerialize(using = EvalContentItem.Serializer::class) +class EvalContentItem +private constructor( + private val textInput: String? = null, + private val responseInputText: ResponseInputText? = null, + private val outputText: OutputText? = null, + private val inputImage: InputImage? = null, + private val responseInputAudio: ResponseInputAudio? = null, + private val _json: JsonValue? = null, +) { + + /** A text input to the model. */ + fun textInput(): Optional = Optional.ofNullable(textInput) + + /** A text input to the model. */ + fun responseInputText(): Optional = Optional.ofNullable(responseInputText) + + /** A text output from the model. */ + fun outputText(): Optional = Optional.ofNullable(outputText) + + /** An image input block used within EvalItem content arrays. */ + fun inputImage(): Optional = Optional.ofNullable(inputImage) + + /** An audio input to the model. */ + fun responseInputAudio(): Optional = Optional.ofNullable(responseInputAudio) + + fun isTextInput(): Boolean = textInput != null + + fun isResponseInputText(): Boolean = responseInputText != null + + fun isOutputText(): Boolean = outputText != null + + fun isInputImage(): Boolean = inputImage != null + + fun isResponseInputAudio(): Boolean = responseInputAudio != null + + /** A text input to the model. */ + fun asTextInput(): String = textInput.getOrThrow("textInput") + + /** A text input to the model. */ + fun asResponseInputText(): ResponseInputText = responseInputText.getOrThrow("responseInputText") + + /** A text output from the model. */ + fun asOutputText(): OutputText = outputText.getOrThrow("outputText") + + /** An image input block used within EvalItem content arrays. */ + fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") + + /** An audio input to the model. */ + fun asResponseInputAudio(): ResponseInputAudio = + responseInputAudio.getOrThrow("responseInputAudio") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + textInput != null -> visitor.visitTextInput(textInput) + responseInputText != null -> visitor.visitResponseInputText(responseInputText) + outputText != null -> visitor.visitOutputText(outputText) + inputImage != null -> visitor.visitInputImage(inputImage) + responseInputAudio != null -> visitor.visitResponseInputAudio(responseInputAudio) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): EvalContentItem = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTextInput(textInput: String) {} + + override fun visitResponseInputText(responseInputText: ResponseInputText) { + responseInputText.validate() + } + + override fun visitOutputText(outputText: OutputText) { + outputText.validate() + } + + override fun visitInputImage(inputImage: InputImage) { + inputImage.validate() + } + + override fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio) { + responseInputAudio.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTextInput(textInput: String) = 1 + + override fun visitResponseInputText(responseInputText: ResponseInputText) = + responseInputText.validity() + + override fun visitOutputText(outputText: OutputText) = outputText.validity() + + override fun visitInputImage(inputImage: InputImage) = inputImage.validity() + + override fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio) = + responseInputAudio.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EvalContentItem && + textInput == other.textInput && + responseInputText == other.responseInputText && + outputText == other.outputText && + inputImage == other.inputImage && + responseInputAudio == other.responseInputAudio + } + + override fun hashCode(): Int = + Objects.hash(textInput, responseInputText, outputText, inputImage, responseInputAudio) + + override fun toString(): String = + when { + textInput != null -> "EvalContentItem{textInput=$textInput}" + responseInputText != null -> "EvalContentItem{responseInputText=$responseInputText}" + outputText != null -> "EvalContentItem{outputText=$outputText}" + inputImage != null -> "EvalContentItem{inputImage=$inputImage}" + responseInputAudio != null -> "EvalContentItem{responseInputAudio=$responseInputAudio}" + _json != null -> "EvalContentItem{_unknown=$_json}" + else -> throw IllegalStateException("Invalid EvalContentItem") + } + + companion object { + + /** A text input to the model. */ + @JvmStatic fun ofTextInput(textInput: String) = EvalContentItem(textInput = textInput) + + /** A text input to the model. */ + @JvmStatic + fun ofResponseInputText(responseInputText: ResponseInputText) = + EvalContentItem(responseInputText = responseInputText) + + /** A text output from the model. */ + @JvmStatic + fun ofOutputText(outputText: OutputText) = EvalContentItem(outputText = outputText) + + /** An image input block used within EvalItem content arrays. */ + @JvmStatic + fun ofInputImage(inputImage: InputImage) = EvalContentItem(inputImage = inputImage) + + /** An audio input to the model. */ + @JvmStatic + fun ofResponseInputAudio(responseInputAudio: ResponseInputAudio) = + EvalContentItem(responseInputAudio = responseInputAudio) + } + + /** + * An interface that defines how to map each variant of [EvalContentItem] to a value of type + * [T]. + */ + interface Visitor { + + /** A text input to the model. */ + fun visitTextInput(textInput: String): T + + /** A text input to the model. */ + fun visitResponseInputText(responseInputText: ResponseInputText): T + + /** A text output from the model. */ + fun visitOutputText(outputText: OutputText): T + + /** An image input block used within EvalItem content arrays. */ + fun visitInputImage(inputImage: InputImage): T + + /** An audio input to the model. */ + fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T + + /** + * Maps an unknown variant of [EvalContentItem] to a value of type [T]. + * + * An instance of [EvalContentItem] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is unaware + * of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException("Unknown EvalContentItem: $json") + } + } + + internal class Deserializer : BaseDeserializer(EvalContentItem::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): EvalContentItem { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + EvalContentItem(responseInputText = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + EvalContentItem(outputText = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + EvalContentItem(inputImage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + EvalContentItem(responseInputAudio = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + EvalContentItem(textInput = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from array). + 0 -> EvalContentItem(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(EvalContentItem::class) { + + override fun serialize( + value: EvalContentItem, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.textInput != null -> generator.writeObject(value.textInput) + value.responseInputText != null -> generator.writeObject(value.responseInputText) + value.outputText != null -> generator.writeObject(value.outputText) + value.inputImage != null -> generator.writeObject(value.inputImage) + value.responseInputAudio != null -> generator.writeObject(value.responseInputAudio) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid EvalContentItem") + } + } + } + + /** A text output from the model. */ + class OutputText + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(text, type, mutableMapOf()) + + /** + * The text output from the model. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * The type of the output text. Always `output_text`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OutputText]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputText]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("output_text") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputText: OutputText) = apply { + text = outputText.text + type = outputText.type + additionalProperties = outputText.additionalProperties.toMutableMap() + } + + /** The text output from the model. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("output_text") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OutputText]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OutputText = + OutputText(checkRequired("text", text), type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): OutputText = apply { + if (validated) { + return@apply + } + + text() + _type().let { + if (it != JsonValue.from("output_text")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("output_text")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputText && + text == other.text && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(text, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" + } + + /** An image input block used within EvalItem content arrays. */ + class InputImage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val imageUrl: JsonField, + private val type: JsonValue, + private val detail: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("image_url") + @ExcludeMissing + imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("detail") @ExcludeMissing detail: JsonField = JsonMissing.of(), + ) : this(imageUrl, type, detail, mutableMapOf()) + + /** + * The URL of the image input. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun imageUrl(): String = imageUrl.getRequired("image_url") + + /** + * The type of the image input. Always `input_image`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. + * Defaults to `auto`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun detail(): Optional = detail.getOptional("detail") + + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("image_url") @ExcludeMissing fun _imageUrl(): JsonField = imageUrl + + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("detail") @ExcludeMissing fun _detail(): JsonField = detail + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InputImage]. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputImage]. */ + class Builder internal constructor() { + + private var imageUrl: JsonField? = null + private var type: JsonValue = JsonValue.from("input_image") + private var detail: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputImage: InputImage) = apply { + imageUrl = inputImage.imageUrl + type = inputImage.type + detail = inputImage.detail + additionalProperties = inputImage.additionalProperties.toMutableMap() + } + + /** The URL of the image input. */ + fun imageUrl(imageUrl: String) = imageUrl(JsonField.of(imageUrl)) + + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageUrl(imageUrl: JsonField) = apply { this.imageUrl = imageUrl } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("input_image") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * The detail level of the image to be sent to the model. One of `high`, `low`, or + * `auto`. Defaults to `auto`. + */ + fun detail(detail: String) = detail(JsonField.of(detail)) + + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun detail(detail: JsonField) = apply { this.detail = detail } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InputImage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .imageUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InputImage = + InputImage( + checkRequired("imageUrl", imageUrl), + type, + detail, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InputImage = apply { + if (validated) { + return@apply + } + + imageUrl() + _type().let { + if (it != JsonValue.from("input_image")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + detail() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (imageUrl.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("input_image")) 1 else 0 } + + (if (detail.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputImage && + imageUrl == other.imageUrl && + type == other.type && + detail == other.detail && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(imageUrl, type, detail, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt index 48fad67e..92d0108c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt @@ -26,7 +26,6 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException -import com.openai.models.EvalContentItem import com.openai.models.responses.ResponseInputAudio import com.openai.models.responses.ResponseInputText import java.util.Collections @@ -1449,783 +1448,6 @@ private constructor( override fun toString() = "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - - /** A single content item: input text, output text, input image, or input audio. */ - @JsonDeserialize(using = EvalContentItem.Deserializer::class) - @JsonSerialize(using = EvalContentItem.Serializer::class) - class EvalContentItem - private constructor( - private val textInput: String? = null, - private val responseInputText: ResponseInputText? = null, - private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, - private val responseInputAudio: ResponseInputAudio? = null, - private val _json: JsonValue? = null, - ) { - - /** A text input to the model. */ - fun textInput(): Optional = Optional.ofNullable(textInput) - - /** A text input to the model. */ - fun responseInputText(): Optional = - Optional.ofNullable(responseInputText) - - /** A text output from the model. */ - fun outputText(): Optional = Optional.ofNullable(outputText) - - /** An image input block used within EvalItem content arrays. */ - fun inputImage(): Optional = Optional.ofNullable(inputImage) - - /** An audio input to the model. */ - fun responseInputAudio(): Optional = - Optional.ofNullable(responseInputAudio) - - fun isTextInput(): Boolean = textInput != null - - fun isResponseInputText(): Boolean = responseInputText != null - - fun isOutputText(): Boolean = outputText != null - - fun isInputImage(): Boolean = inputImage != null - - fun isResponseInputAudio(): Boolean = responseInputAudio != null - - /** A text input to the model. */ - fun asTextInput(): String = textInput.getOrThrow("textInput") - - /** A text input to the model. */ - fun asResponseInputText(): ResponseInputText = - responseInputText.getOrThrow("responseInputText") - - /** A text output from the model. */ - fun asOutputText(): OutputText = outputText.getOrThrow("outputText") - - /** An image input block used within EvalItem content arrays. */ - fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") - - /** An audio input to the model. */ - fun asResponseInputAudio(): ResponseInputAudio = - responseInputAudio.getOrThrow("responseInputAudio") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - textInput != null -> visitor.visitTextInput(textInput) - responseInputText != null -> - visitor.visitResponseInputText(responseInputText) - outputText != null -> visitor.visitOutputText(outputText) - inputImage != null -> visitor.visitInputImage(inputImage) - responseInputAudio != null -> - visitor.visitResponseInputAudio(responseInputAudio) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): EvalContentItem = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitTextInput(textInput: String) {} - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) { - responseInputText.validate() - } - - override fun visitOutputText(outputText: OutputText) { - outputText.validate() - } - - override fun visitInputImage(inputImage: InputImage) { - inputImage.validate() - } - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) { - responseInputAudio.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTextInput(textInput: String) = 1 - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) = responseInputText.validity() - - override fun visitOutputText(outputText: OutputText) = - outputText.validity() - - override fun visitInputImage(inputImage: InputImage) = - inputImage.validity() - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = responseInputAudio.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EvalContentItem && - textInput == other.textInput && - responseInputText == other.responseInputText && - outputText == other.outputText && - inputImage == other.inputImage && - responseInputAudio == other.responseInputAudio - } - - override fun hashCode(): Int = - Objects.hash( - textInput, - responseInputText, - outputText, - inputImage, - responseInputAudio, - ) - - override fun toString(): String = - when { - textInput != null -> "EvalContentItem{textInput=$textInput}" - responseInputText != null -> - "EvalContentItem{responseInputText=$responseInputText}" - outputText != null -> "EvalContentItem{outputText=$outputText}" - inputImage != null -> "EvalContentItem{inputImage=$inputImage}" - responseInputAudio != null -> - "EvalContentItem{responseInputAudio=$responseInputAudio}" - _json != null -> "EvalContentItem{_unknown=$_json}" - else -> throw IllegalStateException("Invalid EvalContentItem") - } - - companion object { - - /** A text input to the model. */ - @JvmStatic - fun ofTextInput(textInput: String) = EvalContentItem(textInput = textInput) - - /** A text input to the model. */ - @JvmStatic - fun ofResponseInputText(responseInputText: ResponseInputText) = - EvalContentItem(responseInputText = responseInputText) - - /** A text output from the model. */ - @JvmStatic - fun ofOutputText(outputText: OutputText) = - EvalContentItem(outputText = outputText) - - /** An image input block used within EvalItem content arrays. */ - @JvmStatic - fun ofInputImage(inputImage: InputImage) = - EvalContentItem(inputImage = inputImage) - - /** An audio input to the model. */ - @JvmStatic - fun ofResponseInputAudio(responseInputAudio: ResponseInputAudio) = - EvalContentItem(responseInputAudio = responseInputAudio) - } - - /** - * An interface that defines how to map each variant of [EvalContentItem] to a value - * of type [T]. - */ - interface Visitor { - - /** A text input to the model. */ - fun visitTextInput(textInput: String): T - - /** A text input to the model. */ - fun visitResponseInputText(responseInputText: ResponseInputText): T - - /** A text output from the model. */ - fun visitOutputText(outputText: OutputText): T - - /** An image input block used within EvalItem content arrays. */ - fun visitInputImage(inputImage: InputImage): T - - /** An audio input to the model. */ - fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T - - /** - * Maps an unknown variant of [EvalContentItem] to a value of type [T]. - * - * An instance of [EvalContentItem] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws OpenAIInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OpenAIInvalidDataException("Unknown EvalContentItem: $json") - } - } - - internal class Deserializer : - BaseDeserializer(EvalContentItem::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): EvalContentItem { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - EvalContentItem(responseInputText = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - EvalContentItem(outputText = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - EvalContentItem(inputImage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - EvalContentItem(responseInputAudio = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - EvalContentItem(textInput = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // array). - 0 -> EvalContentItem(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(EvalContentItem::class) { - - override fun serialize( - value: EvalContentItem, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.textInput != null -> generator.writeObject(value.textInput) - value.responseInputText != null -> - generator.writeObject(value.responseInputText) - value.outputText != null -> generator.writeObject(value.outputText) - value.inputImage != null -> generator.writeObject(value.inputImage) - value.responseInputAudio != null -> - generator.writeObject(value.responseInputAudio) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid EvalContentItem") - } - } - } - - /** A text output from the model. */ - class OutputText - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val text: JsonField, - private val type: JsonValue, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("text") - @ExcludeMissing - text: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(text, type, mutableMapOf()) - - /** - * The text output from the model. - * - * @throws OpenAIInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun text(): String = text.getRequired("text") - - /** - * The type of the output text. Always `output_text`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Returns the raw JSON value of [text]. - * - * Unlike [text], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [OutputText]. - * - * The following fields are required: - * ```java - * .text() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OutputText]. */ - class Builder internal constructor() { - - private var text: JsonField? = null - private var type: JsonValue = JsonValue.from("output_text") - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(outputText: OutputText) = apply { - text = outputText.text - type = outputText.type - additionalProperties = outputText.additionalProperties.toMutableMap() - } - - /** The text output from the model. */ - fun text(text: String) = text(JsonField.of(text)) - - /** - * Sets [Builder.text] to an arbitrary JSON value. - * - * You should usually call [Builder.text] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun text(text: JsonField) = apply { this.text = text } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OutputText]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .text() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): OutputText = - OutputText( - checkRequired("text", text), - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OutputText = apply { - if (validated) { - return@apply - } - - text() - _type().let { - if (it != JsonValue.from("output_text")) { - throw OpenAIInvalidDataException("'type' is invalid, received $it") - } - } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (text.asKnown().isPresent) 1 else 0) + - type.let { if (it == JsonValue.from("output_text")) 1 else 0 } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OutputText && - text == other.text && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(text, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" - } - - /** An image input block used within EvalItem content arrays. */ - class InputImage - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val imageUrl: JsonField, - private val type: JsonValue, - private val detail: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("image_url") - @ExcludeMissing - imageUrl: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - @JsonProperty("detail") - @ExcludeMissing - detail: JsonField = JsonMissing.of(), - ) : this(imageUrl, type, detail, mutableMapOf()) - - /** - * The URL of the image input. - * - * @throws OpenAIInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun imageUrl(): String = imageUrl.getRequired("image_url") - - /** - * The type of the image input. Always `input_image`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * The detail level of the image to be sent to the model. One of `high`, `low`, - * or `auto`. Defaults to `auto`. - * - * @throws OpenAIInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun detail(): Optional = detail.getOptional("detail") - - /** - * Returns the raw JSON value of [imageUrl]. - * - * Unlike [imageUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl(): JsonField = imageUrl - - /** - * Returns the raw JSON value of [detail]. - * - * Unlike [detail], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("detail") - @ExcludeMissing - fun _detail(): JsonField = detail - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [InputImage]. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InputImage]. */ - class Builder internal constructor() { - - private var imageUrl: JsonField? = null - private var type: JsonValue = JsonValue.from("input_image") - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = inputImage.additionalProperties.toMutableMap() - } - - /** The URL of the image input. */ - fun imageUrl(imageUrl: String) = imageUrl(JsonField.of(imageUrl)) - - /** - * Sets [Builder.imageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.imageUrl] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * The detail level of the image to be sent to the model. One of `high`, - * `low`, or `auto`. Defaults to `auto`. - */ - fun detail(detail: String) = detail(JsonField.of(detail)) - - /** - * Sets [Builder.detail] to an arbitrary JSON value. - * - * You should usually call [Builder.detail] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun detail(detail: JsonField) = apply { this.detail = detail } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InputImage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InputImage = - InputImage( - checkRequired("imageUrl", imageUrl), - type, - detail, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InputImage = apply { - if (validated) { - return@apply - } - - imageUrl() - _type().let { - if (it != JsonValue.from("input_image")) { - throw OpenAIInvalidDataException("'type' is invalid, received $it") - } - } - detail() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (imageUrl.asKnown().isPresent) 1 else 0) + - type.let { if (it == JsonValue.from("input_image")) 1 else 0 } + - (if (detail.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InputImage && - imageUrl == other.imageUrl && - type == other.type && - detail == other.detail && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(imageUrl, type, detail, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" - } - } } /** The role of the message input. One of `user`, `assistant`, `system`, or `developer`. */ diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt index a9ad8ead..65e0d8e4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt @@ -26,7 +26,6 @@ import com.openai.core.checkRequired import com.openai.core.getOrThrow import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException -import com.openai.models.EvalContentItem import com.openai.models.ReasoningEffort import com.openai.models.responses.ResponseInputAudio import com.openai.models.responses.ResponseInputText @@ -1442,783 +1441,6 @@ private constructor( override fun toString() = "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" } - - /** A single content item: input text, output text, input image, or input audio. */ - @JsonDeserialize(using = EvalContentItem.Deserializer::class) - @JsonSerialize(using = EvalContentItem.Serializer::class) - class EvalContentItem - private constructor( - private val textInput: String? = null, - private val responseInputText: ResponseInputText? = null, - private val outputText: OutputText? = null, - private val inputImage: InputImage? = null, - private val responseInputAudio: ResponseInputAudio? = null, - private val _json: JsonValue? = null, - ) { - - /** A text input to the model. */ - fun textInput(): Optional = Optional.ofNullable(textInput) - - /** A text input to the model. */ - fun responseInputText(): Optional = - Optional.ofNullable(responseInputText) - - /** A text output from the model. */ - fun outputText(): Optional = Optional.ofNullable(outputText) - - /** An image input block used within EvalItem content arrays. */ - fun inputImage(): Optional = Optional.ofNullable(inputImage) - - /** An audio input to the model. */ - fun responseInputAudio(): Optional = - Optional.ofNullable(responseInputAudio) - - fun isTextInput(): Boolean = textInput != null - - fun isResponseInputText(): Boolean = responseInputText != null - - fun isOutputText(): Boolean = outputText != null - - fun isInputImage(): Boolean = inputImage != null - - fun isResponseInputAudio(): Boolean = responseInputAudio != null - - /** A text input to the model. */ - fun asTextInput(): String = textInput.getOrThrow("textInput") - - /** A text input to the model. */ - fun asResponseInputText(): ResponseInputText = - responseInputText.getOrThrow("responseInputText") - - /** A text output from the model. */ - fun asOutputText(): OutputText = outputText.getOrThrow("outputText") - - /** An image input block used within EvalItem content arrays. */ - fun asInputImage(): InputImage = inputImage.getOrThrow("inputImage") - - /** An audio input to the model. */ - fun asResponseInputAudio(): ResponseInputAudio = - responseInputAudio.getOrThrow("responseInputAudio") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - textInput != null -> visitor.visitTextInput(textInput) - responseInputText != null -> - visitor.visitResponseInputText(responseInputText) - outputText != null -> visitor.visitOutputText(outputText) - inputImage != null -> visitor.visitInputImage(inputImage) - responseInputAudio != null -> - visitor.visitResponseInputAudio(responseInputAudio) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): EvalContentItem = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitTextInput(textInput: String) {} - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) { - responseInputText.validate() - } - - override fun visitOutputText(outputText: OutputText) { - outputText.validate() - } - - override fun visitInputImage(inputImage: InputImage) { - inputImage.validate() - } - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) { - responseInputAudio.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTextInput(textInput: String) = 1 - - override fun visitResponseInputText( - responseInputText: ResponseInputText - ) = responseInputText.validity() - - override fun visitOutputText(outputText: OutputText) = - outputText.validity() - - override fun visitInputImage(inputImage: InputImage) = - inputImage.validity() - - override fun visitResponseInputAudio( - responseInputAudio: ResponseInputAudio - ) = responseInputAudio.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EvalContentItem && - textInput == other.textInput && - responseInputText == other.responseInputText && - outputText == other.outputText && - inputImage == other.inputImage && - responseInputAudio == other.responseInputAudio - } - - override fun hashCode(): Int = - Objects.hash( - textInput, - responseInputText, - outputText, - inputImage, - responseInputAudio, - ) - - override fun toString(): String = - when { - textInput != null -> "EvalContentItem{textInput=$textInput}" - responseInputText != null -> - "EvalContentItem{responseInputText=$responseInputText}" - outputText != null -> "EvalContentItem{outputText=$outputText}" - inputImage != null -> "EvalContentItem{inputImage=$inputImage}" - responseInputAudio != null -> - "EvalContentItem{responseInputAudio=$responseInputAudio}" - _json != null -> "EvalContentItem{_unknown=$_json}" - else -> throw IllegalStateException("Invalid EvalContentItem") - } - - companion object { - - /** A text input to the model. */ - @JvmStatic - fun ofTextInput(textInput: String) = EvalContentItem(textInput = textInput) - - /** A text input to the model. */ - @JvmStatic - fun ofResponseInputText(responseInputText: ResponseInputText) = - EvalContentItem(responseInputText = responseInputText) - - /** A text output from the model. */ - @JvmStatic - fun ofOutputText(outputText: OutputText) = - EvalContentItem(outputText = outputText) - - /** An image input block used within EvalItem content arrays. */ - @JvmStatic - fun ofInputImage(inputImage: InputImage) = - EvalContentItem(inputImage = inputImage) - - /** An audio input to the model. */ - @JvmStatic - fun ofResponseInputAudio(responseInputAudio: ResponseInputAudio) = - EvalContentItem(responseInputAudio = responseInputAudio) - } - - /** - * An interface that defines how to map each variant of [EvalContentItem] to a value - * of type [T]. - */ - interface Visitor { - - /** A text input to the model. */ - fun visitTextInput(textInput: String): T - - /** A text input to the model. */ - fun visitResponseInputText(responseInputText: ResponseInputText): T - - /** A text output from the model. */ - fun visitOutputText(outputText: OutputText): T - - /** An image input block used within EvalItem content arrays. */ - fun visitInputImage(inputImage: InputImage): T - - /** An audio input to the model. */ - fun visitResponseInputAudio(responseInputAudio: ResponseInputAudio): T - - /** - * Maps an unknown variant of [EvalContentItem] to a value of type [T]. - * - * An instance of [EvalContentItem] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws OpenAIInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OpenAIInvalidDataException("Unknown EvalContentItem: $json") - } - } - - internal class Deserializer : - BaseDeserializer(EvalContentItem::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): EvalContentItem { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - EvalContentItem(responseInputText = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - EvalContentItem(outputText = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - EvalContentItem(inputImage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - EvalContentItem(responseInputAudio = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - EvalContentItem(textInput = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // array). - 0 -> EvalContentItem(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(EvalContentItem::class) { - - override fun serialize( - value: EvalContentItem, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.textInput != null -> generator.writeObject(value.textInput) - value.responseInputText != null -> - generator.writeObject(value.responseInputText) - value.outputText != null -> generator.writeObject(value.outputText) - value.inputImage != null -> generator.writeObject(value.inputImage) - value.responseInputAudio != null -> - generator.writeObject(value.responseInputAudio) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid EvalContentItem") - } - } - } - - /** A text output from the model. */ - class OutputText - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val text: JsonField, - private val type: JsonValue, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("text") - @ExcludeMissing - text: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(text, type, mutableMapOf()) - - /** - * The text output from the model. - * - * @throws OpenAIInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun text(): String = text.getRequired("text") - - /** - * The type of the output text. Always `output_text`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Returns the raw JSON value of [text]. - * - * Unlike [text], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [OutputText]. - * - * The following fields are required: - * ```java - * .text() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OutputText]. */ - class Builder internal constructor() { - - private var text: JsonField? = null - private var type: JsonValue = JsonValue.from("output_text") - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(outputText: OutputText) = apply { - text = outputText.text - type = outputText.type - additionalProperties = outputText.additionalProperties.toMutableMap() - } - - /** The text output from the model. */ - fun text(text: String) = text(JsonField.of(text)) - - /** - * Sets [Builder.text] to an arbitrary JSON value. - * - * You should usually call [Builder.text] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun text(text: JsonField) = apply { this.text = text } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("output_text") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OutputText]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .text() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): OutputText = - OutputText( - checkRequired("text", text), - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OutputText = apply { - if (validated) { - return@apply - } - - text() - _type().let { - if (it != JsonValue.from("output_text")) { - throw OpenAIInvalidDataException("'type' is invalid, received $it") - } - } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (text.asKnown().isPresent) 1 else 0) + - type.let { if (it == JsonValue.from("output_text")) 1 else 0 } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OutputText && - text == other.text && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(text, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OutputText{text=$text, type=$type, additionalProperties=$additionalProperties}" - } - - /** An image input block used within EvalItem content arrays. */ - class InputImage - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val imageUrl: JsonField, - private val type: JsonValue, - private val detail: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("image_url") - @ExcludeMissing - imageUrl: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - @JsonProperty("detail") - @ExcludeMissing - detail: JsonField = JsonMissing.of(), - ) : this(imageUrl, type, detail, mutableMapOf()) - - /** - * The URL of the image input. - * - * @throws OpenAIInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun imageUrl(): String = imageUrl.getRequired("image_url") - - /** - * The type of the image input. Always `input_image`. - * - * Expected to always return the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * The detail level of the image to be sent to the model. One of `high`, `low`, - * or `auto`. Defaults to `auto`. - * - * @throws OpenAIInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun detail(): Optional = detail.getOptional("detail") - - /** - * Returns the raw JSON value of [imageUrl]. - * - * Unlike [imageUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl(): JsonField = imageUrl - - /** - * Returns the raw JSON value of [detail]. - * - * Unlike [detail], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("detail") - @ExcludeMissing - fun _detail(): JsonField = detail - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [InputImage]. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InputImage]. */ - class Builder internal constructor() { - - private var imageUrl: JsonField? = null - private var type: JsonValue = JsonValue.from("input_image") - private var detail: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(inputImage: InputImage) = apply { - imageUrl = inputImage.imageUrl - type = inputImage.type - detail = inputImage.detail - additionalProperties = inputImage.additionalProperties.toMutableMap() - } - - /** The URL of the image input. */ - fun imageUrl(imageUrl: String) = imageUrl(JsonField.of(imageUrl)) - - /** - * Sets [Builder.imageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.imageUrl] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageUrl(imageUrl: JsonField) = apply { - this.imageUrl = imageUrl - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("input_image") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * The detail level of the image to be sent to the model. One of `high`, - * `low`, or `auto`. Defaults to `auto`. - */ - fun detail(detail: String) = detail(JsonField.of(detail)) - - /** - * Sets [Builder.detail] to an arbitrary JSON value. - * - * You should usually call [Builder.detail] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun detail(detail: JsonField) = apply { this.detail = detail } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InputImage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .imageUrl() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InputImage = - InputImage( - checkRequired("imageUrl", imageUrl), - type, - detail, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InputImage = apply { - if (validated) { - return@apply - } - - imageUrl() - _type().let { - if (it != JsonValue.from("input_image")) { - throw OpenAIInvalidDataException("'type' is invalid, received $it") - } - } - detail() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OpenAIInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (imageUrl.asKnown().isPresent) 1 else 0) + - type.let { if (it == JsonValue.from("input_image")) 1 else 0 } + - (if (detail.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InputImage && - imageUrl == other.imageUrl && - type == other.type && - detail == other.detail && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(imageUrl, type, detail, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InputImage{imageUrl=$imageUrl, type=$type, detail=$detail, additionalProperties=$additionalProperties}" - } - } } /** The role of the message input. One of `user`, `assistant`, `system`, or `developer`. */ diff --git a/openai-java-core/src/test/kotlin/com/openai/models/graders/gradermodels/EvalContentItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/graders/gradermodels/EvalContentItemTest.kt new file mode 100644 index 00000000..c6435f09 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/graders/gradermodels/EvalContentItemTest.kt @@ -0,0 +1,184 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.graders.gradermodels + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.JsonValue +import com.openai.core.jsonMapper +import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.responses.ResponseInputAudio +import com.openai.models.responses.ResponseInputText +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows + +internal class EvalContentItemTest { + + @Test + fun ofTextInput() { + val textInput = "string" + + val evalContentItem = EvalContentItem.ofTextInput(textInput) + + assertThat(evalContentItem.textInput()).contains(textInput) + assertThat(evalContentItem.responseInputText()).isEmpty + assertThat(evalContentItem.outputText()).isEmpty + assertThat(evalContentItem.inputImage()).isEmpty + assertThat(evalContentItem.responseInputAudio()).isEmpty + } + + @Test + fun ofTextInputRoundtrip() { + val jsonMapper = jsonMapper() + val evalContentItem = EvalContentItem.ofTextInput("string") + + val roundtrippedEvalContentItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(evalContentItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEvalContentItem).isEqualTo(evalContentItem) + } + + @Test + fun ofResponseInputText() { + val responseInputText = ResponseInputText.builder().text("text").build() + + val evalContentItem = EvalContentItem.ofResponseInputText(responseInputText) + + assertThat(evalContentItem.textInput()).isEmpty + assertThat(evalContentItem.responseInputText()).contains(responseInputText) + assertThat(evalContentItem.outputText()).isEmpty + assertThat(evalContentItem.inputImage()).isEmpty + assertThat(evalContentItem.responseInputAudio()).isEmpty + } + + @Test + fun ofResponseInputTextRoundtrip() { + val jsonMapper = jsonMapper() + val evalContentItem = + EvalContentItem.ofResponseInputText(ResponseInputText.builder().text("text").build()) + + val roundtrippedEvalContentItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(evalContentItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEvalContentItem).isEqualTo(evalContentItem) + } + + @Test + fun ofOutputText() { + val outputText = EvalContentItem.OutputText.builder().text("text").build() + + val evalContentItem = EvalContentItem.ofOutputText(outputText) + + assertThat(evalContentItem.textInput()).isEmpty + assertThat(evalContentItem.responseInputText()).isEmpty + assertThat(evalContentItem.outputText()).contains(outputText) + assertThat(evalContentItem.inputImage()).isEmpty + assertThat(evalContentItem.responseInputAudio()).isEmpty + } + + @Test + fun ofOutputTextRoundtrip() { + val jsonMapper = jsonMapper() + val evalContentItem = + EvalContentItem.ofOutputText(EvalContentItem.OutputText.builder().text("text").build()) + + val roundtrippedEvalContentItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(evalContentItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEvalContentItem).isEqualTo(evalContentItem) + } + + @Test + fun ofInputImage() { + val inputImage = + EvalContentItem.InputImage.builder().imageUrl("image_url").detail("detail").build() + + val evalContentItem = EvalContentItem.ofInputImage(inputImage) + + assertThat(evalContentItem.textInput()).isEmpty + assertThat(evalContentItem.responseInputText()).isEmpty + assertThat(evalContentItem.outputText()).isEmpty + assertThat(evalContentItem.inputImage()).contains(inputImage) + assertThat(evalContentItem.responseInputAudio()).isEmpty + } + + @Test + fun ofInputImageRoundtrip() { + val jsonMapper = jsonMapper() + val evalContentItem = + EvalContentItem.ofInputImage( + EvalContentItem.InputImage.builder().imageUrl("image_url").detail("detail").build() + ) + + val roundtrippedEvalContentItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(evalContentItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEvalContentItem).isEqualTo(evalContentItem) + } + + @Test + fun ofResponseInputAudio() { + val responseInputAudio = + ResponseInputAudio.builder() + .inputAudio( + ResponseInputAudio.InputAudio.builder() + .data("data") + .format(ResponseInputAudio.InputAudio.Format.MP3) + .build() + ) + .build() + + val evalContentItem = EvalContentItem.ofResponseInputAudio(responseInputAudio) + + assertThat(evalContentItem.textInput()).isEmpty + assertThat(evalContentItem.responseInputText()).isEmpty + assertThat(evalContentItem.outputText()).isEmpty + assertThat(evalContentItem.inputImage()).isEmpty + assertThat(evalContentItem.responseInputAudio()).contains(responseInputAudio) + } + + @Test + fun ofResponseInputAudioRoundtrip() { + val jsonMapper = jsonMapper() + val evalContentItem = + EvalContentItem.ofResponseInputAudio( + ResponseInputAudio.builder() + .inputAudio( + ResponseInputAudio.InputAudio.builder() + .data("data") + .format(ResponseInputAudio.InputAudio.Format.MP3) + .build() + ) + .build() + ) + + val roundtrippedEvalContentItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(evalContentItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEvalContentItem).isEqualTo(evalContentItem) + } + + @Test + fun incompatibleJsonShapeDeserializesToUnknown() { + val value = JsonValue.from(listOf("invalid", "array")) + val evalContentItem = jsonMapper().convertValue(value, jacksonTypeRef()) + + val e = assertThrows { evalContentItem.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} From 85aa26b08a4ccba27f49883aa39f1f6ab47f635a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 15 Dec 2025 17:42:59 +0000 Subject: [PATCH 4/4] release: 4.12.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 10 ++++++++++ README.md | 14 +++++++------- build.gradle.kts | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index a43b15a4..03276cfb 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.11.0" + ".": "4.12.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0752c1a4..b25f804f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 4.12.0 (2025-12-15) + +Full Changelog: [v4.11.0...v4.12.0](https://github.com/openai/openai-java/compare/v4.11.0...v4.12.0) + +### Features + +* **api:** api update ([29174d7](https://github.com/openai/openai-java/commit/29174d7275d95ef5a6d4f88d4ebe2bcd178746b5)) +* **api:** fix grader input list, add dated slugs for sora-2 ([f75af83](https://github.com/openai/openai-java/commit/f75af830fdaf2874313c125a8de0aecde6f447b7)) +* **api:** manual updates for java ([ffd07a2](https://github.com/openai/openai-java/commit/ffd07a2ad1ae064e65f4564c663502fe3901c21e)) + ## 4.11.0 (2025-12-12) Full Changelog: [v4.10.0...v4.11.0](https://github.com/openai/openai-java/compare/v4.10.0...v4.11.0) diff --git a/README.md b/README.md index 6136d625..91e42936 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/4.11.0) -[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/4.11.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/4.11.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/4.12.0) +[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/4.12.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/4.12.0) @@ -11,7 +11,7 @@ The OpenAI Java SDK provides convenient access to the [OpenAI REST API](https:// -The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/4.11.0). +The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/4.12.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor ### Gradle ```kotlin -implementation("com.openai:openai-java:4.11.0") +implementation("com.openai:openai-java:4.12.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.openai:openai-java:4.11.0") com.openai openai-java - 4.11.0 + 4.12.0 ``` @@ -1342,7 +1342,7 @@ If you're using Spring Boot, then you can use the SDK's [Spring Boot starter](ht #### Gradle ```kotlin -implementation("com.openai:openai-java-spring-boot-starter:4.11.0") +implementation("com.openai:openai-java-spring-boot-starter:4.12.0") ``` #### Maven @@ -1351,7 +1351,7 @@ implementation("com.openai:openai-java-spring-boot-starter:4.11.0") com.openai openai-java-spring-boot-starter - 4.11.0 + 4.12.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 01745c5a..0aac8875 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openai" - version = "4.11.0" // x-release-please-version + version = "4.12.0" // x-release-please-version } subprojects {