@@ -34,9 +34,9 @@ class ResponseOutputText
3434@JsonCreator(mode = JsonCreator .Mode .DISABLED )
3535private constructor (
3636 private val annotations: JsonField <List <Annotation >>,
37- private val logprobs: JsonField <List <Logprob >>,
3837 private val text: JsonField <String >,
3938 private val type: JsonValue ,
39+ private val logprobs: JsonField <List <Logprob >>,
4040 private val additionalProperties: MutableMap <String , JsonValue >,
4141) {
4242
@@ -45,12 +45,12 @@ private constructor(
4545 @JsonProperty(" annotations" )
4646 @ExcludeMissing
4747 annotations: JsonField <List <Annotation >> = JsonMissing .of(),
48+ @JsonProperty(" text" ) @ExcludeMissing text: JsonField <String > = JsonMissing .of(),
49+ @JsonProperty(" type" ) @ExcludeMissing type: JsonValue = JsonMissing .of(),
4850 @JsonProperty(" logprobs" )
4951 @ExcludeMissing
5052 logprobs: JsonField <List <Logprob >> = JsonMissing .of(),
51- @JsonProperty(" text" ) @ExcludeMissing text: JsonField <String > = JsonMissing .of(),
52- @JsonProperty(" type" ) @ExcludeMissing type: JsonValue = JsonMissing .of(),
53- ) : this (annotations, logprobs, text, type, mutableMapOf ())
53+ ) : this (annotations, text, type, logprobs, mutableMapOf ())
5454
5555 /* *
5656 * The annotations of the text output.
@@ -60,12 +60,6 @@ private constructor(
6060 */
6161 fun annotations (): List <Annotation > = annotations.getRequired(" annotations" )
6262
63- /* *
64- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
65- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
66- */
67- fun logprobs (): List <Logprob > = logprobs.getRequired(" logprobs" )
68-
6963 /* *
7064 * The text output from the model.
7165 *
@@ -87,6 +81,12 @@ private constructor(
8781 */
8882 @JsonProperty(" type" ) @ExcludeMissing fun _type (): JsonValue = type
8983
84+ /* *
85+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
86+ * server responded with an unexpected value).
87+ */
88+ fun logprobs (): Optional <List <Logprob >> = logprobs.getOptional(" logprobs" )
89+
9090 /* *
9191 * Returns the raw JSON value of [annotations].
9292 *
@@ -97,18 +97,18 @@ private constructor(
9797 fun _annotations (): JsonField <List <Annotation >> = annotations
9898
9999 /* *
100- * Returns the raw JSON value of [logprobs ].
100+ * Returns the raw JSON value of [text ].
101101 *
102- * Unlike [logprobs ], this method doesn't throw if the JSON field has an unexpected type.
102+ * Unlike [text ], this method doesn't throw if the JSON field has an unexpected type.
103103 */
104- @JsonProperty(" logprobs " ) @ExcludeMissing fun _logprobs (): JsonField <List < Logprob >> = logprobs
104+ @JsonProperty(" text " ) @ExcludeMissing fun _text (): JsonField <String > = text
105105
106106 /* *
107- * Returns the raw JSON value of [text ].
107+ * Returns the raw JSON value of [logprobs ].
108108 *
109- * Unlike [text ], this method doesn't throw if the JSON field has an unexpected type.
109+ * Unlike [logprobs ], this method doesn't throw if the JSON field has an unexpected type.
110110 */
111- @JsonProperty(" text " ) @ExcludeMissing fun _text (): JsonField <String > = text
111+ @JsonProperty(" logprobs " ) @ExcludeMissing fun _logprobs (): JsonField <List < Logprob >> = logprobs
112112
113113 @JsonAnySetter
114114 private fun putAdditionalProperty (key : String , value : JsonValue ) {
@@ -130,7 +130,6 @@ private constructor(
130130 * The following fields are required:
131131 * ```java
132132 * .annotations()
133- * .logprobs()
134133 * .text()
135134 * ```
136135 */
@@ -141,17 +140,17 @@ private constructor(
141140 class Builder internal constructor() {
142141
143142 private var annotations: JsonField <MutableList <Annotation >>? = null
144- private var logprobs: JsonField <MutableList <Logprob >>? = null
145143 private var text: JsonField <String >? = null
146144 private var type: JsonValue = JsonValue .from(" output_text" )
145+ private var logprobs: JsonField <MutableList <Logprob >>? = null
147146 private var additionalProperties: MutableMap <String , JsonValue > = mutableMapOf ()
148147
149148 @JvmSynthetic
150149 internal fun from (responseOutputText : ResponseOutputText ) = apply {
151150 annotations = responseOutputText.annotations.map { it.toMutableList() }
152- logprobs = responseOutputText.logprobs.map { it.toMutableList() }
153151 text = responseOutputText.text
154152 type = responseOutputText.type
153+ logprobs = responseOutputText.logprobs.map { it.toMutableList() }
155154 additionalProperties = responseOutputText.additionalProperties.toMutableMap()
156155 }
157156
@@ -200,31 +199,6 @@ private constructor(
200199 fun addAnnotation (filePath : Annotation .FilePath ) =
201200 addAnnotation(Annotation .ofFilePath(filePath))
202201
203- fun logprobs (logprobs : List <Logprob >) = logprobs(JsonField .of(logprobs))
204-
205- /* *
206- * Sets [Builder.logprobs] to an arbitrary JSON value.
207- *
208- * You should usually call [Builder.logprobs] with a well-typed `List<Logprob>` value
209- * instead. This method is primarily for setting the field to an undocumented or not yet
210- * supported value.
211- */
212- fun logprobs (logprobs : JsonField <List <Logprob >>) = apply {
213- this .logprobs = logprobs.map { it.toMutableList() }
214- }
215-
216- /* *
217- * Adds a single [Logprob] to [logprobs].
218- *
219- * @throws IllegalStateException if the field was previously set to a non-list.
220- */
221- fun addLogprob (logprob : Logprob ) = apply {
222- logprobs =
223- (logprobs ? : JsonField .of(mutableListOf ())).also {
224- checkKnown(" logprobs" , it).add(logprob)
225- }
226- }
227-
228202 /* * The text output from the model. */
229203 fun text (text : String ) = text(JsonField .of(text))
230204
@@ -250,6 +224,31 @@ private constructor(
250224 */
251225 fun type (type : JsonValue ) = apply { this .type = type }
252226
227+ fun logprobs (logprobs : List <Logprob >) = logprobs(JsonField .of(logprobs))
228+
229+ /* *
230+ * Sets [Builder.logprobs] to an arbitrary JSON value.
231+ *
232+ * You should usually call [Builder.logprobs] with a well-typed `List<Logprob>` value
233+ * instead. This method is primarily for setting the field to an undocumented or not yet
234+ * supported value.
235+ */
236+ fun logprobs (logprobs : JsonField <List <Logprob >>) = apply {
237+ this .logprobs = logprobs.map { it.toMutableList() }
238+ }
239+
240+ /* *
241+ * Adds a single [Logprob] to [logprobs].
242+ *
243+ * @throws IllegalStateException if the field was previously set to a non-list.
244+ */
245+ fun addLogprob (logprob : Logprob ) = apply {
246+ logprobs =
247+ (logprobs ? : JsonField .of(mutableListOf ())).also {
248+ checkKnown(" logprobs" , it).add(logprob)
249+ }
250+ }
251+
253252 fun additionalProperties (additionalProperties : Map <String , JsonValue >) = apply {
254253 this .additionalProperties.clear()
255254 putAllAdditionalProperties(additionalProperties)
@@ -277,7 +276,6 @@ private constructor(
277276 * The following fields are required:
278277 * ```java
279278 * .annotations()
280- * .logprobs()
281279 * .text()
282280 * ```
283281 *
@@ -286,9 +284,9 @@ private constructor(
286284 fun build (): ResponseOutputText =
287285 ResponseOutputText (
288286 checkRequired(" annotations" , annotations).map { it.toImmutable() },
289- checkRequired(" logprobs" , logprobs).map { it.toImmutable() },
290287 checkRequired(" text" , text),
291288 type,
289+ (logprobs ? : JsonMissing .of()).map { it.toImmutable() },
292290 additionalProperties.toMutableMap(),
293291 )
294292 }
@@ -301,13 +299,13 @@ private constructor(
301299 }
302300
303301 annotations().forEach { it.validate() }
304- logprobs().forEach { it.validate() }
305302 text()
306303 _type ().let {
307304 if (it != JsonValue .from(" output_text" )) {
308305 throw OpenAIInvalidDataException (" 'type' is invalid, received $it " )
309306 }
310307 }
308+ logprobs().ifPresent { it.forEach { it.validate() } }
311309 validated = true
312310 }
313311
@@ -327,9 +325,9 @@ private constructor(
327325 @JvmSynthetic
328326 internal fun validity (): Int =
329327 (annotations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ? : 0 ) +
330- (logprobs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ? : 0 ) +
331328 (if (text.asKnown().isPresent) 1 else 0 ) +
332- type.let { if (it == JsonValue .from(" output_text" )) 1 else 0 }
329+ type.let { if (it == JsonValue .from(" output_text" )) 1 else 0 } +
330+ (logprobs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ? : 0 )
333331
334332 /* * A citation to a file. */
335333 @JsonDeserialize(using = Annotation .Deserializer ::class )
@@ -2394,18 +2392,18 @@ private constructor(
23942392
23952393 return other is ResponseOutputText &&
23962394 annotations == other.annotations &&
2397- logprobs == other.logprobs &&
23982395 text == other.text &&
23992396 type == other.type &&
2397+ logprobs == other.logprobs &&
24002398 additionalProperties == other.additionalProperties
24012399 }
24022400
24032401 private val hashCode: Int by lazy {
2404- Objects .hash(annotations, logprobs, text, type, additionalProperties)
2402+ Objects .hash(annotations, text, type, logprobs , additionalProperties)
24052403 }
24062404
24072405 override fun hashCode (): Int = hashCode
24082406
24092407 override fun toString () =
2410- " ResponseOutputText{annotations=$annotations , logprobs= $logprobs , text=$text , type=$type , additionalProperties=$additionalProperties }"
2408+ " ResponseOutputText{annotations=$annotations , text=$text , type=$type , logprobs= $logprobs , additionalProperties=$additionalProperties }"
24112409}
0 commit comments