Skip to content

Commit 90d0608

Browse files
feat(ai)!: move to dedicated namespace (#2269)
1 parent f21869f commit 90d0608

File tree

19 files changed

+232
-241
lines changed

19 files changed

+232
-241
lines changed

api.md

+26-26
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

+37
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,
@@ -718,6 +719,12 @@ def abuse_reports(self) -> abuse_reports.AbuseReportsResource:
718719

719720
return AbuseReportsResource(self)
720721

722+
@cached_property
723+
def ai(self) -> ai.AIResource:
724+
from .resources.ai import AIResource
725+
726+
return AIResource(self)
727+
721728
@cached_property
722729
def with_raw_response(self) -> CloudflareWithRawResponse:
723730
return CloudflareWithRawResponse(self)
@@ -1483,6 +1490,12 @@ def abuse_reports(self) -> abuse_reports.AsyncAbuseReportsResource:
14831490

14841491
return AsyncAbuseReportsResource(self)
14851492

1493+
@cached_property
1494+
def ai(self) -> ai.AsyncAIResource:
1495+
from .resources.ai import AsyncAIResource
1496+
1497+
return AsyncAIResource(self)
1498+
14861499
@cached_property
14871500
def with_raw_response(self) -> AsyncCloudflareWithRawResponse:
14881501
return AsyncCloudflareWithRawResponse(self)
@@ -2183,6 +2196,12 @@ def abuse_reports(self) -> abuse_reports.AbuseReportsResourceWithRawResponse:
21832196

21842197
return AbuseReportsResourceWithRawResponse(self._client.abuse_reports)
21852198

2199+
@cached_property
2200+
def ai(self) -> ai.AIResourceWithRawResponse:
2201+
from .resources.ai import AIResourceWithRawResponse
2202+
2203+
return AIResourceWithRawResponse(self._client.ai)
2204+
21862205

21872206
class AsyncCloudflareWithRawResponse:
21882207
_client: AsyncCloudflare
@@ -2702,6 +2721,12 @@ def abuse_reports(self) -> abuse_reports.AsyncAbuseReportsResourceWithRawRespons
27022721

27032722
return AsyncAbuseReportsResourceWithRawResponse(self._client.abuse_reports)
27042723

2724+
@cached_property
2725+
def ai(self) -> ai.AsyncAIResourceWithRawResponse:
2726+
from .resources.ai import AsyncAIResourceWithRawResponse
2727+
2728+
return AsyncAIResourceWithRawResponse(self._client.ai)
2729+
27052730

27062731
class CloudflareWithStreamedResponse:
27072732
_client: Cloudflare
@@ -3221,6 +3246,12 @@ def abuse_reports(self) -> abuse_reports.AbuseReportsResourceWithStreamingRespon
32213246

32223247
return AbuseReportsResourceWithStreamingResponse(self._client.abuse_reports)
32233248

3249+
@cached_property
3250+
def ai(self) -> ai.AIResourceWithStreamingResponse:
3251+
from .resources.ai import AIResourceWithStreamingResponse
3252+
3253+
return AIResourceWithStreamingResponse(self._client.ai)
3254+
32243255

32253256
class AsyncCloudflareWithStreamedResponse:
32263257
_client: AsyncCloudflare
@@ -3750,6 +3781,12 @@ def abuse_reports(self) -> abuse_reports.AsyncAbuseReportsResourceWithStreamingR
37503781

37513782
return AsyncAbuseReportsResourceWithStreamingResponse(self._client.abuse_reports)
37523783

3784+
@cached_property
3785+
def ai(self) -> ai.AsyncAIResourceWithStreamingResponse:
3786+
from .resources.ai import AsyncAIResourceWithStreamingResponse
3787+
3788+
return AsyncAIResourceWithStreamingResponse(self._client.ai)
3789+
37533790

37543791
Client = Cloudflare
37553792

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@
1515
ModelsResourceWithStreamingResponse,
1616
AsyncModelsResourceWithStreamingResponse,
1717
)
18-
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
19-
from ...._utils import (
18+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
19+
from ..._utils import (
2020
required_args,
2121
maybe_transform,
2222
async_maybe_transform,
2323
)
24-
from ...._compat import cached_property
25-
from ...._resource import SyncAPIResource, AsyncAPIResource
26-
from ...._response import (
24+
from ..._compat import cached_property
25+
from ...types.ai import ai_run_params
26+
from ..._resource import SyncAPIResource, AsyncAPIResource
27+
from ..._response import (
2728
to_raw_response_wrapper,
2829
to_streamed_response_wrapper,
2930
async_to_raw_response_wrapper,
3031
async_to_streamed_response_wrapper,
3132
)
32-
from ...._wrappers import ResultWrapper
33+
from ..._wrappers import ResultWrapper
3334
from .models.models import ModelsResource, AsyncModelsResource
34-
from ...._base_client import make_request_options
35-
from ....types.workers import ai_run_params
36-
from ....types.workers.ai_run_response import AIRunResponse
35+
from ..._base_client import make_request_options
36+
from ...types.ai.ai_run_response import AIRunResponse
3737

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

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

+2-2
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 src/cloudflare/resources/ai/models/schema.py

+8-8
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

-14
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

-33
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22

33
from __future__ import annotations
44

5-
from .ai import (
6-
AIResource,
7-
AsyncAIResource,
8-
AIResourceWithRawResponse,
9-
AsyncAIResourceWithRawResponse,
10-
AIResourceWithStreamingResponse,
11-
AsyncAIResourceWithStreamingResponse,
12-
)
13-
from .ai.ai import AIResource, AsyncAIResource
145
from .assets import (
156
AssetsResource,
167
AsyncAssetsResource,
@@ -60,10 +51,6 @@
6051

6152

6253
class WorkersResource(SyncAPIResource):
63-
@cached_property
64-
def ai(self) -> AIResource:
65-
return AIResource(self._client)
66-
6754
@cached_property
6855
def assets(self) -> AssetsResource:
6956
return AssetsResource(self._client)
@@ -105,10 +92,6 @@ def with_streaming_response(self) -> WorkersResourceWithStreamingResponse:
10592

10693

10794
class AsyncWorkersResource(AsyncAPIResource):
108-
@cached_property
109-
def ai(self) -> AsyncAIResource:
110-
return AsyncAIResource(self._client)
111-
11295
@cached_property
11396
def assets(self) -> AsyncAssetsResource:
11497
return AsyncAssetsResource(self._client)
@@ -153,10 +136,6 @@ class WorkersResourceWithRawResponse:
153136
def __init__(self, workers: WorkersResource) -> None:
154137
self._workers = workers
155138

156-
@cached_property
157-
def ai(self) -> AIResourceWithRawResponse:
158-
return AIResourceWithRawResponse(self._workers.ai)
159-
160139
@cached_property
161140
def assets(self) -> AssetsResourceWithRawResponse:
162141
return AssetsResourceWithRawResponse(self._workers.assets)
@@ -182,10 +161,6 @@ class AsyncWorkersResourceWithRawResponse:
182161
def __init__(self, workers: AsyncWorkersResource) -> None:
183162
self._workers = workers
184163

185-
@cached_property
186-
def ai(self) -> AsyncAIResourceWithRawResponse:
187-
return AsyncAIResourceWithRawResponse(self._workers.ai)
188-
189164
@cached_property
190165
def assets(self) -> AsyncAssetsResourceWithRawResponse:
191166
return AsyncAssetsResourceWithRawResponse(self._workers.assets)
@@ -211,10 +186,6 @@ class WorkersResourceWithStreamingResponse:
211186
def __init__(self, workers: WorkersResource) -> None:
212187
self._workers = workers
213188

214-
@cached_property
215-
def ai(self) -> AIResourceWithStreamingResponse:
216-
return AIResourceWithStreamingResponse(self._workers.ai)
217-
218189
@cached_property
219190
def assets(self) -> AssetsResourceWithStreamingResponse:
220191
return AssetsResourceWithStreamingResponse(self._workers.assets)
@@ -240,10 +211,6 @@ class AsyncWorkersResourceWithStreamingResponse:
240211
def __init__(self, workers: AsyncWorkersResource) -> None:
241212
self._workers = workers
242213

243-
@cached_property
244-
def ai(self) -> AsyncAIResourceWithStreamingResponse:
245-
return AsyncAIResourceWithStreamingResponse(self._workers.ai)
246-
247214
@cached_property
248215
def assets(self) -> AsyncAssetsResourceWithStreamingResponse:
249216
return AsyncAssetsResourceWithStreamingResponse(self._workers.assets)
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

-2
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
File renamed without changes.

0 commit comments

Comments
 (0)