@@ -18,6 +18,7 @@ import com.openai.core.toImmutable
18
18
import com.openai.errors.OpenAIInvalidDataException
19
19
import java.util.Objects
20
20
import java.util.Optional
21
+ import kotlin.jvm.optionals.getOrNull
21
22
22
23
/* * Represents an `assistant` that can call the model and use tools. */
23
24
@NoAutoDetect
@@ -345,7 +346,7 @@ private constructor(
345
346
fun description (description : String? ) = description(JsonField .ofNullable(description))
346
347
347
348
/* * The description of the assistant. The maximum length is 512 characters. */
348
- fun description (description : Optional <String >) = description(description.orElse( null ))
349
+ fun description (description : Optional <String >) = description(description.getOrNull( ))
349
350
350
351
/* * The description of the assistant. The maximum length is 512 characters. */
351
352
fun description (description : JsonField <String >) = apply { this .description = description }
@@ -360,7 +361,7 @@ private constructor(
360
361
* The system instructions that the assistant uses. The maximum length is 256,000
361
362
* characters.
362
363
*/
363
- fun instructions (instructions : Optional <String >) = instructions(instructions.orElse( null ))
364
+ fun instructions (instructions : Optional <String >) = instructions(instructions.getOrNull( ))
364
365
365
366
/* *
366
367
* The system instructions that the assistant uses. The maximum length is 256,000
@@ -388,7 +389,7 @@ private constructor(
388
389
* Keys are strings with a maximum length of 64 characters. Values are strings with a
389
390
* maximum length of 512 characters.
390
391
*/
391
- fun metadata (metadata : Optional <Metadata >) = metadata(metadata.orElse( null ))
392
+ fun metadata (metadata : Optional <Metadata >) = metadata(metadata.getOrNull( ))
392
393
393
394
/* *
394
395
* Set of 16 key-value pairs that can be attached to an object. This can be useful for
@@ -420,7 +421,7 @@ private constructor(
420
421
fun name (name : String? ) = name(JsonField .ofNullable(name))
421
422
422
423
/* * The name of the assistant. The maximum length is 256 characters. */
423
- fun name (name : Optional <String >) = name(name.orElse( null ))
424
+ fun name (name : Optional <String >) = name(name.getOrNull( ))
424
425
425
426
/* * The name of the assistant. The maximum length is 256 characters. */
426
427
fun name (name : JsonField <String >) = apply { this .name = name }
@@ -521,7 +522,7 @@ private constructor(
521
522
* `max_tokens` or the conversation exceeded the max context length.
522
523
*/
523
524
fun responseFormat (responseFormat : Optional <AssistantResponseFormatOption >) =
524
- responseFormat(responseFormat.orElse( null ))
525
+ responseFormat(responseFormat.getOrNull( ))
525
526
526
527
/* *
527
528
* Specifies the format that the model must output. Compatible with
@@ -642,9 +643,7 @@ private constructor(
642
643
* output more random, while lower values like 0.2 will make it more focused and
643
644
* deterministic.
644
645
*/
645
- @Suppress(" USELESS_CAST" ) // See https://youtrack.jetbrains.com/issue/KT-74228
646
- fun temperature (temperature : Optional <Double >) =
647
- temperature(temperature.orElse(null ) as Double? )
646
+ fun temperature (temperature : Optional <Double >) = temperature(temperature.getOrNull())
648
647
649
648
/* *
650
649
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the
@@ -667,7 +666,7 @@ private constructor(
667
666
* while the `file_search` tool requires a list of vector store IDs.
668
667
*/
669
668
fun toolResources (toolResources : Optional <ToolResources >) =
670
- toolResources(toolResources.orElse( null ))
669
+ toolResources(toolResources.getOrNull( ))
671
670
672
671
/* *
673
672
* A set of resources that are used by the assistant's tools. The resources are specific to
@@ -703,8 +702,7 @@ private constructor(
703
702
*
704
703
* We generally recommend altering this or temperature but not both.
705
704
*/
706
- @Suppress(" USELESS_CAST" ) // See https://youtrack.jetbrains.com/issue/KT-74228
707
- fun topP (topP : Optional <Double >) = topP(topP.orElse(null ) as Double? )
705
+ fun topP (topP : Optional <Double >) = topP(topP.getOrNull())
708
706
709
707
/* *
710
708
* An alternative to sampling with temperature, called nucleus sampling, where the model
0 commit comments