From ee5fd8b119cb4a53467e71a5c52dac4fc1779385 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 16 Apr 2025 03:20:06 +0000 Subject: [PATCH 1/3] chore: update SDK settings --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ecd4d60..24efe26 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 27 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-b45f922f6a041550870a96f5acec02aa6d8830046fc98b95a275c6486f7586fc.yml openapi_spec_hash: ef7fddfb49b4d9c440b0635d2c86f341 -config_hash: 919042036f115da833f492aa6f7e3ada +config_hash: 810de4c2eee1a7649263cff01f00da7c From 79f022aa879e6c0688197557795e04ffecd93f52 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 16 Apr 2025 04:30:52 +0000 Subject: [PATCH 2/3] feat(api): api update --- .stats.yml | 4 +- api.md | 8 +++- src/replicate/resources/models/models.py | 22 ++++++----- src/replicate/types/__init__.py | 1 + src/replicate/types/model_list_response.py | 46 ++++++++++++++++++++++ tests/api_resources/test_models.py | 15 +++---- 6 files changed, 76 insertions(+), 20 deletions(-) create mode 100644 src/replicate/types/model_list_response.py diff --git a/.stats.yml b/.stats.yml index 24efe26..91aadf3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 27 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-b45f922f6a041550870a96f5acec02aa6d8830046fc98b95a275c6486f7586fc.yml -openapi_spec_hash: ef7fddfb49b4d9c440b0635d2c86f341 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-37bb31ed76da599d3bded543a3765f745c8575d105c13554df7f8361c3641482.yml +openapi_spec_hash: 15bdec12ca84042768bfb28cc48dfce3 config_hash: 810de4c2eee1a7649263cff01f00da7c diff --git a/api.md b/api.md index de9675b..60e91e6 100644 --- a/api.md +++ b/api.md @@ -59,11 +59,17 @@ Methods: # Models +Types: + +```python +from replicate.types import ModelListResponse +``` + Methods: - client.models.create(\*\*params) -> None - client.models.retrieve(model_name, \*, model_owner) -> None -- client.models.list() -> None +- client.models.list() -> SyncCursorURLPage[ModelListResponse] - client.models.delete(model_name, \*, model_owner) -> None - client.models.create_prediction(model_name, \*, model_owner, \*\*params) -> Prediction diff --git a/src/replicate/resources/models/models.py b/src/replicate/resources/models/models.py index 73cfad5..77145ae 100644 --- a/src/replicate/resources/models/models.py +++ b/src/replicate/resources/models/models.py @@ -30,8 +30,10 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ..._base_client import make_request_options +from ...pagination import SyncCursorURLPage, AsyncCursorURLPage +from ..._base_client import AsyncPaginator, make_request_options from ...types.prediction import Prediction +from ...types.model_list_response import ModelListResponse __all__ = ["ModelsResource", "AsyncModelsResource"] @@ -290,7 +292,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> SyncCursorURLPage[ModelListResponse]: """ Get a paginated list of public models. @@ -307,13 +309,13 @@ def list( See the [`models.get`](#models.get) docs for more details about the model object. """ - extra_headers = {"Accept": "*/*", **(extra_headers or {})} - return self._get( + return self._get_api_list( "/models", + page=SyncCursorURLPage[ModelListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + model=ModelListResponse, ) def delete( @@ -758,7 +760,7 @@ async def retrieve( cast_to=NoneType, ) - async def list( + def list( self, *, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -767,7 +769,7 @@ async def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> AsyncPaginator[ModelListResponse, AsyncCursorURLPage[ModelListResponse]]: """ Get a paginated list of public models. @@ -784,13 +786,13 @@ async def list( See the [`models.get`](#models.get) docs for more details about the model object. """ - extra_headers = {"Accept": "*/*", **(extra_headers or {})} - return await self._get( + return self._get_api_list( "/models", + page=AsyncCursorURLPage[ModelListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + model=ModelListResponse, ) async def delete( diff --git a/src/replicate/types/__init__.py b/src/replicate/types/__init__.py index 774d304..e2b3c58 100644 --- a/src/replicate/types/__init__.py +++ b/src/replicate/types/__init__.py @@ -5,6 +5,7 @@ from .prediction import Prediction as Prediction from .prediction_output import PredictionOutput as PredictionOutput from .model_create_params import ModelCreateParams as ModelCreateParams +from .model_list_response import ModelListResponse as ModelListResponse from .account_list_response import AccountListResponse as AccountListResponse from .hardware_list_response import HardwareListResponse as HardwareListResponse from .prediction_list_params import PredictionListParams as PredictionListParams diff --git a/src/replicate/types/model_list_response.py b/src/replicate/types/model_list_response.py new file mode 100644 index 0000000..080cffd --- /dev/null +++ b/src/replicate/types/model_list_response.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["ModelListResponse"] + + +class ModelListResponse(BaseModel): + cover_image_url: Optional[str] = None + """A URL for the model's cover image""" + + default_example: Optional[object] = None + """The model's default example prediction""" + + description: Optional[str] = None + """A description of the model""" + + github_url: Optional[str] = None + """A URL for the model's source code on GitHub""" + + latest_version: Optional[object] = None + """The model's latest version""" + + license_url: Optional[str] = None + """A URL for the model's license""" + + name: Optional[str] = None + """The name of the model""" + + owner: Optional[str] = None + """The name of the user or organization that owns the model""" + + paper_url: Optional[str] = None + """A URL for the model's paper""" + + run_count: Optional[int] = None + """The number of times the model has been run""" + + url: Optional[str] = None + """The URL of the model on Replicate""" + + visibility: Optional[Literal["public", "private"]] = None + """Whether the model is public or private""" diff --git a/tests/api_resources/test_models.py b/tests/api_resources/test_models.py index 13bd068..f56f00c 100644 --- a/tests/api_resources/test_models.py +++ b/tests/api_resources/test_models.py @@ -9,7 +9,8 @@ from replicate import ReplicateClient, AsyncReplicateClient from tests.utils import assert_matches_type -from replicate.types import Prediction +from replicate.types import Prediction, ModelListResponse +from replicate.pagination import SyncCursorURLPage, AsyncCursorURLPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -132,7 +133,7 @@ def test_path_params_retrieve(self, client: ReplicateClient) -> None: @parametrize def test_method_list(self, client: ReplicateClient) -> None: model = client.models.list() - assert model is None + assert_matches_type(SyncCursorURLPage[ModelListResponse], model, path=["response"]) @pytest.mark.skip() @parametrize @@ -142,7 +143,7 @@ def test_raw_response_list(self, client: ReplicateClient) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" model = response.parse() - assert model is None + assert_matches_type(SyncCursorURLPage[ModelListResponse], model, path=["response"]) @pytest.mark.skip() @parametrize @@ -152,7 +153,7 @@ def test_streaming_response_list(self, client: ReplicateClient) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" model = response.parse() - assert model is None + assert_matches_type(SyncCursorURLPage[ModelListResponse], model, path=["response"]) assert cast(Any, response.is_closed) is True @@ -398,7 +399,7 @@ async def test_path_params_retrieve(self, async_client: AsyncReplicateClient) -> @parametrize async def test_method_list(self, async_client: AsyncReplicateClient) -> None: model = await async_client.models.list() - assert model is None + assert_matches_type(AsyncCursorURLPage[ModelListResponse], model, path=["response"]) @pytest.mark.skip() @parametrize @@ -408,7 +409,7 @@ async def test_raw_response_list(self, async_client: AsyncReplicateClient) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" model = await response.parse() - assert model is None + assert_matches_type(AsyncCursorURLPage[ModelListResponse], model, path=["response"]) @pytest.mark.skip() @parametrize @@ -418,7 +419,7 @@ async def test_streaming_response_list(self, async_client: AsyncReplicateClient) assert response.http_request.headers.get("X-Stainless-Lang") == "python" model = await response.parse() - assert model is None + assert_matches_type(AsyncCursorURLPage[ModelListResponse], model, path=["response"]) assert cast(Any, response.is_closed) is True From d90bfa926efa95efe73c30683cc833a1e1e5df4b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 16 Apr 2025 15:58:42 +0000 Subject: [PATCH 3/3] release: 0.1.0-alpha.2 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 13 +++++++++++++ pyproject.toml | 2 +- src/replicate/_version.py | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ba6c348..f14b480 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.1" + ".": "0.1.0-alpha.2" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e1bb8b..d51ac7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.1.0-alpha.2 (2025-04-16) + +Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/replicate/replicate-python-stainless/compare/v0.1.0-alpha.1...v0.1.0-alpha.2) + +### Features + +* **api:** api update ([79f022a](https://github.com/replicate/replicate-python-stainless/commit/79f022aa879e6c0688197557795e04ffecd93f52)) + + +### Chores + +* update SDK settings ([ee5fd8b](https://github.com/replicate/replicate-python-stainless/commit/ee5fd8b119cb4a53467e71a5c52dac4fc1779385)) + ## 0.1.0-alpha.1 (2025-04-15) Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/replicate/replicate-python-stainless/compare/v0.0.1-alpha.0...v0.1.0-alpha.1) diff --git a/pyproject.toml b/pyproject.toml index 1e9a8a0..d9681a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "replicate-stainless" -version = "0.1.0-alpha.1" +version = "0.1.0-alpha.2" description = "The official Python library for the replicate-client API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/replicate/_version.py b/src/replicate/_version.py index 131bd44..dfeb99c 100644 --- a/src/replicate/_version.py +++ b/src/replicate/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "replicate" -__version__ = "0.1.0-alpha.1" # x-release-please-version +__version__ = "0.1.0-alpha.2" # x-release-please-version