Skip to content

Commit 59c66bd

Browse files
feat(api): api update
1 parent d5a13c9 commit 59c66bd

File tree

6 files changed

+69
-17
lines changed

6 files changed

+69
-17
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: 35
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-49078e632f99a7f21fdcd7763517de7118c680b2ff2b90bee601eb3d49ace321.yml
3-
openapi_spec_hash: baf550db5880018d99637a11dee48380
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-f5aff38eef8d7b245a7af062bf02920ae75e5b9b3dc822416aeb48966c2c6874.yml
3+
openapi_spec_hash: c0a966beaf5ae95c6bdddd4a933bd4aa
44
config_hash: 12536d2bf978a995771d076a4647c17d

api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Methods:
6161
Types:
6262

6363
```python
64-
from replicate.types import ModelListResponse, ModelGetResponse
64+
from replicate.types import ModelListResponse, ModelGetResponse, ModelSearchResponse
6565
```
6666

6767
Methods:
@@ -70,7 +70,7 @@ Methods:
7070
- <code title="get /models">replicate.models.<a href="./src/replicate/resources/models/models.py">list</a>() -> <a href="./src/replicate/types/model_list_response.py">SyncCursorURLPage[ModelListResponse]</a></code>
7171
- <code title="delete /models/{model_owner}/{model_name}">replicate.models.<a href="./src/replicate/resources/models/models.py">delete</a>(\*, model_owner, model_name) -> None</code>
7272
- <code title="get /models/{model_owner}/{model_name}">replicate.models.<a href="./src/replicate/resources/models/models.py">get</a>(\*, model_owner, model_name) -> <a href="./src/replicate/types/model_get_response.py">ModelGetResponse</a></code>
73-
- <code title="query /models">replicate.models.<a href="./src/replicate/resources/models/models.py">search</a>(\*\*<a href="src/replicate/types/model_search_params.py">params</a>) -> SyncCursorURLPage[object]</code>
73+
- <code title="query /models">replicate.models.<a href="./src/replicate/resources/models/models.py">search</a>(\*\*<a href="src/replicate/types/model_search_params.py">params</a>) -> <a href="./src/replicate/types/model_search_response.py">SyncCursorURLPage[ModelSearchResponse]</a></code>
7474

7575
## Examples
7676

src/replicate/resources/models/models.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
from ..._base_client import AsyncPaginator, make_request_options
5454
from ...types.model_get_response import ModelGetResponse
5555
from ...types.model_list_response import ModelListResponse
56+
from ...types.model_search_response import ModelSearchResponse
5657

5758
__all__ = ["ModelsResource", "AsyncModelsResource"]
5859

@@ -414,7 +415,7 @@ def search(
414415
extra_query: Query | None = None,
415416
extra_body: Body | None = None,
416417
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
417-
) -> SyncCursorURLPage[object]:
418+
) -> SyncCursorURLPage[ModelSearchResponse]:
418419
"""
419420
Get a list of public models matching a search query.
420421
@@ -447,12 +448,12 @@ def search(
447448
"""
448449
return self._get_api_list(
449450
"/models",
450-
page=SyncCursorURLPage[object],
451+
page=SyncCursorURLPage[ModelSearchResponse],
451452
body=maybe_transform(body, model_search_params.ModelSearchParams),
452453
options=make_request_options(
453454
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
454455
),
455-
model=object,
456+
model=ModelSearchResponse,
456457
method="query",
457458
)
458459

@@ -814,7 +815,7 @@ def search(
814815
extra_query: Query | None = None,
815816
extra_body: Body | None = None,
816817
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
817-
) -> AsyncPaginator[object, AsyncCursorURLPage[object]]:
818+
) -> AsyncPaginator[ModelSearchResponse, AsyncCursorURLPage[ModelSearchResponse]]:
818819
"""
819820
Get a list of public models matching a search query.
820821
@@ -847,12 +848,12 @@ def search(
847848
"""
848849
return self._get_api_list(
849850
"/models",
850-
page=AsyncCursorURLPage[object],
851+
page=AsyncCursorURLPage[ModelSearchResponse],
851852
body=maybe_transform(body, model_search_params.ModelSearchParams),
852853
options=make_request_options(
853854
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
854855
),
855-
model=object,
856+
model=ModelSearchResponse,
856857
method="query",
857858
)
858859

src/replicate/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from .account_get_response import AccountGetResponse as AccountGetResponse
1414
from .file_create_response import FileCreateResponse as FileCreateResponse
1515
from .file_download_params import FileDownloadParams as FileDownloadParams
16+
from .model_search_response import ModelSearchResponse as ModelSearchResponse
1617
from .training_get_response import TrainingGetResponse as TrainingGetResponse
1718
from .hardware_list_response import HardwareListResponse as HardwareListResponse
1819
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__ = ["ModelSearchResponse"]
9+
10+
11+
class ModelSearchResponse(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: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010
from replicate import Replicate, AsyncReplicate
1111
from tests.utils import assert_matches_type
12-
from replicate.types import ModelGetResponse, ModelListResponse
12+
from replicate.types import (
13+
ModelGetResponse,
14+
ModelListResponse,
15+
ModelSearchResponse,
16+
)
1317
from replicate.pagination import SyncCursorURLPage, AsyncCursorURLPage
1418

1519
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -215,7 +219,7 @@ def test_method_search(self, client: Replicate) -> None:
215219
model = client.models.search(
216220
body="body",
217221
)
218-
assert_matches_type(SyncCursorURLPage[object], model, path=["response"])
222+
assert_matches_type(SyncCursorURLPage[ModelSearchResponse], model, path=["response"])
219223

220224
@pytest.mark.skip(reason="Prism doesn't support query methods yet")
221225
@parametrize
@@ -227,7 +231,7 @@ def test_raw_response_search(self, client: Replicate) -> None:
227231
assert response.is_closed is True
228232
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
229233
model = response.parse()
230-
assert_matches_type(SyncCursorURLPage[object], model, path=["response"])
234+
assert_matches_type(SyncCursorURLPage[ModelSearchResponse], model, path=["response"])
231235

232236
@pytest.mark.skip(reason="Prism doesn't support query methods yet")
233237
@parametrize
@@ -239,7 +243,7 @@ def test_streaming_response_search(self, client: Replicate) -> None:
239243
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
240244

241245
model = response.parse()
242-
assert_matches_type(SyncCursorURLPage[object], model, path=["response"])
246+
assert_matches_type(SyncCursorURLPage[ModelSearchResponse], model, path=["response"])
243247

244248
assert cast(Any, response.is_closed) is True
245249

@@ -446,7 +450,7 @@ async def test_method_search(self, async_client: AsyncReplicate) -> None:
446450
model = await async_client.models.search(
447451
body="body",
448452
)
449-
assert_matches_type(AsyncCursorURLPage[object], model, path=["response"])
453+
assert_matches_type(AsyncCursorURLPage[ModelSearchResponse], model, path=["response"])
450454

451455
@pytest.mark.skip(reason="Prism doesn't support query methods yet")
452456
@parametrize
@@ -458,7 +462,7 @@ async def test_raw_response_search(self, async_client: AsyncReplicate) -> None:
458462
assert response.is_closed is True
459463
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
460464
model = await response.parse()
461-
assert_matches_type(AsyncCursorURLPage[object], model, path=["response"])
465+
assert_matches_type(AsyncCursorURLPage[ModelSearchResponse], model, path=["response"])
462466

463467
@pytest.mark.skip(reason="Prism doesn't support query methods yet")
464468
@parametrize
@@ -470,6 +474,6 @@ async def test_streaming_response_search(self, async_client: AsyncReplicate) ->
470474
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
471475

472476
model = await response.parse()
473-
assert_matches_type(AsyncCursorURLPage[object], model, path=["response"])
477+
assert_matches_type(AsyncCursorURLPage[ModelSearchResponse], model, path=["response"])
474478

475479
assert cast(Any, response.is_closed) is True

0 commit comments

Comments
 (0)