|
24 | 24 | AsyncAuthorsResourceWithStreamingResponse, |
25 | 25 | ) |
26 | 26 | from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given |
27 | | -from ..._utils import required_args, maybe_transform, async_maybe_transform |
| 27 | +from ..._utils import path_template, maybe_transform, async_maybe_transform |
28 | 28 | from ..._compat import cached_property |
29 | 29 | from ...types.ai import ai_run_params |
30 | 30 | from ..._resource import SyncAPIResource, AsyncAPIResource |
@@ -110,7 +110,7 @@ def run( |
110 | 110 | self, |
111 | 111 | model_name: str, |
112 | 112 | *, |
113 | | - account_id: str, |
| 113 | + account_id: str | None = None, |
114 | 114 | text: str, |
115 | 115 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
116 | 116 | # The extra values given here take precedence over values defined on the client or passed to this method. |
@@ -148,7 +148,7 @@ def run( |
148 | 148 | self, |
149 | 149 | model_name: str, |
150 | 150 | *, |
151 | | - account_id: str, |
| 151 | + account_id: str | None = None, |
152 | 152 | prompt: str, |
153 | 153 | guidance: float | Omit = omit, |
154 | 154 | height: int | Omit = omit, |
@@ -220,7 +220,7 @@ def run( |
220 | 220 | self, |
221 | 221 | model_name: str, |
222 | 222 | *, |
223 | | - account_id: str, |
| 223 | + account_id: str | None = None, |
224 | 224 | prompt: str, |
225 | 225 | lang: str | Omit = omit, |
226 | 226 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
@@ -262,7 +262,7 @@ def run( |
262 | 262 | self, |
263 | 263 | model_name: str, |
264 | 264 | *, |
265 | | - account_id: str, |
| 265 | + account_id: str | None = None, |
266 | 266 | text: Union[str, SequenceNotStr[str]], |
267 | 267 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
268 | 268 | # The extra values given here take precedence over values defined on the client or passed to this method. |
@@ -300,7 +300,7 @@ def run( |
300 | 300 | self, |
301 | 301 | model_name: str, |
302 | 302 | *, |
303 | | - account_id: str, |
| 303 | + account_id: str | None = None, |
304 | 304 | audio: Iterable[float], |
305 | 305 | source_lang: str | Omit = omit, |
306 | 306 | target_lang: str | Omit = omit, |
@@ -346,7 +346,7 @@ def run( |
346 | 346 | self, |
347 | 347 | model_name: str, |
348 | 348 | *, |
349 | | - account_id: str, |
| 349 | + account_id: str | None = None, |
350 | 350 | image: Iterable[float], |
351 | 351 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
352 | 352 | # The extra values given here take precedence over values defined on the client or passed to this method. |
@@ -385,7 +385,7 @@ def run( |
385 | 385 | self, |
386 | 386 | model_name: str, |
387 | 387 | *, |
388 | | - account_id: str, |
| 388 | + account_id: str | None = None, |
389 | 389 | image: Iterable[float] | Omit = omit, |
390 | 390 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
391 | 391 | # The extra values given here take precedence over values defined on the client or passed to this method. |
@@ -424,7 +424,7 @@ def run( |
424 | 424 | self, |
425 | 425 | model_name: str, |
426 | 426 | *, |
427 | | - account_id: str, |
| 427 | + account_id: str | None = None, |
428 | 428 | prompt: str, |
429 | 429 | frequency_penalty: float | Omit = omit, |
430 | 430 | lora: str | Omit = omit, |
@@ -503,7 +503,7 @@ def run( |
503 | 503 | self, |
504 | 504 | model_name: str, |
505 | 505 | *, |
506 | | - account_id: str, |
| 506 | + account_id: str | None = None, |
507 | 507 | messages: Iterable[ai_run_params.MessagesMessage], |
508 | 508 | frequency_penalty: float | Omit = omit, |
509 | 509 | functions: Iterable[ai_run_params.MessagesFunction] | Omit = omit, |
@@ -583,7 +583,7 @@ def run( |
583 | 583 | self, |
584 | 584 | model_name: str, |
585 | 585 | *, |
586 | | - account_id: str, |
| 586 | + account_id: str | None = None, |
587 | 587 | target_lang: str, |
588 | 588 | text: str, |
589 | 589 | source_lang: str | Omit = omit, |
@@ -628,7 +628,7 @@ def run( |
628 | 628 | self, |
629 | 629 | model_name: str, |
630 | 630 | *, |
631 | | - account_id: str, |
| 631 | + account_id: str | None = None, |
632 | 632 | input_text: str, |
633 | 633 | max_length: int | Omit = omit, |
634 | 634 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
@@ -669,7 +669,7 @@ def run( |
669 | 669 | self, |
670 | 670 | model_name: str, |
671 | 671 | *, |
672 | | - account_id: str, |
| 672 | + account_id: str | None = None, |
673 | 673 | image: Iterable[float], |
674 | 674 | frequency_penalty: float | Omit = omit, |
675 | 675 | max_tokens: int | Omit = omit, |
@@ -744,7 +744,7 @@ def run( |
744 | 744 | self, |
745 | 745 | model_name: str, |
746 | 746 | *, |
747 | | - account_id: str, |
| 747 | + account_id: str | None = None, |
748 | 748 | image: str, |
749 | 749 | prompt: str, |
750 | 750 | frequency_penalty: float | Omit = omit, |
@@ -818,7 +818,7 @@ def run( |
818 | 818 | self, |
819 | 819 | model_name: str, |
820 | 820 | *, |
821 | | - account_id: str, |
| 821 | + account_id: str | None = None, |
822 | 822 | image: str, |
823 | 823 | messages: Iterable[ai_run_params.Variant13Message], |
824 | 824 | frequency_penalty: float | Omit = omit, |
@@ -892,7 +892,7 @@ def run( |
892 | 892 | self, |
893 | 893 | model_name: str, |
894 | 894 | *, |
895 | | - account_id: str, |
| 895 | + account_id: str | None = None, |
896 | 896 | image: str | Omit = omit, |
897 | 897 | text: SequenceNotStr[str] | Omit = omit, |
898 | 898 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
@@ -926,23 +926,11 @@ def run( |
926 | 926 | """ |
927 | 927 | ... |
928 | 928 |
|
929 | | - @required_args( |
930 | | - ["account_id", "text"], |
931 | | - ["account_id", "prompt"], |
932 | | - ["account_id", "audio"], |
933 | | - ["account_id", "image"], |
934 | | - ["account_id"], |
935 | | - ["account_id", "messages"], |
936 | | - ["account_id", "target_lang", "text"], |
937 | | - ["account_id", "input_text"], |
938 | | - ["account_id", "image", "prompt"], |
939 | | - ["account_id", "image", "messages"], |
940 | | - ) |
941 | 929 | def run( |
942 | 930 | self, |
943 | 931 | model_name: str, |
944 | 932 | *, |
945 | | - account_id: str, |
| 933 | + account_id: str | None = None, |
946 | 934 | text: str | Union[str, SequenceNotStr[str]] | SequenceNotStr[str] | Omit = omit, |
947 | 935 | prompt: str | Omit = omit, |
948 | 936 | guidance: float | Omit = omit, |
@@ -983,14 +971,18 @@ def run( |
983 | 971 | extra_body: Body | None = None, |
984 | 972 | timeout: float | httpx.Timeout | None | NotGiven = not_given, |
985 | 973 | ) -> Optional[AIRunResponse]: |
| 974 | + if account_id is None: |
| 975 | + account_id = self._client._get_account_id_path_param() |
986 | 976 | if not account_id: |
987 | 977 | raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") |
988 | 978 | if not model_name: |
989 | 979 | raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}") |
990 | 980 | return cast( |
991 | 981 | Optional[AIRunResponse], |
992 | 982 | self._post( |
993 | | - f"/accounts/{account_id}/ai/run/{model_name}", |
| 983 | + path_template( |
| 984 | + "/accounts/{account_id}/ai/run/{model_name}", account_id=account_id, model_name=model_name |
| 985 | + ), |
994 | 986 | body=maybe_transform( |
995 | 987 | { |
996 | 988 | "text": text, |
@@ -1088,7 +1080,7 @@ async def run( |
1088 | 1080 | self, |
1089 | 1081 | model_name: str, |
1090 | 1082 | *, |
1091 | | - account_id: str, |
| 1083 | + account_id: str | None = None, |
1092 | 1084 | text: str, |
1093 | 1085 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
1094 | 1086 | # The extra values given here take precedence over values defined on the client or passed to this method. |
@@ -1126,7 +1118,7 @@ async def run( |
1126 | 1118 | self, |
1127 | 1119 | model_name: str, |
1128 | 1120 | *, |
1129 | | - account_id: str, |
| 1121 | + account_id: str | None = None, |
1130 | 1122 | prompt: str, |
1131 | 1123 | guidance: float | Omit = omit, |
1132 | 1124 | height: int | Omit = omit, |
@@ -1198,7 +1190,7 @@ async def run( |
1198 | 1190 | self, |
1199 | 1191 | model_name: str, |
1200 | 1192 | *, |
1201 | | - account_id: str, |
| 1193 | + account_id: str | None = None, |
1202 | 1194 | prompt: str, |
1203 | 1195 | lang: str | Omit = omit, |
1204 | 1196 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
@@ -1240,7 +1232,7 @@ async def run( |
1240 | 1232 | self, |
1241 | 1233 | model_name: str, |
1242 | 1234 | *, |
1243 | | - account_id: str, |
| 1235 | + account_id: str | None = None, |
1244 | 1236 | text: Union[str, SequenceNotStr[str]], |
1245 | 1237 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
1246 | 1238 | # The extra values given here take precedence over values defined on the client or passed to this method. |
@@ -1278,7 +1270,7 @@ async def run( |
1278 | 1270 | self, |
1279 | 1271 | model_name: str, |
1280 | 1272 | *, |
1281 | | - account_id: str, |
| 1273 | + account_id: str | None = None, |
1282 | 1274 | audio: Iterable[float], |
1283 | 1275 | source_lang: str | Omit = omit, |
1284 | 1276 | target_lang: str | Omit = omit, |
@@ -1324,7 +1316,7 @@ async def run( |
1324 | 1316 | self, |
1325 | 1317 | model_name: str, |
1326 | 1318 | *, |
1327 | | - account_id: str, |
| 1319 | + account_id: str | None = None, |
1328 | 1320 | image: Iterable[float], |
1329 | 1321 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
1330 | 1322 | # The extra values given here take precedence over values defined on the client or passed to this method. |
@@ -1363,7 +1355,7 @@ async def run( |
1363 | 1355 | self, |
1364 | 1356 | model_name: str, |
1365 | 1357 | *, |
1366 | | - account_id: str, |
| 1358 | + account_id: str | None = None, |
1367 | 1359 | image: Iterable[float] | Omit = omit, |
1368 | 1360 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
1369 | 1361 | # The extra values given here take precedence over values defined on the client or passed to this method. |
@@ -1402,7 +1394,7 @@ async def run( |
1402 | 1394 | self, |
1403 | 1395 | model_name: str, |
1404 | 1396 | *, |
1405 | | - account_id: str, |
| 1397 | + account_id: str | None = None, |
1406 | 1398 | prompt: str, |
1407 | 1399 | frequency_penalty: float | Omit = omit, |
1408 | 1400 | lora: str | Omit = omit, |
@@ -1481,7 +1473,7 @@ async def run( |
1481 | 1473 | self, |
1482 | 1474 | model_name: str, |
1483 | 1475 | *, |
1484 | | - account_id: str, |
| 1476 | + account_id: str | None = None, |
1485 | 1477 | messages: Iterable[ai_run_params.MessagesMessage], |
1486 | 1478 | frequency_penalty: float | Omit = omit, |
1487 | 1479 | functions: Iterable[ai_run_params.MessagesFunction] | Omit = omit, |
@@ -1561,7 +1553,7 @@ async def run( |
1561 | 1553 | self, |
1562 | 1554 | model_name: str, |
1563 | 1555 | *, |
1564 | | - account_id: str, |
| 1556 | + account_id: str | None = None, |
1565 | 1557 | target_lang: str, |
1566 | 1558 | text: str, |
1567 | 1559 | source_lang: str | Omit = omit, |
@@ -1606,7 +1598,7 @@ async def run( |
1606 | 1598 | self, |
1607 | 1599 | model_name: str, |
1608 | 1600 | *, |
1609 | | - account_id: str, |
| 1601 | + account_id: str | None = None, |
1610 | 1602 | input_text: str, |
1611 | 1603 | max_length: int | Omit = omit, |
1612 | 1604 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
@@ -1647,7 +1639,7 @@ async def run( |
1647 | 1639 | self, |
1648 | 1640 | model_name: str, |
1649 | 1641 | *, |
1650 | | - account_id: str, |
| 1642 | + account_id: str | None = None, |
1651 | 1643 | image: Iterable[float], |
1652 | 1644 | frequency_penalty: float | Omit = omit, |
1653 | 1645 | max_tokens: int | Omit = omit, |
@@ -1722,7 +1714,7 @@ async def run( |
1722 | 1714 | self, |
1723 | 1715 | model_name: str, |
1724 | 1716 | *, |
1725 | | - account_id: str, |
| 1717 | + account_id: str | None = None, |
1726 | 1718 | image: str, |
1727 | 1719 | prompt: str, |
1728 | 1720 | frequency_penalty: float | Omit = omit, |
@@ -1796,7 +1788,7 @@ async def run( |
1796 | 1788 | self, |
1797 | 1789 | model_name: str, |
1798 | 1790 | *, |
1799 | | - account_id: str, |
| 1791 | + account_id: str | None = None, |
1800 | 1792 | image: str, |
1801 | 1793 | messages: Iterable[ai_run_params.Variant13Message], |
1802 | 1794 | frequency_penalty: float | Omit = omit, |
@@ -1870,7 +1862,7 @@ async def run( |
1870 | 1862 | self, |
1871 | 1863 | model_name: str, |
1872 | 1864 | *, |
1873 | | - account_id: str, |
| 1865 | + account_id: str | None = None, |
1874 | 1866 | image: str | Omit = omit, |
1875 | 1867 | text: SequenceNotStr[str] | Omit = omit, |
1876 | 1868 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
@@ -1904,23 +1896,11 @@ async def run( |
1904 | 1896 | """ |
1905 | 1897 | ... |
1906 | 1898 |
|
1907 | | - @required_args( |
1908 | | - ["account_id", "text"], |
1909 | | - ["account_id", "prompt"], |
1910 | | - ["account_id", "audio"], |
1911 | | - ["account_id", "image"], |
1912 | | - ["account_id"], |
1913 | | - ["account_id", "messages"], |
1914 | | - ["account_id", "target_lang", "text"], |
1915 | | - ["account_id", "input_text"], |
1916 | | - ["account_id", "image", "prompt"], |
1917 | | - ["account_id", "image", "messages"], |
1918 | | - ) |
1919 | 1899 | async def run( |
1920 | 1900 | self, |
1921 | 1901 | model_name: str, |
1922 | 1902 | *, |
1923 | | - account_id: str, |
| 1903 | + account_id: str | None = None, |
1924 | 1904 | text: str | Union[str, SequenceNotStr[str]] | SequenceNotStr[str] | Omit = omit, |
1925 | 1905 | prompt: str | Omit = omit, |
1926 | 1906 | guidance: float | Omit = omit, |
@@ -1961,14 +1941,18 @@ async def run( |
1961 | 1941 | extra_body: Body | None = None, |
1962 | 1942 | timeout: float | httpx.Timeout | None | NotGiven = not_given, |
1963 | 1943 | ) -> Optional[AIRunResponse]: |
| 1944 | + if account_id is None: |
| 1945 | + account_id = self._client._get_account_id_path_param() |
1964 | 1946 | if not account_id: |
1965 | 1947 | raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") |
1966 | 1948 | if not model_name: |
1967 | 1949 | raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}") |
1968 | 1950 | return cast( |
1969 | 1951 | Optional[AIRunResponse], |
1970 | 1952 | await self._post( |
1971 | | - f"/accounts/{account_id}/ai/run/{model_name}", |
| 1953 | + path_template( |
| 1954 | + "/accounts/{account_id}/ai/run/{model_name}", account_id=account_id, model_name=model_name |
| 1955 | + ), |
1972 | 1956 | body=await async_maybe_transform( |
1973 | 1957 | { |
1974 | 1958 | "text": text, |
|
0 commit comments