Skip to content

Commit eb8ac49

Browse files
feat(api): api update (#2473)
1 parent 9823b64 commit eb8ac49

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 1542
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f564ca6ff9b7da23773fdfbb171c9fa3a9fc4f92119503ceabc55947d193822a.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-452e674010858ce0fde7c08feacd8fbc4fccbf4b317f087361cce10e76014d7d.yml

src/cloudflare/resources/ai/ai.py

+8
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ def run(
424424
presence_penalty: float | NotGiven = NOT_GIVEN,
425425
raw: bool | NotGiven = NOT_GIVEN,
426426
repetition_penalty: float | NotGiven = NOT_GIVEN,
427+
response_format: ai_run_params.PromptResponseFormat | NotGiven = NOT_GIVEN,
427428
seed: int | NotGiven = NOT_GIVEN,
428429
stream: bool | NotGiven = NOT_GIVEN,
429430
temperature: float | NotGiven = NOT_GIVEN,
@@ -501,6 +502,7 @@ def run(
501502
max_tokens: int | NotGiven = NOT_GIVEN,
502503
presence_penalty: float | NotGiven = NOT_GIVEN,
503504
repetition_penalty: float | NotGiven = NOT_GIVEN,
505+
response_format: ai_run_params.MessagesResponseFormat | NotGiven = NOT_GIVEN,
504506
seed: int | NotGiven = NOT_GIVEN,
505507
stream: bool | NotGiven = NOT_GIVEN,
506508
temperature: float | NotGiven = NOT_GIVEN,
@@ -761,6 +763,7 @@ def run(
761763
presence_penalty: float | NotGiven = NOT_GIVEN,
762764
raw: bool | NotGiven = NOT_GIVEN,
763765
repetition_penalty: float | NotGiven = NOT_GIVEN,
766+
response_format: ai_run_params.PromptResponseFormat | NotGiven = NOT_GIVEN,
764767
stream: bool | NotGiven = NOT_GIVEN,
765768
temperature: float | NotGiven = NOT_GIVEN,
766769
top_k: int | float | NotGiven = NOT_GIVEN,
@@ -809,6 +812,7 @@ def run(
809812
"presence_penalty": presence_penalty,
810813
"raw": raw,
811814
"repetition_penalty": repetition_penalty,
815+
"response_format": response_format,
812816
"stream": stream,
813817
"temperature": temperature,
814818
"top_k": top_k,
@@ -1198,6 +1202,7 @@ async def run(
11981202
presence_penalty: float | NotGiven = NOT_GIVEN,
11991203
raw: bool | NotGiven = NOT_GIVEN,
12001204
repetition_penalty: float | NotGiven = NOT_GIVEN,
1205+
response_format: ai_run_params.PromptResponseFormat | NotGiven = NOT_GIVEN,
12011206
seed: int | NotGiven = NOT_GIVEN,
12021207
stream: bool | NotGiven = NOT_GIVEN,
12031208
temperature: float | NotGiven = NOT_GIVEN,
@@ -1275,6 +1280,7 @@ async def run(
12751280
max_tokens: int | NotGiven = NOT_GIVEN,
12761281
presence_penalty: float | NotGiven = NOT_GIVEN,
12771282
repetition_penalty: float | NotGiven = NOT_GIVEN,
1283+
response_format: ai_run_params.MessagesResponseFormat | NotGiven = NOT_GIVEN,
12781284
seed: int | NotGiven = NOT_GIVEN,
12791285
stream: bool | NotGiven = NOT_GIVEN,
12801286
temperature: float | NotGiven = NOT_GIVEN,
@@ -1535,6 +1541,7 @@ async def run(
15351541
presence_penalty: float | NotGiven = NOT_GIVEN,
15361542
raw: bool | NotGiven = NOT_GIVEN,
15371543
repetition_penalty: float | NotGiven = NOT_GIVEN,
1544+
response_format: ai_run_params.PromptResponseFormat | NotGiven = NOT_GIVEN,
15381545
stream: bool | NotGiven = NOT_GIVEN,
15391546
temperature: float | NotGiven = NOT_GIVEN,
15401547
top_k: int | float | NotGiven = NOT_GIVEN,
@@ -1583,6 +1590,7 @@ async def run(
15831590
"presence_penalty": presence_penalty,
15841591
"raw": raw,
15851592
"repetition_penalty": repetition_penalty,
1593+
"response_format": response_format,
15861594
"stream": stream,
15871595
"temperature": temperature,
15881596
"top_k": top_k,

src/cloudflare/types/ai/ai_run_params.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from typing import Dict, List, Union, Iterable
6-
from typing_extensions import Required, TypeAlias, TypedDict
6+
from typing_extensions import Literal, Required, TypeAlias, TypedDict
77

88
__all__ = [
99
"AIRunParams",
@@ -15,9 +15,11 @@
1515
"ImageClassification",
1616
"ObjectDetection",
1717
"Prompt",
18+
"PromptResponseFormat",
1819
"Messages",
1920
"MessagesMessage",
2021
"MessagesFunction",
22+
"MessagesResponseFormat",
2123
"MessagesTool",
2224
"MessagesToolUnionMember0",
2325
"MessagesToolUnionMember0Parameters",
@@ -177,6 +179,8 @@ class Prompt(TypedDict, total=False):
177179
repetition_penalty: float
178180
"""Penalty for repeated tokens; higher values discourage repetition."""
179181

182+
response_format: PromptResponseFormat
183+
180184
seed: int
181185
"""Random seed for reproducibility of the generation."""
182186

@@ -207,6 +211,12 @@ class Prompt(TypedDict, total=False):
207211
"""
208212

209213

214+
class PromptResponseFormat(TypedDict, total=False):
215+
json_schema: object
216+
217+
type: Literal["json_object", "json_schema"]
218+
219+
210220
class Messages(TypedDict, total=False):
211221
account_id: Required[str]
212222

@@ -227,6 +237,8 @@ class Messages(TypedDict, total=False):
227237
repetition_penalty: float
228238
"""Penalty for repeated tokens; higher values discourage repetition."""
229239

240+
response_format: MessagesResponseFormat
241+
230242
seed: int
231243
"""Random seed for reproducibility of the generation."""
232244

@@ -271,6 +283,12 @@ class MessagesFunction(TypedDict, total=False):
271283
name: Required[str]
272284

273285

286+
class MessagesResponseFormat(TypedDict, total=False):
287+
json_schema: object
288+
289+
type: Literal["json_object", "json_schema"]
290+
291+
274292
class MessagesToolUnionMember0ParametersProperties(TypedDict, total=False):
275293
description: Required[str]
276294
"""A description of the expected parameter."""

tests/api_resources/test_ai.py

+16
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ def test_method_run_with_all_params_overload_8(self, client: Cloudflare) -> None
453453
presence_penalty=0,
454454
raw=True,
455455
repetition_penalty=0,
456+
response_format={
457+
"json_schema": {},
458+
"type": "json_object",
459+
},
456460
seed=1,
457461
stream=True,
458462
temperature=0,
@@ -540,6 +544,10 @@ def test_method_run_with_all_params_overload_9(self, client: Cloudflare) -> None
540544
max_tokens=0,
541545
presence_penalty=0,
542546
repetition_penalty=0,
547+
response_format={
548+
"json_schema": {},
549+
"type": "json_object",
550+
},
543551
seed=1,
544552
stream=True,
545553
temperature=0,
@@ -1272,6 +1280,10 @@ async def test_method_run_with_all_params_overload_8(self, async_client: AsyncCl
12721280
presence_penalty=0,
12731281
raw=True,
12741282
repetition_penalty=0,
1283+
response_format={
1284+
"json_schema": {},
1285+
"type": "json_object",
1286+
},
12751287
seed=1,
12761288
stream=True,
12771289
temperature=0,
@@ -1359,6 +1371,10 @@ async def test_method_run_with_all_params_overload_9(self, async_client: AsyncCl
13591371
max_tokens=0,
13601372
presence_penalty=0,
13611373
repetition_penalty=0,
1374+
response_format={
1375+
"json_schema": {},
1376+
"type": "json_object",
1377+
},
13621378
seed=1,
13631379
stream=True,
13641380
temperature=0,

0 commit comments

Comments
 (0)