Skip to content

Commit bcac9e5

Browse files
feat(api): add models.readme.get and models.examples.list operations
These were recently added to Replicate's API, so I've manually added them to the stainless config here.
1 parent 95cdf0a commit bcac9e5

File tree

10 files changed

+801
-2
lines changed

10 files changed

+801
-2
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 27
1+
configured_endpoints: 29
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-2788217b7ad7d61d1a77800bc5ff12a6810f1692d4d770b72fa8f898c6a055ab.yml
33
openapi_spec_hash: 4423bf747e228484547b441468a9f156
4-
config_hash: d1d273c0d97d034d24c7eac8ef51d2ac
4+
config_hash: 976e20887b4e455f639ee6917de350b8

api.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,24 @@ Methods:
7373
- <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>
7474
- <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>
7575

76+
## Examples
77+
78+
Methods:
79+
80+
- <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>
81+
82+
## Readme
83+
84+
Types:
85+
86+
```python
87+
from replicate.types.models import ReadmeGetResponse
88+
```
89+
90+
Methods:
91+
92+
- <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>
93+
7694
## Versions
7795

7896
Types:

src/replicate/resources/models/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@
88
ModelsResourceWithStreamingResponse,
99
AsyncModelsResourceWithStreamingResponse,
1010
)
11+
from .readme import (
12+
ReadmeResource,
13+
AsyncReadmeResource,
14+
ReadmeResourceWithRawResponse,
15+
AsyncReadmeResourceWithRawResponse,
16+
ReadmeResourceWithStreamingResponse,
17+
AsyncReadmeResourceWithStreamingResponse,
18+
)
19+
from .examples import (
20+
ExamplesResource,
21+
AsyncExamplesResource,
22+
ExamplesResourceWithRawResponse,
23+
AsyncExamplesResourceWithRawResponse,
24+
ExamplesResourceWithStreamingResponse,
25+
AsyncExamplesResourceWithStreamingResponse,
26+
)
1127
from .versions import (
1228
VersionsResource,
1329
AsyncVersionsResource,
@@ -18,6 +34,18 @@
1834
)
1935

2036
__all__ = [
37+
"ExamplesResource",
38+
"AsyncExamplesResource",
39+
"ExamplesResourceWithRawResponse",
40+
"AsyncExamplesResourceWithRawResponse",
41+
"ExamplesResourceWithStreamingResponse",
42+
"AsyncExamplesResourceWithStreamingResponse",
43+
"ReadmeResource",
44+
"AsyncReadmeResource",
45+
"ReadmeResourceWithRawResponse",
46+
"AsyncReadmeResourceWithRawResponse",
47+
"ReadmeResourceWithStreamingResponse",
48+
"AsyncReadmeResourceWithStreamingResponse",
2149
"VersionsResource",
2250
"AsyncVersionsResource",
2351
"VersionsResourceWithRawResponse",
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
import httpx
6+
7+
from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
8+
from ..._compat import cached_property
9+
from ..._resource import SyncAPIResource, AsyncAPIResource
10+
from ..._response import (
11+
to_raw_response_wrapper,
12+
to_streamed_response_wrapper,
13+
async_to_raw_response_wrapper,
14+
async_to_streamed_response_wrapper,
15+
)
16+
from ..._base_client import make_request_options
17+
18+
__all__ = ["ExamplesResource", "AsyncExamplesResource"]
19+
20+
21+
class ExamplesResource(SyncAPIResource):
22+
@cached_property
23+
def with_raw_response(self) -> ExamplesResourceWithRawResponse:
24+
"""
25+
This property can be used as a prefix for any HTTP method call to return
26+
the raw response object instead of the parsed content.
27+
28+
For more information, see https://www.github.com/replicate/replicate-python-stainless#accessing-raw-response-data-eg-headers
29+
"""
30+
return ExamplesResourceWithRawResponse(self)
31+
32+
@cached_property
33+
def with_streaming_response(self) -> ExamplesResourceWithStreamingResponse:
34+
"""
35+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
36+
37+
For more information, see https://www.github.com/replicate/replicate-python-stainless#with_streaming_response
38+
"""
39+
return ExamplesResourceWithStreamingResponse(self)
40+
41+
def list(
42+
self,
43+
model_name: str,
44+
*,
45+
model_owner: str,
46+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
47+
# The extra values given here take precedence over values defined on the client or passed to this method.
48+
extra_headers: Headers | None = None,
49+
extra_query: Query | None = None,
50+
extra_body: Body | None = None,
51+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
52+
) -> None:
53+
"""
54+
List
55+
[example predictions](https://replicate.com/docs/topics/models/publish-a-model#what-are-examples)
56+
made using the model. These are predictions that were saved by the model author
57+
as illustrative examples of the model's capabilities.
58+
59+
If you want all the examples for a model, use this operation.
60+
61+
If you just want the model's default example, you can use the
62+
[`models.get`](#models.get) operation instead, which includes a
63+
`default_example` object.
64+
65+
Example cURL request:
66+
67+
```console
68+
curl -s \\
69+
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
70+
https://api.replicate.com/v1/models/replicate/hello-world/examples
71+
```
72+
73+
The response will be a pagination object containing a list of example
74+
predictions:
75+
76+
```json
77+
{
78+
"next": "https://api.replicate.com/v1/models/replicate/hello-world/examples?cursor=...",
79+
"previous": "https://api.replicate.com/v1/models/replicate/hello-world/examples?cursor=...",
80+
"results": [...]
81+
}
82+
```
83+
84+
Each item in the `results` list is a [prediction object](#predictions.get).
85+
86+
Args:
87+
extra_headers: Send extra headers
88+
89+
extra_query: Add additional query parameters to the request
90+
91+
extra_body: Add additional JSON properties to the request
92+
93+
timeout: Override the client-level default timeout for this request, in seconds
94+
"""
95+
if not model_owner:
96+
raise ValueError(f"Expected a non-empty value for `model_owner` but received {model_owner!r}")
97+
if not model_name:
98+
raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}")
99+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
100+
return self._get(
101+
f"/models/{model_owner}/{model_name}/examples",
102+
options=make_request_options(
103+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
104+
),
105+
cast_to=NoneType,
106+
)
107+
108+
109+
class AsyncExamplesResource(AsyncAPIResource):
110+
@cached_property
111+
def with_raw_response(self) -> AsyncExamplesResourceWithRawResponse:
112+
"""
113+
This property can be used as a prefix for any HTTP method call to return
114+
the raw response object instead of the parsed content.
115+
116+
For more information, see https://www.github.com/replicate/replicate-python-stainless#accessing-raw-response-data-eg-headers
117+
"""
118+
return AsyncExamplesResourceWithRawResponse(self)
119+
120+
@cached_property
121+
def with_streaming_response(self) -> AsyncExamplesResourceWithStreamingResponse:
122+
"""
123+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
124+
125+
For more information, see https://www.github.com/replicate/replicate-python-stainless#with_streaming_response
126+
"""
127+
return AsyncExamplesResourceWithStreamingResponse(self)
128+
129+
async def list(
130+
self,
131+
model_name: str,
132+
*,
133+
model_owner: str,
134+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
135+
# The extra values given here take precedence over values defined on the client or passed to this method.
136+
extra_headers: Headers | None = None,
137+
extra_query: Query | None = None,
138+
extra_body: Body | None = None,
139+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
140+
) -> None:
141+
"""
142+
List
143+
[example predictions](https://replicate.com/docs/topics/models/publish-a-model#what-are-examples)
144+
made using the model. These are predictions that were saved by the model author
145+
as illustrative examples of the model's capabilities.
146+
147+
If you want all the examples for a model, use this operation.
148+
149+
If you just want the model's default example, you can use the
150+
[`models.get`](#models.get) operation instead, which includes a
151+
`default_example` object.
152+
153+
Example cURL request:
154+
155+
```console
156+
curl -s \\
157+
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
158+
https://api.replicate.com/v1/models/replicate/hello-world/examples
159+
```
160+
161+
The response will be a pagination object containing a list of example
162+
predictions:
163+
164+
```json
165+
{
166+
"next": "https://api.replicate.com/v1/models/replicate/hello-world/examples?cursor=...",
167+
"previous": "https://api.replicate.com/v1/models/replicate/hello-world/examples?cursor=...",
168+
"results": [...]
169+
}
170+
```
171+
172+
Each item in the `results` list is a [prediction object](#predictions.get).
173+
174+
Args:
175+
extra_headers: Send extra headers
176+
177+
extra_query: Add additional query parameters to the request
178+
179+
extra_body: Add additional JSON properties to the request
180+
181+
timeout: Override the client-level default timeout for this request, in seconds
182+
"""
183+
if not model_owner:
184+
raise ValueError(f"Expected a non-empty value for `model_owner` but received {model_owner!r}")
185+
if not model_name:
186+
raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}")
187+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
188+
return await self._get(
189+
f"/models/{model_owner}/{model_name}/examples",
190+
options=make_request_options(
191+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
192+
),
193+
cast_to=NoneType,
194+
)
195+
196+
197+
class ExamplesResourceWithRawResponse:
198+
def __init__(self, examples: ExamplesResource) -> None:
199+
self._examples = examples
200+
201+
self.list = to_raw_response_wrapper(
202+
examples.list,
203+
)
204+
205+
206+
class AsyncExamplesResourceWithRawResponse:
207+
def __init__(self, examples: AsyncExamplesResource) -> None:
208+
self._examples = examples
209+
210+
self.list = async_to_raw_response_wrapper(
211+
examples.list,
212+
)
213+
214+
215+
class ExamplesResourceWithStreamingResponse:
216+
def __init__(self, examples: ExamplesResource) -> None:
217+
self._examples = examples
218+
219+
self.list = to_streamed_response_wrapper(
220+
examples.list,
221+
)
222+
223+
224+
class AsyncExamplesResourceWithStreamingResponse:
225+
def __init__(self, examples: AsyncExamplesResource) -> None:
226+
self._examples = examples
227+
228+
self.list = async_to_streamed_response_wrapper(
229+
examples.list,
230+
)

0 commit comments

Comments
 (0)