|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from typing_extensions import Literal |
| 6 | + |
| 7 | +import httpx |
| 8 | + |
| 9 | +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given |
| 10 | +from ..._utils import maybe_transform, async_maybe_transform |
| 11 | +from ..._compat import cached_property |
| 12 | +from ...types.v1 import model_call_params |
| 13 | +from ..._resource import SyncAPIResource, AsyncAPIResource |
| 14 | +from ..._response import ( |
| 15 | + to_raw_response_wrapper, |
| 16 | + to_streamed_response_wrapper, |
| 17 | + async_to_raw_response_wrapper, |
| 18 | + async_to_streamed_response_wrapper, |
| 19 | +) |
| 20 | +from ..._base_client import make_request_options |
| 21 | +from ...types.v1.model_call_response import ModelCallResponse |
| 22 | + |
| 23 | +__all__ = ["ModelsResource", "AsyncModelsResource"] |
| 24 | + |
| 25 | + |
| 26 | +class ModelsResource(SyncAPIResource): |
| 27 | + @cached_property |
| 28 | + def with_raw_response(self) -> ModelsResourceWithRawResponse: |
| 29 | + """ |
| 30 | + This property can be used as a prefix for any HTTP method call to return |
| 31 | + the raw response object instead of the parsed content. |
| 32 | +
|
| 33 | + For more information, see https://www.github.com/babelcloud/gbox-sdk-py#accessing-raw-response-data-eg-headers |
| 34 | + """ |
| 35 | + return ModelsResourceWithRawResponse(self) |
| 36 | + |
| 37 | + @cached_property |
| 38 | + def with_streaming_response(self) -> ModelsResourceWithStreamingResponse: |
| 39 | + """ |
| 40 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 41 | +
|
| 42 | + For more information, see https://www.github.com/babelcloud/gbox-sdk-py#with_streaming_response |
| 43 | + """ |
| 44 | + return ModelsResourceWithStreamingResponse(self) |
| 45 | + |
| 46 | + def call( |
| 47 | + self, |
| 48 | + *, |
| 49 | + action: object, |
| 50 | + screenshot: str, |
| 51 | + model: Literal["gbox-handy-1"] | Omit = omit, |
| 52 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 53 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 54 | + extra_headers: Headers | None = None, |
| 55 | + extra_query: Query | None = None, |
| 56 | + extra_body: Body | None = None, |
| 57 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 58 | + ) -> ModelCallResponse: |
| 59 | + """ |
| 60 | + Generate coordinates for a model |
| 61 | +
|
| 62 | + Args: |
| 63 | + action: Structured action object (click or drag) |
| 64 | +
|
| 65 | + screenshot: HTTP(S) URL to screenshot image |
| 66 | +
|
| 67 | + model: Model to use |
| 68 | +
|
| 69 | + extra_headers: Send extra headers |
| 70 | +
|
| 71 | + extra_query: Add additional query parameters to the request |
| 72 | +
|
| 73 | + extra_body: Add additional JSON properties to the request |
| 74 | +
|
| 75 | + timeout: Override the client-level default timeout for this request, in seconds |
| 76 | + """ |
| 77 | + return self._post( |
| 78 | + "/model", |
| 79 | + body=maybe_transform( |
| 80 | + { |
| 81 | + "action": action, |
| 82 | + "screenshot": screenshot, |
| 83 | + "model": model, |
| 84 | + }, |
| 85 | + model_call_params.ModelCallParams, |
| 86 | + ), |
| 87 | + options=make_request_options( |
| 88 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 89 | + ), |
| 90 | + cast_to=ModelCallResponse, |
| 91 | + ) |
| 92 | + |
| 93 | + |
| 94 | +class AsyncModelsResource(AsyncAPIResource): |
| 95 | + @cached_property |
| 96 | + def with_raw_response(self) -> AsyncModelsResourceWithRawResponse: |
| 97 | + """ |
| 98 | + This property can be used as a prefix for any HTTP method call to return |
| 99 | + the raw response object instead of the parsed content. |
| 100 | +
|
| 101 | + For more information, see https://www.github.com/babelcloud/gbox-sdk-py#accessing-raw-response-data-eg-headers |
| 102 | + """ |
| 103 | + return AsyncModelsResourceWithRawResponse(self) |
| 104 | + |
| 105 | + @cached_property |
| 106 | + def with_streaming_response(self) -> AsyncModelsResourceWithStreamingResponse: |
| 107 | + """ |
| 108 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 109 | +
|
| 110 | + For more information, see https://www.github.com/babelcloud/gbox-sdk-py#with_streaming_response |
| 111 | + """ |
| 112 | + return AsyncModelsResourceWithStreamingResponse(self) |
| 113 | + |
| 114 | + async def call( |
| 115 | + self, |
| 116 | + *, |
| 117 | + action: object, |
| 118 | + screenshot: str, |
| 119 | + model: Literal["gbox-handy-1"] | Omit = omit, |
| 120 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 121 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 122 | + extra_headers: Headers | None = None, |
| 123 | + extra_query: Query | None = None, |
| 124 | + extra_body: Body | None = None, |
| 125 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 126 | + ) -> ModelCallResponse: |
| 127 | + """ |
| 128 | + Generate coordinates for a model |
| 129 | +
|
| 130 | + Args: |
| 131 | + action: Structured action object (click or drag) |
| 132 | +
|
| 133 | + screenshot: HTTP(S) URL to screenshot image |
| 134 | +
|
| 135 | + model: Model to use |
| 136 | +
|
| 137 | + extra_headers: Send extra headers |
| 138 | +
|
| 139 | + extra_query: Add additional query parameters to the request |
| 140 | +
|
| 141 | + extra_body: Add additional JSON properties to the request |
| 142 | +
|
| 143 | + timeout: Override the client-level default timeout for this request, in seconds |
| 144 | + """ |
| 145 | + return await self._post( |
| 146 | + "/model", |
| 147 | + body=await async_maybe_transform( |
| 148 | + { |
| 149 | + "action": action, |
| 150 | + "screenshot": screenshot, |
| 151 | + "model": model, |
| 152 | + }, |
| 153 | + model_call_params.ModelCallParams, |
| 154 | + ), |
| 155 | + options=make_request_options( |
| 156 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 157 | + ), |
| 158 | + cast_to=ModelCallResponse, |
| 159 | + ) |
| 160 | + |
| 161 | + |
| 162 | +class ModelsResourceWithRawResponse: |
| 163 | + def __init__(self, models: ModelsResource) -> None: |
| 164 | + self._models = models |
| 165 | + |
| 166 | + self.call = to_raw_response_wrapper( |
| 167 | + models.call, |
| 168 | + ) |
| 169 | + |
| 170 | + |
| 171 | +class AsyncModelsResourceWithRawResponse: |
| 172 | + def __init__(self, models: AsyncModelsResource) -> None: |
| 173 | + self._models = models |
| 174 | + |
| 175 | + self.call = async_to_raw_response_wrapper( |
| 176 | + models.call, |
| 177 | + ) |
| 178 | + |
| 179 | + |
| 180 | +class ModelsResourceWithStreamingResponse: |
| 181 | + def __init__(self, models: ModelsResource) -> None: |
| 182 | + self._models = models |
| 183 | + |
| 184 | + self.call = to_streamed_response_wrapper( |
| 185 | + models.call, |
| 186 | + ) |
| 187 | + |
| 188 | + |
| 189 | +class AsyncModelsResourceWithStreamingResponse: |
| 190 | + def __init__(self, models: AsyncModelsResource) -> None: |
| 191 | + self._models = models |
| 192 | + |
| 193 | + self.call = async_to_streamed_response_wrapper( |
| 194 | + models.call, |
| 195 | + ) |
0 commit comments