diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ec9417a..68f4960 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0-alpha.27" + ".": "2.0.0-alpha.28" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 0277638..627f641 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 36 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-87c7c57bd75c54990c679c9e87d009851cdff572815a55d1b6ee4d4ee20adaa1.yml -openapi_spec_hash: d987f14befa536004eece7b49caad993 -config_hash: a916e7f3559ab312c7b6696cd6b35fb5 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-8b68f03c8602e25ede74e66221e04bb17ac1f3170b8de49b8311fbe492636245.yml +openapi_spec_hash: 81a7c6f32c6d77c1f329ca5a3c700a7a +config_hash: 407acf62c906ee301314f2d23cdb58b1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dae4bb..1b486c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## 2.0.0-alpha.28 (2025-10-07) + +Full Changelog: [v2.0.0-alpha.27...v2.0.0-alpha.28](https://github.com/replicate/replicate-python-stainless/compare/v2.0.0-alpha.27...v2.0.0-alpha.28) + +### Chores + +* do not install brew dependencies in ./scripts/bootstrap by default ([40f38a7](https://github.com/replicate/replicate-python-stainless/commit/40f38a774220bb1364e12de4d7aef9448fb60c58)) +* **types:** change optional parameter type from NotGiven to Omit ([f331b97](https://github.com/replicate/replicate-python-stainless/commit/f331b97a15226c9ae17112567a3be01010439f21)) +* update OpenAPI spec and rebuild SDKs ([8b43277](https://github.com/replicate/replicate-python-stainless/commit/8b432772af94ac3f471bc642671322c11c7d4ff0)) +* update OpenAPI spec and rebuild SDKs ([77c9c21](https://github.com/replicate/replicate-python-stainless/commit/77c9c216dea9886a412fd5a1b8f0dfec2e0de155)) +* update OpenAPI spec and rebuild SDKs ([d5ed889](https://github.com/replicate/replicate-python-stainless/commit/d5ed889c6f84e0ea48129f12db494d1d08e3ffbf)) +* update OpenAPI spec and rebuild SDKs ([0a821f8](https://github.com/replicate/replicate-python-stainless/commit/0a821f8f63208585cd4730a50842907ce26a3139)) +* update OpenAPI spec and rebuild SDKs ([a4bdae2](https://github.com/replicate/replicate-python-stainless/commit/a4bdae264cff81657e2e7dcd43eb41bbd1f15237)) + + +### Documentation + +* remove replicate.stream from README ([#78](https://github.com/replicate/replicate-python-stainless/issues/78)) ([9efac9a](https://github.com/replicate/replicate-python-stainless/commit/9efac9a97e7db41d5829c055959b29f154f4c175)) + ## 2.0.0-alpha.27 (2025-09-29) Full Changelog: [v2.0.0-alpha.26...v2.0.0-alpha.27](https://github.com/replicate/replicate-python-stainless/compare/v2.0.0-alpha.26...v2.0.0-alpha.27) diff --git a/pyproject.toml b/pyproject.toml index 9ba41af..5137c3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "replicate" -version = "2.0.0-alpha.27" +version = "2.0.0-alpha.28" description = "The official Python library for the replicate API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/scripts/bootstrap b/scripts/bootstrap index e84fe62..b430fee 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,10 +4,18 @@ set -e cd "$(dirname "$0")/.." -if ! command -v rye >/dev/null 2>&1 && [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { - echo "==> Installing Homebrew dependencies…" - brew bundle + echo -n "==> Install Homebrew dependencies? (y/N): " + read -r response + case "$response" in + [yY][eE][sS]|[yY]) + brew bundle + ;; + *) + ;; + esac + echo } fi diff --git a/src/replicate/_client.py b/src/replicate/_client.py index 390a552..5fb9334 100644 --- a/src/replicate/_client.py +++ b/src/replicate/_client.py @@ -29,7 +29,6 @@ from ._qs import Querystring from .types import client_search_params from ._types import ( - NOT_GIVEN, Body, Omit, Query, @@ -39,6 +38,8 @@ Transport, ProxiesTypes, RequestOptions, + omit, + not_given, ) from ._utils import ( is_given, @@ -103,7 +104,7 @@ def __init__( *, bearer_token: str | None = None, base_url: str | httpx.URL | None = None, - timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, max_retries: int = DEFAULT_MAX_RETRIES, default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -241,7 +242,7 @@ def run( *, file_encoding_strategy: Optional["FileEncodingStrategy"] = None, use_file_output: bool = True, - wait: Union[int, bool, NotGiven] = NOT_GIVEN, + wait: Union[int, bool, NotGiven] = not_given, **params: Unpack[PredictionCreateParamsWithoutVersion], ) -> Any: """ @@ -325,9 +326,9 @@ def copy( *, bearer_token: str | None = None, base_url: str | httpx.URL | None = None, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.Client | None = None, - max_retries: int | NotGiven = NOT_GIVEN, + max_retries: int | NotGiven = not_given, default_headers: Mapping[str, str] | None = None, set_default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -375,13 +376,13 @@ def search( self, *, query: str, - limit: int | NotGiven = NOT_GIVEN, + limit: int | Omit = omit, # 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, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SearchResponse: """ Search for public models, collections, and docs using a text query. @@ -478,7 +479,7 @@ def __init__( *, bearer_token: str | None = None, base_url: str | httpx.URL | None = None, - timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, max_retries: int = DEFAULT_MAX_RETRIES, default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -616,7 +617,7 @@ async def run( *, use_file_output: bool = True, file_encoding_strategy: Optional["FileEncodingStrategy"] = None, - wait: Union[int, bool, NotGiven] = NOT_GIVEN, + wait: Union[int, bool, NotGiven] = not_given, **params: Unpack[PredictionCreateParamsWithoutVersion], ) -> Any: """ @@ -700,9 +701,9 @@ def copy( *, bearer_token: str | None = None, base_url: str | httpx.URL | None = None, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.AsyncClient | None = None, - max_retries: int | NotGiven = NOT_GIVEN, + max_retries: int | NotGiven = not_given, default_headers: Mapping[str, str] | None = None, set_default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -750,13 +751,13 @@ async def search( self, *, query: str, - limit: int | NotGiven = NOT_GIVEN, + limit: int | Omit = omit, # 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, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SearchResponse: """ Search for public models, collections, and docs using a text query. diff --git a/src/replicate/_version.py b/src/replicate/_version.py index da0284e..80a4c91 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__ = "2.0.0-alpha.27" # x-release-please-version +__version__ = "2.0.0-alpha.28" # x-release-please-version diff --git a/src/replicate/resources/collections.py b/src/replicate/resources/collections.py index 1a89c01..823257e 100644 --- a/src/replicate/resources/collections.py +++ b/src/replicate/resources/collections.py @@ -113,6 +113,7 @@ def get( "name": "Super resolution", "slug": "super-resolution", "description": "Upscaling models that create high-quality images from low-quality images.", + "full_description": "## Overview\n\nThese models generate high-quality images from low-quality images. Many of these models are based on **advanced upscaling techniques**.\n\n### Key Features\n\n- Enhance image resolution\n- Restore fine details\n- Improve overall image quality", "models": [...] } ``` @@ -229,6 +230,7 @@ async def get( "name": "Super resolution", "slug": "super-resolution", "description": "Upscaling models that create high-quality images from low-quality images.", + "full_description": "## Overview\n\nThese models generate high-quality images from low-quality images. Many of these models are based on **advanced upscaling techniques**.\n\n### Key Features\n\n- Enhance image resolution\n- Restore fine details\n- Improve overall image quality", "models": [...] } ``` diff --git a/src/replicate/resources/deployments/predictions.py b/src/replicate/resources/deployments/predictions.py index 572ba33..23a487c 100644 --- a/src/replicate/resources/deployments/predictions.py +++ b/src/replicate/resources/deployments/predictions.py @@ -54,6 +54,7 @@ def create( webhook: str | Omit = omit, webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit, prefer: str | Omit = omit, + replicate_max_lifetime: str | Omit = omit, # 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, @@ -111,7 +112,7 @@ def create( [server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). This field is no longer needed as the returned prediction will always have a - `stream` entry in its `url` property if the model supports streaming. + `stream` entry in its `urls` property if the model supports streaming. webhook: An HTTPS URL for receiving a webhook when the prediction has new output. The webhook will be a POST request where the request body is the same as the @@ -162,7 +163,15 @@ def create( raise ValueError(f"Expected a non-empty value for `deployment_owner` but received {deployment_owner!r}") if not deployment_name: raise ValueError(f"Expected a non-empty value for `deployment_name` but received {deployment_name!r}") - extra_headers = {**strip_not_given({"Prefer": prefer}), **(extra_headers or {})} + extra_headers = { + **strip_not_given( + { + "Prefer": prefer, + "Replicate-Max-Lifetime": replicate_max_lifetime, + } + ), + **(extra_headers or {}), + } return self._post( f"/deployments/{deployment_owner}/{deployment_name}/predictions", body=maybe_transform( @@ -211,6 +220,7 @@ async def create( webhook: str | Omit = omit, webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit, prefer: str | Omit = omit, + replicate_max_lifetime: str | Omit = omit, # 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, @@ -268,7 +278,7 @@ async def create( [server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). This field is no longer needed as the returned prediction will always have a - `stream` entry in its `url` property if the model supports streaming. + `stream` entry in its `urls` property if the model supports streaming. webhook: An HTTPS URL for receiving a webhook when the prediction has new output. The webhook will be a POST request where the request body is the same as the @@ -319,7 +329,15 @@ async def create( raise ValueError(f"Expected a non-empty value for `deployment_owner` but received {deployment_owner!r}") if not deployment_name: raise ValueError(f"Expected a non-empty value for `deployment_name` but received {deployment_name!r}") - extra_headers = {**strip_not_given({"Prefer": prefer}), **(extra_headers or {})} + extra_headers = { + **strip_not_given( + { + "Prefer": prefer, + "Replicate-Max-Lifetime": replicate_max_lifetime, + } + ), + **(extra_headers or {}), + } return await self._post( f"/deployments/{deployment_owner}/{deployment_name}/predictions", body=await async_maybe_transform( diff --git a/src/replicate/resources/models/predictions.py b/src/replicate/resources/models/predictions.py index f88e551..eebedfd 100644 --- a/src/replicate/resources/models/predictions.py +++ b/src/replicate/resources/models/predictions.py @@ -56,6 +56,7 @@ def create( webhook: str | Omit = omit, webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit, prefer: str | Omit = omit, + replicate_max_lifetime: str | Omit = omit, file_encoding_strategy: Optional["FileEncodingStrategy"] = None, # 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. @@ -118,7 +119,7 @@ def create( [server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). This field is no longer needed as the returned prediction will always have a - `stream` entry in its `url` property if the model supports streaming. + `stream` entry in its `urls` property if the model supports streaming. webhook: An HTTPS URL for receiving a webhook when the prediction has new output. The webhook will be a POST request where the request body is the same as the @@ -169,7 +170,15 @@ def create( 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 = {**strip_not_given({"Prefer": prefer}), **(extra_headers or {})} + extra_headers = { + **strip_not_given( + { + "Prefer": prefer, + "Replicate-Max-Lifetime": replicate_max_lifetime, + } + ), + **(extra_headers or {}), + } return self._post( f"/models/{model_owner}/{model_name}/predictions", body=maybe_transform( @@ -218,6 +227,7 @@ async def create( webhook: str | Omit = omit, webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit, prefer: str | Omit = omit, + replicate_max_lifetime: str | Omit = omit, file_encoding_strategy: Optional["FileEncodingStrategy"] = None, # 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. @@ -280,7 +290,7 @@ async def create( [server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). This field is no longer needed as the returned prediction will always have a - `stream` entry in its `url` property if the model supports streaming. + `stream` entry in its `urls` property if the model supports streaming. webhook: An HTTPS URL for receiving a webhook when the prediction has new output. The webhook will be a POST request where the request body is the same as the @@ -331,7 +341,15 @@ async def create( 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 = {**strip_not_given({"Prefer": prefer}), **(extra_headers or {})} + extra_headers = { + **strip_not_given( + { + "Prefer": prefer, + "Replicate-Max-Lifetime": replicate_max_lifetime, + } + ), + **(extra_headers or {}), + } return await self._post( f"/models/{model_owner}/{model_name}/predictions", body=await async_maybe_transform( diff --git a/src/replicate/resources/predictions.py b/src/replicate/resources/predictions.py index 04158d1..afd49a7 100644 --- a/src/replicate/resources/predictions.py +++ b/src/replicate/resources/predictions.py @@ -11,7 +11,7 @@ from replicate.lib._files import FileEncodingStrategy, encode_json, async_encode_json from ..types import prediction_list_params, prediction_create_params -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from .._utils import maybe_transform, strip_not_given, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -63,17 +63,18 @@ def create( *, input: object, version: str, - stream: bool | NotGiven = NOT_GIVEN, - webhook: str | NotGiven = NOT_GIVEN, - webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | NotGiven = NOT_GIVEN, - prefer: str | NotGiven = NOT_GIVEN, + stream: bool | Omit = omit, + webhook: str | Omit = omit, + webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit, + prefer: str | Omit = omit, + replicate_max_lifetime: str | Omit = omit, file_encoding_strategy: Optional["FileEncodingStrategy"] = None, # 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, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Prediction: """ Create a prediction for the model version and inputs you provide. @@ -138,7 +139,7 @@ def create( [server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). This field is no longer needed as the returned prediction will always have a - `stream` entry in its `url` property if the model supports streaming. + `stream` entry in its `urls` property if the model supports streaming. webhook: An HTTPS URL for receiving a webhook when the prediction has new output. The webhook will be a POST request where the request body is the same as the @@ -186,7 +187,15 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ - extra_headers = {**strip_not_given({"Prefer": prefer}), **(extra_headers or {})} + extra_headers = { + **strip_not_given( + { + "Prefer": prefer, + "Replicate-Max-Lifetime": replicate_max_lifetime, + } + ), + **(extra_headers or {}), + } return self._post( "/predictions", body=maybe_transform( @@ -208,14 +217,14 @@ def create( def list( self, *, - created_after: Union[str, datetime] | NotGiven = NOT_GIVEN, - created_before: Union[str, datetime] | NotGiven = NOT_GIVEN, + created_after: Union[str, datetime] | Omit = omit, + created_before: Union[str, datetime] | Omit = omit, # 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, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncCursorURLPageWithCreatedFilters[Prediction]: """ Get a paginated list of all predictions created by the user or organization @@ -330,7 +339,7 @@ def cancel( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Prediction: """ Cancel a prediction that is currently running. @@ -386,7 +395,7 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Prediction: """ Get the current state of a prediction. @@ -448,7 +457,9 @@ def get( Terminated predictions (with a status of `succeeded`, `failed`, or `canceled`) will include a `metrics` object with a `predict_time` property showing the amount of CPU or GPU time, in seconds, that the prediction used while running. - It won't include time waiting for the prediction to start. + It won't include time waiting for the prediction to start. The `metrics` object + will also include a `total_time` property showing the total time, in seconds, + that the prediction took to complete. All input parameters, output values, and logs are automatically removed after an hour, by default, for predictions created through the API. @@ -514,17 +525,18 @@ async def create( *, input: object, version: str, - stream: bool | NotGiven = NOT_GIVEN, - webhook: str | NotGiven = NOT_GIVEN, - webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | NotGiven = NOT_GIVEN, - prefer: str | NotGiven = NOT_GIVEN, + stream: bool | Omit = omit, + webhook: str | Omit = omit, + webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit, + prefer: str | Omit = omit, + replicate_max_lifetime: str | Omit = omit, file_encoding_strategy: Optional["FileEncodingStrategy"] = None, # 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, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Prediction: """ Create a prediction for the model version and inputs you provide. @@ -589,7 +601,7 @@ async def create( [server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). This field is no longer needed as the returned prediction will always have a - `stream` entry in its `url` property if the model supports streaming. + `stream` entry in its `urls` property if the model supports streaming. webhook: An HTTPS URL for receiving a webhook when the prediction has new output. The webhook will be a POST request where the request body is the same as the @@ -637,7 +649,15 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ - extra_headers = {**strip_not_given({"Prefer": prefer}), **(extra_headers or {})} + extra_headers = { + **strip_not_given( + { + "Prefer": prefer, + "Replicate-Max-Lifetime": replicate_max_lifetime, + } + ), + **(extra_headers or {}), + } return await self._post( "/predictions", body=await async_maybe_transform( @@ -661,14 +681,14 @@ async def create( def list( self, *, - created_after: Union[str, datetime] | NotGiven = NOT_GIVEN, - created_before: Union[str, datetime] | NotGiven = NOT_GIVEN, + created_after: Union[str, datetime] | Omit = omit, + created_before: Union[str, datetime] | Omit = omit, # 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, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[Prediction, AsyncCursorURLPageWithCreatedFilters[Prediction]]: """ Get a paginated list of all predictions created by the user or organization @@ -783,7 +803,7 @@ async def cancel( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Prediction: """ Cancel a prediction that is currently running. @@ -839,7 +859,7 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Prediction: """ Get the current state of a prediction. @@ -901,7 +921,9 @@ async def get( Terminated predictions (with a status of `succeeded`, `failed`, or `canceled`) will include a `metrics` object with a `predict_time` property showing the amount of CPU or GPU time, in seconds, that the prediction used while running. - It won't include time waiting for the prediction to start. + It won't include time waiting for the prediction to start. The `metrics` object + will also include a `total_time` property showing the total time, in seconds, + that the prediction took to complete. All input parameters, output values, and logs are automatically removed after an hour, by default, for predictions created through the API. diff --git a/src/replicate/resources/trainings.py b/src/replicate/resources/trainings.py index 67600a9..a16b2f2 100644 --- a/src/replicate/resources/trainings.py +++ b/src/replicate/resources/trainings.py @@ -390,7 +390,9 @@ def get( Terminated trainings (with a status of `succeeded`, `failed`, or `canceled`) will include a `metrics` object with a `predict_time` property showing the amount of CPU or GPU time, in seconds, that the training used while running. It - won't include time waiting for the training to start. + won't include time waiting for the training to start. The `metrics` object will + also include a `total_time` property showing the total time, in seconds, that + the training took to complete. Args: extra_headers: Send extra headers @@ -774,7 +776,9 @@ async def get( Terminated trainings (with a status of `succeeded`, `failed`, or `canceled`) will include a `metrics` object with a `predict_time` property showing the amount of CPU or GPU time, in seconds, that the training used while running. It - won't include time waiting for the training to start. + won't include time waiting for the training to start. The `metrics` object will + also include a `total_time` property showing the total time, in seconds, that + the training took to complete. Args: extra_headers: Send extra headers diff --git a/src/replicate/types/collection_get_response.py b/src/replicate/types/collection_get_response.py index 0573b66..396a839 100644 --- a/src/replicate/types/collection_get_response.py +++ b/src/replicate/types/collection_get_response.py @@ -67,3 +67,6 @@ class CollectionGetResponse(BaseModel): slug: str """The slug of the collection (lowercase with dashes)""" + + full_description: Optional[str] = None + """The full description of the collection in markdown format""" diff --git a/src/replicate/types/deployments/prediction_create_params.py b/src/replicate/types/deployments/prediction_create_params.py index ed99336..6bc0863 100644 --- a/src/replicate/types/deployments/prediction_create_params.py +++ b/src/replicate/types/deployments/prediction_create_params.py @@ -47,7 +47,7 @@ class PredictionCreateParams(TypedDict, total=False): [server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). This field is no longer needed as the returned prediction will always have a - `stream` entry in its `url` property if the model supports streaming. + `stream` entry in its `urls` property if the model supports streaming. """ webhook: str @@ -94,3 +94,5 @@ class PredictionCreateParams(TypedDict, total=False): """ prefer: Annotated[str, PropertyInfo(alias="Prefer")] + + replicate_max_lifetime: Annotated[str, PropertyInfo(alias="Replicate-Max-Lifetime")] diff --git a/src/replicate/types/models/prediction_create_params.py b/src/replicate/types/models/prediction_create_params.py index 0427671..69f8d38 100644 --- a/src/replicate/types/models/prediction_create_params.py +++ b/src/replicate/types/models/prediction_create_params.py @@ -47,7 +47,7 @@ class PredictionCreateParams(TypedDict, total=False): [server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). This field is no longer needed as the returned prediction will always have a - `stream` entry in its `url` property if the model supports streaming. + `stream` entry in its `urls` property if the model supports streaming. """ webhook: str @@ -94,3 +94,5 @@ class PredictionCreateParams(TypedDict, total=False): """ prefer: Annotated[str, PropertyInfo(alias="Prefer")] + + replicate_max_lifetime: Annotated[str, PropertyInfo(alias="Replicate-Max-Lifetime")] diff --git a/src/replicate/types/prediction.py b/src/replicate/types/prediction.py index 4a5122b..83071e8 100644 --- a/src/replicate/types/prediction.py +++ b/src/replicate/types/prediction.py @@ -1,12 +1,14 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, Union, Optional +from typing import TYPE_CHECKING, Dict, Union, Optional from datetime import datetime from typing_extensions import Literal +from pydantic import Field as FieldInfo + from .._models import BaseModel -__all__ = ["Prediction", "URLs"] +__all__ = ["Prediction", "URLs", "Metrics"] class URLs(BaseModel): @@ -23,6 +25,23 @@ class URLs(BaseModel): """An event source to stream the output of the prediction via API""" +class Metrics(BaseModel): + total_time: Optional[float] = None + """The total time, in seconds, that the prediction took to complete""" + + if TYPE_CHECKING: + # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a + # value to this field, so for compatibility we avoid doing it at runtime. + __pydantic_extra__: Dict[str, object] = FieldInfo(init=False) # pyright: ignore[reportIncompatibleVariableOverride] + + # Stub to indicate that arbitrary properties are accepted. + # To access properties that are not valid identifiers you can use `getattr`, e.g. + # `getattr(obj, '$type')` + def __getattr__(self, attr: str) -> object: ... + else: + __pydantic_extra__: Dict[str, object] + + class Prediction(BaseModel): id: str @@ -58,13 +77,19 @@ class Prediction(BaseModel): completed_at: Optional[datetime] = None """The time that the model completed the prediction and all outputs were uploaded""" + deadline: Optional[datetime] = None + """ + The absolute time at which the prediction will be automatically canceled if it + has not completed + """ + deployment: Optional[str] = None """The name of the deployment that created the prediction""" logs: Optional[str] = None """The log output from the model""" - metrics: Optional[Dict[str, object]] = None + metrics: Optional[Metrics] = None """Additional metrics associated with the prediction""" started_at: Optional[datetime] = None diff --git a/src/replicate/types/prediction_create_params.py b/src/replicate/types/prediction_create_params.py index 8665e35..8578a34 100644 --- a/src/replicate/types/prediction_create_params.py +++ b/src/replicate/types/prediction_create_params.py @@ -43,7 +43,7 @@ class PredictionCreateParamsWithoutVersion(TypedDict, total=False): [server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). This field is no longer needed as the returned prediction will always have a - `stream` entry in its `url` property if the model supports streaming. + `stream` entry in its `urls` property if the model supports streaming. """ webhook: str @@ -92,6 +92,8 @@ class PredictionCreateParamsWithoutVersion(TypedDict, total=False): prefer: Annotated[str, PropertyInfo(alias="Prefer")] + replicate_max_lifetime: Annotated[str, PropertyInfo(alias="Replicate-Max-Lifetime")] + class PredictionCreateParams(PredictionCreateParamsWithoutVersion): version: Required[str] diff --git a/src/replicate/types/training_cancel_response.py b/src/replicate/types/training_cancel_response.py index 9af512b..097d094 100644 --- a/src/replicate/types/training_cancel_response.py +++ b/src/replicate/types/training_cancel_response.py @@ -13,6 +13,9 @@ class Metrics(BaseModel): predict_time: Optional[float] = None """The amount of CPU or GPU time, in seconds, that the training used while running""" + total_time: Optional[float] = None + """The total time, in seconds, that the training took to complete""" + class Output(BaseModel): version: Optional[str] = None diff --git a/src/replicate/types/training_create_response.py b/src/replicate/types/training_create_response.py index d29e3fa..02340dd 100644 --- a/src/replicate/types/training_create_response.py +++ b/src/replicate/types/training_create_response.py @@ -13,6 +13,9 @@ class Metrics(BaseModel): predict_time: Optional[float] = None """The amount of CPU or GPU time, in seconds, that the training used while running""" + total_time: Optional[float] = None + """The total time, in seconds, that the training took to complete""" + class Output(BaseModel): version: Optional[str] = None diff --git a/src/replicate/types/training_get_response.py b/src/replicate/types/training_get_response.py index 4169da7..07b4571 100644 --- a/src/replicate/types/training_get_response.py +++ b/src/replicate/types/training_get_response.py @@ -13,6 +13,9 @@ class Metrics(BaseModel): predict_time: Optional[float] = None """The amount of CPU or GPU time, in seconds, that the training used while running""" + total_time: Optional[float] = None + """The total time, in seconds, that the training took to complete""" + class Output(BaseModel): version: Optional[str] = None diff --git a/src/replicate/types/training_list_response.py b/src/replicate/types/training_list_response.py index 02adf3a..9313ede 100644 --- a/src/replicate/types/training_list_response.py +++ b/src/replicate/types/training_list_response.py @@ -13,6 +13,9 @@ class Metrics(BaseModel): predict_time: Optional[float] = None """The amount of CPU or GPU time, in seconds, that the training used while running""" + total_time: Optional[float] = None + """The total time, in seconds, that the training took to complete""" + class Output(BaseModel): version: Optional[str] = None diff --git a/tests/api_resources/deployments/test_predictions.py b/tests/api_resources/deployments/test_predictions.py index c9d95e0..eeeed64 100644 --- a/tests/api_resources/deployments/test_predictions.py +++ b/tests/api_resources/deployments/test_predictions.py @@ -44,6 +44,7 @@ def test_method_create_with_all_params(self, client: Replicate) -> None: webhook="https://example.com/my-webhook-handler", webhook_events_filter=["start", "completed"], prefer="wait=5", + replicate_max_lifetime="5m", ) assert_matches_type(Prediction, prediction, path=["response"]) @@ -139,6 +140,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncReplicate) webhook="https://example.com/my-webhook-handler", webhook_events_filter=["start", "completed"], prefer="wait=5", + replicate_max_lifetime="5m", ) assert_matches_type(Prediction, prediction, path=["response"]) diff --git a/tests/api_resources/models/test_predictions.py b/tests/api_resources/models/test_predictions.py index 6c7f099..f702b05 100644 --- a/tests/api_resources/models/test_predictions.py +++ b/tests/api_resources/models/test_predictions.py @@ -44,6 +44,7 @@ def test_method_create_with_all_params(self, client: Replicate) -> None: webhook="https://example.com/my-webhook-handler", webhook_events_filter=["start", "completed"], prefer="wait=5", + replicate_max_lifetime="5m", ) assert_matches_type(Prediction, prediction, path=["response"]) @@ -139,6 +140,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncReplicate) webhook="https://example.com/my-webhook-handler", webhook_events_filter=["start", "completed"], prefer="wait=5", + replicate_max_lifetime="5m", ) assert_matches_type(Prediction, prediction, path=["response"]) diff --git a/tests/api_resources/test_predictions.py b/tests/api_resources/test_predictions.py index 1f0498a..e1640b2 100644 --- a/tests/api_resources/test_predictions.py +++ b/tests/api_resources/test_predictions.py @@ -38,6 +38,7 @@ def test_method_create_with_all_params(self, client: Replicate) -> None: webhook="https://example.com/my-webhook-handler", webhook_events_filter=["start", "completed"], prefer="wait=5", + replicate_max_lifetime="5m", ) assert_matches_type(Prediction, prediction, path=["response"]) @@ -215,6 +216,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncReplicate) webhook="https://example.com/my-webhook-handler", webhook_events_filter=["start", "completed"], prefer="wait=5", + replicate_max_lifetime="5m", ) assert_matches_type(Prediction, prediction, path=["response"])