diff --git a/.release-please-manifest.json b/.release-please-manifest.json index aaf968a..b56c3d0 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.3" + ".": "0.1.0-alpha.4" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 190fe36..ca7f462 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 27 +configured_endpoints: 29 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-2788217b7ad7d61d1a77800bc5ff12a6810f1692d4d770b72fa8f898c6a055ab.yml openapi_spec_hash: 4423bf747e228484547b441468a9f156 -config_hash: d1d273c0d97d034d24c7eac8ef51d2ac +config_hash: 976e20887b4e455f639ee6917de350b8 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bde67f..5be0765 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0-alpha.4 (2025-04-23) + +Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/replicate/replicate-python-stainless/compare/v0.1.0-alpha.3...v0.1.0-alpha.4) + +### Features + +* **api:** add `models.readme.get` and `models.examples.list` operations ([bcac9e5](https://github.com/replicate/replicate-python-stainless/commit/bcac9e51671f466b76f5eed7f4336189c6967326)) + ## 0.1.0-alpha.3 (2025-04-23) Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/replicate/replicate-python-stainless/compare/v0.1.0-alpha.2...v0.1.0-alpha.3) diff --git a/api.md b/api.md index e972297..65828d6 100644 --- a/api.md +++ b/api.md @@ -73,6 +73,24 @@ Methods: - client.models.create_prediction(model_name, \*, model_owner, \*\*params) -> Prediction - client.models.get(model_name, \*, model_owner) -> None +## Examples + +Methods: + +- client.models.examples.list(model_name, \*, model_owner) -> None + +## Readme + +Types: + +```python +from replicate.types.models import ReadmeGetResponse +``` + +Methods: + +- client.models.readme.get(model_name, \*, model_owner) -> str + ## Versions Types: diff --git a/pyproject.toml b/pyproject.toml index 4376f13..8854bbc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "replicate-stainless" -version = "0.1.0-alpha.3" +version = "0.1.0-alpha.4" 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 5b5e6c4..e966f49 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.3" # x-release-please-version +__version__ = "0.1.0-alpha.4" # x-release-please-version diff --git a/src/replicate/resources/models/__init__.py b/src/replicate/resources/models/__init__.py index 7a3c3ff..8afd09c 100644 --- a/src/replicate/resources/models/__init__.py +++ b/src/replicate/resources/models/__init__.py @@ -8,6 +8,22 @@ ModelsResourceWithStreamingResponse, AsyncModelsResourceWithStreamingResponse, ) +from .readme import ( + ReadmeResource, + AsyncReadmeResource, + ReadmeResourceWithRawResponse, + AsyncReadmeResourceWithRawResponse, + ReadmeResourceWithStreamingResponse, + AsyncReadmeResourceWithStreamingResponse, +) +from .examples import ( + ExamplesResource, + AsyncExamplesResource, + ExamplesResourceWithRawResponse, + AsyncExamplesResourceWithRawResponse, + ExamplesResourceWithStreamingResponse, + AsyncExamplesResourceWithStreamingResponse, +) from .versions import ( VersionsResource, AsyncVersionsResource, @@ -18,6 +34,18 @@ ) __all__ = [ + "ExamplesResource", + "AsyncExamplesResource", + "ExamplesResourceWithRawResponse", + "AsyncExamplesResourceWithRawResponse", + "ExamplesResourceWithStreamingResponse", + "AsyncExamplesResourceWithStreamingResponse", + "ReadmeResource", + "AsyncReadmeResource", + "ReadmeResourceWithRawResponse", + "AsyncReadmeResourceWithRawResponse", + "ReadmeResourceWithStreamingResponse", + "AsyncReadmeResourceWithStreamingResponse", "VersionsResource", "AsyncVersionsResource", "VersionsResourceWithRawResponse", diff --git a/src/replicate/resources/models/examples.py b/src/replicate/resources/models/examples.py new file mode 100644 index 0000000..dfb4df5 --- /dev/null +++ b/src/replicate/resources/models/examples.py @@ -0,0 +1,230 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +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 ..._base_client import make_request_options + +__all__ = ["ExamplesResource", "AsyncExamplesResource"] + + +class ExamplesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ExamplesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/replicate/replicate-python-stainless#accessing-raw-response-data-eg-headers + """ + return ExamplesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ExamplesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/replicate/replicate-python-stainless#with_streaming_response + """ + return ExamplesResourceWithStreamingResponse(self) + + def list( + self, + model_name: str, + *, + model_owner: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> None: + """ + List + [example predictions](https://replicate.com/docs/topics/models/publish-a-model#what-are-examples) + made using the model. These are predictions that were saved by the model author + as illustrative examples of the model's capabilities. + + If you want all the examples for a model, use this operation. + + If you just want the model's default example, you can use the + [`models.get`](#models.get) operation instead, which includes a + `default_example` object. + + Example cURL request: + + ```console + curl -s \\ + -H "Authorization: Bearer $REPLICATE_API_TOKEN" \\ + https://api.replicate.com/v1/models/replicate/hello-world/examples + ``` + + The response will be a pagination object containing a list of example + predictions: + + ```json + { + "next": "https://api.replicate.com/v1/models/replicate/hello-world/examples?cursor=...", + "previous": "https://api.replicate.com/v1/models/replicate/hello-world/examples?cursor=...", + "results": [...] + } + ``` + + Each item in the `results` list is a [prediction object](#predictions.get). + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not model_owner: + 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( + f"/models/{model_owner}/{model_name}/examples", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + +class AsyncExamplesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncExamplesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/replicate/replicate-python-stainless#accessing-raw-response-data-eg-headers + """ + return AsyncExamplesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncExamplesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/replicate/replicate-python-stainless#with_streaming_response + """ + return AsyncExamplesResourceWithStreamingResponse(self) + + async def list( + self, + model_name: str, + *, + model_owner: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> None: + """ + List + [example predictions](https://replicate.com/docs/topics/models/publish-a-model#what-are-examples) + made using the model. These are predictions that were saved by the model author + as illustrative examples of the model's capabilities. + + If you want all the examples for a model, use this operation. + + If you just want the model's default example, you can use the + [`models.get`](#models.get) operation instead, which includes a + `default_example` object. + + Example cURL request: + + ```console + curl -s \\ + -H "Authorization: Bearer $REPLICATE_API_TOKEN" \\ + https://api.replicate.com/v1/models/replicate/hello-world/examples + ``` + + The response will be a pagination object containing a list of example + predictions: + + ```json + { + "next": "https://api.replicate.com/v1/models/replicate/hello-world/examples?cursor=...", + "previous": "https://api.replicate.com/v1/models/replicate/hello-world/examples?cursor=...", + "results": [...] + } + ``` + + Each item in the `results` list is a [prediction object](#predictions.get). + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not model_owner: + 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( + f"/models/{model_owner}/{model_name}/examples", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + +class ExamplesResourceWithRawResponse: + def __init__(self, examples: ExamplesResource) -> None: + self._examples = examples + + self.list = to_raw_response_wrapper( + examples.list, + ) + + +class AsyncExamplesResourceWithRawResponse: + def __init__(self, examples: AsyncExamplesResource) -> None: + self._examples = examples + + self.list = async_to_raw_response_wrapper( + examples.list, + ) + + +class ExamplesResourceWithStreamingResponse: + def __init__(self, examples: ExamplesResource) -> None: + self._examples = examples + + self.list = to_streamed_response_wrapper( + examples.list, + ) + + +class AsyncExamplesResourceWithStreamingResponse: + def __init__(self, examples: AsyncExamplesResource) -> None: + self._examples = examples + + self.list = async_to_streamed_response_wrapper( + examples.list, + ) diff --git a/src/replicate/resources/models/models.py b/src/replicate/resources/models/models.py index 435101f..df1bf42 100644 --- a/src/replicate/resources/models/models.py +++ b/src/replicate/resources/models/models.py @@ -7,9 +7,25 @@ import httpx +from .readme import ( + ReadmeResource, + AsyncReadmeResource, + ReadmeResourceWithRawResponse, + AsyncReadmeResourceWithRawResponse, + ReadmeResourceWithStreamingResponse, + AsyncReadmeResourceWithStreamingResponse, +) from ...types import model_create_params, model_create_prediction_params from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven from ..._utils import maybe_transform, strip_not_given, async_maybe_transform +from .examples import ( + ExamplesResource, + AsyncExamplesResource, + ExamplesResourceWithRawResponse, + AsyncExamplesResourceWithRawResponse, + ExamplesResourceWithStreamingResponse, + AsyncExamplesResourceWithStreamingResponse, +) from .versions import ( VersionsResource, AsyncVersionsResource, @@ -35,6 +51,14 @@ class ModelsResource(SyncAPIResource): + @cached_property + def examples(self) -> ExamplesResource: + return ExamplesResource(self._client) + + @cached_property + def readme(self) -> ReadmeResource: + return ReadmeResource(self._client) + @cached_property def versions(self) -> VersionsResource: return VersionsResource(self._client) @@ -512,6 +536,14 @@ def get( class AsyncModelsResource(AsyncAPIResource): + @cached_property + def examples(self) -> AsyncExamplesResource: + return AsyncExamplesResource(self._client) + + @cached_property + def readme(self) -> AsyncReadmeResource: + return AsyncReadmeResource(self._client) + @cached_property def versions(self) -> AsyncVersionsResource: return AsyncVersionsResource(self._client) @@ -1008,6 +1040,14 @@ def __init__(self, models: ModelsResource) -> None: models.get, ) + @cached_property + def examples(self) -> ExamplesResourceWithRawResponse: + return ExamplesResourceWithRawResponse(self._models.examples) + + @cached_property + def readme(self) -> ReadmeResourceWithRawResponse: + return ReadmeResourceWithRawResponse(self._models.readme) + @cached_property def versions(self) -> VersionsResourceWithRawResponse: return VersionsResourceWithRawResponse(self._models.versions) @@ -1033,6 +1073,14 @@ def __init__(self, models: AsyncModelsResource) -> None: models.get, ) + @cached_property + def examples(self) -> AsyncExamplesResourceWithRawResponse: + return AsyncExamplesResourceWithRawResponse(self._models.examples) + + @cached_property + def readme(self) -> AsyncReadmeResourceWithRawResponse: + return AsyncReadmeResourceWithRawResponse(self._models.readme) + @cached_property def versions(self) -> AsyncVersionsResourceWithRawResponse: return AsyncVersionsResourceWithRawResponse(self._models.versions) @@ -1058,6 +1106,14 @@ def __init__(self, models: ModelsResource) -> None: models.get, ) + @cached_property + def examples(self) -> ExamplesResourceWithStreamingResponse: + return ExamplesResourceWithStreamingResponse(self._models.examples) + + @cached_property + def readme(self) -> ReadmeResourceWithStreamingResponse: + return ReadmeResourceWithStreamingResponse(self._models.readme) + @cached_property def versions(self) -> VersionsResourceWithStreamingResponse: return VersionsResourceWithStreamingResponse(self._models.versions) @@ -1083,6 +1139,14 @@ def __init__(self, models: AsyncModelsResource) -> None: models.get, ) + @cached_property + def examples(self) -> AsyncExamplesResourceWithStreamingResponse: + return AsyncExamplesResourceWithStreamingResponse(self._models.examples) + + @cached_property + def readme(self) -> AsyncReadmeResourceWithStreamingResponse: + return AsyncReadmeResourceWithStreamingResponse(self._models.readme) + @cached_property def versions(self) -> AsyncVersionsResourceWithStreamingResponse: return AsyncVersionsResourceWithStreamingResponse(self._models.versions) diff --git a/src/replicate/resources/models/readme.py b/src/replicate/resources/models/readme.py new file mode 100644 index 0000000..39c006e --- /dev/null +++ b/src/replicate/resources/models/readme.py @@ -0,0 +1,202 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +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 ..._base_client import make_request_options + +__all__ = ["ReadmeResource", "AsyncReadmeResource"] + + +class ReadmeResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ReadmeResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/replicate/replicate-python-stainless#accessing-raw-response-data-eg-headers + """ + return ReadmeResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ReadmeResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/replicate/replicate-python-stainless#with_streaming_response + """ + return ReadmeResourceWithStreamingResponse(self) + + def get( + self, + model_name: str, + *, + model_owner: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> str: + """ + Get the README content for a model. + + Example cURL request: + + ```console + curl -s \\ + -H "Authorization: Bearer $REPLICATE_API_TOKEN" \\ + https://api.replicate.com/v1/models/replicate/hello-world/readme + ``` + + The response will be the README content as plain text in Markdown format: + + ``` + # Hello World Model + + This is an example model that... + ``` + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not model_owner: + 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": "text/plain", **(extra_headers or {})} + return self._get( + f"/models/{model_owner}/{model_name}/readme", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=str, + ) + + +class AsyncReadmeResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncReadmeResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/replicate/replicate-python-stainless#accessing-raw-response-data-eg-headers + """ + return AsyncReadmeResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncReadmeResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/replicate/replicate-python-stainless#with_streaming_response + """ + return AsyncReadmeResourceWithStreamingResponse(self) + + async def get( + self, + model_name: str, + *, + model_owner: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> str: + """ + Get the README content for a model. + + Example cURL request: + + ```console + curl -s \\ + -H "Authorization: Bearer $REPLICATE_API_TOKEN" \\ + https://api.replicate.com/v1/models/replicate/hello-world/readme + ``` + + The response will be the README content as plain text in Markdown format: + + ``` + # Hello World Model + + This is an example model that... + ``` + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not model_owner: + 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": "text/plain", **(extra_headers or {})} + return await self._get( + f"/models/{model_owner}/{model_name}/readme", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=str, + ) + + +class ReadmeResourceWithRawResponse: + def __init__(self, readme: ReadmeResource) -> None: + self._readme = readme + + self.get = to_raw_response_wrapper( + readme.get, + ) + + +class AsyncReadmeResourceWithRawResponse: + def __init__(self, readme: AsyncReadmeResource) -> None: + self._readme = readme + + self.get = async_to_raw_response_wrapper( + readme.get, + ) + + +class ReadmeResourceWithStreamingResponse: + def __init__(self, readme: ReadmeResource) -> None: + self._readme = readme + + self.get = to_streamed_response_wrapper( + readme.get, + ) + + +class AsyncReadmeResourceWithStreamingResponse: + def __init__(self, readme: AsyncReadmeResource) -> None: + self._readme = readme + + self.get = async_to_streamed_response_wrapper( + readme.get, + ) diff --git a/src/replicate/types/models/__init__.py b/src/replicate/types/models/__init__.py index 2d89bc6..05fbb6f 100644 --- a/src/replicate/types/models/__init__.py +++ b/src/replicate/types/models/__init__.py @@ -2,5 +2,6 @@ from __future__ import annotations +from .readme_get_response import ReadmeGetResponse as ReadmeGetResponse from .version_create_training_params import VersionCreateTrainingParams as VersionCreateTrainingParams from .version_create_training_response import VersionCreateTrainingResponse as VersionCreateTrainingResponse diff --git a/src/replicate/types/models/readme_get_response.py b/src/replicate/types/models/readme_get_response.py new file mode 100644 index 0000000..fa6be60 --- /dev/null +++ b/src/replicate/types/models/readme_get_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import TypeAlias + +__all__ = ["ReadmeGetResponse"] + +ReadmeGetResponse: TypeAlias = str diff --git a/tests/api_resources/models/test_examples.py b/tests/api_resources/models/test_examples.py new file mode 100644 index 0000000..c3d655e --- /dev/null +++ b/tests/api_resources/models/test_examples.py @@ -0,0 +1,124 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from replicate import ReplicateClient, AsyncReplicateClient + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestExamples: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_list(self, client: ReplicateClient) -> None: + example = client.models.examples.list( + model_name="model_name", + model_owner="model_owner", + ) + assert example is None + + @pytest.mark.skip() + @parametrize + def test_raw_response_list(self, client: ReplicateClient) -> None: + response = client.models.examples.with_raw_response.list( + model_name="model_name", + model_owner="model_owner", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + example = response.parse() + assert example is None + + @pytest.mark.skip() + @parametrize + def test_streaming_response_list(self, client: ReplicateClient) -> None: + with client.models.examples.with_streaming_response.list( + model_name="model_name", + model_owner="model_owner", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + example = response.parse() + assert example is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_list(self, client: ReplicateClient) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_owner` but received ''"): + client.models.examples.with_raw_response.list( + model_name="model_name", + model_owner="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): + client.models.examples.with_raw_response.list( + model_name="", + model_owner="model_owner", + ) + + +class TestAsyncExamples: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_list(self, async_client: AsyncReplicateClient) -> None: + example = await async_client.models.examples.list( + model_name="model_name", + model_owner="model_owner", + ) + assert example is None + + @pytest.mark.skip() + @parametrize + async def test_raw_response_list(self, async_client: AsyncReplicateClient) -> None: + response = await async_client.models.examples.with_raw_response.list( + model_name="model_name", + model_owner="model_owner", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + example = await response.parse() + assert example is None + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_list(self, async_client: AsyncReplicateClient) -> None: + async with async_client.models.examples.with_streaming_response.list( + model_name="model_name", + model_owner="model_owner", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + example = await response.parse() + assert example is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_list(self, async_client: AsyncReplicateClient) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_owner` but received ''"): + await async_client.models.examples.with_raw_response.list( + model_name="model_name", + model_owner="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): + await async_client.models.examples.with_raw_response.list( + model_name="", + model_owner="model_owner", + ) diff --git a/tests/api_resources/models/test_readme.py b/tests/api_resources/models/test_readme.py new file mode 100644 index 0000000..048334b --- /dev/null +++ b/tests/api_resources/models/test_readme.py @@ -0,0 +1,125 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from replicate import ReplicateClient, AsyncReplicateClient +from tests.utils import assert_matches_type + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestReadme: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: ReplicateClient) -> None: + readme = client.models.readme.get( + model_name="model_name", + model_owner="model_owner", + ) + assert_matches_type(str, readme, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: ReplicateClient) -> None: + response = client.models.readme.with_raw_response.get( + model_name="model_name", + model_owner="model_owner", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + readme = response.parse() + assert_matches_type(str, readme, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: ReplicateClient) -> None: + with client.models.readme.with_streaming_response.get( + model_name="model_name", + model_owner="model_owner", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + readme = response.parse() + assert_matches_type(str, readme, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: ReplicateClient) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_owner` but received ''"): + client.models.readme.with_raw_response.get( + model_name="model_name", + model_owner="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): + client.models.readme.with_raw_response.get( + model_name="", + model_owner="model_owner", + ) + + +class TestAsyncReadme: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncReplicateClient) -> None: + readme = await async_client.models.readme.get( + model_name="model_name", + model_owner="model_owner", + ) + assert_matches_type(str, readme, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncReplicateClient) -> None: + response = await async_client.models.readme.with_raw_response.get( + model_name="model_name", + model_owner="model_owner", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + readme = await response.parse() + assert_matches_type(str, readme, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncReplicateClient) -> None: + async with async_client.models.readme.with_streaming_response.get( + model_name="model_name", + model_owner="model_owner", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + readme = await response.parse() + assert_matches_type(str, readme, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncReplicateClient) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_owner` but received ''"): + await async_client.models.readme.with_raw_response.get( + model_name="model_name", + model_owner="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): + await async_client.models.readme.with_raw_response.get( + model_name="", + model_owner="model_owner", + )