Skip to content

Commit 5a22559

Browse files
committed
feat(ai): update generated types and methods
fix: move type: ignore[call-arg] to _get_api_list call site in to_markdown.py
1 parent 105f469 commit 5a22559

121 files changed

Lines changed: 4357 additions & 546 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/cloudflare/resources/ai/ai.py

Lines changed: 43 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
AsyncAuthorsResourceWithStreamingResponse,
2525
)
2626
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
2828
from ..._compat import cached_property
2929
from ...types.ai import ai_run_params
3030
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -110,7 +110,7 @@ def run(
110110
self,
111111
model_name: str,
112112
*,
113-
account_id: str,
113+
account_id: str | None = None,
114114
text: str,
115115
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
116116
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -148,7 +148,7 @@ def run(
148148
self,
149149
model_name: str,
150150
*,
151-
account_id: str,
151+
account_id: str | None = None,
152152
prompt: str,
153153
guidance: float | Omit = omit,
154154
height: int | Omit = omit,
@@ -220,7 +220,7 @@ def run(
220220
self,
221221
model_name: str,
222222
*,
223-
account_id: str,
223+
account_id: str | None = None,
224224
prompt: str,
225225
lang: str | Omit = omit,
226226
# 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(
262262
self,
263263
model_name: str,
264264
*,
265-
account_id: str,
265+
account_id: str | None = None,
266266
text: Union[str, SequenceNotStr[str]],
267267
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
268268
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -300,7 +300,7 @@ def run(
300300
self,
301301
model_name: str,
302302
*,
303-
account_id: str,
303+
account_id: str | None = None,
304304
audio: Iterable[float],
305305
source_lang: str | Omit = omit,
306306
target_lang: str | Omit = omit,
@@ -346,7 +346,7 @@ def run(
346346
self,
347347
model_name: str,
348348
*,
349-
account_id: str,
349+
account_id: str | None = None,
350350
image: Iterable[float],
351351
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
352352
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -385,7 +385,7 @@ def run(
385385
self,
386386
model_name: str,
387387
*,
388-
account_id: str,
388+
account_id: str | None = None,
389389
image: Iterable[float] | Omit = omit,
390390
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
391391
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -424,7 +424,7 @@ def run(
424424
self,
425425
model_name: str,
426426
*,
427-
account_id: str,
427+
account_id: str | None = None,
428428
prompt: str,
429429
frequency_penalty: float | Omit = omit,
430430
lora: str | Omit = omit,
@@ -503,7 +503,7 @@ def run(
503503
self,
504504
model_name: str,
505505
*,
506-
account_id: str,
506+
account_id: str | None = None,
507507
messages: Iterable[ai_run_params.MessagesMessage],
508508
frequency_penalty: float | Omit = omit,
509509
functions: Iterable[ai_run_params.MessagesFunction] | Omit = omit,
@@ -583,7 +583,7 @@ def run(
583583
self,
584584
model_name: str,
585585
*,
586-
account_id: str,
586+
account_id: str | None = None,
587587
target_lang: str,
588588
text: str,
589589
source_lang: str | Omit = omit,
@@ -628,7 +628,7 @@ def run(
628628
self,
629629
model_name: str,
630630
*,
631-
account_id: str,
631+
account_id: str | None = None,
632632
input_text: str,
633633
max_length: int | Omit = omit,
634634
# 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(
669669
self,
670670
model_name: str,
671671
*,
672-
account_id: str,
672+
account_id: str | None = None,
673673
image: Iterable[float],
674674
frequency_penalty: float | Omit = omit,
675675
max_tokens: int | Omit = omit,
@@ -744,7 +744,7 @@ def run(
744744
self,
745745
model_name: str,
746746
*,
747-
account_id: str,
747+
account_id: str | None = None,
748748
image: str,
749749
prompt: str,
750750
frequency_penalty: float | Omit = omit,
@@ -818,7 +818,7 @@ def run(
818818
self,
819819
model_name: str,
820820
*,
821-
account_id: str,
821+
account_id: str | None = None,
822822
image: str,
823823
messages: Iterable[ai_run_params.Variant13Message],
824824
frequency_penalty: float | Omit = omit,
@@ -892,7 +892,7 @@ def run(
892892
self,
893893
model_name: str,
894894
*,
895-
account_id: str,
895+
account_id: str | None = None,
896896
image: str | Omit = omit,
897897
text: SequenceNotStr[str] | Omit = omit,
898898
# 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(
926926
"""
927927
...
928928

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-
)
941929
def run(
942930
self,
943931
model_name: str,
944932
*,
945-
account_id: str,
933+
account_id: str | None = None,
946934
text: str | Union[str, SequenceNotStr[str]] | SequenceNotStr[str] | Omit = omit,
947935
prompt: str | Omit = omit,
948936
guidance: float | Omit = omit,
@@ -983,14 +971,18 @@ def run(
983971
extra_body: Body | None = None,
984972
timeout: float | httpx.Timeout | None | NotGiven = not_given,
985973
) -> Optional[AIRunResponse]:
974+
if account_id is None:
975+
account_id = self._client._get_account_id_path_param()
986976
if not account_id:
987977
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
988978
if not model_name:
989979
raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}")
990980
return cast(
991981
Optional[AIRunResponse],
992982
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+
),
994986
body=maybe_transform(
995987
{
996988
"text": text,
@@ -1088,7 +1080,7 @@ async def run(
10881080
self,
10891081
model_name: str,
10901082
*,
1091-
account_id: str,
1083+
account_id: str | None = None,
10921084
text: str,
10931085
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
10941086
# 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(
11261118
self,
11271119
model_name: str,
11281120
*,
1129-
account_id: str,
1121+
account_id: str | None = None,
11301122
prompt: str,
11311123
guidance: float | Omit = omit,
11321124
height: int | Omit = omit,
@@ -1198,7 +1190,7 @@ async def run(
11981190
self,
11991191
model_name: str,
12001192
*,
1201-
account_id: str,
1193+
account_id: str | None = None,
12021194
prompt: str,
12031195
lang: str | Omit = omit,
12041196
# 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(
12401232
self,
12411233
model_name: str,
12421234
*,
1243-
account_id: str,
1235+
account_id: str | None = None,
12441236
text: Union[str, SequenceNotStr[str]],
12451237
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
12461238
# 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(
12781270
self,
12791271
model_name: str,
12801272
*,
1281-
account_id: str,
1273+
account_id: str | None = None,
12821274
audio: Iterable[float],
12831275
source_lang: str | Omit = omit,
12841276
target_lang: str | Omit = omit,
@@ -1324,7 +1316,7 @@ async def run(
13241316
self,
13251317
model_name: str,
13261318
*,
1327-
account_id: str,
1319+
account_id: str | None = None,
13281320
image: Iterable[float],
13291321
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
13301322
# 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(
13631355
self,
13641356
model_name: str,
13651357
*,
1366-
account_id: str,
1358+
account_id: str | None = None,
13671359
image: Iterable[float] | Omit = omit,
13681360
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
13691361
# 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(
14021394
self,
14031395
model_name: str,
14041396
*,
1405-
account_id: str,
1397+
account_id: str | None = None,
14061398
prompt: str,
14071399
frequency_penalty: float | Omit = omit,
14081400
lora: str | Omit = omit,
@@ -1481,7 +1473,7 @@ async def run(
14811473
self,
14821474
model_name: str,
14831475
*,
1484-
account_id: str,
1476+
account_id: str | None = None,
14851477
messages: Iterable[ai_run_params.MessagesMessage],
14861478
frequency_penalty: float | Omit = omit,
14871479
functions: Iterable[ai_run_params.MessagesFunction] | Omit = omit,
@@ -1561,7 +1553,7 @@ async def run(
15611553
self,
15621554
model_name: str,
15631555
*,
1564-
account_id: str,
1556+
account_id: str | None = None,
15651557
target_lang: str,
15661558
text: str,
15671559
source_lang: str | Omit = omit,
@@ -1606,7 +1598,7 @@ async def run(
16061598
self,
16071599
model_name: str,
16081600
*,
1609-
account_id: str,
1601+
account_id: str | None = None,
16101602
input_text: str,
16111603
max_length: int | Omit = omit,
16121604
# 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(
16471639
self,
16481640
model_name: str,
16491641
*,
1650-
account_id: str,
1642+
account_id: str | None = None,
16511643
image: Iterable[float],
16521644
frequency_penalty: float | Omit = omit,
16531645
max_tokens: int | Omit = omit,
@@ -1722,7 +1714,7 @@ async def run(
17221714
self,
17231715
model_name: str,
17241716
*,
1725-
account_id: str,
1717+
account_id: str | None = None,
17261718
image: str,
17271719
prompt: str,
17281720
frequency_penalty: float | Omit = omit,
@@ -1796,7 +1788,7 @@ async def run(
17961788
self,
17971789
model_name: str,
17981790
*,
1799-
account_id: str,
1791+
account_id: str | None = None,
18001792
image: str,
18011793
messages: Iterable[ai_run_params.Variant13Message],
18021794
frequency_penalty: float | Omit = omit,
@@ -1870,7 +1862,7 @@ async def run(
18701862
self,
18711863
model_name: str,
18721864
*,
1873-
account_id: str,
1865+
account_id: str | None = None,
18741866
image: str | Omit = omit,
18751867
text: SequenceNotStr[str] | Omit = omit,
18761868
# 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(
19041896
"""
19051897
...
19061898

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-
)
19191899
async def run(
19201900
self,
19211901
model_name: str,
19221902
*,
1923-
account_id: str,
1903+
account_id: str | None = None,
19241904
text: str | Union[str, SequenceNotStr[str]] | SequenceNotStr[str] | Omit = omit,
19251905
prompt: str | Omit = omit,
19261906
guidance: float | Omit = omit,
@@ -1961,14 +1941,18 @@ async def run(
19611941
extra_body: Body | None = None,
19621942
timeout: float | httpx.Timeout | None | NotGiven = not_given,
19631943
) -> Optional[AIRunResponse]:
1944+
if account_id is None:
1945+
account_id = self._client._get_account_id_path_param()
19641946
if not account_id:
19651947
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
19661948
if not model_name:
19671949
raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}")
19681950
return cast(
19691951
Optional[AIRunResponse],
19701952
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+
),
19721956
body=await async_maybe_transform(
19731957
{
19741958
"text": text,

0 commit comments

Comments
 (0)