Skip to content
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.3"
".": "0.1.0-alpha.4"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
18 changes: 18 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ Methods:
- <code title="post /models/{model_owner}/{model_name}/predictions">client.models.<a href="./src/replicate/resources/models/models.py">create_prediction</a>(model_name, \*, model_owner, \*\*<a href="src/replicate/types/model_create_prediction_params.py">params</a>) -> <a href="./src/replicate/types/prediction.py">Prediction</a></code>
- <code title="get /models/{model_owner}/{model_name}">client.models.<a href="./src/replicate/resources/models/models.py">get</a>(model_name, \*, model_owner) -> None</code>

## Examples

Methods:

- <code title="get /models/{model_owner}/{model_name}/examples">client.models.examples.<a href="./src/replicate/resources/models/examples.py">list</a>(model_name, \*, model_owner) -> None</code>

## Readme

Types:

```python
from replicate.types.models import ReadmeGetResponse
```

Methods:

- <code title="get /models/{model_owner}/{model_name}/readme">client.models.readme.<a href="./src/replicate/resources/models/readme.py">get</a>(model_name, \*, model_owner) -> str</code>

## Versions

Types:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/replicate/_version.py
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions src/replicate/resources/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -18,6 +34,18 @@
)

__all__ = [
"ExamplesResource",
"AsyncExamplesResource",
"ExamplesResourceWithRawResponse",
"AsyncExamplesResourceWithRawResponse",
"ExamplesResourceWithStreamingResponse",
"AsyncExamplesResourceWithStreamingResponse",
"ReadmeResource",
"AsyncReadmeResource",
"ReadmeResourceWithRawResponse",
"AsyncReadmeResourceWithRawResponse",
"ReadmeResourceWithStreamingResponse",
"AsyncReadmeResourceWithStreamingResponse",
"VersionsResource",
"AsyncVersionsResource",
"VersionsResourceWithRawResponse",
Expand Down
230 changes: 230 additions & 0 deletions src/replicate/resources/models/examples.py
Original file line number Diff line number Diff line change
@@ -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,
)
Loading