@@ -21,7 +21,7 @@ import java.util.Objects
21
21
import java.util.Optional
22
22
import kotlin.jvm.optionals.getOrNull
23
23
24
- /* * Update a conversation's metadata with the given ID. */
24
+ /* * Update a conversation */
25
25
class ConversationUpdateParams
26
26
private constructor (
27
27
private val conversationId: String? ,
@@ -35,13 +35,15 @@ private constructor(
35
35
/* *
36
36
* Set of 16 key-value pairs that can be attached to an object. This can be useful for storing
37
37
* additional information about the object in a structured format, and querying for objects via
38
- * API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are
39
- * strings with a maximum length of 512 characters.
38
+ * API or the dashboard.
40
39
*
41
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
42
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
40
+ * Keys are strings with a maximum length of 64 characters. Values are strings with a maximum
41
+ * length of 512 characters.
42
+ *
43
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
44
+ * server responded with an unexpected value).
43
45
*/
44
- fun metadata (): Metadata = body.metadata()
46
+ fun metadata (): Optional < Metadata > = body.metadata()
45
47
46
48
/* *
47
49
* Returns the raw JSON value of [metadata].
@@ -107,10 +109,15 @@ private constructor(
107
109
/* *
108
110
* Set of 16 key-value pairs that can be attached to an object. This can be useful for
109
111
* storing additional information about the object in a structured format, and querying for
110
- * objects via API or the dashboard. Keys are strings with a maximum length of 64
111
- * characters. Values are strings with a maximum length of 512 characters.
112
+ * objects via API or the dashboard.
113
+ *
114
+ * Keys are strings with a maximum length of 64 characters. Values are strings with a
115
+ * maximum length of 512 characters.
112
116
*/
113
- fun metadata (metadata : Metadata ) = apply { body.metadata(metadata) }
117
+ fun metadata (metadata : Metadata ? ) = apply { body.metadata(metadata) }
118
+
119
+ /* * Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */
120
+ fun metadata (metadata : Optional <Metadata >) = metadata(metadata.getOrNull())
114
121
115
122
/* *
116
123
* Sets [Builder.metadata] to an arbitrary JSON value.
@@ -287,13 +294,15 @@ private constructor(
287
294
/* *
288
295
* Set of 16 key-value pairs that can be attached to an object. This can be useful for
289
296
* storing additional information about the object in a structured format, and querying for
290
- * objects via API or the dashboard. Keys are strings with a maximum length of 64
291
- * characters. Values are strings with a maximum length of 512 characters.
297
+ * objects via API or the dashboard.
298
+ *
299
+ * Keys are strings with a maximum length of 64 characters. Values are strings with a
300
+ * maximum length of 512 characters.
292
301
*
293
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
294
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
302
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
303
+ * server responded with an unexpected value).
295
304
*/
296
- fun metadata (): Metadata = metadata.getRequired (" metadata" )
305
+ fun metadata (): Optional < Metadata > = metadata.getOptional (" metadata" )
297
306
298
307
/* *
299
308
* Returns the raw JSON value of [metadata].
@@ -342,10 +351,15 @@ private constructor(
342
351
/* *
343
352
* Set of 16 key-value pairs that can be attached to an object. This can be useful for
344
353
* storing additional information about the object in a structured format, and querying
345
- * for objects via API or the dashboard. Keys are strings with a maximum length of 64
346
- * characters. Values are strings with a maximum length of 512 characters.
354
+ * for objects via API or the dashboard.
355
+ *
356
+ * Keys are strings with a maximum length of 64 characters. Values are strings with a
357
+ * maximum length of 512 characters.
347
358
*/
348
- fun metadata (metadata : Metadata ) = metadata(JsonField .of(metadata))
359
+ fun metadata (metadata : Metadata ? ) = metadata(JsonField .ofNullable(metadata))
360
+
361
+ /* * Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */
362
+ fun metadata (metadata : Optional <Metadata >) = metadata(metadata.getOrNull())
349
363
350
364
/* *
351
365
* Sets [Builder.metadata] to an arbitrary JSON value.
@@ -398,7 +412,7 @@ private constructor(
398
412
return @apply
399
413
}
400
414
401
- metadata().validate()
415
+ metadata().ifPresent { it. validate() }
402
416
validated = true
403
417
}
404
418
@@ -440,8 +454,10 @@ private constructor(
440
454
/* *
441
455
* Set of 16 key-value pairs that can be attached to an object. This can be useful for storing
442
456
* additional information about the object in a structured format, and querying for objects via
443
- * API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are
444
- * strings with a maximum length of 512 characters.
457
+ * API or the dashboard.
458
+ *
459
+ * Keys are strings with a maximum length of 64 characters. Values are strings with a maximum
460
+ * length of 512 characters.
445
461
*/
446
462
class Metadata
447
463
@JsonCreator
0 commit comments