Skip to content

Commit c4200c3

Browse files
fix(client): fix verbosity parameter location in Responses
fixes error with unsupported `verbosity` parameter by correctly placing it inside the `text` parameter
1 parent 67dde1f commit c4200c3

16 files changed

+262
-468
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 111
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-56d3a72a5caa187aebcf9de169a6a28a9dc3f70a79d7467a03a9e22595936066.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-6a1bfd4738fff02ef5becc3fdb2bf0cd6c026f2c924d4147a2a515474477dd9a.yml
33
openapi_spec_hash: 3eb8d86c06f0bb5e1190983e5acfc9ba
4-
config_hash: 7e18239879286d68a48ac5487a649aa6
4+
config_hash: a67c5e195a59855fe8a5db0dc61a3e7f

openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt

Lines changed: 4 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ private constructor(
6565
private val truncation: JsonField<Truncation>,
6666
private val usage: JsonField<ResponseUsage>,
6767
private val user: JsonField<String>,
68-
private val verbosity: JsonField<Verbosity>,
6968
private val additionalProperties: MutableMap<String, JsonValue>,
7069
) {
7170

@@ -138,9 +137,6 @@ private constructor(
138137
truncation: JsonField<Truncation> = JsonMissing.of(),
139138
@JsonProperty("usage") @ExcludeMissing usage: JsonField<ResponseUsage> = JsonMissing.of(),
140139
@JsonProperty("user") @ExcludeMissing user: JsonField<String> = JsonMissing.of(),
141-
@JsonProperty("verbosity")
142-
@ExcludeMissing
143-
verbosity: JsonField<Verbosity> = JsonMissing.of(),
144140
) : this(
145141
id,
146142
createdAt,
@@ -171,7 +167,6 @@ private constructor(
171167
truncation,
172168
usage,
173169
user,
174-
verbosity,
175170
mutableMapOf(),
176171
)
177172

@@ -492,16 +487,6 @@ private constructor(
492487
*/
493488
@Deprecated("deprecated") fun user(): Optional<String> = user.getOptional("user")
494489

495-
/**
496-
* Constrains the verbosity of the model's response. Lower values will result in more concise
497-
* responses, while higher values will result in more verbose responses. Currently supported
498-
* values are `low`, `medium`, and `high`.
499-
*
500-
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
501-
* server responded with an unexpected value).
502-
*/
503-
fun verbosity(): Optional<Verbosity> = verbosity.getOptional("verbosity")
504-
505490
/**
506491
* Returns the raw JSON value of [id].
507492
*
@@ -729,13 +714,6 @@ private constructor(
729714
@ExcludeMissing
730715
fun _user(): JsonField<String> = user
731716

732-
/**
733-
* Returns the raw JSON value of [verbosity].
734-
*
735-
* Unlike [verbosity], this method doesn't throw if the JSON field has an unexpected type.
736-
*/
737-
@JsonProperty("verbosity") @ExcludeMissing fun _verbosity(): JsonField<Verbosity> = verbosity
738-
739717
@JsonAnySetter
740718
private fun putAdditionalProperty(key: String, value: JsonValue) {
741719
additionalProperties.put(key, value)
@@ -805,7 +783,6 @@ private constructor(
805783
private var truncation: JsonField<Truncation> = JsonMissing.of()
806784
private var usage: JsonField<ResponseUsage> = JsonMissing.of()
807785
private var user: JsonField<String> = JsonMissing.of()
808-
private var verbosity: JsonField<Verbosity> = JsonMissing.of()
809786
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
810787

811788
@JvmSynthetic
@@ -839,7 +816,6 @@ private constructor(
839816
truncation = response.truncation
840817
usage = response.usage
841818
user = response.user
842-
verbosity = response.verbosity
843819
additionalProperties = response.additionalProperties.toMutableMap()
844820
}
845821

@@ -1641,25 +1617,6 @@ private constructor(
16411617
*/
16421618
@Deprecated("deprecated") fun user(user: JsonField<String>) = apply { this.user = user }
16431619

1644-
/**
1645-
* Constrains the verbosity of the model's response. Lower values will result in more
1646-
* concise responses, while higher values will result in more verbose responses. Currently
1647-
* supported values are `low`, `medium`, and `high`.
1648-
*/
1649-
fun verbosity(verbosity: Verbosity?) = verbosity(JsonField.ofNullable(verbosity))
1650-
1651-
/** Alias for calling [Builder.verbosity] with `verbosity.orElse(null)`. */
1652-
fun verbosity(verbosity: Optional<Verbosity>) = verbosity(verbosity.getOrNull())
1653-
1654-
/**
1655-
* Sets [Builder.verbosity] to an arbitrary JSON value.
1656-
*
1657-
* You should usually call [Builder.verbosity] with a well-typed [Verbosity] value instead.
1658-
* This method is primarily for setting the field to an undocumented or not yet supported
1659-
* value.
1660-
*/
1661-
fun verbosity(verbosity: JsonField<Verbosity>) = apply { this.verbosity = verbosity }
1662-
16631620
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
16641621
this.additionalProperties.clear()
16651622
putAllAdditionalProperties(additionalProperties)
@@ -1734,7 +1691,6 @@ private constructor(
17341691
truncation,
17351692
usage,
17361693
user,
1737-
verbosity,
17381694
additionalProperties.toMutableMap(),
17391695
)
17401696
}
@@ -1779,7 +1735,6 @@ private constructor(
17791735
truncation().ifPresent { it.validate() }
17801736
usage().ifPresent { it.validate() }
17811737
user()
1782-
verbosity().ifPresent { it.validate() }
17831738
validated = true
17841739
}
17851740

@@ -1826,8 +1781,7 @@ private constructor(
18261781
(if (topLogprobs.asKnown().isPresent) 1 else 0) +
18271782
(truncation.asKnown().getOrNull()?.validity() ?: 0) +
18281783
(usage.asKnown().getOrNull()?.validity() ?: 0) +
1829-
(if (user.asKnown().isPresent) 1 else 0) +
1830-
(verbosity.asKnown().getOrNull()?.validity() ?: 0)
1784+
(if (user.asKnown().isPresent) 1 else 0)
18311785

18321786
/** Details about why the response is incomplete. */
18331787
class IncompleteDetails
@@ -3046,158 +3000,20 @@ private constructor(
30463000
override fun toString() = value.toString()
30473001
}
30483002

3049-
/**
3050-
* Constrains the verbosity of the model's response. Lower values will result in more concise
3051-
* responses, while higher values will result in more verbose responses. Currently supported
3052-
* values are `low`, `medium`, and `high`.
3053-
*/
3054-
class Verbosity @JsonCreator private constructor(private val value: JsonField<String>) : Enum {
3055-
3056-
/**
3057-
* Returns this class instance's raw value.
3058-
*
3059-
* This is usually only useful if this instance was deserialized from data that doesn't
3060-
* match any known member, and you want to know that value. For example, if the SDK is on an
3061-
* older version than the API, then the API may respond with new members that the SDK is
3062-
* unaware of.
3063-
*/
3064-
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value
3065-
3066-
companion object {
3067-
3068-
@JvmField val LOW = of("low")
3069-
3070-
@JvmField val MEDIUM = of("medium")
3071-
3072-
@JvmField val HIGH = of("high")
3073-
3074-
@JvmStatic fun of(value: String) = Verbosity(JsonField.of(value))
3075-
}
3076-
3077-
/** An enum containing [Verbosity]'s known values. */
3078-
enum class Known {
3079-
LOW,
3080-
MEDIUM,
3081-
HIGH,
3082-
}
3083-
3084-
/**
3085-
* An enum containing [Verbosity]'s known values, as well as an [_UNKNOWN] member.
3086-
*
3087-
* An instance of [Verbosity] can contain an unknown value in a couple of cases:
3088-
* - It was deserialized from data that doesn't match any known member. For example, if the
3089-
* SDK is on an older version than the API, then the API may respond with new members that
3090-
* the SDK is unaware of.
3091-
* - It was constructed with an arbitrary value using the [of] method.
3092-
*/
3093-
enum class Value {
3094-
LOW,
3095-
MEDIUM,
3096-
HIGH,
3097-
/**
3098-
* An enum member indicating that [Verbosity] was instantiated with an unknown value.
3099-
*/
3100-
_UNKNOWN,
3101-
}
3102-
3103-
/**
3104-
* Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN]
3105-
* if the class was instantiated with an unknown value.
3106-
*
3107-
* Use the [known] method instead if you're certain the value is always known or if you want
3108-
* to throw for the unknown case.
3109-
*/
3110-
fun value(): Value =
3111-
when (this) {
3112-
LOW -> Value.LOW
3113-
MEDIUM -> Value.MEDIUM
3114-
HIGH -> Value.HIGH
3115-
else -> Value._UNKNOWN
3116-
}
3117-
3118-
/**
3119-
* Returns an enum member corresponding to this class instance's value.
3120-
*
3121-
* Use the [value] method instead if you're uncertain the value is always known and don't
3122-
* want to throw for the unknown case.
3123-
*
3124-
* @throws OpenAIInvalidDataException if this class instance's value is a not a known
3125-
* member.
3126-
*/
3127-
fun known(): Known =
3128-
when (this) {
3129-
LOW -> Known.LOW
3130-
MEDIUM -> Known.MEDIUM
3131-
HIGH -> Known.HIGH
3132-
else -> throw OpenAIInvalidDataException("Unknown Verbosity: $value")
3133-
}
3134-
3135-
/**
3136-
* Returns this class instance's primitive wire representation.
3137-
*
3138-
* This differs from the [toString] method because that method is primarily for debugging
3139-
* and generally doesn't throw.
3140-
*
3141-
* @throws OpenAIInvalidDataException if this class instance's value does not have the
3142-
* expected primitive type.
3143-
*/
3144-
fun asString(): String =
3145-
_value().asString().orElseThrow { OpenAIInvalidDataException("Value is not a String") }
3146-
3147-
private var validated: Boolean = false
3148-
3149-
fun validate(): Verbosity = apply {
3150-
if (validated) {
3151-
return@apply
3152-
}
3153-
3154-
known()
3155-
validated = true
3156-
}
3157-
3158-
fun isValid(): Boolean =
3159-
try {
3160-
validate()
3161-
true
3162-
} catch (e: OpenAIInvalidDataException) {
3163-
false
3164-
}
3165-
3166-
/**
3167-
* Returns a score indicating how many valid values are contained in this object
3168-
* recursively.
3169-
*
3170-
* Used for best match union deserialization.
3171-
*/
3172-
@JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1
3173-
3174-
override fun equals(other: Any?): Boolean {
3175-
if (this === other) {
3176-
return true
3177-
}
3178-
3179-
return /* spotless:off */ other is Verbosity && value == other.value /* spotless:on */
3180-
}
3181-
3182-
override fun hashCode() = value.hashCode()
3183-
3184-
override fun toString() = value.toString()
3185-
}
3186-
31873003
override fun equals(other: Any?): Boolean {
31883004
if (this === other) {
31893005
return true
31903006
}
31913007

3192-
return /* spotless:off */ other is Response && id == other.id && createdAt == other.createdAt && error == other.error && incompleteDetails == other.incompleteDetails && instructions == other.instructions && metadata == other.metadata && model == other.model && object_ == other.object_ && output == other.output && parallelToolCalls == other.parallelToolCalls && temperature == other.temperature && toolChoice == other.toolChoice && tools == other.tools && topP == other.topP && background == other.background && maxOutputTokens == other.maxOutputTokens && maxToolCalls == other.maxToolCalls && previousResponseId == other.previousResponseId && prompt == other.prompt && promptCacheKey == other.promptCacheKey && reasoning == other.reasoning && safetyIdentifier == other.safetyIdentifier && serviceTier == other.serviceTier && status == other.status && text == other.text && topLogprobs == other.topLogprobs && truncation == other.truncation && usage == other.usage && user == other.user && verbosity == other.verbosity && additionalProperties == other.additionalProperties /* spotless:on */
3008+
return /* spotless:off */ other is Response && id == other.id && createdAt == other.createdAt && error == other.error && incompleteDetails == other.incompleteDetails && instructions == other.instructions && metadata == other.metadata && model == other.model && object_ == other.object_ && output == other.output && parallelToolCalls == other.parallelToolCalls && temperature == other.temperature && toolChoice == other.toolChoice && tools == other.tools && topP == other.topP && background == other.background && maxOutputTokens == other.maxOutputTokens && maxToolCalls == other.maxToolCalls && previousResponseId == other.previousResponseId && prompt == other.prompt && promptCacheKey == other.promptCacheKey && reasoning == other.reasoning && safetyIdentifier == other.safetyIdentifier && serviceTier == other.serviceTier && status == other.status && text == other.text && topLogprobs == other.topLogprobs && truncation == other.truncation && usage == other.usage && user == other.user && additionalProperties == other.additionalProperties /* spotless:on */
31933009
}
31943010

31953011
/* spotless:off */
3196-
private val hashCode: Int by lazy { Objects.hash(id, createdAt, error, incompleteDetails, instructions, metadata, model, object_, output, parallelToolCalls, temperature, toolChoice, tools, topP, background, maxOutputTokens, maxToolCalls, previousResponseId, prompt, promptCacheKey, reasoning, safetyIdentifier, serviceTier, status, text, topLogprobs, truncation, usage, user, verbosity, additionalProperties) }
3012+
private val hashCode: Int by lazy { Objects.hash(id, createdAt, error, incompleteDetails, instructions, metadata, model, object_, output, parallelToolCalls, temperature, toolChoice, tools, topP, background, maxOutputTokens, maxToolCalls, previousResponseId, prompt, promptCacheKey, reasoning, safetyIdentifier, serviceTier, status, text, topLogprobs, truncation, usage, user, additionalProperties) }
31973013
/* spotless:on */
31983014

31993015
override fun hashCode(): Int = hashCode
32003016

32013017
override fun toString() =
3202-
"Response{id=$id, createdAt=$createdAt, error=$error, incompleteDetails=$incompleteDetails, instructions=$instructions, metadata=$metadata, model=$model, object_=$object_, output=$output, parallelToolCalls=$parallelToolCalls, temperature=$temperature, toolChoice=$toolChoice, tools=$tools, topP=$topP, background=$background, maxOutputTokens=$maxOutputTokens, maxToolCalls=$maxToolCalls, previousResponseId=$previousResponseId, prompt=$prompt, promptCacheKey=$promptCacheKey, reasoning=$reasoning, safetyIdentifier=$safetyIdentifier, serviceTier=$serviceTier, status=$status, text=$text, topLogprobs=$topLogprobs, truncation=$truncation, usage=$usage, user=$user, verbosity=$verbosity, additionalProperties=$additionalProperties}"
3018+
"Response{id=$id, createdAt=$createdAt, error=$error, incompleteDetails=$incompleteDetails, instructions=$instructions, metadata=$metadata, model=$model, object_=$object_, output=$output, parallelToolCalls=$parallelToolCalls, temperature=$temperature, toolChoice=$toolChoice, tools=$tools, topP=$topP, background=$background, maxOutputTokens=$maxOutputTokens, maxToolCalls=$maxToolCalls, previousResponseId=$previousResponseId, prompt=$prompt, promptCacheKey=$promptCacheKey, reasoning=$reasoning, safetyIdentifier=$safetyIdentifier, serviceTier=$serviceTier, status=$status, text=$text, topLogprobs=$topLogprobs, truncation=$truncation, usage=$usage, user=$user, additionalProperties=$additionalProperties}"
32033019
}

0 commit comments

Comments
 (0)