@@ -1017,14 +1017,7 @@ constructor(
1017
1017
* [model endpoint compatibility](https://platform.openai.com/docs/models#model-endpoint-compatibility)
1018
1018
* table for details on which models work with the Chat API.
1019
1019
*/
1020
- fun model (string : String ) = apply { this .model = Model .ofString(string) }
1021
-
1022
- /* *
1023
- * ID of the model to use. See the
1024
- * [model endpoint compatibility](https://platform.openai.com/docs/models#model-endpoint-compatibility)
1025
- * table for details on which models work with the Chat API.
1026
- */
1027
- fun model (chatModel : ChatModel ) = apply { this .model = Model .ofChatModel(chatModel) }
1020
+ fun model (value : String ) = apply { this .model = Model .of(value) }
1028
1021
1029
1022
/* *
1030
1023
* Parameters for audio output. Required when audio output is requested with `modalities:
@@ -1609,118 +1602,251 @@ constructor(
1609
1602
)
1610
1603
}
1611
1604
1612
- @JsonDeserialize(using = Model .Deserializer ::class )
1613
- @JsonSerialize(using = Model .Serializer ::class )
1614
1605
class Model
1606
+ @JsonCreator
1615
1607
private constructor (
1616
- private val string: String? = null ,
1617
- private val chatModel: ChatModel ? = null ,
1618
- private val _json : JsonValue ? = null ,
1619
- ) {
1608
+ private val value: JsonField <String >,
1609
+ ) : Enum {
1620
1610
1621
- private var validated : Boolean = false
1611
+ @com.fasterxml.jackson.annotation. JsonValue fun _value (): JsonField < String > = value
1622
1612
1623
- fun string (): Optional <String > = Optional .ofNullable(string)
1613
+ override fun equals (other : Any? ): Boolean {
1614
+ if (this == = other) {
1615
+ return true
1616
+ }
1624
1617
1625
- fun chatModel (): Optional <ChatModel > = Optional .ofNullable(chatModel)
1618
+ return /* spotless:off */ other is Model && this .value == other.value /* spotless:on */
1619
+ }
1626
1620
1627
- fun isString (): Boolean = string != null
1621
+ override fun hashCode () = value.hashCode()
1628
1622
1629
- fun isChatModel (): Boolean = chatModel != null
1623
+ override fun toString () = value.toString()
1630
1624
1631
- fun asString (): String = string.getOrThrow( " string " )
1625
+ companion object {
1632
1626
1633
- fun asChatModel (): ChatModel = chatModel.getOrThrow( " chatModel " )
1627
+ @JvmField val O1_PREVIEW = Model ( JsonField .of( " o1-preview " ) )
1634
1628
1635
- fun _json (): Optional < JsonValue > = Optional .ofNullable( _json )
1629
+ @JvmField val O1_PREVIEW_2024_09_12 = Model ( JsonField .of( " o1-preview-2024-09-12 " ) )
1636
1630
1637
- fun <T > accept (visitor : Visitor <T >): T {
1638
- return when {
1639
- string != null -> visitor.visitString(string)
1640
- chatModel != null -> visitor.visitChatModel(chatModel)
1641
- else -> visitor.unknown(_json )
1642
- }
1643
- }
1631
+ @JvmField val O1_MINI = Model (JsonField .of(" o1-mini" ))
1644
1632
1645
- fun validate (): Model = apply {
1646
- if (! validated) {
1647
- if (string == null && chatModel == null ) {
1648
- throw OpenAIInvalidDataException (" Unknown Model: $_json " )
1649
- }
1650
- validated = true
1651
- }
1652
- }
1633
+ @JvmField val O1_MINI_2024_09_12 = Model (JsonField .of(" o1-mini-2024-09-12" ))
1653
1634
1654
- override fun equals (other : Any? ): Boolean {
1655
- if (this == = other) {
1656
- return true
1657
- }
1635
+ @JvmField val GPT_4O = Model (JsonField .of(" gpt-4o" ))
1658
1636
1659
- return /* spotless:off */ other is Model && this .string == other.string && this .chatModel == other.chatModel /* spotless:on */
1660
- }
1637
+ @JvmField val GPT_4O_2024_08_06 = Model (JsonField .of(" gpt-4o-2024-08-06" ))
1661
1638
1662
- override fun hashCode (): Int {
1663
- return /* spotless:off */ Objects .hash(string, chatModel) /* spotless:on */
1664
- }
1639
+ @JvmField val GPT_4O_2024_05_13 = Model (JsonField .of(" gpt-4o-2024-05-13" ))
1665
1640
1666
- override fun toString (): String {
1667
- return when {
1668
- string != null -> " Model{string=$string }"
1669
- chatModel != null -> " Model{chatModel=$chatModel }"
1670
- _json != null -> " Model{_unknown=$_json }"
1671
- else -> throw IllegalStateException (" Invalid Model" )
1672
- }
1673
- }
1641
+ @JvmField val GPT_4O_REALTIME_PREVIEW = Model (JsonField .of(" gpt-4o-realtime-preview" ))
1674
1642
1675
- companion object {
1643
+ @JvmField
1644
+ val GPT_4O_REALTIME_PREVIEW_2024_10_01 =
1645
+ Model (JsonField .of(" gpt-4o-realtime-preview-2024-10-01" ))
1676
1646
1677
- @JvmStatic fun ofString ( string : String ) = Model (string = string )
1647
+ @JvmField val GPT_4O_AUDIO_PREVIEW = Model (JsonField .of( " gpt-4o-audio-preview " ) )
1678
1648
1679
- @JvmStatic fun ofChatModel (chatModel : ChatModel ) = Model (chatModel = chatModel)
1680
- }
1649
+ @JvmField
1650
+ val GPT_4O_AUDIO_PREVIEW_2024_10_01 =
1651
+ Model (JsonField .of(" gpt-4o-audio-preview-2024-10-01" ))
1681
1652
1682
- interface Visitor < out T > {
1653
+ @JvmField val CHATGPT_4O_LATEST = Model ( JsonField .of( " chatgpt-4o-latest " ))
1683
1654
1684
- fun visitString ( string : String ): T
1655
+ @JvmField val GPT_4O_MINI = Model ( JsonField .of( " gpt-4o-mini " ))
1685
1656
1686
- fun visitChatModel ( chatModel : ChatModel ): T
1657
+ @JvmField val GPT_4O_MINI_2024_07_18 = Model ( JsonField .of( " gpt-4o-mini-2024-07-18 " ))
1687
1658
1688
- fun unknown (json : JsonValue ? ): T {
1689
- throw OpenAIInvalidDataException (" Unknown Model: $json " )
1690
- }
1691
- }
1659
+ @JvmField val GPT_4_TURBO = Model (JsonField .of(" gpt-4-turbo" ))
1692
1660
1693
- class Deserializer : BaseDeserializer < Model >( Model : :class) {
1661
+ @JvmField val GPT_4_TURBO_2024_04_09 = Model ( JsonField .of( " gpt-4-turbo-2024-04-09 " ))
1694
1662
1695
- override fun ObjectCodec.deserialize (node : JsonNode ): Model {
1696
- val json = JsonValue .fromJsonNode(node)
1663
+ @JvmField val GPT_4_0125_PREVIEW = Model (JsonField .of(" gpt-4-0125-preview" ))
1697
1664
1698
- tryDeserialize(node, jacksonTypeRef<String >())?.let {
1699
- return Model (string = it, _json = json)
1700
- }
1701
- tryDeserialize(node, jacksonTypeRef<ChatModel >())?.let {
1702
- return Model (chatModel = it, _json = json)
1703
- }
1665
+ @JvmField val GPT_4_TURBO_PREVIEW = Model (JsonField .of(" gpt-4-turbo-preview" ))
1704
1666
1705
- return Model (_json = json)
1706
- }
1667
+ @JvmField val GPT_4_1106_PREVIEW = Model (JsonField .of(" gpt-4-1106-preview" ))
1668
+
1669
+ @JvmField val GPT_4_VISION_PREVIEW = Model (JsonField .of(" gpt-4-vision-preview" ))
1670
+
1671
+ @JvmField val GPT_4 = Model (JsonField .of(" gpt-4" ))
1672
+
1673
+ @JvmField val GPT_4_0314 = Model (JsonField .of(" gpt-4-0314" ))
1674
+
1675
+ @JvmField val GPT_4_0613 = Model (JsonField .of(" gpt-4-0613" ))
1676
+
1677
+ @JvmField val GPT_4_32K = Model (JsonField .of(" gpt-4-32k" ))
1678
+
1679
+ @JvmField val GPT_4_32K_0314 = Model (JsonField .of(" gpt-4-32k-0314" ))
1680
+
1681
+ @JvmField val GPT_4_32K_0613 = Model (JsonField .of(" gpt-4-32k-0613" ))
1682
+
1683
+ @JvmField val GPT_3_5_TURBO = Model (JsonField .of(" gpt-3.5-turbo" ))
1684
+
1685
+ @JvmField val GPT_3_5_TURBO_16K = Model (JsonField .of(" gpt-3.5-turbo-16k" ))
1686
+
1687
+ @JvmField val GPT_3_5_TURBO_0301 = Model (JsonField .of(" gpt-3.5-turbo-0301" ))
1688
+
1689
+ @JvmField val GPT_3_5_TURBO_0613 = Model (JsonField .of(" gpt-3.5-turbo-0613" ))
1690
+
1691
+ @JvmField val GPT_3_5_TURBO_1106 = Model (JsonField .of(" gpt-3.5-turbo-1106" ))
1692
+
1693
+ @JvmField val GPT_3_5_TURBO_0125 = Model (JsonField .of(" gpt-3.5-turbo-0125" ))
1694
+
1695
+ @JvmField val GPT_3_5_TURBO_16K_0613 = Model (JsonField .of(" gpt-3.5-turbo-16k-0613" ))
1696
+
1697
+ @JvmStatic fun of (value : String ) = Model (JsonField .of(value))
1707
1698
}
1708
1699
1709
- class Serializer : BaseSerializer <Model >(Model : :class) {
1700
+ enum class Known {
1701
+ O1_PREVIEW ,
1702
+ O1_PREVIEW_2024_09_12 ,
1703
+ O1_MINI ,
1704
+ O1_MINI_2024_09_12 ,
1705
+ GPT_4O ,
1706
+ GPT_4O_2024_08_06 ,
1707
+ GPT_4O_2024_05_13 ,
1708
+ GPT_4O_REALTIME_PREVIEW ,
1709
+ GPT_4O_REALTIME_PREVIEW_2024_10_01 ,
1710
+ GPT_4O_AUDIO_PREVIEW ,
1711
+ GPT_4O_AUDIO_PREVIEW_2024_10_01 ,
1712
+ CHATGPT_4O_LATEST ,
1713
+ GPT_4O_MINI ,
1714
+ GPT_4O_MINI_2024_07_18 ,
1715
+ GPT_4_TURBO ,
1716
+ GPT_4_TURBO_2024_04_09 ,
1717
+ GPT_4_0125_PREVIEW ,
1718
+ GPT_4_TURBO_PREVIEW ,
1719
+ GPT_4_1106_PREVIEW ,
1720
+ GPT_4_VISION_PREVIEW ,
1721
+ GPT_4 ,
1722
+ GPT_4_0314 ,
1723
+ GPT_4_0613 ,
1724
+ GPT_4_32K ,
1725
+ GPT_4_32K_0314 ,
1726
+ GPT_4_32K_0613 ,
1727
+ GPT_3_5_TURBO ,
1728
+ GPT_3_5_TURBO_16K ,
1729
+ GPT_3_5_TURBO_0301 ,
1730
+ GPT_3_5_TURBO_0613 ,
1731
+ GPT_3_5_TURBO_1106 ,
1732
+ GPT_3_5_TURBO_0125 ,
1733
+ GPT_3_5_TURBO_16K_0613 ,
1734
+ }
1710
1735
1711
- override fun serialize (
1712
- value : Model ,
1713
- generator : JsonGenerator ,
1714
- provider : SerializerProvider
1715
- ) {
1716
- when {
1717
- value.string != null -> generator.writeObject(value.string)
1718
- value.chatModel != null -> generator.writeObject(value.chatModel)
1719
- value._json != null -> generator.writeObject(value._json )
1720
- else -> throw IllegalStateException (" Invalid Model" )
1721
- }
1722
- }
1736
+ enum class Value {
1737
+ O1_PREVIEW ,
1738
+ O1_PREVIEW_2024_09_12 ,
1739
+ O1_MINI ,
1740
+ O1_MINI_2024_09_12 ,
1741
+ GPT_4O ,
1742
+ GPT_4O_2024_08_06 ,
1743
+ GPT_4O_2024_05_13 ,
1744
+ GPT_4O_REALTIME_PREVIEW ,
1745
+ GPT_4O_REALTIME_PREVIEW_2024_10_01 ,
1746
+ GPT_4O_AUDIO_PREVIEW ,
1747
+ GPT_4O_AUDIO_PREVIEW_2024_10_01 ,
1748
+ CHATGPT_4O_LATEST ,
1749
+ GPT_4O_MINI ,
1750
+ GPT_4O_MINI_2024_07_18 ,
1751
+ GPT_4_TURBO ,
1752
+ GPT_4_TURBO_2024_04_09 ,
1753
+ GPT_4_0125_PREVIEW ,
1754
+ GPT_4_TURBO_PREVIEW ,
1755
+ GPT_4_1106_PREVIEW ,
1756
+ GPT_4_VISION_PREVIEW ,
1757
+ GPT_4 ,
1758
+ GPT_4_0314 ,
1759
+ GPT_4_0613 ,
1760
+ GPT_4_32K ,
1761
+ GPT_4_32K_0314 ,
1762
+ GPT_4_32K_0613 ,
1763
+ GPT_3_5_TURBO ,
1764
+ GPT_3_5_TURBO_16K ,
1765
+ GPT_3_5_TURBO_0301 ,
1766
+ GPT_3_5_TURBO_0613 ,
1767
+ GPT_3_5_TURBO_1106 ,
1768
+ GPT_3_5_TURBO_0125 ,
1769
+ GPT_3_5_TURBO_16K_0613 ,
1770
+ _UNKNOWN ,
1723
1771
}
1772
+
1773
+ fun value (): Value =
1774
+ when (this ) {
1775
+ O1_PREVIEW -> Value .O1_PREVIEW
1776
+ O1_PREVIEW_2024_09_12 -> Value .O1_PREVIEW_2024_09_12
1777
+ O1_MINI -> Value .O1_MINI
1778
+ O1_MINI_2024_09_12 -> Value .O1_MINI_2024_09_12
1779
+ GPT_4O -> Value .GPT_4O
1780
+ GPT_4O_2024_08_06 -> Value .GPT_4O_2024_08_06
1781
+ GPT_4O_2024_05_13 -> Value .GPT_4O_2024_05_13
1782
+ GPT_4O_REALTIME_PREVIEW -> Value .GPT_4O_REALTIME_PREVIEW
1783
+ GPT_4O_REALTIME_PREVIEW_2024_10_01 -> Value .GPT_4O_REALTIME_PREVIEW_2024_10_01
1784
+ GPT_4O_AUDIO_PREVIEW -> Value .GPT_4O_AUDIO_PREVIEW
1785
+ GPT_4O_AUDIO_PREVIEW_2024_10_01 -> Value .GPT_4O_AUDIO_PREVIEW_2024_10_01
1786
+ CHATGPT_4O_LATEST -> Value .CHATGPT_4O_LATEST
1787
+ GPT_4O_MINI -> Value .GPT_4O_MINI
1788
+ GPT_4O_MINI_2024_07_18 -> Value .GPT_4O_MINI_2024_07_18
1789
+ GPT_4_TURBO -> Value .GPT_4_TURBO
1790
+ GPT_4_TURBO_2024_04_09 -> Value .GPT_4_TURBO_2024_04_09
1791
+ GPT_4_0125_PREVIEW -> Value .GPT_4_0125_PREVIEW
1792
+ GPT_4_TURBO_PREVIEW -> Value .GPT_4_TURBO_PREVIEW
1793
+ GPT_4_1106_PREVIEW -> Value .GPT_4_1106_PREVIEW
1794
+ GPT_4_VISION_PREVIEW -> Value .GPT_4_VISION_PREVIEW
1795
+ GPT_4 -> Value .GPT_4
1796
+ GPT_4_0314 -> Value .GPT_4_0314
1797
+ GPT_4_0613 -> Value .GPT_4_0613
1798
+ GPT_4_32K -> Value .GPT_4_32K
1799
+ GPT_4_32K_0314 -> Value .GPT_4_32K_0314
1800
+ GPT_4_32K_0613 -> Value .GPT_4_32K_0613
1801
+ GPT_3_5_TURBO -> Value .GPT_3_5_TURBO
1802
+ GPT_3_5_TURBO_16K -> Value .GPT_3_5_TURBO_16K
1803
+ GPT_3_5_TURBO_0301 -> Value .GPT_3_5_TURBO_0301
1804
+ GPT_3_5_TURBO_0613 -> Value .GPT_3_5_TURBO_0613
1805
+ GPT_3_5_TURBO_1106 -> Value .GPT_3_5_TURBO_1106
1806
+ GPT_3_5_TURBO_0125 -> Value .GPT_3_5_TURBO_0125
1807
+ GPT_3_5_TURBO_16K_0613 -> Value .GPT_3_5_TURBO_16K_0613
1808
+ else -> Value ._UNKNOWN
1809
+ }
1810
+
1811
+ fun known (): Known =
1812
+ when (this ) {
1813
+ O1_PREVIEW -> Known .O1_PREVIEW
1814
+ O1_PREVIEW_2024_09_12 -> Known .O1_PREVIEW_2024_09_12
1815
+ O1_MINI -> Known .O1_MINI
1816
+ O1_MINI_2024_09_12 -> Known .O1_MINI_2024_09_12
1817
+ GPT_4O -> Known .GPT_4O
1818
+ GPT_4O_2024_08_06 -> Known .GPT_4O_2024_08_06
1819
+ GPT_4O_2024_05_13 -> Known .GPT_4O_2024_05_13
1820
+ GPT_4O_REALTIME_PREVIEW -> Known .GPT_4O_REALTIME_PREVIEW
1821
+ GPT_4O_REALTIME_PREVIEW_2024_10_01 -> Known .GPT_4O_REALTIME_PREVIEW_2024_10_01
1822
+ GPT_4O_AUDIO_PREVIEW -> Known .GPT_4O_AUDIO_PREVIEW
1823
+ GPT_4O_AUDIO_PREVIEW_2024_10_01 -> Known .GPT_4O_AUDIO_PREVIEW_2024_10_01
1824
+ CHATGPT_4O_LATEST -> Known .CHATGPT_4O_LATEST
1825
+ GPT_4O_MINI -> Known .GPT_4O_MINI
1826
+ GPT_4O_MINI_2024_07_18 -> Known .GPT_4O_MINI_2024_07_18
1827
+ GPT_4_TURBO -> Known .GPT_4_TURBO
1828
+ GPT_4_TURBO_2024_04_09 -> Known .GPT_4_TURBO_2024_04_09
1829
+ GPT_4_0125_PREVIEW -> Known .GPT_4_0125_PREVIEW
1830
+ GPT_4_TURBO_PREVIEW -> Known .GPT_4_TURBO_PREVIEW
1831
+ GPT_4_1106_PREVIEW -> Known .GPT_4_1106_PREVIEW
1832
+ GPT_4_VISION_PREVIEW -> Known .GPT_4_VISION_PREVIEW
1833
+ GPT_4 -> Known .GPT_4
1834
+ GPT_4_0314 -> Known .GPT_4_0314
1835
+ GPT_4_0613 -> Known .GPT_4_0613
1836
+ GPT_4_32K -> Known .GPT_4_32K
1837
+ GPT_4_32K_0314 -> Known .GPT_4_32K_0314
1838
+ GPT_4_32K_0613 -> Known .GPT_4_32K_0613
1839
+ GPT_3_5_TURBO -> Known .GPT_3_5_TURBO
1840
+ GPT_3_5_TURBO_16K -> Known .GPT_3_5_TURBO_16K
1841
+ GPT_3_5_TURBO_0301 -> Known .GPT_3_5_TURBO_0301
1842
+ GPT_3_5_TURBO_0613 -> Known .GPT_3_5_TURBO_0613
1843
+ GPT_3_5_TURBO_1106 -> Known .GPT_3_5_TURBO_1106
1844
+ GPT_3_5_TURBO_0125 -> Known .GPT_3_5_TURBO_0125
1845
+ GPT_3_5_TURBO_16K_0613 -> Known .GPT_3_5_TURBO_16K_0613
1846
+ else -> throw OpenAIInvalidDataException (" Unknown Model: $value " )
1847
+ }
1848
+
1849
+ fun asString (): String = _value ().asStringOrThrow()
1724
1850
}
1725
1851
1726
1852
@JsonDeserialize(using = FunctionCall .Deserializer ::class )
0 commit comments