Skip to content

Commit a7577dd

Browse files
feat(api): api update
1 parent 9c61d54 commit a7577dd

File tree

6 files changed

+76
-20
lines changed

6 files changed

+76
-20
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 27
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-b45f922f6a041550870a96f5acec02aa6d8830046fc98b95a275c6486f7586fc.yml
3-
openapi_spec_hash: ef7fddfb49b4d9c440b0635d2c86f341
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-37bb31ed76da599d3bded543a3765f745c8575d105c13554df7f8361c3641482.yml
3+
openapi_spec_hash: 15bdec12ca84042768bfb28cc48dfce3
44
config_hash: 810de4c2eee1a7649263cff01f00da7c

api.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,17 @@ Methods:
5959

6060
# Models
6161

62+
Types:
63+
64+
```python
65+
from replicate.types import ModelListResponse
66+
```
67+
6268
Methods:
6369

6470
- <code title="post /models">client.models.<a href="./src/replicate/resources/models/models.py">create</a>(\*\*<a href="src/replicate/types/model_create_params.py">params</a>) -> None</code>
6571
- <code title="get /models/{model_owner}/{model_name}">client.models.<a href="./src/replicate/resources/models/models.py">retrieve</a>(model_name, \*, model_owner) -> None</code>
66-
- <code title="get /models">client.models.<a href="./src/replicate/resources/models/models.py">list</a>() -> None</code>
72+
- <code title="get /models">client.models.<a href="./src/replicate/resources/models/models.py">list</a>() -> <a href="./src/replicate/types/model_list_response.py">SyncCursorURLPage[ModelListResponse]</a></code>
6773
- <code title="delete /models/{model_owner}/{model_name}">client.models.<a href="./src/replicate/resources/models/models.py">delete</a>(model_name, \*, model_owner) -> None</code>
6874
- <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>
6975

src/replicate/resources/models/models.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
async_to_raw_response_wrapper,
3131
async_to_streamed_response_wrapper,
3232
)
33-
from ..._base_client import make_request_options
33+
from ...pagination import SyncCursorURLPage, AsyncCursorURLPage
34+
from ..._base_client import AsyncPaginator, make_request_options
3435
from ...types.prediction import Prediction
36+
from ...types.model_list_response import ModelListResponse
3537

3638
__all__ = ["ModelsResource", "AsyncModelsResource"]
3739

@@ -290,7 +292,7 @@ def list(
290292
extra_query: Query | None = None,
291293
extra_body: Body | None = None,
292294
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
293-
) -> None:
295+
) -> SyncCursorURLPage[ModelListResponse]:
294296
"""
295297
Get a paginated list of public models.
296298
@@ -307,13 +309,13 @@ def list(
307309
See the [`models.get`](#models.get) docs for more details about the model
308310
object.
309311
"""
310-
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
311-
return self._get(
312+
return self._get_api_list(
312313
"/models",
314+
page=SyncCursorURLPage[ModelListResponse],
313315
options=make_request_options(
314316
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
315317
),
316-
cast_to=NoneType,
318+
model=ModelListResponse,
317319
)
318320

319321
def delete(
@@ -758,7 +760,7 @@ async def retrieve(
758760
cast_to=NoneType,
759761
)
760762

761-
async def list(
763+
def list(
762764
self,
763765
*,
764766
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -767,7 +769,7 @@ async def list(
767769
extra_query: Query | None = None,
768770
extra_body: Body | None = None,
769771
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
770-
) -> None:
772+
) -> AsyncPaginator[ModelListResponse, AsyncCursorURLPage[ModelListResponse]]:
771773
"""
772774
Get a paginated list of public models.
773775
@@ -784,13 +786,13 @@ async def list(
784786
See the [`models.get`](#models.get) docs for more details about the model
785787
object.
786788
"""
787-
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
788-
return await self._get(
789+
return self._get_api_list(
789790
"/models",
791+
page=AsyncCursorURLPage[ModelListResponse],
790792
options=make_request_options(
791793
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
792794
),
793-
cast_to=NoneType,
795+
model=ModelListResponse,
794796
)
795797

796798
async def delete(

src/replicate/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .prediction import Prediction as Prediction
66
from .prediction_output import PredictionOutput as PredictionOutput
77
from .model_create_params import ModelCreateParams as ModelCreateParams
8+
from .model_list_response import ModelListResponse as ModelListResponse
89
from .account_list_response import AccountListResponse as AccountListResponse
910
from .hardware_list_response import HardwareListResponse as HardwareListResponse
1011
from .prediction_list_params import PredictionListParams as PredictionListParams
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import Optional
4+
from typing_extensions import Literal
5+
6+
from .._models import BaseModel
7+
8+
__all__ = ["ModelListResponse"]
9+
10+
11+
class ModelListResponse(BaseModel):
12+
cover_image_url: Optional[str] = None
13+
"""A URL for the model's cover image"""
14+
15+
default_example: Optional[object] = None
16+
"""The model's default example prediction"""
17+
18+
description: Optional[str] = None
19+
"""A description of the model"""
20+
21+
github_url: Optional[str] = None
22+
"""A URL for the model's source code on GitHub"""
23+
24+
latest_version: Optional[object] = None
25+
"""The model's latest version"""
26+
27+
license_url: Optional[str] = None
28+
"""A URL for the model's license"""
29+
30+
name: Optional[str] = None
31+
"""The name of the model"""
32+
33+
owner: Optional[str] = None
34+
"""The name of the user or organization that owns the model"""
35+
36+
paper_url: Optional[str] = None
37+
"""A URL for the model's paper"""
38+
39+
run_count: Optional[int] = None
40+
"""The number of times the model has been run"""
41+
42+
url: Optional[str] = None
43+
"""The URL of the model on Replicate"""
44+
45+
visibility: Optional[Literal["public", "private"]] = None
46+
"""Whether the model is public or private"""

tests/api_resources/test_models.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
from replicate import ReplicateClient, AsyncReplicateClient
1111
from tests.utils import assert_matches_type
12-
from replicate.types import Prediction
12+
from replicate.types import Prediction, ModelListResponse
13+
from replicate.pagination import SyncCursorURLPage, AsyncCursorURLPage
1314

1415
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
1516

@@ -132,7 +133,7 @@ def test_path_params_retrieve(self, client: ReplicateClient) -> None:
132133
@parametrize
133134
def test_method_list(self, client: ReplicateClient) -> None:
134135
model = client.models.list()
135-
assert model is None
136+
assert_matches_type(SyncCursorURLPage[ModelListResponse], model, path=["response"])
136137

137138
@pytest.mark.skip()
138139
@parametrize
@@ -142,7 +143,7 @@ def test_raw_response_list(self, client: ReplicateClient) -> None:
142143
assert response.is_closed is True
143144
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
144145
model = response.parse()
145-
assert model is None
146+
assert_matches_type(SyncCursorURLPage[ModelListResponse], model, path=["response"])
146147

147148
@pytest.mark.skip()
148149
@parametrize
@@ -152,7 +153,7 @@ def test_streaming_response_list(self, client: ReplicateClient) -> None:
152153
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
153154

154155
model = response.parse()
155-
assert model is None
156+
assert_matches_type(SyncCursorURLPage[ModelListResponse], model, path=["response"])
156157

157158
assert cast(Any, response.is_closed) is True
158159

@@ -398,7 +399,7 @@ async def test_path_params_retrieve(self, async_client: AsyncReplicateClient) ->
398399
@parametrize
399400
async def test_method_list(self, async_client: AsyncReplicateClient) -> None:
400401
model = await async_client.models.list()
401-
assert model is None
402+
assert_matches_type(AsyncCursorURLPage[ModelListResponse], model, path=["response"])
402403

403404
@pytest.mark.skip()
404405
@parametrize
@@ -408,7 +409,7 @@ async def test_raw_response_list(self, async_client: AsyncReplicateClient) -> No
408409
assert response.is_closed is True
409410
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
410411
model = await response.parse()
411-
assert model is None
412+
assert_matches_type(AsyncCursorURLPage[ModelListResponse], model, path=["response"])
412413

413414
@pytest.mark.skip()
414415
@parametrize
@@ -418,7 +419,7 @@ async def test_streaming_response_list(self, async_client: AsyncReplicateClient)
418419
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
419420

420421
model = await response.parse()
421-
assert model is None
422+
assert_matches_type(AsyncCursorURLPage[ModelListResponse], model, path=["response"])
422423

423424
assert cast(Any, response.is_closed) is True
424425

0 commit comments

Comments
 (0)