Skip to content

feat(ai)!: move to dedicated namespace #2269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
37 changes: 37 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 @@ -718,6 +719,12 @@ def abuse_reports(self) -> abuse_reports.AbuseReportsResource:

return AbuseReportsResource(self)

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

return AIResource(self)

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

return AsyncAbuseReportsResource(self)

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

return AsyncAIResource(self)

@cached_property
def with_raw_response(self) -> AsyncCloudflareWithRawResponse:
return AsyncCloudflareWithRawResponse(self)
Expand Down Expand Up @@ -2183,6 +2196,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 @@ -2702,6 +2721,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 @@ -3221,6 +3246,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 @@ -3750,6 +3781,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
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@
ModelsResourceWithStreamingResponse,
AsyncModelsResourceWithStreamingResponse,
)
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
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
33 changes: 0 additions & 33 deletions src/cloudflare/resources/workers/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

from __future__ import annotations

from .ai import (
AIResource,
AsyncAIResource,
AIResourceWithRawResponse,
AsyncAIResourceWithRawResponse,
AIResourceWithStreamingResponse,
AsyncAIResourceWithStreamingResponse,
)
from .ai.ai import AIResource, AsyncAIResource
from .assets import (
AssetsResource,
AsyncAssetsResource,
Expand Down Expand Up @@ -60,10 +51,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 @@ -105,10 +92,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 @@ -153,10 +136,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 @@ -182,10 +161,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 @@ -211,10 +186,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 @@ -240,10 +211,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
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
Loading