Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jul 15, 2024
1 parent c08fb0d commit efafb96
Show file tree
Hide file tree
Showing 4 changed files with 648 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1256
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9f6e9da01b27f4f387991ca14ecafe0c42a356cc3c47b269e5f8b4f6cd0ed700.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-cb76af21f6fcf485b7e41586c3076cd45d25d6d04971c77ec814523b894dcb97.yml
134 changes: 126 additions & 8 deletions src/cloudflare/resources/workers/ai/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,64 @@ def run(
model_name: str,
*,
account_id: str,
prompt: str,
frequency_penalty: float | NotGiven = NOT_GIVEN,
lora: str | NotGiven = NOT_GIVEN,
max_tokens: int | NotGiven = NOT_GIVEN,
messages: Iterable[ai_run_params.TextGenerationMessage] | NotGiven = NOT_GIVEN,
prompt: str | NotGiven = NOT_GIVEN,
presence_penalty: float | NotGiven = NOT_GIVEN,
raw: bool | NotGiven = NOT_GIVEN,
repetition_penalty: float | NotGiven = NOT_GIVEN,
seed: int | NotGiven = NOT_GIVEN,
stream: bool | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
top_k: int | NotGiven = NOT_GIVEN,
top_p: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[AIRunResponse]:
"""
This endpoint provides users with the capability to run specific AI models
on-demand.
By submitting the required input data, users can receive real-time predictions
or results generated by the chosen AI model. The endpoint supports various AI
model types, ensuring flexibility and adaptability for diverse use cases.
Model specific inputs available in
[Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/).
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
...

@overload
def run(
self,
model_name: str,
*,
account_id: str,
messages: Iterable[ai_run_params.Variant8Message],
frequency_penalty: float | NotGiven = NOT_GIVEN,
max_tokens: int | NotGiven = NOT_GIVEN,
presence_penalty: float | NotGiven = NOT_GIVEN,
repetition_penalty: float | NotGiven = NOT_GIVEN,
seed: int | NotGiven = NOT_GIVEN,
stream: bool | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
tools: Iterable[ai_run_params.Variant8Tool] | NotGiven = NOT_GIVEN,
top_k: int | NotGiven = NOT_GIVEN,
top_p: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -478,6 +530,7 @@ def run(
["account_id", "audio"],
["account_id", "image"],
["account_id"],
["account_id", "messages"],
["account_id", "target_lang", "text"],
["account_id", "input_text"],
)
Expand All @@ -502,16 +555,22 @@ def run(
strength: float | NotGiven = NOT_GIVEN,
width: int | NotGiven = NOT_GIVEN,
audio: Iterable[float] | NotGiven = NOT_GIVEN,
frequency_penalty: float | NotGiven = NOT_GIVEN,
lora: str | NotGiven = NOT_GIVEN,
max_tokens: int | NotGiven = NOT_GIVEN,
messages: Iterable[ai_run_params.TextGenerationMessage] | NotGiven = NOT_GIVEN,
presence_penalty: float | NotGiven = NOT_GIVEN,
raw: bool | NotGiven = NOT_GIVEN,
repetition_penalty: float | NotGiven = NOT_GIVEN,
stream: bool | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
top_k: int | NotGiven = NOT_GIVEN,
top_p: float | NotGiven = NOT_GIVEN,
messages: Iterable[ai_run_params.Variant8Message] | NotGiven = NOT_GIVEN,
tools: Iterable[ai_run_params.Variant8Tool] | NotGiven = NOT_GIVEN,
target_lang: str | NotGiven = NOT_GIVEN,
source_lang: str | NotGiven = NOT_GIVEN,
input_text: str | NotGiven = NOT_GIVEN,
max_length: int | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -825,12 +884,64 @@ async def run(
model_name: str,
*,
account_id: str,
prompt: str,
frequency_penalty: float | NotGiven = NOT_GIVEN,
lora: str | NotGiven = NOT_GIVEN,
max_tokens: int | NotGiven = NOT_GIVEN,
messages: Iterable[ai_run_params.TextGenerationMessage] | NotGiven = NOT_GIVEN,
prompt: str | NotGiven = NOT_GIVEN,
presence_penalty: float | NotGiven = NOT_GIVEN,
raw: bool | NotGiven = NOT_GIVEN,
repetition_penalty: float | NotGiven = NOT_GIVEN,
seed: int | NotGiven = NOT_GIVEN,
stream: bool | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
top_k: int | NotGiven = NOT_GIVEN,
top_p: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[AIRunResponse]:
"""
This endpoint provides users with the capability to run specific AI models
on-demand.
By submitting the required input data, users can receive real-time predictions
or results generated by the chosen AI model. The endpoint supports various AI
model types, ensuring flexibility and adaptability for diverse use cases.
Model specific inputs available in
[Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/).
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
...

@overload
async def run(
self,
model_name: str,
*,
account_id: str,
messages: Iterable[ai_run_params.Variant8Message],
frequency_penalty: float | NotGiven = NOT_GIVEN,
max_tokens: int | NotGiven = NOT_GIVEN,
presence_penalty: float | NotGiven = NOT_GIVEN,
repetition_penalty: float | NotGiven = NOT_GIVEN,
seed: int | NotGiven = NOT_GIVEN,
stream: bool | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
tools: Iterable[ai_run_params.Variant8Tool] | NotGiven = NOT_GIVEN,
top_k: int | NotGiven = NOT_GIVEN,
top_p: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -983,6 +1094,7 @@ async def run(
["account_id", "audio"],
["account_id", "image"],
["account_id"],
["account_id", "messages"],
["account_id", "target_lang", "text"],
["account_id", "input_text"],
)
Expand All @@ -1007,16 +1119,22 @@ async def run(
strength: float | NotGiven = NOT_GIVEN,
width: int | NotGiven = NOT_GIVEN,
audio: Iterable[float] | NotGiven = NOT_GIVEN,
frequency_penalty: float | NotGiven = NOT_GIVEN,
lora: str | NotGiven = NOT_GIVEN,
max_tokens: int | NotGiven = NOT_GIVEN,
messages: Iterable[ai_run_params.TextGenerationMessage] | NotGiven = NOT_GIVEN,
presence_penalty: float | NotGiven = NOT_GIVEN,
raw: bool | NotGiven = NOT_GIVEN,
repetition_penalty: float | NotGiven = NOT_GIVEN,
stream: bool | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
top_k: int | NotGiven = NOT_GIVEN,
top_p: float | NotGiven = NOT_GIVEN,
messages: Iterable[ai_run_params.Variant8Message] | NotGiven = NOT_GIVEN,
tools: Iterable[ai_run_params.Variant8Tool] | NotGiven = NOT_GIVEN,
target_lang: str | NotGiven = NOT_GIVEN,
source_lang: str | NotGiven = NOT_GIVEN,
input_text: str | NotGiven = NOT_GIVEN,
max_length: int | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
90 changes: 81 additions & 9 deletions src/cloudflare/types/workers/ai_run_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import List, Union, Iterable
from typing import Dict, List, Union, Iterable
from typing_extensions import Required, TypedDict

__all__ = [
Expand All @@ -14,8 +14,13 @@
"AutomaticSpeechRecognition",
"ImageClassification",
"ObjectDetection",
"TextGeneration",
"TextGenerationMessage",
"Variant7",
"Variant8",
"Variant8Message",
"Variant8Tool",
"Variant8ToolFunction",
"Variant8ToolFunctionParameters",
"Variant8ToolFunctionParametersProperties",
"Translation",
"Summarization",
"ImageToText",
Expand Down Expand Up @@ -89,28 +94,94 @@ class ObjectDetection(TypedDict, total=False):
image: Iterable[float]


class TextGeneration(TypedDict, total=False):
class Variant7(TypedDict, total=False):
account_id: Required[str]

prompt: Required[str]

frequency_penalty: float

lora: str

max_tokens: int

messages: Iterable[TextGenerationMessage]

prompt: str
presence_penalty: float

raw: bool

repetition_penalty: float

seed: int

stream: bool

temperature: float

top_k: int

top_p: float


class Variant8(TypedDict, total=False):
account_id: Required[str]

messages: Required[Iterable[Variant8Message]]

frequency_penalty: float

max_tokens: int

presence_penalty: float

repetition_penalty: float

seed: int

stream: bool

temperature: float

tools: Iterable[Variant8Tool]

top_k: int

class TextGenerationMessage(TypedDict, total=False):
top_p: float


class Variant8Message(TypedDict, total=False):
content: Required[str]

role: Required[str]


class Variant8ToolFunctionParametersProperties(TypedDict, total=False):
description: str

type: str


class Variant8ToolFunctionParameters(TypedDict, total=False):
properties: Dict[str, Variant8ToolFunctionParametersProperties]

required: List[str]

type: str


class Variant8ToolFunction(TypedDict, total=False):
description: str

name: str

parameters: Variant8ToolFunctionParameters


class Variant8Tool(TypedDict, total=False):
function: Variant8ToolFunction

type: str


class Translation(TypedDict, total=False):
account_id: Required[str]

Expand Down Expand Up @@ -159,7 +230,8 @@ class ImageToTextMessage(TypedDict, total=False):
AutomaticSpeechRecognition,
ImageClassification,
ObjectDetection,
TextGeneration,
Variant7,
Variant8,
Translation,
Summarization,
ImageToText,
Expand Down
Loading

0 comments on commit efafb96

Please sign in to comment.