Skip to content

Commit efafb96

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): update via SDK Studio (#1181)
1 parent c08fb0d commit efafb96

File tree

4 files changed

+648
-58
lines changed

4 files changed

+648
-58
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 1256
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9f6e9da01b27f4f387991ca14ecafe0c42a356cc3c47b269e5f8b4f6cd0ed700.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-cb76af21f6fcf485b7e41586c3076cd45d25d6d04971c77ec814523b894dcb97.yml

src/cloudflare/resources/workers/ai/ai.py

+126-8
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,64 @@ def run(
320320
model_name: str,
321321
*,
322322
account_id: str,
323+
prompt: str,
324+
frequency_penalty: float | NotGiven = NOT_GIVEN,
323325
lora: str | NotGiven = NOT_GIVEN,
324326
max_tokens: int | NotGiven = NOT_GIVEN,
325-
messages: Iterable[ai_run_params.TextGenerationMessage] | NotGiven = NOT_GIVEN,
326-
prompt: str | NotGiven = NOT_GIVEN,
327+
presence_penalty: float | NotGiven = NOT_GIVEN,
327328
raw: bool | NotGiven = NOT_GIVEN,
329+
repetition_penalty: float | NotGiven = NOT_GIVEN,
330+
seed: int | NotGiven = NOT_GIVEN,
328331
stream: bool | NotGiven = NOT_GIVEN,
332+
temperature: float | NotGiven = NOT_GIVEN,
333+
top_k: int | NotGiven = NOT_GIVEN,
334+
top_p: float | NotGiven = NOT_GIVEN,
335+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
336+
# The extra values given here take precedence over values defined on the client or passed to this method.
337+
extra_headers: Headers | None = None,
338+
extra_query: Query | None = None,
339+
extra_body: Body | None = None,
340+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
341+
) -> Optional[AIRunResponse]:
342+
"""
343+
This endpoint provides users with the capability to run specific AI models
344+
on-demand.
345+
346+
By submitting the required input data, users can receive real-time predictions
347+
or results generated by the chosen AI model. The endpoint supports various AI
348+
model types, ensuring flexibility and adaptability for diverse use cases.
349+
350+
Model specific inputs available in
351+
[Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/).
352+
353+
Args:
354+
extra_headers: Send extra headers
355+
356+
extra_query: Add additional query parameters to the request
357+
358+
extra_body: Add additional JSON properties to the request
359+
360+
timeout: Override the client-level default timeout for this request, in seconds
361+
"""
362+
...
363+
364+
@overload
365+
def run(
366+
self,
367+
model_name: str,
368+
*,
369+
account_id: str,
370+
messages: Iterable[ai_run_params.Variant8Message],
371+
frequency_penalty: float | NotGiven = NOT_GIVEN,
372+
max_tokens: int | NotGiven = NOT_GIVEN,
373+
presence_penalty: float | NotGiven = NOT_GIVEN,
374+
repetition_penalty: float | NotGiven = NOT_GIVEN,
375+
seed: int | NotGiven = NOT_GIVEN,
376+
stream: bool | NotGiven = NOT_GIVEN,
377+
temperature: float | NotGiven = NOT_GIVEN,
378+
tools: Iterable[ai_run_params.Variant8Tool] | NotGiven = NOT_GIVEN,
379+
top_k: int | NotGiven = NOT_GIVEN,
380+
top_p: float | NotGiven = NOT_GIVEN,
329381
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
330382
# The extra values given here take precedence over values defined on the client or passed to this method.
331383
extra_headers: Headers | None = None,
@@ -478,6 +530,7 @@ def run(
478530
["account_id", "audio"],
479531
["account_id", "image"],
480532
["account_id"],
533+
["account_id", "messages"],
481534
["account_id", "target_lang", "text"],
482535
["account_id", "input_text"],
483536
)
@@ -502,16 +555,22 @@ def run(
502555
strength: float | NotGiven = NOT_GIVEN,
503556
width: int | NotGiven = NOT_GIVEN,
504557
audio: Iterable[float] | NotGiven = NOT_GIVEN,
558+
frequency_penalty: float | NotGiven = NOT_GIVEN,
505559
lora: str | NotGiven = NOT_GIVEN,
506560
max_tokens: int | NotGiven = NOT_GIVEN,
507-
messages: Iterable[ai_run_params.TextGenerationMessage] | NotGiven = NOT_GIVEN,
561+
presence_penalty: float | NotGiven = NOT_GIVEN,
508562
raw: bool | NotGiven = NOT_GIVEN,
563+
repetition_penalty: float | NotGiven = NOT_GIVEN,
509564
stream: bool | NotGiven = NOT_GIVEN,
565+
temperature: float | NotGiven = NOT_GIVEN,
566+
top_k: int | NotGiven = NOT_GIVEN,
567+
top_p: float | NotGiven = NOT_GIVEN,
568+
messages: Iterable[ai_run_params.Variant8Message] | NotGiven = NOT_GIVEN,
569+
tools: Iterable[ai_run_params.Variant8Tool] | NotGiven = NOT_GIVEN,
510570
target_lang: str | NotGiven = NOT_GIVEN,
511571
source_lang: str | NotGiven = NOT_GIVEN,
512572
input_text: str | NotGiven = NOT_GIVEN,
513573
max_length: int | NotGiven = NOT_GIVEN,
514-
temperature: float | NotGiven = NOT_GIVEN,
515574
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
516575
# The extra values given here take precedence over values defined on the client or passed to this method.
517576
extra_headers: Headers | None = None,
@@ -825,12 +884,64 @@ async def run(
825884
model_name: str,
826885
*,
827886
account_id: str,
887+
prompt: str,
888+
frequency_penalty: float | NotGiven = NOT_GIVEN,
828889
lora: str | NotGiven = NOT_GIVEN,
829890
max_tokens: int | NotGiven = NOT_GIVEN,
830-
messages: Iterable[ai_run_params.TextGenerationMessage] | NotGiven = NOT_GIVEN,
831-
prompt: str | NotGiven = NOT_GIVEN,
891+
presence_penalty: float | NotGiven = NOT_GIVEN,
832892
raw: bool | NotGiven = NOT_GIVEN,
893+
repetition_penalty: float | NotGiven = NOT_GIVEN,
894+
seed: int | NotGiven = NOT_GIVEN,
833895
stream: bool | NotGiven = NOT_GIVEN,
896+
temperature: float | NotGiven = NOT_GIVEN,
897+
top_k: int | NotGiven = NOT_GIVEN,
898+
top_p: float | NotGiven = NOT_GIVEN,
899+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
900+
# The extra values given here take precedence over values defined on the client or passed to this method.
901+
extra_headers: Headers | None = None,
902+
extra_query: Query | None = None,
903+
extra_body: Body | None = None,
904+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
905+
) -> Optional[AIRunResponse]:
906+
"""
907+
This endpoint provides users with the capability to run specific AI models
908+
on-demand.
909+
910+
By submitting the required input data, users can receive real-time predictions
911+
or results generated by the chosen AI model. The endpoint supports various AI
912+
model types, ensuring flexibility and adaptability for diverse use cases.
913+
914+
Model specific inputs available in
915+
[Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/).
916+
917+
Args:
918+
extra_headers: Send extra headers
919+
920+
extra_query: Add additional query parameters to the request
921+
922+
extra_body: Add additional JSON properties to the request
923+
924+
timeout: Override the client-level default timeout for this request, in seconds
925+
"""
926+
...
927+
928+
@overload
929+
async def run(
930+
self,
931+
model_name: str,
932+
*,
933+
account_id: str,
934+
messages: Iterable[ai_run_params.Variant8Message],
935+
frequency_penalty: float | NotGiven = NOT_GIVEN,
936+
max_tokens: int | NotGiven = NOT_GIVEN,
937+
presence_penalty: float | NotGiven = NOT_GIVEN,
938+
repetition_penalty: float | NotGiven = NOT_GIVEN,
939+
seed: int | NotGiven = NOT_GIVEN,
940+
stream: bool | NotGiven = NOT_GIVEN,
941+
temperature: float | NotGiven = NOT_GIVEN,
942+
tools: Iterable[ai_run_params.Variant8Tool] | NotGiven = NOT_GIVEN,
943+
top_k: int | NotGiven = NOT_GIVEN,
944+
top_p: float | NotGiven = NOT_GIVEN,
834945
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
835946
# The extra values given here take precedence over values defined on the client or passed to this method.
836947
extra_headers: Headers | None = None,
@@ -983,6 +1094,7 @@ async def run(
9831094
["account_id", "audio"],
9841095
["account_id", "image"],
9851096
["account_id"],
1097+
["account_id", "messages"],
9861098
["account_id", "target_lang", "text"],
9871099
["account_id", "input_text"],
9881100
)
@@ -1007,16 +1119,22 @@ async def run(
10071119
strength: float | NotGiven = NOT_GIVEN,
10081120
width: int | NotGiven = NOT_GIVEN,
10091121
audio: Iterable[float] | NotGiven = NOT_GIVEN,
1122+
frequency_penalty: float | NotGiven = NOT_GIVEN,
10101123
lora: str | NotGiven = NOT_GIVEN,
10111124
max_tokens: int | NotGiven = NOT_GIVEN,
1012-
messages: Iterable[ai_run_params.TextGenerationMessage] | NotGiven = NOT_GIVEN,
1125+
presence_penalty: float | NotGiven = NOT_GIVEN,
10131126
raw: bool | NotGiven = NOT_GIVEN,
1127+
repetition_penalty: float | NotGiven = NOT_GIVEN,
10141128
stream: bool | NotGiven = NOT_GIVEN,
1129+
temperature: float | NotGiven = NOT_GIVEN,
1130+
top_k: int | NotGiven = NOT_GIVEN,
1131+
top_p: float | NotGiven = NOT_GIVEN,
1132+
messages: Iterable[ai_run_params.Variant8Message] | NotGiven = NOT_GIVEN,
1133+
tools: Iterable[ai_run_params.Variant8Tool] | NotGiven = NOT_GIVEN,
10151134
target_lang: str | NotGiven = NOT_GIVEN,
10161135
source_lang: str | NotGiven = NOT_GIVEN,
10171136
input_text: str | NotGiven = NOT_GIVEN,
10181137
max_length: int | NotGiven = NOT_GIVEN,
1019-
temperature: float | NotGiven = NOT_GIVEN,
10201138
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
10211139
# The extra values given here take precedence over values defined on the client or passed to this method.
10221140
extra_headers: Headers | None = None,

src/cloudflare/types/workers/ai_run_params.py

+81-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Union, Iterable
5+
from typing import Dict, List, Union, Iterable
66
from typing_extensions import Required, TypedDict
77

88
__all__ = [
@@ -14,8 +14,13 @@
1414
"AutomaticSpeechRecognition",
1515
"ImageClassification",
1616
"ObjectDetection",
17-
"TextGeneration",
18-
"TextGenerationMessage",
17+
"Variant7",
18+
"Variant8",
19+
"Variant8Message",
20+
"Variant8Tool",
21+
"Variant8ToolFunction",
22+
"Variant8ToolFunctionParameters",
23+
"Variant8ToolFunctionParametersProperties",
1924
"Translation",
2025
"Summarization",
2126
"ImageToText",
@@ -89,28 +94,94 @@ class ObjectDetection(TypedDict, total=False):
8994
image: Iterable[float]
9095

9196

92-
class TextGeneration(TypedDict, total=False):
97+
class Variant7(TypedDict, total=False):
9398
account_id: Required[str]
9499

100+
prompt: Required[str]
101+
102+
frequency_penalty: float
103+
95104
lora: str
96105

97106
max_tokens: int
98107

99-
messages: Iterable[TextGenerationMessage]
100-
101-
prompt: str
108+
presence_penalty: float
102109

103110
raw: bool
104111

112+
repetition_penalty: float
113+
114+
seed: int
115+
116+
stream: bool
117+
118+
temperature: float
119+
120+
top_k: int
121+
122+
top_p: float
123+
124+
125+
class Variant8(TypedDict, total=False):
126+
account_id: Required[str]
127+
128+
messages: Required[Iterable[Variant8Message]]
129+
130+
frequency_penalty: float
131+
132+
max_tokens: int
133+
134+
presence_penalty: float
135+
136+
repetition_penalty: float
137+
138+
seed: int
139+
105140
stream: bool
106141

142+
temperature: float
143+
144+
tools: Iterable[Variant8Tool]
145+
146+
top_k: int
107147

108-
class TextGenerationMessage(TypedDict, total=False):
148+
top_p: float
149+
150+
151+
class Variant8Message(TypedDict, total=False):
109152
content: Required[str]
110153

111154
role: Required[str]
112155

113156

157+
class Variant8ToolFunctionParametersProperties(TypedDict, total=False):
158+
description: str
159+
160+
type: str
161+
162+
163+
class Variant8ToolFunctionParameters(TypedDict, total=False):
164+
properties: Dict[str, Variant8ToolFunctionParametersProperties]
165+
166+
required: List[str]
167+
168+
type: str
169+
170+
171+
class Variant8ToolFunction(TypedDict, total=False):
172+
description: str
173+
174+
name: str
175+
176+
parameters: Variant8ToolFunctionParameters
177+
178+
179+
class Variant8Tool(TypedDict, total=False):
180+
function: Variant8ToolFunction
181+
182+
type: str
183+
184+
114185
class Translation(TypedDict, total=False):
115186
account_id: Required[str]
116187

@@ -159,7 +230,8 @@ class ImageToTextMessage(TypedDict, total=False):
159230
AutomaticSpeechRecognition,
160231
ImageClassification,
161232
ObjectDetection,
162-
TextGeneration,
233+
Variant7,
234+
Variant8,
163235
Translation,
164236
Summarization,
165237
ImageToText,

0 commit comments

Comments
 (0)