diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 194e72b..36c1986 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0-alpha.6" + ".": "2.0.0-alpha.7" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 96d6bf4..f09ad10 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 35 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-f5aff38eef8d7b245a7af062bf02920ae75e5b9b3dc822416aeb48966c2c6874.yml -openapi_spec_hash: c0a966beaf5ae95c6bdddd4a933bd4aa +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-d174b63c516640a0987bbb0879d1cb435ecf6cbcfe7c9f6465bfcc5416eff8e1.yml +openapi_spec_hash: 46f69b0827b955f2adf93928fcfb2c57 config_hash: 71c9e54dad5d546e9a98afe5edc6742b diff --git a/CHANGELOG.md b/CHANGELOG.md index 5db9583..b1c7f02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 2.0.0-alpha.7 (2025-06-27) + +Full Changelog: [v2.0.0-alpha.6...v2.0.0-alpha.7](https://github.com/replicate/replicate-python-stainless/compare/v2.0.0-alpha.6...v2.0.0-alpha.7) + +### Features + +* **api:** api update ([b1c14c8](https://github.com/replicate/replicate-python-stainless/commit/b1c14c8291ca205930dafbf639ba5e7bf9939d3a)) + ## 2.0.0-alpha.6 (2025-06-26) Full Changelog: [v2.0.0-alpha.5...v2.0.0-alpha.6](https://github.com/replicate/replicate-python-stainless/compare/v2.0.0-alpha.5...v2.0.0-alpha.6) diff --git a/api.md b/api.md index a28a485..9bf36c7 100644 --- a/api.md +++ b/api.md @@ -1,9 +1,15 @@ # Collections +Types: + +```python +from replicate.types import CollectionListResponse, CollectionGetResponse +``` + Methods: -- replicate.collections.list() -> None -- replicate.collections.get(\*, collection_slug) -> None +- replicate.collections.list() -> SyncCursorURLPage[CollectionListResponse] +- replicate.collections.get(\*, collection_slug) -> CollectionGetResponse # Deployments @@ -61,12 +67,17 @@ Methods: Types: ```python -from replicate.types import ModelListResponse, ModelGetResponse, ModelSearchResponse +from replicate.types import ( + ModelCreateResponse, + ModelListResponse, + ModelGetResponse, + ModelSearchResponse, +) ``` Methods: -- replicate.models.create(\*\*params) -> None +- replicate.models.create(\*\*params) -> ModelCreateResponse - replicate.models.list() -> SyncCursorURLPage[ModelListResponse] - replicate.models.delete(\*, model_owner, model_name) -> None - replicate.models.get(\*, model_owner, model_name) -> ModelGetResponse @@ -76,7 +87,7 @@ Methods: Methods: -- replicate.models.examples.list(\*, model_owner, model_name) -> None +- replicate.models.examples.list(\*, model_owner, model_name) -> SyncCursorURLPage[Prediction] ## Predictions @@ -98,11 +109,17 @@ Methods: ## Versions +Types: + +```python +from replicate.types.models import VersionListResponse, VersionGetResponse +``` + Methods: -- replicate.models.versions.list(\*, model_owner, model_name) -> None +- replicate.models.versions.list(\*, model_owner, model_name) -> SyncCursorURLPage[VersionListResponse] - replicate.models.versions.delete(\*, model_owner, model_name, version_id) -> None -- replicate.models.versions.get(\*, model_owner, model_name, version_id) -> None +- replicate.models.versions.get(\*, model_owner, model_name, version_id) -> VersionGetResponse # Predictions diff --git a/pyproject.toml b/pyproject.toml index 95dd27d..9bdee11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "replicate" -version = "2.0.0-alpha.6" +version = "2.0.0-alpha.7" description = "The official Python library for the replicate API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/replicate/_version.py b/src/replicate/_version.py index a42a8e2..55abf49 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__ = "2.0.0-alpha.6" # x-release-please-version +__version__ = "2.0.0-alpha.7" # x-release-please-version diff --git a/src/replicate/resources/collections.py b/src/replicate/resources/collections.py index 57aeffd..3852d35 100644 --- a/src/replicate/resources/collections.py +++ b/src/replicate/resources/collections.py @@ -4,7 +4,7 @@ import httpx -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import ( @@ -13,7 +13,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.collection_get_response import CollectionGetResponse +from ..types.collection_list_response import CollectionListResponse __all__ = ["CollectionsResource", "AsyncCollectionsResource"] @@ -47,7 +50,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> SyncCursorURLPage[CollectionListResponse]: """ Example cURL request: @@ -73,13 +76,13 @@ def list( } ``` """ - extra_headers = {"Accept": "*/*", **(extra_headers or {})} - return self._get( + return self._get_api_list( "/collections", + page=SyncCursorURLPage[CollectionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + model=CollectionListResponse, ) def get( @@ -92,7 +95,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> CollectionGetResponse: """ Example cURL request: @@ -125,13 +128,12 @@ def get( """ if not collection_slug: raise ValueError(f"Expected a non-empty value for `collection_slug` but received {collection_slug!r}") - extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._get( f"/collections/{collection_slug}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + cast_to=CollectionGetResponse, ) @@ -155,7 +157,7 @@ def with_streaming_response(self) -> AsyncCollectionsResourceWithStreamingRespon """ return AsyncCollectionsResourceWithStreamingResponse(self) - 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. @@ -164,7 +166,7 @@ async def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> AsyncPaginator[CollectionListResponse, AsyncCursorURLPage[CollectionListResponse]]: """ Example cURL request: @@ -190,13 +192,13 @@ async def list( } ``` """ - extra_headers = {"Accept": "*/*", **(extra_headers or {})} - return await self._get( + return self._get_api_list( "/collections", + page=AsyncCursorURLPage[CollectionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + model=CollectionListResponse, ) async def get( @@ -209,7 +211,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> CollectionGetResponse: """ Example cURL request: @@ -242,13 +244,12 @@ async def get( """ if not collection_slug: raise ValueError(f"Expected a non-empty value for `collection_slug` but received {collection_slug!r}") - extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._get( f"/collections/{collection_slug}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + cast_to=CollectionGetResponse, ) diff --git a/src/replicate/resources/models/examples.py b/src/replicate/resources/models/examples.py index a989051..4425953 100644 --- a/src/replicate/resources/models/examples.py +++ b/src/replicate/resources/models/examples.py @@ -4,7 +4,7 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -13,7 +13,9 @@ 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 __all__ = ["ExamplesResource", "AsyncExamplesResource"] @@ -49,7 +51,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> SyncCursorURLPage[Prediction]: """ List [example predictions](https://replicate.com/docs/topics/models/publish-a-model#what-are-examples) @@ -96,13 +98,13 @@ def list( raise ValueError(f"Expected a non-empty value for `model_owner` but received {model_owner!r}") if not model_name: raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}") - extra_headers = {"Accept": "*/*", **(extra_headers or {})} - return self._get( + return self._get_api_list( f"/models/{model_owner}/{model_name}/examples", + page=SyncCursorURLPage[Prediction], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + model=Prediction, ) @@ -126,7 +128,7 @@ def with_streaming_response(self) -> AsyncExamplesResourceWithStreamingResponse: """ return AsyncExamplesResourceWithStreamingResponse(self) - async def list( + def list( self, *, model_owner: str, @@ -137,7 +139,7 @@ async def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> AsyncPaginator[Prediction, AsyncCursorURLPage[Prediction]]: """ List [example predictions](https://replicate.com/docs/topics/models/publish-a-model#what-are-examples) @@ -184,13 +186,13 @@ async def list( raise ValueError(f"Expected a non-empty value for `model_owner` but received {model_owner!r}") if not model_name: raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}") - extra_headers = {"Accept": "*/*", **(extra_headers or {})} - return await self._get( + return self._get_api_list( f"/models/{model_owner}/{model_name}/examples", + page=AsyncCursorURLPage[Prediction], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + model=Prediction, ) diff --git a/src/replicate/resources/models/models.py b/src/replicate/resources/models/models.py index 004bd07..671f482 100644 --- a/src/replicate/resources/models/models.py +++ b/src/replicate/resources/models/models.py @@ -53,6 +53,7 @@ from ..._base_client import AsyncPaginator, make_request_options from ...types.model_get_response import ModelGetResponse from ...types.model_list_response import ModelListResponse +from ...types.model_create_response import ModelCreateResponse from ...types.model_search_response import ModelSearchResponse __all__ = ["ModelsResource", "AsyncModelsResource"] @@ -112,7 +113,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> ModelCreateResponse: """ Create a model. @@ -183,7 +184,6 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ - extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._post( "/models", body=maybe_transform( @@ -203,7 +203,7 @@ def create( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + cast_to=ModelCreateResponse, ) def list( @@ -512,7 +512,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> ModelCreateResponse: """ Create a model. @@ -583,7 +583,6 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ - extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._post( "/models", body=await async_maybe_transform( @@ -603,7 +602,7 @@ async def create( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + cast_to=ModelCreateResponse, ) def list( diff --git a/src/replicate/resources/models/versions.py b/src/replicate/resources/models/versions.py index ac24b39..13a0f1b 100644 --- a/src/replicate/resources/models/versions.py +++ b/src/replicate/resources/models/versions.py @@ -13,7 +13,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.models.version_get_response import VersionGetResponse +from ...types.models.version_list_response import VersionListResponse __all__ = ["VersionsResource", "AsyncVersionsResource"] @@ -49,7 +52,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> SyncCursorURLPage[VersionListResponse]: """ Example cURL request: @@ -90,13 +93,13 @@ def list( raise ValueError(f"Expected a non-empty value for `model_owner` but received {model_owner!r}") if not model_name: raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}") - extra_headers = {"Accept": "*/*", **(extra_headers or {})} - return self._get( + return self._get_api_list( f"/models/{model_owner}/{model_name}/versions", + page=SyncCursorURLPage[VersionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + model=VersionListResponse, ) def delete( @@ -174,7 +177,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> VersionGetResponse: """ Example cURL request: @@ -248,13 +251,12 @@ def get( raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}") if not version_id: raise ValueError(f"Expected a non-empty value for `version_id` but received {version_id!r}") - extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._get( f"/models/{model_owner}/{model_name}/versions/{version_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + cast_to=VersionGetResponse, ) @@ -278,7 +280,7 @@ def with_streaming_response(self) -> AsyncVersionsResourceWithStreamingResponse: """ return AsyncVersionsResourceWithStreamingResponse(self) - async def list( + def list( self, *, model_owner: str, @@ -289,7 +291,7 @@ async def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> AsyncPaginator[VersionListResponse, AsyncCursorURLPage[VersionListResponse]]: """ Example cURL request: @@ -330,13 +332,13 @@ async def list( raise ValueError(f"Expected a non-empty value for `model_owner` but received {model_owner!r}") if not model_name: raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}") - extra_headers = {"Accept": "*/*", **(extra_headers or {})} - return await self._get( + return self._get_api_list( f"/models/{model_owner}/{model_name}/versions", + page=AsyncCursorURLPage[VersionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + model=VersionListResponse, ) async def delete( @@ -414,7 +416,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> None: + ) -> VersionGetResponse: """ Example cURL request: @@ -488,13 +490,12 @@ async def get( raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}") if not version_id: raise ValueError(f"Expected a non-empty value for `version_id` but received {version_id!r}") - extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._get( f"/models/{model_owner}/{model_name}/versions/{version_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=NoneType, + cast_to=VersionGetResponse, ) diff --git a/src/replicate/types/__init__.py b/src/replicate/types/__init__.py index f398100..ea8b27c 100644 --- a/src/replicate/types/__init__.py +++ b/src/replicate/types/__init__.py @@ -13,13 +13,16 @@ from .account_get_response import AccountGetResponse as AccountGetResponse from .file_create_response import FileCreateResponse as FileCreateResponse from .file_download_params import FileDownloadParams as FileDownloadParams +from .model_create_response import ModelCreateResponse as ModelCreateResponse from .model_search_response import ModelSearchResponse as ModelSearchResponse from .training_get_response import TrainingGetResponse as TrainingGetResponse from .hardware_list_response import HardwareListResponse as HardwareListResponse from .prediction_list_params import PredictionListParams as PredictionListParams from .training_create_params import TrainingCreateParams as TrainingCreateParams from .training_list_response import TrainingListResponse as TrainingListResponse +from .collection_get_response import CollectionGetResponse as CollectionGetResponse from .deployment_get_response import DeploymentGetResponse as DeploymentGetResponse +from .collection_list_response import CollectionListResponse as CollectionListResponse from .deployment_create_params import DeploymentCreateParams as DeploymentCreateParams from .deployment_list_response import DeploymentListResponse as DeploymentListResponse from .deployment_update_params import DeploymentUpdateParams as DeploymentUpdateParams diff --git a/src/replicate/types/collection_get_response.py b/src/replicate/types/collection_get_response.py new file mode 100644 index 0000000..3644266 --- /dev/null +++ b/src/replicate/types/collection_get_response.py @@ -0,0 +1,60 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["CollectionGetResponse", "Model"] + + +class Model(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""" + + +class CollectionGetResponse(BaseModel): + description: str + """A description of the collection""" + + models: List[Model] + """The models in this collection""" + + name: str + """The name of the collection""" + + slug: str + """The slug of the collection (lowercase with dashes)""" diff --git a/src/replicate/types/collection_list_response.py b/src/replicate/types/collection_list_response.py new file mode 100644 index 0000000..b4c950c --- /dev/null +++ b/src/replicate/types/collection_list_response.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .._models import BaseModel + +__all__ = ["CollectionListResponse"] + + +class CollectionListResponse(BaseModel): + description: str + """A description of the collection""" + + name: str + """The name of the collection""" + + slug: str + """The slug of the collection (lowercase with dashes)""" diff --git a/src/replicate/types/model_create_response.py b/src/replicate/types/model_create_response.py new file mode 100644 index 0000000..f053782 --- /dev/null +++ b/src/replicate/types/model_create_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__ = ["ModelCreateResponse"] + + +class ModelCreateResponse(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/src/replicate/types/models/__init__.py b/src/replicate/types/models/__init__.py index b53e1a7..bb24e66 100644 --- a/src/replicate/types/models/__init__.py +++ b/src/replicate/types/models/__init__.py @@ -3,4 +3,6 @@ from __future__ import annotations from .readme_get_response import ReadmeGetResponse as ReadmeGetResponse +from .version_get_response import VersionGetResponse as VersionGetResponse +from .version_list_response import VersionListResponse as VersionListResponse from .prediction_create_params import PredictionCreateParams as PredictionCreateParams diff --git a/src/replicate/types/models/version_get_response.py b/src/replicate/types/models/version_get_response.py new file mode 100644 index 0000000..78cdd7b --- /dev/null +++ b/src/replicate/types/models/version_get_response.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["VersionGetResponse"] + + +class VersionGetResponse(BaseModel): + id: Optional[str] = None + """The ID of the version""" + + cog_version: Optional[str] = None + """The version of Cog used to create this version""" + + created_at: Optional[datetime] = None + """The date and time the version was created""" + + openapi_schema: Optional[object] = None + """The OpenAPI schema for the model's inputs and outputs""" diff --git a/src/replicate/types/models/version_list_response.py b/src/replicate/types/models/version_list_response.py new file mode 100644 index 0000000..a915374 --- /dev/null +++ b/src/replicate/types/models/version_list_response.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["VersionListResponse"] + + +class VersionListResponse(BaseModel): + id: Optional[str] = None + """The ID of the version""" + + cog_version: Optional[str] = None + """The version of Cog used to create this version""" + + created_at: Optional[datetime] = None + """The date and time the version was created""" + + openapi_schema: Optional[object] = None + """The OpenAPI schema for the model's inputs and outputs""" diff --git a/tests/api_resources/models/test_examples.py b/tests/api_resources/models/test_examples.py index 8d499cc..64ca11e 100644 --- a/tests/api_resources/models/test_examples.py +++ b/tests/api_resources/models/test_examples.py @@ -8,6 +8,9 @@ import pytest from replicate import Replicate, AsyncReplicate +from tests.utils import assert_matches_type +from replicate.types import Prediction +from replicate.pagination import SyncCursorURLPage, AsyncCursorURLPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -22,7 +25,7 @@ def test_method_list(self, client: Replicate) -> None: model_owner="model_owner", model_name="model_name", ) - assert example is None + assert_matches_type(SyncCursorURLPage[Prediction], example, path=["response"]) @pytest.mark.skip() @parametrize @@ -35,7 +38,7 @@ def test_raw_response_list(self, client: Replicate) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" example = response.parse() - assert example is None + assert_matches_type(SyncCursorURLPage[Prediction], example, path=["response"]) @pytest.mark.skip() @parametrize @@ -48,7 +51,7 @@ def test_streaming_response_list(self, client: Replicate) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" example = response.parse() - assert example is None + assert_matches_type(SyncCursorURLPage[Prediction], example, path=["response"]) assert cast(Any, response.is_closed) is True @@ -80,7 +83,7 @@ async def test_method_list(self, async_client: AsyncReplicate) -> None: model_owner="model_owner", model_name="model_name", ) - assert example is None + assert_matches_type(AsyncCursorURLPage[Prediction], example, path=["response"]) @pytest.mark.skip() @parametrize @@ -93,7 +96,7 @@ async def test_raw_response_list(self, async_client: AsyncReplicate) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" example = await response.parse() - assert example is None + assert_matches_type(AsyncCursorURLPage[Prediction], example, path=["response"]) @pytest.mark.skip() @parametrize @@ -106,7 +109,7 @@ async def test_streaming_response_list(self, async_client: AsyncReplicate) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" example = await response.parse() - assert example is None + assert_matches_type(AsyncCursorURLPage[Prediction], example, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/models/test_versions.py b/tests/api_resources/models/test_versions.py index b827c92..82b0c60 100644 --- a/tests/api_resources/models/test_versions.py +++ b/tests/api_resources/models/test_versions.py @@ -8,6 +8,9 @@ import pytest from replicate import Replicate, AsyncReplicate +from tests.utils import assert_matches_type +from replicate.pagination import SyncCursorURLPage, AsyncCursorURLPage +from replicate.types.models import VersionGetResponse, VersionListResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -22,7 +25,7 @@ def test_method_list(self, client: Replicate) -> None: model_owner="model_owner", model_name="model_name", ) - assert version is None + assert_matches_type(SyncCursorURLPage[VersionListResponse], version, path=["response"]) @pytest.mark.skip() @parametrize @@ -35,7 +38,7 @@ def test_raw_response_list(self, client: Replicate) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = response.parse() - assert version is None + assert_matches_type(SyncCursorURLPage[VersionListResponse], version, path=["response"]) @pytest.mark.skip() @parametrize @@ -48,7 +51,7 @@ def test_streaming_response_list(self, client: Replicate) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = response.parse() - assert version is None + assert_matches_type(SyncCursorURLPage[VersionListResponse], version, path=["response"]) assert cast(Any, response.is_closed) is True @@ -139,7 +142,7 @@ def test_method_get(self, client: Replicate) -> None: model_name="model_name", version_id="version_id", ) - assert version is None + assert_matches_type(VersionGetResponse, version, path=["response"]) @pytest.mark.skip() @parametrize @@ -153,7 +156,7 @@ def test_raw_response_get(self, client: Replicate) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = response.parse() - assert version is None + assert_matches_type(VersionGetResponse, version, path=["response"]) @pytest.mark.skip() @parametrize @@ -167,7 +170,7 @@ def test_streaming_response_get(self, client: Replicate) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = response.parse() - assert version is None + assert_matches_type(VersionGetResponse, version, path=["response"]) assert cast(Any, response.is_closed) is True @@ -208,7 +211,7 @@ async def test_method_list(self, async_client: AsyncReplicate) -> None: model_owner="model_owner", model_name="model_name", ) - assert version is None + assert_matches_type(AsyncCursorURLPage[VersionListResponse], version, path=["response"]) @pytest.mark.skip() @parametrize @@ -221,7 +224,7 @@ async def test_raw_response_list(self, async_client: AsyncReplicate) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = await response.parse() - assert version is None + assert_matches_type(AsyncCursorURLPage[VersionListResponse], version, path=["response"]) @pytest.mark.skip() @parametrize @@ -234,7 +237,7 @@ async def test_streaming_response_list(self, async_client: AsyncReplicate) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = await response.parse() - assert version is None + assert_matches_type(AsyncCursorURLPage[VersionListResponse], version, path=["response"]) assert cast(Any, response.is_closed) is True @@ -325,7 +328,7 @@ async def test_method_get(self, async_client: AsyncReplicate) -> None: model_name="model_name", version_id="version_id", ) - assert version is None + assert_matches_type(VersionGetResponse, version, path=["response"]) @pytest.mark.skip() @parametrize @@ -339,7 +342,7 @@ async def test_raw_response_get(self, async_client: AsyncReplicate) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = await response.parse() - assert version is None + assert_matches_type(VersionGetResponse, version, path=["response"]) @pytest.mark.skip() @parametrize @@ -353,7 +356,7 @@ async def test_streaming_response_get(self, async_client: AsyncReplicate) -> Non assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = await response.parse() - assert version is None + assert_matches_type(VersionGetResponse, version, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_collections.py b/tests/api_resources/test_collections.py index b3834f8..56e88b0 100644 --- a/tests/api_resources/test_collections.py +++ b/tests/api_resources/test_collections.py @@ -8,6 +8,9 @@ import pytest from replicate import Replicate, AsyncReplicate +from tests.utils import assert_matches_type +from replicate.types import CollectionGetResponse, CollectionListResponse +from replicate.pagination import SyncCursorURLPage, AsyncCursorURLPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -19,7 +22,7 @@ class TestCollections: @parametrize def test_method_list(self, client: Replicate) -> None: collection = client.collections.list() - assert collection is None + assert_matches_type(SyncCursorURLPage[CollectionListResponse], collection, path=["response"]) @pytest.mark.skip() @parametrize @@ -29,7 +32,7 @@ def test_raw_response_list(self, client: Replicate) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" collection = response.parse() - assert collection is None + assert_matches_type(SyncCursorURLPage[CollectionListResponse], collection, path=["response"]) @pytest.mark.skip() @parametrize @@ -39,7 +42,7 @@ def test_streaming_response_list(self, client: Replicate) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" collection = response.parse() - assert collection is None + assert_matches_type(SyncCursorURLPage[CollectionListResponse], collection, path=["response"]) assert cast(Any, response.is_closed) is True @@ -49,7 +52,7 @@ def test_method_get(self, client: Replicate) -> None: collection = client.collections.get( collection_slug="collection_slug", ) - assert collection is None + assert_matches_type(CollectionGetResponse, collection, path=["response"]) @pytest.mark.skip() @parametrize @@ -61,7 +64,7 @@ def test_raw_response_get(self, client: Replicate) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" collection = response.parse() - assert collection is None + assert_matches_type(CollectionGetResponse, collection, path=["response"]) @pytest.mark.skip() @parametrize @@ -73,7 +76,7 @@ def test_streaming_response_get(self, client: Replicate) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" collection = response.parse() - assert collection is None + assert_matches_type(CollectionGetResponse, collection, path=["response"]) assert cast(Any, response.is_closed) is True @@ -95,7 +98,7 @@ class TestAsyncCollections: @parametrize async def test_method_list(self, async_client: AsyncReplicate) -> None: collection = await async_client.collections.list() - assert collection is None + assert_matches_type(AsyncCursorURLPage[CollectionListResponse], collection, path=["response"]) @pytest.mark.skip() @parametrize @@ -105,7 +108,7 @@ async def test_raw_response_list(self, async_client: AsyncReplicate) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" collection = await response.parse() - assert collection is None + assert_matches_type(AsyncCursorURLPage[CollectionListResponse], collection, path=["response"]) @pytest.mark.skip() @parametrize @@ -115,7 +118,7 @@ async def test_streaming_response_list(self, async_client: AsyncReplicate) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" collection = await response.parse() - assert collection is None + assert_matches_type(AsyncCursorURLPage[CollectionListResponse], collection, path=["response"]) assert cast(Any, response.is_closed) is True @@ -125,7 +128,7 @@ async def test_method_get(self, async_client: AsyncReplicate) -> None: collection = await async_client.collections.get( collection_slug="collection_slug", ) - assert collection is None + assert_matches_type(CollectionGetResponse, collection, path=["response"]) @pytest.mark.skip() @parametrize @@ -137,7 +140,7 @@ async def test_raw_response_get(self, async_client: AsyncReplicate) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" collection = await response.parse() - assert collection is None + assert_matches_type(CollectionGetResponse, collection, path=["response"]) @pytest.mark.skip() @parametrize @@ -149,7 +152,7 @@ async def test_streaming_response_get(self, async_client: AsyncReplicate) -> Non assert response.http_request.headers.get("X-Stainless-Lang") == "python" collection = await response.parse() - assert collection is None + assert_matches_type(CollectionGetResponse, collection, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_models.py b/tests/api_resources/test_models.py index 9b07d74..02b98c6 100644 --- a/tests/api_resources/test_models.py +++ b/tests/api_resources/test_models.py @@ -12,6 +12,7 @@ from replicate.types import ( ModelGetResponse, ModelListResponse, + ModelCreateResponse, ModelSearchResponse, ) from replicate.pagination import SyncCursorURLPage, AsyncCursorURLPage @@ -31,7 +32,7 @@ def test_method_create(self, client: Replicate) -> None: owner="alice", visibility="public", ) - assert model is None + assert_matches_type(ModelCreateResponse, model, path=["response"]) @pytest.mark.skip() @parametrize @@ -47,7 +48,7 @@ def test_method_create_with_all_params(self, client: Replicate) -> None: license_url="license_url", paper_url="https://arxiv.org/abs/2504.17639", ) - assert model is None + assert_matches_type(ModelCreateResponse, model, path=["response"]) @pytest.mark.skip() @parametrize @@ -62,7 +63,7 @@ def test_raw_response_create(self, client: Replicate) -> 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(ModelCreateResponse, model, path=["response"]) @pytest.mark.skip() @parametrize @@ -77,7 +78,7 @@ def test_streaming_response_create(self, client: Replicate) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" model = response.parse() - assert model is None + assert_matches_type(ModelCreateResponse, model, path=["response"]) assert cast(Any, response.is_closed) is True @@ -262,7 +263,7 @@ async def test_method_create(self, async_client: AsyncReplicate) -> None: owner="alice", visibility="public", ) - assert model is None + assert_matches_type(ModelCreateResponse, model, path=["response"]) @pytest.mark.skip() @parametrize @@ -278,7 +279,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncReplicate) license_url="license_url", paper_url="https://arxiv.org/abs/2504.17639", ) - assert model is None + assert_matches_type(ModelCreateResponse, model, path=["response"]) @pytest.mark.skip() @parametrize @@ -293,7 +294,7 @@ async def test_raw_response_create(self, async_client: AsyncReplicate) -> None: 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(ModelCreateResponse, model, path=["response"]) @pytest.mark.skip() @parametrize @@ -308,7 +309,7 @@ async def test_streaming_response_create(self, async_client: AsyncReplicate) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" model = await response.parse() - assert model is None + assert_matches_type(ModelCreateResponse, model, path=["response"]) assert cast(Any, response.is_closed) is True