@@ -263,6 +263,21 @@ private constructor(
263
263
fun addSummaryTextContent (text : String ) =
264
264
addContent(SummaryTextContent .builder().text(text).build())
265
265
266
+ /* * Alias for calling [addContent] with `Content.ofReasoningText(reasoningText)`. */
267
+ fun addContent (reasoningText : Content .ReasoningText ) =
268
+ addContent(Content .ofReasoningText(reasoningText))
269
+
270
+ /* *
271
+ * Alias for calling [addContent] with the following:
272
+ * ```java
273
+ * Content.ReasoningText.builder()
274
+ * .text(text)
275
+ * .build()
276
+ * ```
277
+ */
278
+ fun addReasoningTextContent (text : String ) =
279
+ addContent(Content .ReasoningText .builder().text(text).build())
280
+
266
281
/* * Alias for calling [addContent] with `Content.ofRefusal(refusal)`. */
267
282
fun addContent (refusal : ResponseOutputRefusal ) = addContent(Content .ofRefusal(refusal))
268
283
@@ -437,6 +452,7 @@ private constructor(
437
452
private val outputText: ResponseOutputText ? = null ,
438
453
private val text: TextContent ? = null ,
439
454
private val summaryText: SummaryTextContent ? = null ,
455
+ private val reasoningText: ReasoningText ? = null ,
440
456
private val refusal: ResponseOutputRefusal ? = null ,
441
457
private val inputImage: ResponseInputImage ? = null ,
442
458
private val computerScreenshot: ComputerScreenshotContent ? = null ,
@@ -456,6 +472,9 @@ private constructor(
456
472
/* * A summary text from the model. */
457
473
fun summaryText (): Optional <SummaryTextContent > = Optional .ofNullable(summaryText)
458
474
475
+ /* * Reasoning text from the model. */
476
+ fun reasoningText (): Optional <ReasoningText > = Optional .ofNullable(reasoningText)
477
+
459
478
/* * A refusal from the model. */
460
479
fun refusal (): Optional <ResponseOutputRefusal > = Optional .ofNullable(refusal)
461
480
@@ -480,6 +499,8 @@ private constructor(
480
499
481
500
fun isSummaryText (): Boolean = summaryText != null
482
501
502
+ fun isReasoningText (): Boolean = reasoningText != null
503
+
483
504
fun isRefusal (): Boolean = refusal != null
484
505
485
506
fun isInputImage (): Boolean = inputImage != null
@@ -500,6 +521,9 @@ private constructor(
500
521
/* * A summary text from the model. */
501
522
fun asSummaryText (): SummaryTextContent = summaryText.getOrThrow(" summaryText" )
502
523
524
+ /* * Reasoning text from the model. */
525
+ fun asReasoningText (): ReasoningText = reasoningText.getOrThrow(" reasoningText" )
526
+
503
527
/* * A refusal from the model. */
504
528
fun asRefusal (): ResponseOutputRefusal = refusal.getOrThrow(" refusal" )
505
529
@@ -524,6 +548,7 @@ private constructor(
524
548
outputText != null -> visitor.visitOutputText(outputText)
525
549
text != null -> visitor.visitText(text)
526
550
summaryText != null -> visitor.visitSummaryText(summaryText)
551
+ reasoningText != null -> visitor.visitReasoningText(reasoningText)
527
552
refusal != null -> visitor.visitRefusal(refusal)
528
553
inputImage != null -> visitor.visitInputImage(inputImage)
529
554
computerScreenshot != null -> visitor.visitComputerScreenshot(computerScreenshot)
@@ -556,6 +581,10 @@ private constructor(
556
581
summaryText.validate()
557
582
}
558
583
584
+ override fun visitReasoningText (reasoningText : ReasoningText ) {
585
+ reasoningText.validate()
586
+ }
587
+
559
588
override fun visitRefusal (refusal : ResponseOutputRefusal ) {
560
589
refusal.validate()
561
590
}
@@ -606,6 +635,9 @@ private constructor(
606
635
override fun visitSummaryText (summaryText : SummaryTextContent ) =
607
636
summaryText.validity()
608
637
638
+ override fun visitReasoningText (reasoningText : ReasoningText ) =
639
+ reasoningText.validity()
640
+
609
641
override fun visitRefusal (refusal : ResponseOutputRefusal ) = refusal.validity()
610
642
611
643
override fun visitInputImage (inputImage : ResponseInputImage ) =
@@ -631,6 +663,7 @@ private constructor(
631
663
outputText == other.outputText &&
632
664
text == other.text &&
633
665
summaryText == other.summaryText &&
666
+ reasoningText == other.reasoningText &&
634
667
refusal == other.refusal &&
635
668
inputImage == other.inputImage &&
636
669
computerScreenshot == other.computerScreenshot &&
@@ -643,6 +676,7 @@ private constructor(
643
676
outputText,
644
677
text,
645
678
summaryText,
679
+ reasoningText,
646
680
refusal,
647
681
inputImage,
648
682
computerScreenshot,
@@ -655,6 +689,7 @@ private constructor(
655
689
outputText != null -> " Content{outputText=$outputText }"
656
690
text != null -> " Content{text=$text }"
657
691
summaryText != null -> " Content{summaryText=$summaryText }"
692
+ reasoningText != null -> " Content{reasoningText=$reasoningText }"
658
693
refusal != null -> " Content{refusal=$refusal }"
659
694
inputImage != null -> " Content{inputImage=$inputImage }"
660
695
computerScreenshot != null -> " Content{computerScreenshot=$computerScreenshot }"
@@ -680,6 +715,11 @@ private constructor(
680
715
@JvmStatic
681
716
fun ofSummaryText (summaryText : SummaryTextContent ) = Content (summaryText = summaryText)
682
717
718
+ /* * Reasoning text from the model. */
719
+ @JvmStatic
720
+ fun ofReasoningText (reasoningText : ReasoningText ) =
721
+ Content (reasoningText = reasoningText)
722
+
683
723
/* * A refusal from the model. */
684
724
@JvmStatic fun ofRefusal (refusal : ResponseOutputRefusal ) = Content (refusal = refusal)
685
725
@@ -717,6 +757,9 @@ private constructor(
717
757
/* * A summary text from the model. */
718
758
fun visitSummaryText (summaryText : SummaryTextContent ): T
719
759
760
+ /* * Reasoning text from the model. */
761
+ fun visitReasoningText (reasoningText : ReasoningText ): T
762
+
720
763
/* * A refusal from the model. */
721
764
fun visitRefusal (refusal : ResponseOutputRefusal ): T
722
765
@@ -774,6 +817,11 @@ private constructor(
774
817
Content (summaryText = it, _json = json)
775
818
} ? : Content (_json = json)
776
819
}
820
+ " reasoning_text" -> {
821
+ return tryDeserialize(node, jacksonTypeRef<ReasoningText >())?.let {
822
+ Content (reasoningText = it, _json = json)
823
+ } ? : Content (_json = json)
824
+ }
777
825
" refusal" -> {
778
826
return tryDeserialize(node, jacksonTypeRef<ResponseOutputRefusal >())?.let {
779
827
Content (refusal = it, _json = json)
@@ -812,6 +860,7 @@ private constructor(
812
860
value.outputText != null -> generator.writeObject(value.outputText)
813
861
value.text != null -> generator.writeObject(value.text)
814
862
value.summaryText != null -> generator.writeObject(value.summaryText)
863
+ value.reasoningText != null -> generator.writeObject(value.reasoningText)
815
864
value.refusal != null -> generator.writeObject(value.refusal)
816
865
value.inputImage != null -> generator.writeObject(value.inputImage)
817
866
value.computerScreenshot != null ->
@@ -822,6 +871,210 @@ private constructor(
822
871
}
823
872
}
824
873
}
874
+
875
+ /* * Reasoning text from the model. */
876
+ class ReasoningText
877
+ private constructor (
878
+ private val text: JsonField <String >,
879
+ private val type: JsonValue ,
880
+ private val additionalProperties: MutableMap <String , JsonValue >,
881
+ ) {
882
+
883
+ @JsonCreator
884
+ private constructor (
885
+ @JsonProperty(" text" ) @ExcludeMissing text: JsonField <String > = JsonMissing .of(),
886
+ @JsonProperty(" type" ) @ExcludeMissing type: JsonValue = JsonMissing .of(),
887
+ ) : this (text, type, mutableMapOf ())
888
+
889
+ /* *
890
+ * The reasoning text from the model.
891
+ *
892
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
893
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected
894
+ * value).
895
+ */
896
+ fun text (): String = text.getRequired(" text" )
897
+
898
+ /* *
899
+ * The type of the reasoning text. Always `reasoning_text`.
900
+ *
901
+ * Expected to always return the following:
902
+ * ```java
903
+ * JsonValue.from("reasoning_text")
904
+ * ```
905
+ *
906
+ * However, this method can be useful for debugging and logging (e.g. if the server
907
+ * responded with an unexpected value).
908
+ */
909
+ @JsonProperty(" type" ) @ExcludeMissing fun _type (): JsonValue = type
910
+
911
+ /* *
912
+ * Returns the raw JSON value of [text].
913
+ *
914
+ * Unlike [text], this method doesn't throw if the JSON field has an unexpected type.
915
+ */
916
+ @JsonProperty(" text" ) @ExcludeMissing fun _text (): JsonField <String > = text
917
+
918
+ @JsonAnySetter
919
+ private fun putAdditionalProperty (key : String , value : JsonValue ) {
920
+ additionalProperties.put(key, value)
921
+ }
922
+
923
+ @JsonAnyGetter
924
+ @ExcludeMissing
925
+ fun _additionalProperties (): Map <String , JsonValue > =
926
+ Collections .unmodifiableMap(additionalProperties)
927
+
928
+ fun toBuilder () = Builder ().from(this )
929
+
930
+ companion object {
931
+
932
+ /* *
933
+ * Returns a mutable builder for constructing an instance of [ReasoningText].
934
+ *
935
+ * The following fields are required:
936
+ * ```java
937
+ * .text()
938
+ * ```
939
+ */
940
+ @JvmStatic fun builder () = Builder ()
941
+ }
942
+
943
+ /* * A builder for [ReasoningText]. */
944
+ class Builder internal constructor() {
945
+
946
+ private var text: JsonField <String >? = null
947
+ private var type: JsonValue = JsonValue .from(" reasoning_text" )
948
+ private var additionalProperties: MutableMap <String , JsonValue > = mutableMapOf ()
949
+
950
+ @JvmSynthetic
951
+ internal fun from (reasoningText : ReasoningText ) = apply {
952
+ text = reasoningText.text
953
+ type = reasoningText.type
954
+ additionalProperties = reasoningText.additionalProperties.toMutableMap()
955
+ }
956
+
957
+ /* * The reasoning text from the model. */
958
+ fun text (text : String ) = text(JsonField .of(text))
959
+
960
+ /* *
961
+ * Sets [Builder.text] to an arbitrary JSON value.
962
+ *
963
+ * You should usually call [Builder.text] with a well-typed [String] value instead.
964
+ * This method is primarily for setting the field to an undocumented or not yet
965
+ * supported value.
966
+ */
967
+ fun text (text : JsonField <String >) = apply { this .text = text }
968
+
969
+ /* *
970
+ * Sets the field to an arbitrary JSON value.
971
+ *
972
+ * It is usually unnecessary to call this method because the field defaults to the
973
+ * following:
974
+ * ```java
975
+ * JsonValue.from("reasoning_text")
976
+ * ```
977
+ *
978
+ * This method is primarily for setting the field to an undocumented or not yet
979
+ * supported value.
980
+ */
981
+ fun type (type : JsonValue ) = apply { this .type = type }
982
+
983
+ fun additionalProperties (additionalProperties : Map <String , JsonValue >) = apply {
984
+ this .additionalProperties.clear()
985
+ putAllAdditionalProperties(additionalProperties)
986
+ }
987
+
988
+ fun putAdditionalProperty (key : String , value : JsonValue ) = apply {
989
+ additionalProperties.put(key, value)
990
+ }
991
+
992
+ fun putAllAdditionalProperties (additionalProperties : Map <String , JsonValue >) =
993
+ apply {
994
+ this .additionalProperties.putAll(additionalProperties)
995
+ }
996
+
997
+ fun removeAdditionalProperty (key : String ) = apply {
998
+ additionalProperties.remove(key)
999
+ }
1000
+
1001
+ fun removeAllAdditionalProperties (keys : Set <String >) = apply {
1002
+ keys.forEach(::removeAdditionalProperty)
1003
+ }
1004
+
1005
+ /* *
1006
+ * Returns an immutable instance of [ReasoningText].
1007
+ *
1008
+ * Further updates to this [Builder] will not mutate the returned instance.
1009
+ *
1010
+ * The following fields are required:
1011
+ * ```java
1012
+ * .text()
1013
+ * ```
1014
+ *
1015
+ * @throws IllegalStateException if any required field is unset.
1016
+ */
1017
+ fun build (): ReasoningText =
1018
+ ReasoningText (
1019
+ checkRequired(" text" , text),
1020
+ type,
1021
+ additionalProperties.toMutableMap(),
1022
+ )
1023
+ }
1024
+
1025
+ private var validated: Boolean = false
1026
+
1027
+ fun validate (): ReasoningText = apply {
1028
+ if (validated) {
1029
+ return @apply
1030
+ }
1031
+
1032
+ text()
1033
+ _type ().let {
1034
+ if (it != JsonValue .from(" reasoning_text" )) {
1035
+ throw OpenAIInvalidDataException (" 'type' is invalid, received $it " )
1036
+ }
1037
+ }
1038
+ validated = true
1039
+ }
1040
+
1041
+ fun isValid (): Boolean =
1042
+ try {
1043
+ validate()
1044
+ true
1045
+ } catch (e: OpenAIInvalidDataException ) {
1046
+ false
1047
+ }
1048
+
1049
+ /* *
1050
+ * Returns a score indicating how many valid values are contained in this object
1051
+ * recursively.
1052
+ *
1053
+ * Used for best match union deserialization.
1054
+ */
1055
+ @JvmSynthetic
1056
+ internal fun validity (): Int =
1057
+ (if (text.asKnown().isPresent) 1 else 0 ) +
1058
+ type.let { if (it == JsonValue .from(" reasoning_text" )) 1 else 0 }
1059
+
1060
+ override fun equals (other : Any? ): Boolean {
1061
+ if (this == = other) {
1062
+ return true
1063
+ }
1064
+
1065
+ return other is ReasoningText &&
1066
+ text == other.text &&
1067
+ type == other.type &&
1068
+ additionalProperties == other.additionalProperties
1069
+ }
1070
+
1071
+ private val hashCode: Int by lazy { Objects .hash(text, type, additionalProperties) }
1072
+
1073
+ override fun hashCode (): Int = hashCode
1074
+
1075
+ override fun toString () =
1076
+ " ReasoningText{text=$text , type=$type , additionalProperties=$additionalProperties }"
1077
+ }
825
1078
}
826
1079
827
1080
/* *
0 commit comments