|
11 | 11 | from replicate.lib._files import FileEncodingStrategy, encode_json, async_encode_json |
12 | 12 |
|
13 | 13 | from ..types import prediction_list_params, prediction_create_params |
14 | | -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 14 | +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given |
15 | 15 | from .._utils import maybe_transform, strip_not_given, async_maybe_transform |
16 | 16 | from .._compat import cached_property |
17 | 17 | from .._resource import SyncAPIResource, AsyncAPIResource |
@@ -63,17 +63,17 @@ def create( |
63 | 63 | *, |
64 | 64 | input: object, |
65 | 65 | version: str, |
66 | | - stream: bool | NotGiven = NOT_GIVEN, |
67 | | - webhook: str | NotGiven = NOT_GIVEN, |
68 | | - webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | NotGiven = NOT_GIVEN, |
69 | | - prefer: str | NotGiven = NOT_GIVEN, |
| 66 | + stream: bool | Omit = omit, |
| 67 | + webhook: str | Omit = omit, |
| 68 | + webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit, |
| 69 | + prefer: str | Omit = omit, |
70 | 70 | file_encoding_strategy: Optional["FileEncodingStrategy"] = None, |
71 | 71 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
72 | 72 | # The extra values given here take precedence over values defined on the client or passed to this method. |
73 | 73 | extra_headers: Headers | None = None, |
74 | 74 | extra_query: Query | None = None, |
75 | 75 | extra_body: Body | None = None, |
76 | | - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 76 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
77 | 77 | ) -> Prediction: |
78 | 78 | """ |
79 | 79 | Create a prediction for the model version and inputs you provide. |
@@ -138,7 +138,7 @@ def create( |
138 | 138 | [server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). |
139 | 139 |
|
140 | 140 | This field is no longer needed as the returned prediction will always have a |
141 | | - `stream` entry in its `url` property if the model supports streaming. |
| 141 | + `stream` entry in its `urls` property if the model supports streaming. |
142 | 142 |
|
143 | 143 | webhook: An HTTPS URL for receiving a webhook when the prediction has new output. The |
144 | 144 | webhook will be a POST request where the request body is the same as the |
@@ -208,14 +208,14 @@ def create( |
208 | 208 | def list( |
209 | 209 | self, |
210 | 210 | *, |
211 | | - created_after: Union[str, datetime] | NotGiven = NOT_GIVEN, |
212 | | - created_before: Union[str, datetime] | NotGiven = NOT_GIVEN, |
| 211 | + created_after: Union[str, datetime] | Omit = omit, |
| 212 | + created_before: Union[str, datetime] | Omit = omit, |
213 | 213 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
214 | 214 | # The extra values given here take precedence over values defined on the client or passed to this method. |
215 | 215 | extra_headers: Headers | None = None, |
216 | 216 | extra_query: Query | None = None, |
217 | 217 | extra_body: Body | None = None, |
218 | | - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 218 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
219 | 219 | ) -> SyncCursorURLPageWithCreatedFilters[Prediction]: |
220 | 220 | """ |
221 | 221 | Get a paginated list of all predictions created by the user or organization |
@@ -330,7 +330,7 @@ def cancel( |
330 | 330 | extra_headers: Headers | None = None, |
331 | 331 | extra_query: Query | None = None, |
332 | 332 | extra_body: Body | None = None, |
333 | | - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 333 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
334 | 334 | ) -> Prediction: |
335 | 335 | """ |
336 | 336 | Cancel a prediction that is currently running. |
@@ -386,7 +386,7 @@ def get( |
386 | 386 | extra_headers: Headers | None = None, |
387 | 387 | extra_query: Query | None = None, |
388 | 388 | extra_body: Body | None = None, |
389 | | - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 389 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
390 | 390 | ) -> Prediction: |
391 | 391 | """ |
392 | 392 | Get the current state of a prediction. |
@@ -448,7 +448,9 @@ def get( |
448 | 448 | Terminated predictions (with a status of `succeeded`, `failed`, or `canceled`) |
449 | 449 | will include a `metrics` object with a `predict_time` property showing the |
450 | 450 | amount of CPU or GPU time, in seconds, that the prediction used while running. |
451 | | - It won't include time waiting for the prediction to start. |
| 451 | + It won't include time waiting for the prediction to start. The `metrics` object |
| 452 | + will also include a `total_time` property showing the total time, in seconds, |
| 453 | + that the prediction took to complete. |
452 | 454 |
|
453 | 455 | All input parameters, output values, and logs are automatically removed after an |
454 | 456 | hour, by default, for predictions created through the API. |
@@ -514,17 +516,17 @@ async def create( |
514 | 516 | *, |
515 | 517 | input: object, |
516 | 518 | version: str, |
517 | | - stream: bool | NotGiven = NOT_GIVEN, |
518 | | - webhook: str | NotGiven = NOT_GIVEN, |
519 | | - webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | NotGiven = NOT_GIVEN, |
520 | | - prefer: str | NotGiven = NOT_GIVEN, |
| 519 | + stream: bool | Omit = omit, |
| 520 | + webhook: str | Omit = omit, |
| 521 | + webhook_events_filter: List[Literal["start", "output", "logs", "completed"]] | Omit = omit, |
| 522 | + prefer: str | Omit = omit, |
521 | 523 | file_encoding_strategy: Optional["FileEncodingStrategy"] = None, |
522 | 524 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
523 | 525 | # The extra values given here take precedence over values defined on the client or passed to this method. |
524 | 526 | extra_headers: Headers | None = None, |
525 | 527 | extra_query: Query | None = None, |
526 | 528 | extra_body: Body | None = None, |
527 | | - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 529 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
528 | 530 | ) -> Prediction: |
529 | 531 | """ |
530 | 532 | Create a prediction for the model version and inputs you provide. |
@@ -589,7 +591,7 @@ async def create( |
589 | 591 | [server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). |
590 | 592 |
|
591 | 593 | This field is no longer needed as the returned prediction will always have a |
592 | | - `stream` entry in its `url` property if the model supports streaming. |
| 594 | + `stream` entry in its `urls` property if the model supports streaming. |
593 | 595 |
|
594 | 596 | webhook: An HTTPS URL for receiving a webhook when the prediction has new output. The |
595 | 597 | webhook will be a POST request where the request body is the same as the |
@@ -661,14 +663,14 @@ async def create( |
661 | 663 | def list( |
662 | 664 | self, |
663 | 665 | *, |
664 | | - created_after: Union[str, datetime] | NotGiven = NOT_GIVEN, |
665 | | - created_before: Union[str, datetime] | NotGiven = NOT_GIVEN, |
| 666 | + created_after: Union[str, datetime] | Omit = omit, |
| 667 | + created_before: Union[str, datetime] | Omit = omit, |
666 | 668 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
667 | 669 | # The extra values given here take precedence over values defined on the client or passed to this method. |
668 | 670 | extra_headers: Headers | None = None, |
669 | 671 | extra_query: Query | None = None, |
670 | 672 | extra_body: Body | None = None, |
671 | | - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 673 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
672 | 674 | ) -> AsyncPaginator[Prediction, AsyncCursorURLPageWithCreatedFilters[Prediction]]: |
673 | 675 | """ |
674 | 676 | Get a paginated list of all predictions created by the user or organization |
@@ -783,7 +785,7 @@ async def cancel( |
783 | 785 | extra_headers: Headers | None = None, |
784 | 786 | extra_query: Query | None = None, |
785 | 787 | extra_body: Body | None = None, |
786 | | - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 788 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
787 | 789 | ) -> Prediction: |
788 | 790 | """ |
789 | 791 | Cancel a prediction that is currently running. |
@@ -839,7 +841,7 @@ async def get( |
839 | 841 | extra_headers: Headers | None = None, |
840 | 842 | extra_query: Query | None = None, |
841 | 843 | extra_body: Body | None = None, |
842 | | - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 844 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
843 | 845 | ) -> Prediction: |
844 | 846 | """ |
845 | 847 | Get the current state of a prediction. |
@@ -901,7 +903,9 @@ async def get( |
901 | 903 | Terminated predictions (with a status of `succeeded`, `failed`, or `canceled`) |
902 | 904 | will include a `metrics` object with a `predict_time` property showing the |
903 | 905 | amount of CPU or GPU time, in seconds, that the prediction used while running. |
904 | | - It won't include time waiting for the prediction to start. |
| 906 | + It won't include time waiting for the prediction to start. The `metrics` object |
| 907 | + will also include a `total_time` property showing the total time, in seconds, |
| 908 | + that the prediction took to complete. |
905 | 909 |
|
906 | 910 | All input parameters, output values, and logs are automatically removed after an |
907 | 911 | hour, by default, for predictions created through the API. |
|
0 commit comments