Skip to content

Commit 674c2ce

Browse files
feat(ai): move AI back to dedicated namespace (#2277)
1 parent d77a47e commit 674c2ce

File tree

19 files changed

+233
-240
lines changed

19 files changed

+233
-240
lines changed

api.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2284,32 +2284,6 @@ from cloudflare.types.workers import (
22842284
)
22852285
```
22862286

2287-
## AI
2288-
2289-
Types:
2290-
2291-
```python
2292-
from cloudflare.types.workers import AIRunResponse
2293-
```
2294-
2295-
Methods:
2296-
2297-
- <code title="post /accounts/{account_id}/ai/run/{model_name}">client.workers.ai.<a href="./src/cloudflare/resources/workers/ai/ai.py">run</a>(model_name, \*, account_id, \*\*<a href="src/cloudflare/types/workers/ai_run_params.py">params</a>) -> <a href="./src/cloudflare/types/workers/ai_run_response.py">Optional[AIRunResponse]</a></code>
2298-
2299-
### Models
2300-
2301-
#### Schema
2302-
2303-
Types:
2304-
2305-
```python
2306-
from cloudflare.types.workers.ai.models import SchemaGetResponse
2307-
```
2308-
2309-
Methods:
2310-
2311-
- <code title="get /accounts/{account_id}/ai/models/schema">client.workers.ai.models.schema.<a href="./src/cloudflare/resources/workers/ai/models/schema.py">get</a>(\*, account_id, \*\*<a href="src/cloudflare/types/workers/ai/models/schema_get_params.py">params</a>) -> <a href="./src/cloudflare/types/workers/ai/models/schema_get_response.py">object</a></code>
2312-
23132287
## Assets
23142288

23152289
### Upload
@@ -8415,3 +8389,29 @@ from cloudflare.types.abuse_reports import AbuseReportCreateResponse
84158389
Methods:
84168390

84178391
- <code title="post /accounts/{account_id}/v1/abuse-reports/{report_type}">client.abuse_reports.<a href="./src/cloudflare/resources/abuse_reports.py">create</a>(report_type, \*, account_id, \*\*<a href="src/cloudflare/types/abuse_reports/abuse_report_create_params.py">params</a>) -> <a href="./src/cloudflare/types/abuse_reports/abuse_report_create_response.py">str</a></code>
8392+
8393+
# AI
8394+
8395+
Types:
8396+
8397+
```python
8398+
from cloudflare.types.ai import AIRunResponse
8399+
```
8400+
8401+
Methods:
8402+
8403+
- <code title="post /accounts/{account_id}/ai/run/{model_name}">client.ai.<a href="./src/cloudflare/resources/ai/ai.py">run</a>(model_name, \*, account_id, \*\*<a href="src/cloudflare/types/ai/ai_run_params.py">params</a>) -> <a href="./src/cloudflare/types/ai/ai_run_response.py">Optional[AIRunResponse]</a></code>
8404+
8405+
## Models
8406+
8407+
### Schema
8408+
8409+
Types:
8410+
8411+
```python
8412+
from cloudflare.types.ai.models import SchemaGetResponse
8413+
```
8414+
8415+
Methods:
8416+
8417+
- <code title="get /accounts/{account_id}/ai/models/schema">client.ai.models.schema.<a href="./src/cloudflare/resources/ai/models/schema.py">get</a>(\*, account_id, \*\*<a href="src/cloudflare/types/ai/models/schema_get_params.py">params</a>) -> <a href="./src/cloudflare/types/ai/models/schema_get_response.py">object</a></code>

src/cloudflare/_client.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
if TYPE_CHECKING:
3838
from .resources import (
39+
ai,
3940
d1,
4041
kv,
4142
r2,
@@ -123,6 +124,7 @@
123124
origin_post_quantum_encryption,
124125
)
125126
from .resources.ips import IPsResource, AsyncIPsResource
127+
from .resources.ai.ai import AIResource, AsyncAIResource
126128
from .resources.d1.d1 import D1Resource, AsyncD1Resource
127129
from .resources.kv.kv import KVResource, AsyncKVResource
128130
from .resources.r2.r2 import R2Resource, AsyncR2Resource
@@ -824,6 +826,12 @@ def abuse_reports(self) -> AbuseReportsResource:
824826

825827
return AbuseReportsResource(self)
826828

829+
@cached_property
830+
def ai(self) -> AIResource:
831+
from .resources.ai import AIResource
832+
833+
return AIResource(self)
834+
827835
@cached_property
828836
def with_raw_response(self) -> CloudflareWithRawResponse:
829837
return CloudflareWithRawResponse(self)
@@ -1589,6 +1597,12 @@ def abuse_reports(self) -> AsyncAbuseReportsResource:
15891597

15901598
return AsyncAbuseReportsResource(self)
15911599

1600+
@cached_property
1601+
def ai(self) -> AsyncAIResource:
1602+
from .resources.ai import AsyncAIResource
1603+
1604+
return AsyncAIResource(self)
1605+
15921606
@cached_property
15931607
def with_raw_response(self) -> AsyncCloudflareWithRawResponse:
15941608
return AsyncCloudflareWithRawResponse(self)
@@ -2289,6 +2303,12 @@ def abuse_reports(self) -> abuse_reports.AbuseReportsResourceWithRawResponse:
22892303

22902304
return AbuseReportsResourceWithRawResponse(self._client.abuse_reports)
22912305

2306+
@cached_property
2307+
def ai(self) -> ai.AIResourceWithRawResponse:
2308+
from .resources.ai import AIResourceWithRawResponse
2309+
2310+
return AIResourceWithRawResponse(self._client.ai)
2311+
22922312

22932313
class AsyncCloudflareWithRawResponse:
22942314
_client: AsyncCloudflare
@@ -2808,6 +2828,12 @@ def abuse_reports(self) -> abuse_reports.AsyncAbuseReportsResourceWithRawRespons
28082828

28092829
return AsyncAbuseReportsResourceWithRawResponse(self._client.abuse_reports)
28102830

2831+
@cached_property
2832+
def ai(self) -> ai.AsyncAIResourceWithRawResponse:
2833+
from .resources.ai import AsyncAIResourceWithRawResponse
2834+
2835+
return AsyncAIResourceWithRawResponse(self._client.ai)
2836+
28112837

28122838
class CloudflareWithStreamedResponse:
28132839
_client: Cloudflare
@@ -3327,6 +3353,12 @@ def abuse_reports(self) -> abuse_reports.AbuseReportsResourceWithStreamingRespon
33273353

33283354
return AbuseReportsResourceWithStreamingResponse(self._client.abuse_reports)
33293355

3356+
@cached_property
3357+
def ai(self) -> ai.AIResourceWithStreamingResponse:
3358+
from .resources.ai import AIResourceWithStreamingResponse
3359+
3360+
return AIResourceWithStreamingResponse(self._client.ai)
3361+
33303362

33313363
class AsyncCloudflareWithStreamedResponse:
33323364
_client: AsyncCloudflare
@@ -3856,6 +3888,12 @@ def abuse_reports(self) -> abuse_reports.AsyncAbuseReportsResourceWithStreamingR
38563888

38573889
return AsyncAbuseReportsResourceWithStreamingResponse(self._client.abuse_reports)
38583890

3891+
@cached_property
3892+
def ai(self) -> ai.AsyncAIResourceWithStreamingResponse:
3893+
from .resources.ai import AsyncAIResourceWithStreamingResponse
3894+
3895+
return AsyncAIResourceWithStreamingResponse(self._client.ai)
3896+
38593897

38603898
Client = Cloudflare
38613899

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@
77

88
import httpx
99

10-
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
11-
from ...._utils import (
10+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
11+
from ..._utils import (
1212
required_args,
1313
maybe_transform,
1414
async_maybe_transform,
1515
)
16-
from ...._compat import cached_property
17-
from ...._resource import SyncAPIResource, AsyncAPIResource
18-
from ...._response import (
16+
from ..._compat import cached_property
17+
from ...types.ai import ai_run_params
18+
from ..._resource import SyncAPIResource, AsyncAPIResource
19+
from ..._response import (
1920
to_raw_response_wrapper,
2021
to_streamed_response_wrapper,
2122
async_to_raw_response_wrapper,
2223
async_to_streamed_response_wrapper,
2324
)
24-
from ...._wrappers import ResultWrapper
25+
from ..._wrappers import ResultWrapper
2526
from .models.models import (
2627
ModelsResource,
2728
AsyncModelsResource,
@@ -30,9 +31,8 @@
3031
ModelsResourceWithStreamingResponse,
3132
AsyncModelsResourceWithStreamingResponse,
3233
)
33-
from ...._base_client import make_request_options
34-
from ....types.workers import ai_run_params
35-
from ....types.workers.ai_run_response import AIRunResponse
34+
from ..._base_client import make_request_options
35+
from ...types.ai.ai_run_response import AIRunResponse
3636

3737
__all__ = ["AIResource", "AsyncAIResource"]
3838

src/cloudflare/resources/workers/ai/models/models.py renamed to src/cloudflare/resources/ai/models/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
SchemaResourceWithStreamingResponse,
1111
AsyncSchemaResourceWithStreamingResponse,
1212
)
13-
from ....._compat import cached_property
14-
from ....._resource import SyncAPIResource, AsyncAPIResource
13+
from ...._compat import cached_property
14+
from ...._resource import SyncAPIResource, AsyncAPIResource
1515

1616
__all__ = ["ModelsResource", "AsyncModelsResource"]
1717

src/cloudflare/resources/workers/ai/models/schema.py renamed to src/cloudflare/resources/ai/models/schema.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66

77
import httpx
88

9-
from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10-
from ....._utils import (
9+
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10+
from ...._utils import (
1111
maybe_transform,
1212
async_maybe_transform,
1313
)
14-
from ....._compat import cached_property
15-
from ....._resource import SyncAPIResource, AsyncAPIResource
16-
from ....._response import (
14+
from ...._compat import cached_property
15+
from ...._resource import SyncAPIResource, AsyncAPIResource
16+
from ...._response import (
1717
to_raw_response_wrapper,
1818
to_streamed_response_wrapper,
1919
async_to_raw_response_wrapper,
2020
async_to_streamed_response_wrapper,
2121
)
22-
from ....._wrappers import ResultWrapper
23-
from ....._base_client import make_request_options
24-
from .....types.workers.ai.models import schema_get_params
22+
from ...._wrappers import ResultWrapper
23+
from ...._base_client import make_request_options
24+
from ....types.ai.models import schema_get_params
2525

2626
__all__ = ["SchemaResource", "AsyncSchemaResource"]
2727

src/cloudflare/resources/workers/__init__.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from .ai import (
4-
AIResource,
5-
AsyncAIResource,
6-
AIResourceWithRawResponse,
7-
AsyncAIResourceWithRawResponse,
8-
AIResourceWithStreamingResponse,
9-
AsyncAIResourceWithStreamingResponse,
10-
)
113
from .assets import (
124
AssetsResource,
135
AsyncAssetsResource,
@@ -58,12 +50,6 @@
5850
)
5951

6052
__all__ = [
61-
"AIResource",
62-
"AsyncAIResource",
63-
"AIResourceWithRawResponse",
64-
"AsyncAIResourceWithRawResponse",
65-
"AIResourceWithStreamingResponse",
66-
"AsyncAIResourceWithStreamingResponse",
6753
"AssetsResource",
6854
"AsyncAssetsResource",
6955
"AssetsResourceWithRawResponse",

src/cloudflare/resources/workers/workers.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22

33
from __future__ import annotations
44

5-
from .ai.ai import (
6-
AIResource,
7-
AsyncAIResource,
8-
AIResourceWithRawResponse,
9-
AsyncAIResourceWithRawResponse,
10-
AIResourceWithStreamingResponse,
11-
AsyncAIResourceWithStreamingResponse,
12-
)
135
from .domains import (
146
DomainsResource,
157
AsyncDomainsResource,
@@ -57,10 +49,6 @@
5749

5850

5951
class WorkersResource(SyncAPIResource):
60-
@cached_property
61-
def ai(self) -> AIResource:
62-
return AIResource(self._client)
63-
6452
@cached_property
6553
def assets(self) -> AssetsResource:
6654
return AssetsResource(self._client)
@@ -102,10 +90,6 @@ def with_streaming_response(self) -> WorkersResourceWithStreamingResponse:
10290

10391

10492
class AsyncWorkersResource(AsyncAPIResource):
105-
@cached_property
106-
def ai(self) -> AsyncAIResource:
107-
return AsyncAIResource(self._client)
108-
10993
@cached_property
11094
def assets(self) -> AsyncAssetsResource:
11195
return AsyncAssetsResource(self._client)
@@ -150,10 +134,6 @@ class WorkersResourceWithRawResponse:
150134
def __init__(self, workers: WorkersResource) -> None:
151135
self._workers = workers
152136

153-
@cached_property
154-
def ai(self) -> AIResourceWithRawResponse:
155-
return AIResourceWithRawResponse(self._workers.ai)
156-
157137
@cached_property
158138
def assets(self) -> AssetsResourceWithRawResponse:
159139
return AssetsResourceWithRawResponse(self._workers.assets)
@@ -179,10 +159,6 @@ class AsyncWorkersResourceWithRawResponse:
179159
def __init__(self, workers: AsyncWorkersResource) -> None:
180160
self._workers = workers
181161

182-
@cached_property
183-
def ai(self) -> AsyncAIResourceWithRawResponse:
184-
return AsyncAIResourceWithRawResponse(self._workers.ai)
185-
186162
@cached_property
187163
def assets(self) -> AsyncAssetsResourceWithRawResponse:
188164
return AsyncAssetsResourceWithRawResponse(self._workers.assets)
@@ -208,10 +184,6 @@ class WorkersResourceWithStreamingResponse:
208184
def __init__(self, workers: WorkersResource) -> None:
209185
self._workers = workers
210186

211-
@cached_property
212-
def ai(self) -> AIResourceWithStreamingResponse:
213-
return AIResourceWithStreamingResponse(self._workers.ai)
214-
215187
@cached_property
216188
def assets(self) -> AssetsResourceWithStreamingResponse:
217189
return AssetsResourceWithStreamingResponse(self._workers.assets)
@@ -237,10 +209,6 @@ class AsyncWorkersResourceWithStreamingResponse:
237209
def __init__(self, workers: AsyncWorkersResource) -> None:
238210
self._workers = workers
239211

240-
@cached_property
241-
def ai(self) -> AsyncAIResourceWithStreamingResponse:
242-
return AsyncAIResourceWithStreamingResponse(self._workers.ai)
243-
244212
@cached_property
245213
def assets(self) -> AsyncAssetsResourceWithStreamingResponse:
246214
return AsyncAssetsResourceWithStreamingResponse(self._workers.assets)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
from __future__ import annotations
4+
5+
from .ai_run_params import AIRunParams as AIRunParams
6+
from .ai_run_response import AIRunResponse as AIRunResponse

src/cloudflare/types/workers/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
from .binding import Binding as Binding
88
from .d1_binding import D1Binding as D1Binding
99
from .r2_binding import R2Binding as R2Binding
10-
from .ai_run_params import AIRunParams as AIRunParams
1110
from .binding_param import BindingParam as BindingParam
1211
from .migration_step import MigrationStep as MigrationStep
1312
from .script_setting import ScriptSetting as ScriptSetting
14-
from .ai_run_response import AIRunResponse as AIRunResponse
1513
from .service_binding import ServiceBinding as ServiceBinding
1614
from .d1_binding_param import D1BindingParam as D1BindingParam
1715
from .r2_binding_param import R2BindingParam as R2BindingParam

0 commit comments

Comments
 (0)