|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from typing import Optional |
| 6 | + |
| 7 | +import httpx |
| 8 | + |
| 9 | +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 10 | +from ..._utils import ( |
| 11 | + maybe_transform, |
| 12 | + async_maybe_transform, |
| 13 | +) |
| 14 | +from ..._compat import cached_property |
| 15 | +from ..._resource import SyncAPIResource, AsyncAPIResource |
| 16 | +from ..._response import ( |
| 17 | + to_raw_response_wrapper, |
| 18 | + to_streamed_response_wrapper, |
| 19 | + async_to_raw_response_wrapper, |
| 20 | + async_to_streamed_response_wrapper, |
| 21 | +) |
| 22 | +from ..._base_client import make_request_options |
| 23 | +from ...types.inference_pipelines import row_stream_params |
| 24 | +from ...types.inference_pipelines.row_stream_response import RowStreamResponse |
| 25 | + |
| 26 | +__all__ = ["RowsResource", "AsyncRowsResource"] |
| 27 | + |
| 28 | + |
| 29 | +class RowsResource(SyncAPIResource): |
| 30 | + @cached_property |
| 31 | + def with_raw_response(self) -> RowsResourceWithRawResponse: |
| 32 | + return RowsResourceWithRawResponse(self) |
| 33 | + |
| 34 | + @cached_property |
| 35 | + def with_streaming_response(self) -> RowsResourceWithStreamingResponse: |
| 36 | + return RowsResourceWithStreamingResponse(self) |
| 37 | + |
| 38 | + def stream( |
| 39 | + self, |
| 40 | + inference_pipeline_id: str, |
| 41 | + *, |
| 42 | + inference_id: str, |
| 43 | + row: object, |
| 44 | + config: Optional[row_stream_params.Config] | NotGiven = NOT_GIVEN, |
| 45 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 46 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 47 | + extra_headers: Headers | None = None, |
| 48 | + extra_query: Query | None = None, |
| 49 | + extra_body: Body | None = None, |
| 50 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 51 | + ) -> RowStreamResponse: |
| 52 | + """ |
| 53 | + Update an inference data point in an inference pipeline. |
| 54 | +
|
| 55 | + Args: |
| 56 | + inference_id: Specify the inference id as a query param. |
| 57 | +
|
| 58 | + extra_headers: Send extra headers |
| 59 | +
|
| 60 | + extra_query: Add additional query parameters to the request |
| 61 | +
|
| 62 | + extra_body: Add additional JSON properties to the request |
| 63 | +
|
| 64 | + timeout: Override the client-level default timeout for this request, in seconds |
| 65 | + """ |
| 66 | + if not inference_pipeline_id: |
| 67 | + raise ValueError( |
| 68 | + f"Expected a non-empty value for `inference_pipeline_id` but received {inference_pipeline_id!r}" |
| 69 | + ) |
| 70 | + return self._put( |
| 71 | + f"/inference-pipelines/{inference_pipeline_id}/rows", |
| 72 | + body=maybe_transform( |
| 73 | + { |
| 74 | + "row": row, |
| 75 | + "config": config, |
| 76 | + }, |
| 77 | + row_stream_params.RowStreamParams, |
| 78 | + ), |
| 79 | + options=make_request_options( |
| 80 | + extra_headers=extra_headers, |
| 81 | + extra_query=extra_query, |
| 82 | + extra_body=extra_body, |
| 83 | + timeout=timeout, |
| 84 | + query=maybe_transform({"inference_id": inference_id}, row_stream_params.RowStreamParams), |
| 85 | + ), |
| 86 | + cast_to=RowStreamResponse, |
| 87 | + ) |
| 88 | + |
| 89 | + |
| 90 | +class AsyncRowsResource(AsyncAPIResource): |
| 91 | + @cached_property |
| 92 | + def with_raw_response(self) -> AsyncRowsResourceWithRawResponse: |
| 93 | + return AsyncRowsResourceWithRawResponse(self) |
| 94 | + |
| 95 | + @cached_property |
| 96 | + def with_streaming_response(self) -> AsyncRowsResourceWithStreamingResponse: |
| 97 | + return AsyncRowsResourceWithStreamingResponse(self) |
| 98 | + |
| 99 | + async def stream( |
| 100 | + self, |
| 101 | + inference_pipeline_id: str, |
| 102 | + *, |
| 103 | + inference_id: str, |
| 104 | + row: object, |
| 105 | + config: Optional[row_stream_params.Config] | NotGiven = NOT_GIVEN, |
| 106 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 107 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 108 | + extra_headers: Headers | None = None, |
| 109 | + extra_query: Query | None = None, |
| 110 | + extra_body: Body | None = None, |
| 111 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 112 | + ) -> RowStreamResponse: |
| 113 | + """ |
| 114 | + Update an inference data point in an inference pipeline. |
| 115 | +
|
| 116 | + Args: |
| 117 | + inference_id: Specify the inference id as a query param. |
| 118 | +
|
| 119 | + extra_headers: Send extra headers |
| 120 | +
|
| 121 | + extra_query: Add additional query parameters to the request |
| 122 | +
|
| 123 | + extra_body: Add additional JSON properties to the request |
| 124 | +
|
| 125 | + timeout: Override the client-level default timeout for this request, in seconds |
| 126 | + """ |
| 127 | + if not inference_pipeline_id: |
| 128 | + raise ValueError( |
| 129 | + f"Expected a non-empty value for `inference_pipeline_id` but received {inference_pipeline_id!r}" |
| 130 | + ) |
| 131 | + return await self._put( |
| 132 | + f"/inference-pipelines/{inference_pipeline_id}/rows", |
| 133 | + body=await async_maybe_transform( |
| 134 | + { |
| 135 | + "row": row, |
| 136 | + "config": config, |
| 137 | + }, |
| 138 | + row_stream_params.RowStreamParams, |
| 139 | + ), |
| 140 | + options=make_request_options( |
| 141 | + extra_headers=extra_headers, |
| 142 | + extra_query=extra_query, |
| 143 | + extra_body=extra_body, |
| 144 | + timeout=timeout, |
| 145 | + query=await async_maybe_transform({"inference_id": inference_id}, row_stream_params.RowStreamParams), |
| 146 | + ), |
| 147 | + cast_to=RowStreamResponse, |
| 148 | + ) |
| 149 | + |
| 150 | + |
| 151 | +class RowsResourceWithRawResponse: |
| 152 | + def __init__(self, rows: RowsResource) -> None: |
| 153 | + self._rows = rows |
| 154 | + |
| 155 | + self.stream = to_raw_response_wrapper( |
| 156 | + rows.stream, |
| 157 | + ) |
| 158 | + |
| 159 | + |
| 160 | +class AsyncRowsResourceWithRawResponse: |
| 161 | + def __init__(self, rows: AsyncRowsResource) -> None: |
| 162 | + self._rows = rows |
| 163 | + |
| 164 | + self.stream = async_to_raw_response_wrapper( |
| 165 | + rows.stream, |
| 166 | + ) |
| 167 | + |
| 168 | + |
| 169 | +class RowsResourceWithStreamingResponse: |
| 170 | + def __init__(self, rows: RowsResource) -> None: |
| 171 | + self._rows = rows |
| 172 | + |
| 173 | + self.stream = to_streamed_response_wrapper( |
| 174 | + rows.stream, |
| 175 | + ) |
| 176 | + |
| 177 | + |
| 178 | +class AsyncRowsResourceWithStreamingResponse: |
| 179 | + def __init__(self, rows: AsyncRowsResource) -> None: |
| 180 | + self._rows = rows |
| 181 | + |
| 182 | + self.stream = async_to_streamed_response_wrapper( |
| 183 | + rows.stream, |
| 184 | + ) |
0 commit comments