Skip to content

Commit

Permalink
feat(ai): move AI back to dedicated namespace (#2277)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Dec 15, 2024
1 parent d77a47e commit 674c2ce
Show file tree
Hide file tree
Showing 19 changed files with 233 additions and 240 deletions.
52 changes: 26 additions & 26 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2284,32 +2284,6 @@ from cloudflare.types.workers import (
)
```

## AI

Types:

```python
from cloudflare.types.workers import AIRunResponse
```

Methods:

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

### Models

#### Schema

Types:

```python
from cloudflare.types.workers.ai.models import SchemaGetResponse
```

Methods:

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

## Assets

### Upload
Expand Down Expand Up @@ -8415,3 +8389,29 @@ from cloudflare.types.abuse_reports import AbuseReportCreateResponse
Methods:

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

# AI

Types:

```python
from cloudflare.types.ai import AIRunResponse
```

Methods:

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

## Models

### Schema

Types:

```python
from cloudflare.types.ai.models import SchemaGetResponse
```

Methods:

- <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>
38 changes: 38 additions & 0 deletions src/cloudflare/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

if TYPE_CHECKING:
from .resources import (
ai,
d1,
kv,
r2,
Expand Down Expand Up @@ -123,6 +124,7 @@
origin_post_quantum_encryption,
)
from .resources.ips import IPsResource, AsyncIPsResource
from .resources.ai.ai import AIResource, AsyncAIResource
from .resources.d1.d1 import D1Resource, AsyncD1Resource
from .resources.kv.kv import KVResource, AsyncKVResource
from .resources.r2.r2 import R2Resource, AsyncR2Resource
Expand Down Expand Up @@ -824,6 +826,12 @@ def abuse_reports(self) -> AbuseReportsResource:

return AbuseReportsResource(self)

@cached_property
def ai(self) -> AIResource:
from .resources.ai import AIResource

return AIResource(self)

@cached_property
def with_raw_response(self) -> CloudflareWithRawResponse:
return CloudflareWithRawResponse(self)
Expand Down Expand Up @@ -1589,6 +1597,12 @@ def abuse_reports(self) -> AsyncAbuseReportsResource:

return AsyncAbuseReportsResource(self)

@cached_property
def ai(self) -> AsyncAIResource:
from .resources.ai import AsyncAIResource

return AsyncAIResource(self)

@cached_property
def with_raw_response(self) -> AsyncCloudflareWithRawResponse:
return AsyncCloudflareWithRawResponse(self)
Expand Down Expand Up @@ -2289,6 +2303,12 @@ def abuse_reports(self) -> abuse_reports.AbuseReportsResourceWithRawResponse:

return AbuseReportsResourceWithRawResponse(self._client.abuse_reports)

@cached_property
def ai(self) -> ai.AIResourceWithRawResponse:
from .resources.ai import AIResourceWithRawResponse

return AIResourceWithRawResponse(self._client.ai)


class AsyncCloudflareWithRawResponse:
_client: AsyncCloudflare
Expand Down Expand Up @@ -2808,6 +2828,12 @@ def abuse_reports(self) -> abuse_reports.AsyncAbuseReportsResourceWithRawRespons

return AsyncAbuseReportsResourceWithRawResponse(self._client.abuse_reports)

@cached_property
def ai(self) -> ai.AsyncAIResourceWithRawResponse:
from .resources.ai import AsyncAIResourceWithRawResponse

return AsyncAIResourceWithRawResponse(self._client.ai)


class CloudflareWithStreamedResponse:
_client: Cloudflare
Expand Down Expand Up @@ -3327,6 +3353,12 @@ def abuse_reports(self) -> abuse_reports.AbuseReportsResourceWithStreamingRespon

return AbuseReportsResourceWithStreamingResponse(self._client.abuse_reports)

@cached_property
def ai(self) -> ai.AIResourceWithStreamingResponse:
from .resources.ai import AIResourceWithStreamingResponse

return AIResourceWithStreamingResponse(self._client.ai)


class AsyncCloudflareWithStreamedResponse:
_client: AsyncCloudflare
Expand Down Expand Up @@ -3856,6 +3888,12 @@ def abuse_reports(self) -> abuse_reports.AsyncAbuseReportsResourceWithStreamingR

return AsyncAbuseReportsResourceWithStreamingResponse(self._client.abuse_reports)

@cached_property
def ai(self) -> ai.AsyncAIResourceWithStreamingResponse:
from .resources.ai import AsyncAIResourceWithStreamingResponse

return AsyncAIResourceWithStreamingResponse(self._client.ai)


Client = Cloudflare

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@

import httpx

from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import (
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import (
required_args,
maybe_transform,
async_maybe_transform,
)
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import (
from ..._compat import cached_property
from ...types.ai import ai_run_params
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
to_raw_response_wrapper,
to_streamed_response_wrapper,
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from ...._wrappers import ResultWrapper
from ..._wrappers import ResultWrapper
from .models.models import (
ModelsResource,
AsyncModelsResource,
Expand All @@ -30,9 +31,8 @@
ModelsResourceWithStreamingResponse,
AsyncModelsResourceWithStreamingResponse,
)
from ...._base_client import make_request_options
from ....types.workers import ai_run_params
from ....types.workers.ai_run_response import AIRunResponse
from ..._base_client import make_request_options
from ...types.ai.ai_run_response import AIRunResponse

__all__ = ["AIResource", "AsyncAIResource"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
SchemaResourceWithStreamingResponse,
AsyncSchemaResourceWithStreamingResponse,
)
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource

__all__ = ["ModelsResource", "AsyncModelsResource"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@

import httpx

from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ....._utils import (
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import (
maybe_transform,
async_maybe_transform,
)
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import (
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import (
to_raw_response_wrapper,
to_streamed_response_wrapper,
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from ....._wrappers import ResultWrapper
from ....._base_client import make_request_options
from .....types.workers.ai.models import schema_get_params
from ...._wrappers import ResultWrapper
from ...._base_client import make_request_options
from ....types.ai.models import schema_get_params

__all__ = ["SchemaResource", "AsyncSchemaResource"]

Expand Down
14 changes: 0 additions & 14 deletions src/cloudflare/resources/workers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .ai import (
AIResource,
AsyncAIResource,
AIResourceWithRawResponse,
AsyncAIResourceWithRawResponse,
AIResourceWithStreamingResponse,
AsyncAIResourceWithStreamingResponse,
)
from .assets import (
AssetsResource,
AsyncAssetsResource,
Expand Down Expand Up @@ -58,12 +50,6 @@
)

__all__ = [
"AIResource",
"AsyncAIResource",
"AIResourceWithRawResponse",
"AsyncAIResourceWithRawResponse",
"AIResourceWithStreamingResponse",
"AsyncAIResourceWithStreamingResponse",
"AssetsResource",
"AsyncAssetsResource",
"AssetsResourceWithRawResponse",
Expand Down
32 changes: 0 additions & 32 deletions src/cloudflare/resources/workers/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

from __future__ import annotations

from .ai.ai import (
AIResource,
AsyncAIResource,
AIResourceWithRawResponse,
AsyncAIResourceWithRawResponse,
AIResourceWithStreamingResponse,
AsyncAIResourceWithStreamingResponse,
)
from .domains import (
DomainsResource,
AsyncDomainsResource,
Expand Down Expand Up @@ -57,10 +49,6 @@


class WorkersResource(SyncAPIResource):
@cached_property
def ai(self) -> AIResource:
return AIResource(self._client)

@cached_property
def assets(self) -> AssetsResource:
return AssetsResource(self._client)
Expand Down Expand Up @@ -102,10 +90,6 @@ def with_streaming_response(self) -> WorkersResourceWithStreamingResponse:


class AsyncWorkersResource(AsyncAPIResource):
@cached_property
def ai(self) -> AsyncAIResource:
return AsyncAIResource(self._client)

@cached_property
def assets(self) -> AsyncAssetsResource:
return AsyncAssetsResource(self._client)
Expand Down Expand Up @@ -150,10 +134,6 @@ class WorkersResourceWithRawResponse:
def __init__(self, workers: WorkersResource) -> None:
self._workers = workers

@cached_property
def ai(self) -> AIResourceWithRawResponse:
return AIResourceWithRawResponse(self._workers.ai)

@cached_property
def assets(self) -> AssetsResourceWithRawResponse:
return AssetsResourceWithRawResponse(self._workers.assets)
Expand All @@ -179,10 +159,6 @@ class AsyncWorkersResourceWithRawResponse:
def __init__(self, workers: AsyncWorkersResource) -> None:
self._workers = workers

@cached_property
def ai(self) -> AsyncAIResourceWithRawResponse:
return AsyncAIResourceWithRawResponse(self._workers.ai)

@cached_property
def assets(self) -> AsyncAssetsResourceWithRawResponse:
return AsyncAssetsResourceWithRawResponse(self._workers.assets)
Expand All @@ -208,10 +184,6 @@ class WorkersResourceWithStreamingResponse:
def __init__(self, workers: WorkersResource) -> None:
self._workers = workers

@cached_property
def ai(self) -> AIResourceWithStreamingResponse:
return AIResourceWithStreamingResponse(self._workers.ai)

@cached_property
def assets(self) -> AssetsResourceWithStreamingResponse:
return AssetsResourceWithStreamingResponse(self._workers.assets)
Expand All @@ -237,10 +209,6 @@ class AsyncWorkersResourceWithStreamingResponse:
def __init__(self, workers: AsyncWorkersResource) -> None:
self._workers = workers

@cached_property
def ai(self) -> AsyncAIResourceWithStreamingResponse:
return AsyncAIResourceWithStreamingResponse(self._workers.ai)

@cached_property
def assets(self) -> AsyncAssetsResourceWithStreamingResponse:
return AsyncAssetsResourceWithStreamingResponse(self._workers.assets)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from .ai_run_params import AIRunParams as AIRunParams
from .ai_run_response import AIRunResponse as AIRunResponse
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions src/cloudflare/types/workers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
from .binding import Binding as Binding
from .d1_binding import D1Binding as D1Binding
from .r2_binding import R2Binding as R2Binding
from .ai_run_params import AIRunParams as AIRunParams
from .binding_param import BindingParam as BindingParam
from .migration_step import MigrationStep as MigrationStep
from .script_setting import ScriptSetting as ScriptSetting
from .ai_run_response import AIRunResponse as AIRunResponse
from .service_binding import ServiceBinding as ServiceBinding
from .d1_binding_param import D1BindingParam as D1BindingParam
from .r2_binding_param import R2BindingParam as R2BindingParam
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 674c2ce

Please sign in to comment.