relaxai 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of relaxai might be problematic. Click here for more details.
- relaxai/__init__.py +90 -0
- relaxai/_base_client.py +1985 -0
- relaxai/_client.py +437 -0
- relaxai/_compat.py +219 -0
- relaxai/_constants.py +14 -0
- relaxai/_exceptions.py +108 -0
- relaxai/_files.py +123 -0
- relaxai/_models.py +805 -0
- relaxai/_qs.py +150 -0
- relaxai/_resource.py +43 -0
- relaxai/_response.py +830 -0
- relaxai/_streaming.py +333 -0
- relaxai/_types.py +219 -0
- relaxai/_utils/__init__.py +57 -0
- relaxai/_utils/_logs.py +25 -0
- relaxai/_utils/_proxy.py +65 -0
- relaxai/_utils/_reflection.py +42 -0
- relaxai/_utils/_resources_proxy.py +24 -0
- relaxai/_utils/_streams.py +12 -0
- relaxai/_utils/_sync.py +86 -0
- relaxai/_utils/_transform.py +447 -0
- relaxai/_utils/_typing.py +151 -0
- relaxai/_utils/_utils.py +422 -0
- relaxai/_version.py +4 -0
- relaxai/lib/.keep +4 -0
- relaxai/py.typed +0 -0
- relaxai/resources/__init__.py +61 -0
- relaxai/resources/chat.py +285 -0
- relaxai/resources/embeddings.py +189 -0
- relaxai/resources/health.py +134 -0
- relaxai/resources/models.py +214 -0
- relaxai/types/__init__.py +18 -0
- relaxai/types/chat_completion_message.py +54 -0
- relaxai/types/chat_completion_message_param.py +55 -0
- relaxai/types/chat_create_completion_params.py +106 -0
- relaxai/types/chat_create_completion_response.py +79 -0
- relaxai/types/content_filter_results.py +57 -0
- relaxai/types/embedding_create_params.py +19 -0
- relaxai/types/embedding_create_response.py +30 -0
- relaxai/types/function_call.py +13 -0
- relaxai/types/function_call_param.py +13 -0
- relaxai/types/function_definition_param.py +17 -0
- relaxai/types/health_check_response.py +7 -0
- relaxai/types/model.py +53 -0
- relaxai/types/model_list_response.py +16 -0
- relaxai/types/usage.py +33 -0
- relaxai-0.0.1.dist-info/METADATA +484 -0
- relaxai-0.0.1.dist-info/RECORD +50 -0
- relaxai-0.0.1.dist-info/WHEEL +4 -0
- relaxai-0.0.1.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,285 @@
|
|
|
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 Dict, List, Iterable
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from ..types import chat_create_completion_params
|
|
10
|
+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
|
11
|
+
from .._utils import maybe_transform, async_maybe_transform
|
|
12
|
+
from .._compat import cached_property
|
|
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.function_definition_param import FunctionDefinitionParam
|
|
22
|
+
from ..types.chat_completion_message_param import ChatCompletionMessageParam
|
|
23
|
+
from ..types.chat_create_completion_response import ChatCreateCompletionResponse
|
|
24
|
+
|
|
25
|
+
__all__ = ["ChatResource", "AsyncChatResource"]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ChatResource(SyncAPIResource):
|
|
29
|
+
@cached_property
|
|
30
|
+
def with_raw_response(self) -> ChatResourceWithRawResponse:
|
|
31
|
+
"""
|
|
32
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
33
|
+
the raw response object instead of the parsed content.
|
|
34
|
+
|
|
35
|
+
For more information, see https://www.github.com/relax-ai/python-sdk#accessing-raw-response-data-eg-headers
|
|
36
|
+
"""
|
|
37
|
+
return ChatResourceWithRawResponse(self)
|
|
38
|
+
|
|
39
|
+
@cached_property
|
|
40
|
+
def with_streaming_response(self) -> ChatResourceWithStreamingResponse:
|
|
41
|
+
"""
|
|
42
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
43
|
+
|
|
44
|
+
For more information, see https://www.github.com/relax-ai/python-sdk#with_streaming_response
|
|
45
|
+
"""
|
|
46
|
+
return ChatResourceWithStreamingResponse(self)
|
|
47
|
+
|
|
48
|
+
def create_completion(
|
|
49
|
+
self,
|
|
50
|
+
*,
|
|
51
|
+
messages: Iterable[ChatCompletionMessageParam],
|
|
52
|
+
model: str,
|
|
53
|
+
chat_template_kwargs: object | NotGiven = NOT_GIVEN,
|
|
54
|
+
frequency_penalty: float | NotGiven = NOT_GIVEN,
|
|
55
|
+
function_call: object | NotGiven = NOT_GIVEN,
|
|
56
|
+
functions: Iterable[FunctionDefinitionParam] | NotGiven = NOT_GIVEN,
|
|
57
|
+
logit_bias: Dict[str, int] | NotGiven = NOT_GIVEN,
|
|
58
|
+
logprobs: bool | NotGiven = NOT_GIVEN,
|
|
59
|
+
max_completion_tokens: int | NotGiven = NOT_GIVEN,
|
|
60
|
+
max_tokens: int | NotGiven = NOT_GIVEN,
|
|
61
|
+
metadata: Dict[str, str] | NotGiven = NOT_GIVEN,
|
|
62
|
+
n: int | NotGiven = NOT_GIVEN,
|
|
63
|
+
parallel_tool_calls: object | NotGiven = NOT_GIVEN,
|
|
64
|
+
prediction: chat_create_completion_params.Prediction | NotGiven = NOT_GIVEN,
|
|
65
|
+
presence_penalty: float | NotGiven = NOT_GIVEN,
|
|
66
|
+
reasoning_effort: str | NotGiven = NOT_GIVEN,
|
|
67
|
+
response_format: chat_create_completion_params.ResponseFormat | NotGiven = NOT_GIVEN,
|
|
68
|
+
seed: int | NotGiven = NOT_GIVEN,
|
|
69
|
+
stop: List[str] | NotGiven = NOT_GIVEN,
|
|
70
|
+
store: bool | NotGiven = NOT_GIVEN,
|
|
71
|
+
stream: bool | NotGiven = NOT_GIVEN,
|
|
72
|
+
stream_options: chat_create_completion_params.StreamOptions | NotGiven = NOT_GIVEN,
|
|
73
|
+
temperature: float | NotGiven = NOT_GIVEN,
|
|
74
|
+
tool_choice: object | NotGiven = NOT_GIVEN,
|
|
75
|
+
tools: Iterable[chat_create_completion_params.Tool] | NotGiven = NOT_GIVEN,
|
|
76
|
+
top_logprobs: int | NotGiven = NOT_GIVEN,
|
|
77
|
+
top_p: float | NotGiven = NOT_GIVEN,
|
|
78
|
+
user: str | NotGiven = NOT_GIVEN,
|
|
79
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
80
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
81
|
+
extra_headers: Headers | None = None,
|
|
82
|
+
extra_query: Query | None = None,
|
|
83
|
+
extra_body: Body | None = None,
|
|
84
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
85
|
+
) -> ChatCreateCompletionResponse:
|
|
86
|
+
"""
|
|
87
|
+
Creates a chat completion for the given model
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
extra_headers: Send extra headers
|
|
91
|
+
|
|
92
|
+
extra_query: Add additional query parameters to the request
|
|
93
|
+
|
|
94
|
+
extra_body: Add additional JSON properties to the request
|
|
95
|
+
|
|
96
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
97
|
+
"""
|
|
98
|
+
return self._post(
|
|
99
|
+
"/v1/chat/completions",
|
|
100
|
+
body=maybe_transform(
|
|
101
|
+
{
|
|
102
|
+
"messages": messages,
|
|
103
|
+
"model": model,
|
|
104
|
+
"chat_template_kwargs": chat_template_kwargs,
|
|
105
|
+
"frequency_penalty": frequency_penalty,
|
|
106
|
+
"function_call": function_call,
|
|
107
|
+
"functions": functions,
|
|
108
|
+
"logit_bias": logit_bias,
|
|
109
|
+
"logprobs": logprobs,
|
|
110
|
+
"max_completion_tokens": max_completion_tokens,
|
|
111
|
+
"max_tokens": max_tokens,
|
|
112
|
+
"metadata": metadata,
|
|
113
|
+
"n": n,
|
|
114
|
+
"parallel_tool_calls": parallel_tool_calls,
|
|
115
|
+
"prediction": prediction,
|
|
116
|
+
"presence_penalty": presence_penalty,
|
|
117
|
+
"reasoning_effort": reasoning_effort,
|
|
118
|
+
"response_format": response_format,
|
|
119
|
+
"seed": seed,
|
|
120
|
+
"stop": stop,
|
|
121
|
+
"store": store,
|
|
122
|
+
"stream": stream,
|
|
123
|
+
"stream_options": stream_options,
|
|
124
|
+
"temperature": temperature,
|
|
125
|
+
"tool_choice": tool_choice,
|
|
126
|
+
"tools": tools,
|
|
127
|
+
"top_logprobs": top_logprobs,
|
|
128
|
+
"top_p": top_p,
|
|
129
|
+
"user": user,
|
|
130
|
+
},
|
|
131
|
+
chat_create_completion_params.ChatCreateCompletionParams,
|
|
132
|
+
),
|
|
133
|
+
options=make_request_options(
|
|
134
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
135
|
+
),
|
|
136
|
+
cast_to=ChatCreateCompletionResponse,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class AsyncChatResource(AsyncAPIResource):
|
|
141
|
+
@cached_property
|
|
142
|
+
def with_raw_response(self) -> AsyncChatResourceWithRawResponse:
|
|
143
|
+
"""
|
|
144
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
145
|
+
the raw response object instead of the parsed content.
|
|
146
|
+
|
|
147
|
+
For more information, see https://www.github.com/relax-ai/python-sdk#accessing-raw-response-data-eg-headers
|
|
148
|
+
"""
|
|
149
|
+
return AsyncChatResourceWithRawResponse(self)
|
|
150
|
+
|
|
151
|
+
@cached_property
|
|
152
|
+
def with_streaming_response(self) -> AsyncChatResourceWithStreamingResponse:
|
|
153
|
+
"""
|
|
154
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
155
|
+
|
|
156
|
+
For more information, see https://www.github.com/relax-ai/python-sdk#with_streaming_response
|
|
157
|
+
"""
|
|
158
|
+
return AsyncChatResourceWithStreamingResponse(self)
|
|
159
|
+
|
|
160
|
+
async def create_completion(
|
|
161
|
+
self,
|
|
162
|
+
*,
|
|
163
|
+
messages: Iterable[ChatCompletionMessageParam],
|
|
164
|
+
model: str,
|
|
165
|
+
chat_template_kwargs: object | NotGiven = NOT_GIVEN,
|
|
166
|
+
frequency_penalty: float | NotGiven = NOT_GIVEN,
|
|
167
|
+
function_call: object | NotGiven = NOT_GIVEN,
|
|
168
|
+
functions: Iterable[FunctionDefinitionParam] | NotGiven = NOT_GIVEN,
|
|
169
|
+
logit_bias: Dict[str, int] | NotGiven = NOT_GIVEN,
|
|
170
|
+
logprobs: bool | NotGiven = NOT_GIVEN,
|
|
171
|
+
max_completion_tokens: int | NotGiven = NOT_GIVEN,
|
|
172
|
+
max_tokens: int | NotGiven = NOT_GIVEN,
|
|
173
|
+
metadata: Dict[str, str] | NotGiven = NOT_GIVEN,
|
|
174
|
+
n: int | NotGiven = NOT_GIVEN,
|
|
175
|
+
parallel_tool_calls: object | NotGiven = NOT_GIVEN,
|
|
176
|
+
prediction: chat_create_completion_params.Prediction | NotGiven = NOT_GIVEN,
|
|
177
|
+
presence_penalty: float | NotGiven = NOT_GIVEN,
|
|
178
|
+
reasoning_effort: str | NotGiven = NOT_GIVEN,
|
|
179
|
+
response_format: chat_create_completion_params.ResponseFormat | NotGiven = NOT_GIVEN,
|
|
180
|
+
seed: int | NotGiven = NOT_GIVEN,
|
|
181
|
+
stop: List[str] | NotGiven = NOT_GIVEN,
|
|
182
|
+
store: bool | NotGiven = NOT_GIVEN,
|
|
183
|
+
stream: bool | NotGiven = NOT_GIVEN,
|
|
184
|
+
stream_options: chat_create_completion_params.StreamOptions | NotGiven = NOT_GIVEN,
|
|
185
|
+
temperature: float | NotGiven = NOT_GIVEN,
|
|
186
|
+
tool_choice: object | NotGiven = NOT_GIVEN,
|
|
187
|
+
tools: Iterable[chat_create_completion_params.Tool] | NotGiven = NOT_GIVEN,
|
|
188
|
+
top_logprobs: int | NotGiven = NOT_GIVEN,
|
|
189
|
+
top_p: float | NotGiven = NOT_GIVEN,
|
|
190
|
+
user: str | NotGiven = NOT_GIVEN,
|
|
191
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
192
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
193
|
+
extra_headers: Headers | None = None,
|
|
194
|
+
extra_query: Query | None = None,
|
|
195
|
+
extra_body: Body | None = None,
|
|
196
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
197
|
+
) -> ChatCreateCompletionResponse:
|
|
198
|
+
"""
|
|
199
|
+
Creates a chat completion for the given model
|
|
200
|
+
|
|
201
|
+
Args:
|
|
202
|
+
extra_headers: Send extra headers
|
|
203
|
+
|
|
204
|
+
extra_query: Add additional query parameters to the request
|
|
205
|
+
|
|
206
|
+
extra_body: Add additional JSON properties to the request
|
|
207
|
+
|
|
208
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
209
|
+
"""
|
|
210
|
+
return await self._post(
|
|
211
|
+
"/v1/chat/completions",
|
|
212
|
+
body=await async_maybe_transform(
|
|
213
|
+
{
|
|
214
|
+
"messages": messages,
|
|
215
|
+
"model": model,
|
|
216
|
+
"chat_template_kwargs": chat_template_kwargs,
|
|
217
|
+
"frequency_penalty": frequency_penalty,
|
|
218
|
+
"function_call": function_call,
|
|
219
|
+
"functions": functions,
|
|
220
|
+
"logit_bias": logit_bias,
|
|
221
|
+
"logprobs": logprobs,
|
|
222
|
+
"max_completion_tokens": max_completion_tokens,
|
|
223
|
+
"max_tokens": max_tokens,
|
|
224
|
+
"metadata": metadata,
|
|
225
|
+
"n": n,
|
|
226
|
+
"parallel_tool_calls": parallel_tool_calls,
|
|
227
|
+
"prediction": prediction,
|
|
228
|
+
"presence_penalty": presence_penalty,
|
|
229
|
+
"reasoning_effort": reasoning_effort,
|
|
230
|
+
"response_format": response_format,
|
|
231
|
+
"seed": seed,
|
|
232
|
+
"stop": stop,
|
|
233
|
+
"store": store,
|
|
234
|
+
"stream": stream,
|
|
235
|
+
"stream_options": stream_options,
|
|
236
|
+
"temperature": temperature,
|
|
237
|
+
"tool_choice": tool_choice,
|
|
238
|
+
"tools": tools,
|
|
239
|
+
"top_logprobs": top_logprobs,
|
|
240
|
+
"top_p": top_p,
|
|
241
|
+
"user": user,
|
|
242
|
+
},
|
|
243
|
+
chat_create_completion_params.ChatCreateCompletionParams,
|
|
244
|
+
),
|
|
245
|
+
options=make_request_options(
|
|
246
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
247
|
+
),
|
|
248
|
+
cast_to=ChatCreateCompletionResponse,
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
class ChatResourceWithRawResponse:
|
|
253
|
+
def __init__(self, chat: ChatResource) -> None:
|
|
254
|
+
self._chat = chat
|
|
255
|
+
|
|
256
|
+
self.create_completion = to_raw_response_wrapper(
|
|
257
|
+
chat.create_completion,
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
class AsyncChatResourceWithRawResponse:
|
|
262
|
+
def __init__(self, chat: AsyncChatResource) -> None:
|
|
263
|
+
self._chat = chat
|
|
264
|
+
|
|
265
|
+
self.create_completion = async_to_raw_response_wrapper(
|
|
266
|
+
chat.create_completion,
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class ChatResourceWithStreamingResponse:
|
|
271
|
+
def __init__(self, chat: ChatResource) -> None:
|
|
272
|
+
self._chat = chat
|
|
273
|
+
|
|
274
|
+
self.create_completion = to_streamed_response_wrapper(
|
|
275
|
+
chat.create_completion,
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
class AsyncChatResourceWithStreamingResponse:
|
|
280
|
+
def __init__(self, chat: AsyncChatResource) -> None:
|
|
281
|
+
self._chat = chat
|
|
282
|
+
|
|
283
|
+
self.create_completion = async_to_streamed_response_wrapper(
|
|
284
|
+
chat.create_completion,
|
|
285
|
+
)
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ..types import embedding_create_params
|
|
8
|
+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
|
9
|
+
from .._utils import maybe_transform, async_maybe_transform
|
|
10
|
+
from .._compat import cached_property
|
|
11
|
+
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
12
|
+
from .._response import (
|
|
13
|
+
to_raw_response_wrapper,
|
|
14
|
+
to_streamed_response_wrapper,
|
|
15
|
+
async_to_raw_response_wrapper,
|
|
16
|
+
async_to_streamed_response_wrapper,
|
|
17
|
+
)
|
|
18
|
+
from .._base_client import make_request_options
|
|
19
|
+
from ..types.embedding_create_response import EmbeddingCreateResponse
|
|
20
|
+
|
|
21
|
+
__all__ = ["EmbeddingsResource", "AsyncEmbeddingsResource"]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class EmbeddingsResource(SyncAPIResource):
|
|
25
|
+
@cached_property
|
|
26
|
+
def with_raw_response(self) -> EmbeddingsResourceWithRawResponse:
|
|
27
|
+
"""
|
|
28
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
29
|
+
the raw response object instead of the parsed content.
|
|
30
|
+
|
|
31
|
+
For more information, see https://www.github.com/relax-ai/python-sdk#accessing-raw-response-data-eg-headers
|
|
32
|
+
"""
|
|
33
|
+
return EmbeddingsResourceWithRawResponse(self)
|
|
34
|
+
|
|
35
|
+
@cached_property
|
|
36
|
+
def with_streaming_response(self) -> EmbeddingsResourceWithStreamingResponse:
|
|
37
|
+
"""
|
|
38
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
39
|
+
|
|
40
|
+
For more information, see https://www.github.com/relax-ai/python-sdk#with_streaming_response
|
|
41
|
+
"""
|
|
42
|
+
return EmbeddingsResourceWithStreamingResponse(self)
|
|
43
|
+
|
|
44
|
+
def create(
|
|
45
|
+
self,
|
|
46
|
+
*,
|
|
47
|
+
input: object,
|
|
48
|
+
model: str,
|
|
49
|
+
dimensions: int | NotGiven = NOT_GIVEN,
|
|
50
|
+
encoding_format: str | NotGiven = NOT_GIVEN,
|
|
51
|
+
user: str | NotGiven = NOT_GIVEN,
|
|
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
|
+
) -> EmbeddingCreateResponse:
|
|
59
|
+
"""
|
|
60
|
+
Creates an embedding vector representing the input text.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
extra_headers: Send extra headers
|
|
64
|
+
|
|
65
|
+
extra_query: Add additional query parameters to the request
|
|
66
|
+
|
|
67
|
+
extra_body: Add additional JSON properties to the request
|
|
68
|
+
|
|
69
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
70
|
+
"""
|
|
71
|
+
return self._post(
|
|
72
|
+
"/v1/embeddings",
|
|
73
|
+
body=maybe_transform(
|
|
74
|
+
{
|
|
75
|
+
"input": input,
|
|
76
|
+
"model": model,
|
|
77
|
+
"dimensions": dimensions,
|
|
78
|
+
"encoding_format": encoding_format,
|
|
79
|
+
"user": user,
|
|
80
|
+
},
|
|
81
|
+
embedding_create_params.EmbeddingCreateParams,
|
|
82
|
+
),
|
|
83
|
+
options=make_request_options(
|
|
84
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
85
|
+
),
|
|
86
|
+
cast_to=EmbeddingCreateResponse,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class AsyncEmbeddingsResource(AsyncAPIResource):
|
|
91
|
+
@cached_property
|
|
92
|
+
def with_raw_response(self) -> AsyncEmbeddingsResourceWithRawResponse:
|
|
93
|
+
"""
|
|
94
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
95
|
+
the raw response object instead of the parsed content.
|
|
96
|
+
|
|
97
|
+
For more information, see https://www.github.com/relax-ai/python-sdk#accessing-raw-response-data-eg-headers
|
|
98
|
+
"""
|
|
99
|
+
return AsyncEmbeddingsResourceWithRawResponse(self)
|
|
100
|
+
|
|
101
|
+
@cached_property
|
|
102
|
+
def with_streaming_response(self) -> AsyncEmbeddingsResourceWithStreamingResponse:
|
|
103
|
+
"""
|
|
104
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
105
|
+
|
|
106
|
+
For more information, see https://www.github.com/relax-ai/python-sdk#with_streaming_response
|
|
107
|
+
"""
|
|
108
|
+
return AsyncEmbeddingsResourceWithStreamingResponse(self)
|
|
109
|
+
|
|
110
|
+
async def create(
|
|
111
|
+
self,
|
|
112
|
+
*,
|
|
113
|
+
input: object,
|
|
114
|
+
model: str,
|
|
115
|
+
dimensions: int | NotGiven = NOT_GIVEN,
|
|
116
|
+
encoding_format: str | NotGiven = NOT_GIVEN,
|
|
117
|
+
user: str | NotGiven = NOT_GIVEN,
|
|
118
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
119
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
120
|
+
extra_headers: Headers | None = None,
|
|
121
|
+
extra_query: Query | None = None,
|
|
122
|
+
extra_body: Body | None = None,
|
|
123
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
124
|
+
) -> EmbeddingCreateResponse:
|
|
125
|
+
"""
|
|
126
|
+
Creates an embedding vector representing the input text.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
extra_headers: Send extra headers
|
|
130
|
+
|
|
131
|
+
extra_query: Add additional query parameters to the request
|
|
132
|
+
|
|
133
|
+
extra_body: Add additional JSON properties to the request
|
|
134
|
+
|
|
135
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
136
|
+
"""
|
|
137
|
+
return await self._post(
|
|
138
|
+
"/v1/embeddings",
|
|
139
|
+
body=await async_maybe_transform(
|
|
140
|
+
{
|
|
141
|
+
"input": input,
|
|
142
|
+
"model": model,
|
|
143
|
+
"dimensions": dimensions,
|
|
144
|
+
"encoding_format": encoding_format,
|
|
145
|
+
"user": user,
|
|
146
|
+
},
|
|
147
|
+
embedding_create_params.EmbeddingCreateParams,
|
|
148
|
+
),
|
|
149
|
+
options=make_request_options(
|
|
150
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
151
|
+
),
|
|
152
|
+
cast_to=EmbeddingCreateResponse,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class EmbeddingsResourceWithRawResponse:
|
|
157
|
+
def __init__(self, embeddings: EmbeddingsResource) -> None:
|
|
158
|
+
self._embeddings = embeddings
|
|
159
|
+
|
|
160
|
+
self.create = to_raw_response_wrapper(
|
|
161
|
+
embeddings.create,
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class AsyncEmbeddingsResourceWithRawResponse:
|
|
166
|
+
def __init__(self, embeddings: AsyncEmbeddingsResource) -> None:
|
|
167
|
+
self._embeddings = embeddings
|
|
168
|
+
|
|
169
|
+
self.create = async_to_raw_response_wrapper(
|
|
170
|
+
embeddings.create,
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class EmbeddingsResourceWithStreamingResponse:
|
|
175
|
+
def __init__(self, embeddings: EmbeddingsResource) -> None:
|
|
176
|
+
self._embeddings = embeddings
|
|
177
|
+
|
|
178
|
+
self.create = to_streamed_response_wrapper(
|
|
179
|
+
embeddings.create,
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class AsyncEmbeddingsResourceWithStreamingResponse:
|
|
184
|
+
def __init__(self, embeddings: AsyncEmbeddingsResource) -> None:
|
|
185
|
+
self._embeddings = embeddings
|
|
186
|
+
|
|
187
|
+
self.create = async_to_streamed_response_wrapper(
|
|
188
|
+
embeddings.create,
|
|
189
|
+
)
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
|
8
|
+
from .._compat import cached_property
|
|
9
|
+
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
10
|
+
from .._response import (
|
|
11
|
+
to_raw_response_wrapper,
|
|
12
|
+
to_streamed_response_wrapper,
|
|
13
|
+
async_to_raw_response_wrapper,
|
|
14
|
+
async_to_streamed_response_wrapper,
|
|
15
|
+
)
|
|
16
|
+
from .._base_client import make_request_options
|
|
17
|
+
|
|
18
|
+
__all__ = ["HealthResource", "AsyncHealthResource"]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class HealthResource(SyncAPIResource):
|
|
22
|
+
@cached_property
|
|
23
|
+
def with_raw_response(self) -> HealthResourceWithRawResponse:
|
|
24
|
+
"""
|
|
25
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
26
|
+
the raw response object instead of the parsed content.
|
|
27
|
+
|
|
28
|
+
For more information, see https://www.github.com/relax-ai/python-sdk#accessing-raw-response-data-eg-headers
|
|
29
|
+
"""
|
|
30
|
+
return HealthResourceWithRawResponse(self)
|
|
31
|
+
|
|
32
|
+
@cached_property
|
|
33
|
+
def with_streaming_response(self) -> HealthResourceWithStreamingResponse:
|
|
34
|
+
"""
|
|
35
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
36
|
+
|
|
37
|
+
For more information, see https://www.github.com/relax-ai/python-sdk#with_streaming_response
|
|
38
|
+
"""
|
|
39
|
+
return HealthResourceWithStreamingResponse(self)
|
|
40
|
+
|
|
41
|
+
def check(
|
|
42
|
+
self,
|
|
43
|
+
*,
|
|
44
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
45
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
46
|
+
extra_headers: Headers | None = None,
|
|
47
|
+
extra_query: Query | None = None,
|
|
48
|
+
extra_body: Body | None = None,
|
|
49
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
50
|
+
) -> str:
|
|
51
|
+
"""Check the health of the service."""
|
|
52
|
+
return self._get(
|
|
53
|
+
"/v1/health",
|
|
54
|
+
options=make_request_options(
|
|
55
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
56
|
+
),
|
|
57
|
+
cast_to=str,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class AsyncHealthResource(AsyncAPIResource):
|
|
62
|
+
@cached_property
|
|
63
|
+
def with_raw_response(self) -> AsyncHealthResourceWithRawResponse:
|
|
64
|
+
"""
|
|
65
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
66
|
+
the raw response object instead of the parsed content.
|
|
67
|
+
|
|
68
|
+
For more information, see https://www.github.com/relax-ai/python-sdk#accessing-raw-response-data-eg-headers
|
|
69
|
+
"""
|
|
70
|
+
return AsyncHealthResourceWithRawResponse(self)
|
|
71
|
+
|
|
72
|
+
@cached_property
|
|
73
|
+
def with_streaming_response(self) -> AsyncHealthResourceWithStreamingResponse:
|
|
74
|
+
"""
|
|
75
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
76
|
+
|
|
77
|
+
For more information, see https://www.github.com/relax-ai/python-sdk#with_streaming_response
|
|
78
|
+
"""
|
|
79
|
+
return AsyncHealthResourceWithStreamingResponse(self)
|
|
80
|
+
|
|
81
|
+
async def check(
|
|
82
|
+
self,
|
|
83
|
+
*,
|
|
84
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
85
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
86
|
+
extra_headers: Headers | None = None,
|
|
87
|
+
extra_query: Query | None = None,
|
|
88
|
+
extra_body: Body | None = None,
|
|
89
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
90
|
+
) -> str:
|
|
91
|
+
"""Check the health of the service."""
|
|
92
|
+
return await self._get(
|
|
93
|
+
"/v1/health",
|
|
94
|
+
options=make_request_options(
|
|
95
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
96
|
+
),
|
|
97
|
+
cast_to=str,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class HealthResourceWithRawResponse:
|
|
102
|
+
def __init__(self, health: HealthResource) -> None:
|
|
103
|
+
self._health = health
|
|
104
|
+
|
|
105
|
+
self.check = to_raw_response_wrapper(
|
|
106
|
+
health.check,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class AsyncHealthResourceWithRawResponse:
|
|
111
|
+
def __init__(self, health: AsyncHealthResource) -> None:
|
|
112
|
+
self._health = health
|
|
113
|
+
|
|
114
|
+
self.check = async_to_raw_response_wrapper(
|
|
115
|
+
health.check,
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class HealthResourceWithStreamingResponse:
|
|
120
|
+
def __init__(self, health: HealthResource) -> None:
|
|
121
|
+
self._health = health
|
|
122
|
+
|
|
123
|
+
self.check = to_streamed_response_wrapper(
|
|
124
|
+
health.check,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class AsyncHealthResourceWithStreamingResponse:
|
|
129
|
+
def __init__(self, health: AsyncHealthResource) -> None:
|
|
130
|
+
self._health = health
|
|
131
|
+
|
|
132
|
+
self.check = async_to_streamed_response_wrapper(
|
|
133
|
+
health.check,
|
|
134
|
+
)
|