orq-ai-sdk 4.2.0rc49__py3-none-any.whl → 4.2.15__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.
- orq_ai_sdk/_hooks/globalhook.py +0 -1
- orq_ai_sdk/_version.py +3 -3
- orq_ai_sdk/agents.py +186 -186
- orq_ai_sdk/audio.py +30 -0
- orq_ai_sdk/chat.py +22 -0
- orq_ai_sdk/completions.py +438 -0
- orq_ai_sdk/contacts.py +43 -886
- orq_ai_sdk/deployments.py +61 -0
- orq_ai_sdk/edits.py +364 -0
- orq_ai_sdk/embeddings.py +344 -0
- orq_ai_sdk/generations.py +370 -0
- orq_ai_sdk/images.py +28 -0
- orq_ai_sdk/models/__init__.py +3839 -424
- orq_ai_sdk/models/conversationresponse.py +1 -1
- orq_ai_sdk/models/conversationwithmessagesresponse.py +1 -1
- orq_ai_sdk/models/createagentrequestop.py +768 -12
- orq_ai_sdk/models/createagentresponse.py +68 -2
- orq_ai_sdk/models/createchatcompletionop.py +538 -313
- orq_ai_sdk/models/createcompletionop.py +2078 -0
- orq_ai_sdk/models/createcontactop.py +5 -10
- orq_ai_sdk/models/createconversationop.py +1 -1
- orq_ai_sdk/models/createconversationresponseop.py +2 -2
- orq_ai_sdk/models/createdatasetitemop.py +4 -4
- orq_ai_sdk/models/createdatasetop.py +1 -1
- orq_ai_sdk/models/createdatasourceop.py +1 -1
- orq_ai_sdk/models/createembeddingop.py +579 -0
- orq_ai_sdk/models/createevalop.py +14 -14
- orq_ai_sdk/models/createidentityop.py +1 -1
- orq_ai_sdk/models/createimageeditop.py +715 -0
- orq_ai_sdk/models/createimageop.py +228 -82
- orq_ai_sdk/models/createimagevariationop.py +706 -0
- orq_ai_sdk/models/creatememoryop.py +4 -2
- orq_ai_sdk/models/createmoderationop.py +521 -0
- orq_ai_sdk/models/createpromptop.py +375 -6
- orq_ai_sdk/models/creatererankop.py +608 -0
- orq_ai_sdk/models/createresponseop.py +2567 -0
- orq_ai_sdk/models/createspeechop.py +466 -0
- orq_ai_sdk/models/createtoolop.py +6 -6
- orq_ai_sdk/models/createtranscriptionop.py +732 -0
- orq_ai_sdk/models/createtranslationop.py +702 -0
- orq_ai_sdk/models/deploymentgetconfigop.py +17 -7
- orq_ai_sdk/models/deploymentsop.py +1 -0
- orq_ai_sdk/models/deploymentstreamop.py +7 -0
- orq_ai_sdk/models/filegetop.py +1 -1
- orq_ai_sdk/models/filelistop.py +1 -1
- orq_ai_sdk/models/fileuploadop.py +1 -1
- orq_ai_sdk/models/generateconversationnameop.py +1 -1
- orq_ai_sdk/models/getallmemoriesop.py +4 -2
- orq_ai_sdk/models/getallpromptsop.py +188 -3
- orq_ai_sdk/models/getalltoolsop.py +6 -6
- orq_ai_sdk/models/getevalsop.py +17 -17
- orq_ai_sdk/models/getonepromptop.py +188 -3
- orq_ai_sdk/models/getpromptversionop.py +188 -3
- orq_ai_sdk/models/invokedeploymentrequest.py +11 -4
- orq_ai_sdk/models/listagentsop.py +372 -0
- orq_ai_sdk/models/listdatasetdatapointsop.py +4 -4
- orq_ai_sdk/models/listdatasetsop.py +1 -1
- orq_ai_sdk/models/listdatasourcesop.py +1 -1
- orq_ai_sdk/models/listidentitiesop.py +1 -1
- orq_ai_sdk/models/listmodelsop.py +1 -0
- orq_ai_sdk/models/listpromptversionsop.py +188 -3
- orq_ai_sdk/models/partdoneevent.py +1 -1
- orq_ai_sdk/models/post_v2_router_ocrop.py +408 -0
- orq_ai_sdk/models/publiccontact.py +9 -3
- orq_ai_sdk/models/publicidentity.py +62 -0
- orq_ai_sdk/models/reasoningpart.py +1 -1
- orq_ai_sdk/models/responsedoneevent.py +14 -11
- orq_ai_sdk/models/retrieveagentrequestop.py +382 -0
- orq_ai_sdk/models/retrievedatapointop.py +4 -4
- orq_ai_sdk/models/retrievedatasetop.py +1 -1
- orq_ai_sdk/models/retrievedatasourceop.py +1 -1
- orq_ai_sdk/models/retrieveidentityop.py +1 -1
- orq_ai_sdk/models/retrievememoryop.py +4 -2
- orq_ai_sdk/models/retrievetoolop.py +6 -6
- orq_ai_sdk/models/runagentop.py +379 -9
- orq_ai_sdk/models/streamrunagentop.py +385 -9
- orq_ai_sdk/models/updateagentop.py +770 -12
- orq_ai_sdk/models/updateconversationop.py +1 -1
- orq_ai_sdk/models/updatedatapointop.py +4 -4
- orq_ai_sdk/models/updatedatasetop.py +1 -1
- orq_ai_sdk/models/updatedatasourceop.py +1 -1
- orq_ai_sdk/models/updateevalop.py +14 -14
- orq_ai_sdk/models/updateidentityop.py +1 -1
- orq_ai_sdk/models/updatememoryop.py +4 -2
- orq_ai_sdk/models/updatepromptop.py +375 -6
- orq_ai_sdk/models/updatetoolop.py +7 -7
- orq_ai_sdk/moderations.py +218 -0
- orq_ai_sdk/orq_completions.py +666 -0
- orq_ai_sdk/orq_responses.py +398 -0
- orq_ai_sdk/rerank.py +330 -0
- orq_ai_sdk/router.py +89 -641
- orq_ai_sdk/speech.py +333 -0
- orq_ai_sdk/transcriptions.py +416 -0
- orq_ai_sdk/translations.py +384 -0
- orq_ai_sdk/variations.py +364 -0
- orq_ai_sdk-4.2.15.dist-info/METADATA +888 -0
- {orq_ai_sdk-4.2.0rc49.dist-info → orq_ai_sdk-4.2.15.dist-info}/RECORD +99 -76
- {orq_ai_sdk-4.2.0rc49.dist-info → orq_ai_sdk-4.2.15.dist-info}/WHEEL +1 -1
- orq_ai_sdk/models/deletecontactop.py +0 -44
- orq_ai_sdk/models/listcontactsop.py +0 -265
- orq_ai_sdk/models/retrievecontactop.py +0 -142
- orq_ai_sdk/models/updatecontactop.py +0 -233
- orq_ai_sdk-4.2.0rc49.dist-info/METADATA +0 -788
- {orq_ai_sdk-4.2.0rc49.dist-info → orq_ai_sdk-4.2.15.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,2078 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .publiccontact import PublicContact, PublicContactTypedDict
|
|
5
|
+
from .publicidentity import PublicIdentity, PublicIdentityTypedDict
|
|
6
|
+
from orq_ai_sdk.types import (
|
|
7
|
+
BaseModel,
|
|
8
|
+
Nullable,
|
|
9
|
+
OptionalNullable,
|
|
10
|
+
UNSET,
|
|
11
|
+
UNSET_SENTINEL,
|
|
12
|
+
)
|
|
13
|
+
from orq_ai_sdk.utils import eventstreaming
|
|
14
|
+
import pydantic
|
|
15
|
+
from pydantic import model_serializer
|
|
16
|
+
from typing import Any, Dict, List, Literal, Optional, Union
|
|
17
|
+
from typing_extensions import (
|
|
18
|
+
Annotated,
|
|
19
|
+
NotRequired,
|
|
20
|
+
TypeAliasType,
|
|
21
|
+
TypedDict,
|
|
22
|
+
deprecated,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
CreateCompletionStopTypedDict = TypeAliasType(
|
|
27
|
+
"CreateCompletionStopTypedDict", Union[str, List[str]]
|
|
28
|
+
)
|
|
29
|
+
r"""Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence."""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
CreateCompletionStop = TypeAliasType("CreateCompletionStop", Union[str, List[str]])
|
|
33
|
+
r"""Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence."""
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class CreateCompletionFallbacksTypedDict(TypedDict):
|
|
37
|
+
model: str
|
|
38
|
+
r"""Fallback model identifier"""
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class CreateCompletionFallbacks(BaseModel):
|
|
42
|
+
model: str
|
|
43
|
+
r"""Fallback model identifier"""
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class CreateCompletionRetryTypedDict(TypedDict):
|
|
47
|
+
r"""Retry configuration for the request"""
|
|
48
|
+
|
|
49
|
+
count: NotRequired[float]
|
|
50
|
+
r"""Number of retry attempts (1-5)"""
|
|
51
|
+
on_codes: NotRequired[List[float]]
|
|
52
|
+
r"""HTTP status codes that trigger retry logic"""
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class CreateCompletionRetry(BaseModel):
|
|
56
|
+
r"""Retry configuration for the request"""
|
|
57
|
+
|
|
58
|
+
count: Optional[float] = 3
|
|
59
|
+
r"""Number of retry attempts (1-5)"""
|
|
60
|
+
|
|
61
|
+
on_codes: Optional[List[float]] = None
|
|
62
|
+
r"""HTTP status codes that trigger retry logic"""
|
|
63
|
+
|
|
64
|
+
@model_serializer(mode="wrap")
|
|
65
|
+
def serialize_model(self, handler):
|
|
66
|
+
optional_fields = set(["count", "on_codes"])
|
|
67
|
+
serialized = handler(self)
|
|
68
|
+
m = {}
|
|
69
|
+
|
|
70
|
+
for n, f in type(self).model_fields.items():
|
|
71
|
+
k = f.alias or n
|
|
72
|
+
val = serialized.get(k)
|
|
73
|
+
|
|
74
|
+
if val != UNSET_SENTINEL:
|
|
75
|
+
if val is not None or k not in optional_fields:
|
|
76
|
+
m[k] = val
|
|
77
|
+
|
|
78
|
+
return m
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
CreateCompletionType = Literal["exact_match",]
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class CreateCompletionCacheTypedDict(TypedDict):
|
|
85
|
+
r"""Cache configuration for the request."""
|
|
86
|
+
|
|
87
|
+
type: CreateCompletionType
|
|
88
|
+
ttl: NotRequired[float]
|
|
89
|
+
r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class CreateCompletionCache(BaseModel):
|
|
93
|
+
r"""Cache configuration for the request."""
|
|
94
|
+
|
|
95
|
+
type: CreateCompletionType
|
|
96
|
+
|
|
97
|
+
ttl: Optional[float] = 1800
|
|
98
|
+
r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
|
|
99
|
+
|
|
100
|
+
@model_serializer(mode="wrap")
|
|
101
|
+
def serialize_model(self, handler):
|
|
102
|
+
optional_fields = set(["ttl"])
|
|
103
|
+
serialized = handler(self)
|
|
104
|
+
m = {}
|
|
105
|
+
|
|
106
|
+
for n, f in type(self).model_fields.items():
|
|
107
|
+
k = f.alias or n
|
|
108
|
+
val = serialized.get(k)
|
|
109
|
+
|
|
110
|
+
if val != UNSET_SENTINEL:
|
|
111
|
+
if val is not None or k not in optional_fields:
|
|
112
|
+
m[k] = val
|
|
113
|
+
|
|
114
|
+
return m
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
CreateCompletionLoadBalancerType = Literal["weight_based",]
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class CreateCompletionLoadBalancerModelsTypedDict(TypedDict):
|
|
121
|
+
model: str
|
|
122
|
+
r"""Model identifier for load balancing"""
|
|
123
|
+
weight: NotRequired[float]
|
|
124
|
+
r"""Weight assigned to this model for load balancing"""
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class CreateCompletionLoadBalancerModels(BaseModel):
|
|
128
|
+
model: str
|
|
129
|
+
r"""Model identifier for load balancing"""
|
|
130
|
+
|
|
131
|
+
weight: Optional[float] = 0.5
|
|
132
|
+
r"""Weight assigned to this model for load balancing"""
|
|
133
|
+
|
|
134
|
+
@model_serializer(mode="wrap")
|
|
135
|
+
def serialize_model(self, handler):
|
|
136
|
+
optional_fields = set(["weight"])
|
|
137
|
+
serialized = handler(self)
|
|
138
|
+
m = {}
|
|
139
|
+
|
|
140
|
+
for n, f in type(self).model_fields.items():
|
|
141
|
+
k = f.alias or n
|
|
142
|
+
val = serialized.get(k)
|
|
143
|
+
|
|
144
|
+
if val != UNSET_SENTINEL:
|
|
145
|
+
if val is not None or k not in optional_fields:
|
|
146
|
+
m[k] = val
|
|
147
|
+
|
|
148
|
+
return m
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class CreateCompletionLoadBalancer1TypedDict(TypedDict):
|
|
152
|
+
type: CreateCompletionLoadBalancerType
|
|
153
|
+
models: List[CreateCompletionLoadBalancerModelsTypedDict]
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class CreateCompletionLoadBalancer1(BaseModel):
|
|
157
|
+
type: CreateCompletionLoadBalancerType
|
|
158
|
+
|
|
159
|
+
models: List[CreateCompletionLoadBalancerModels]
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
CreateCompletionLoadBalancerTypedDict = CreateCompletionLoadBalancer1TypedDict
|
|
163
|
+
r"""Load balancer configuration for the request."""
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
CreateCompletionLoadBalancer = CreateCompletionLoadBalancer1
|
|
167
|
+
r"""Load balancer configuration for the request."""
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class CreateCompletionTimeoutTypedDict(TypedDict):
|
|
171
|
+
r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
|
|
172
|
+
|
|
173
|
+
call_timeout: float
|
|
174
|
+
r"""Timeout value in milliseconds"""
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
class CreateCompletionTimeout(BaseModel):
|
|
178
|
+
r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
|
|
179
|
+
|
|
180
|
+
call_timeout: float
|
|
181
|
+
r"""Timeout value in milliseconds"""
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
class CreateCompletionRouterCompletionsRetryTypedDict(TypedDict):
|
|
185
|
+
r"""Retry configuration for the request"""
|
|
186
|
+
|
|
187
|
+
count: NotRequired[float]
|
|
188
|
+
r"""Number of retry attempts (1-5)"""
|
|
189
|
+
on_codes: NotRequired[List[float]]
|
|
190
|
+
r"""HTTP status codes that trigger retry logic"""
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class CreateCompletionRouterCompletionsRetry(BaseModel):
|
|
194
|
+
r"""Retry configuration for the request"""
|
|
195
|
+
|
|
196
|
+
count: Optional[float] = 3
|
|
197
|
+
r"""Number of retry attempts (1-5)"""
|
|
198
|
+
|
|
199
|
+
on_codes: Optional[List[float]] = None
|
|
200
|
+
r"""HTTP status codes that trigger retry logic"""
|
|
201
|
+
|
|
202
|
+
@model_serializer(mode="wrap")
|
|
203
|
+
def serialize_model(self, handler):
|
|
204
|
+
optional_fields = set(["count", "on_codes"])
|
|
205
|
+
serialized = handler(self)
|
|
206
|
+
m = {}
|
|
207
|
+
|
|
208
|
+
for n, f in type(self).model_fields.items():
|
|
209
|
+
k = f.alias or n
|
|
210
|
+
val = serialized.get(k)
|
|
211
|
+
|
|
212
|
+
if val != UNSET_SENTINEL:
|
|
213
|
+
if val is not None or k not in optional_fields:
|
|
214
|
+
m[k] = val
|
|
215
|
+
|
|
216
|
+
return m
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class CreateCompletionRouterCompletionsFallbacksTypedDict(TypedDict):
|
|
220
|
+
model: str
|
|
221
|
+
r"""Fallback model identifier"""
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
class CreateCompletionRouterCompletionsFallbacks(BaseModel):
|
|
225
|
+
model: str
|
|
226
|
+
r"""Fallback model identifier"""
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
CreateCompletionVersion = Literal["latest",]
|
|
230
|
+
r"""Version of the prompt to use (currently only \"latest\" supported)"""
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
class CreateCompletionPromptTypedDict(TypedDict):
|
|
234
|
+
r"""Prompt configuration for the request"""
|
|
235
|
+
|
|
236
|
+
id: str
|
|
237
|
+
r"""Unique identifier of the prompt to use"""
|
|
238
|
+
version: CreateCompletionVersion
|
|
239
|
+
r"""Version of the prompt to use (currently only \"latest\" supported)"""
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class CreateCompletionPrompt(BaseModel):
|
|
243
|
+
r"""Prompt configuration for the request"""
|
|
244
|
+
|
|
245
|
+
id: str
|
|
246
|
+
r"""Unique identifier of the prompt to use"""
|
|
247
|
+
|
|
248
|
+
version: CreateCompletionVersion
|
|
249
|
+
r"""Version of the prompt to use (currently only \"latest\" supported)"""
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
class CreateCompletionThreadTypedDict(TypedDict):
|
|
253
|
+
r"""Thread information to group related requests"""
|
|
254
|
+
|
|
255
|
+
id: str
|
|
256
|
+
r"""Unique thread identifier to group related invocations."""
|
|
257
|
+
tags: NotRequired[List[str]]
|
|
258
|
+
r"""Optional tags to differentiate or categorize threads"""
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
class CreateCompletionThread(BaseModel):
|
|
262
|
+
r"""Thread information to group related requests"""
|
|
263
|
+
|
|
264
|
+
id: str
|
|
265
|
+
r"""Unique thread identifier to group related invocations."""
|
|
266
|
+
|
|
267
|
+
tags: Optional[List[str]] = None
|
|
268
|
+
r"""Optional tags to differentiate or categorize threads"""
|
|
269
|
+
|
|
270
|
+
@model_serializer(mode="wrap")
|
|
271
|
+
def serialize_model(self, handler):
|
|
272
|
+
optional_fields = set(["tags"])
|
|
273
|
+
serialized = handler(self)
|
|
274
|
+
m = {}
|
|
275
|
+
|
|
276
|
+
for n, f in type(self).model_fields.items():
|
|
277
|
+
k = f.alias or n
|
|
278
|
+
val = serialized.get(k)
|
|
279
|
+
|
|
280
|
+
if val != UNSET_SENTINEL:
|
|
281
|
+
if val is not None or k not in optional_fields:
|
|
282
|
+
m[k] = val
|
|
283
|
+
|
|
284
|
+
return m
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
class CreateCompletionInputs2TypedDict(TypedDict):
|
|
288
|
+
key: str
|
|
289
|
+
value: NotRequired[Any]
|
|
290
|
+
is_pii: NotRequired[bool]
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
class CreateCompletionInputs2(BaseModel):
|
|
294
|
+
key: str
|
|
295
|
+
|
|
296
|
+
value: Optional[Any] = None
|
|
297
|
+
|
|
298
|
+
is_pii: Optional[bool] = None
|
|
299
|
+
|
|
300
|
+
@model_serializer(mode="wrap")
|
|
301
|
+
def serialize_model(self, handler):
|
|
302
|
+
optional_fields = set(["value", "is_pii"])
|
|
303
|
+
serialized = handler(self)
|
|
304
|
+
m = {}
|
|
305
|
+
|
|
306
|
+
for n, f in type(self).model_fields.items():
|
|
307
|
+
k = f.alias or n
|
|
308
|
+
val = serialized.get(k)
|
|
309
|
+
|
|
310
|
+
if val != UNSET_SENTINEL:
|
|
311
|
+
if val is not None or k not in optional_fields:
|
|
312
|
+
m[k] = val
|
|
313
|
+
|
|
314
|
+
return m
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
CreateCompletionInputsTypedDict = TypeAliasType(
|
|
318
|
+
"CreateCompletionInputsTypedDict",
|
|
319
|
+
Union[Dict[str, Any], List[CreateCompletionInputs2TypedDict]],
|
|
320
|
+
)
|
|
321
|
+
r"""Values to replace in the prompt messages using {{variableName}} syntax"""
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
CreateCompletionInputs = TypeAliasType(
|
|
325
|
+
"CreateCompletionInputs", Union[Dict[str, Any], List[CreateCompletionInputs2]]
|
|
326
|
+
)
|
|
327
|
+
r"""Values to replace in the prompt messages using {{variableName}} syntax"""
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
CreateCompletionRouterCompletionsType = Literal["exact_match",]
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
class CreateCompletionRouterCompletionsCacheTypedDict(TypedDict):
|
|
334
|
+
r"""Cache configuration for the request."""
|
|
335
|
+
|
|
336
|
+
type: CreateCompletionRouterCompletionsType
|
|
337
|
+
ttl: NotRequired[float]
|
|
338
|
+
r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
class CreateCompletionRouterCompletionsCache(BaseModel):
|
|
342
|
+
r"""Cache configuration for the request."""
|
|
343
|
+
|
|
344
|
+
type: CreateCompletionRouterCompletionsType
|
|
345
|
+
|
|
346
|
+
ttl: Optional[float] = 1800
|
|
347
|
+
r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
|
|
348
|
+
|
|
349
|
+
@model_serializer(mode="wrap")
|
|
350
|
+
def serialize_model(self, handler):
|
|
351
|
+
optional_fields = set(["ttl"])
|
|
352
|
+
serialized = handler(self)
|
|
353
|
+
m = {}
|
|
354
|
+
|
|
355
|
+
for n, f in type(self).model_fields.items():
|
|
356
|
+
k = f.alias or n
|
|
357
|
+
val = serialized.get(k)
|
|
358
|
+
|
|
359
|
+
if val != UNSET_SENTINEL:
|
|
360
|
+
if val is not None or k not in optional_fields:
|
|
361
|
+
m[k] = val
|
|
362
|
+
|
|
363
|
+
return m
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
CreateCompletionSearchType = Literal[
|
|
367
|
+
"vector_search",
|
|
368
|
+
"keyword_search",
|
|
369
|
+
"hybrid_search",
|
|
370
|
+
]
|
|
371
|
+
r"""The type of search to perform. If not provided, will default to the knowledge base configured `retrieval_type`"""
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
class CreateCompletionOrExistsTypedDict(TypedDict):
|
|
375
|
+
r"""Exists"""
|
|
376
|
+
|
|
377
|
+
exists: bool
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
class CreateCompletionOrExists(BaseModel):
|
|
381
|
+
r"""Exists"""
|
|
382
|
+
|
|
383
|
+
exists: bool
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
CreateCompletionOrRouterCompletionsNinTypedDict = TypeAliasType(
|
|
387
|
+
"CreateCompletionOrRouterCompletionsNinTypedDict", Union[str, float, bool]
|
|
388
|
+
)
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
CreateCompletionOrRouterCompletionsNin = TypeAliasType(
|
|
392
|
+
"CreateCompletionOrRouterCompletionsNin", Union[str, float, bool]
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
class CreateCompletionOrNinTypedDict(TypedDict):
|
|
397
|
+
r"""Not in"""
|
|
398
|
+
|
|
399
|
+
nin: List[CreateCompletionOrRouterCompletionsNinTypedDict]
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
class CreateCompletionOrNin(BaseModel):
|
|
403
|
+
r"""Not in"""
|
|
404
|
+
|
|
405
|
+
nin: List[CreateCompletionOrRouterCompletionsNin]
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
CreateCompletionOrRouterCompletionsInTypedDict = TypeAliasType(
|
|
409
|
+
"CreateCompletionOrRouterCompletionsInTypedDict", Union[str, float, bool]
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
CreateCompletionOrRouterCompletionsIn = TypeAliasType(
|
|
414
|
+
"CreateCompletionOrRouterCompletionsIn", Union[str, float, bool]
|
|
415
|
+
)
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
class CreateCompletionOrInTypedDict(TypedDict):
|
|
419
|
+
r"""In"""
|
|
420
|
+
|
|
421
|
+
in_: List[CreateCompletionOrRouterCompletionsInTypedDict]
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
class CreateCompletionOrIn(BaseModel):
|
|
425
|
+
r"""In"""
|
|
426
|
+
|
|
427
|
+
in_: Annotated[
|
|
428
|
+
List[CreateCompletionOrRouterCompletionsIn], pydantic.Field(alias="in")
|
|
429
|
+
]
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
class CreateCompletionOrLteTypedDict(TypedDict):
|
|
433
|
+
r"""Less than or equal to"""
|
|
434
|
+
|
|
435
|
+
lte: float
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
class CreateCompletionOrLte(BaseModel):
|
|
439
|
+
r"""Less than or equal to"""
|
|
440
|
+
|
|
441
|
+
lte: float
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
class CreateCompletionOrLtTypedDict(TypedDict):
|
|
445
|
+
r"""Less than"""
|
|
446
|
+
|
|
447
|
+
lt: float
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
class CreateCompletionOrLt(BaseModel):
|
|
451
|
+
r"""Less than"""
|
|
452
|
+
|
|
453
|
+
lt: float
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
class CreateCompletionOrGteTypedDict(TypedDict):
|
|
457
|
+
r"""Greater than or equal to"""
|
|
458
|
+
|
|
459
|
+
gte: float
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
class CreateCompletionOrGte(BaseModel):
|
|
463
|
+
r"""Greater than or equal to"""
|
|
464
|
+
|
|
465
|
+
gte: float
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
class CreateCompletionOrGtTypedDict(TypedDict):
|
|
469
|
+
r"""Greater than"""
|
|
470
|
+
|
|
471
|
+
gt: float
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
class CreateCompletionOrGt(BaseModel):
|
|
475
|
+
r"""Greater than"""
|
|
476
|
+
|
|
477
|
+
gt: float
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
CreateCompletionOrRouterCompletionsNeTypedDict = TypeAliasType(
|
|
481
|
+
"CreateCompletionOrRouterCompletionsNeTypedDict", Union[str, float, bool]
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
CreateCompletionOrRouterCompletionsNe = TypeAliasType(
|
|
486
|
+
"CreateCompletionOrRouterCompletionsNe", Union[str, float, bool]
|
|
487
|
+
)
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
class CreateCompletionOrNeTypedDict(TypedDict):
|
|
491
|
+
r"""Not equal to"""
|
|
492
|
+
|
|
493
|
+
ne: CreateCompletionOrRouterCompletionsNeTypedDict
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
class CreateCompletionOrNe(BaseModel):
|
|
497
|
+
r"""Not equal to"""
|
|
498
|
+
|
|
499
|
+
ne: CreateCompletionOrRouterCompletionsNe
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
CreateCompletionOrRouterCompletionsEqTypedDict = TypeAliasType(
|
|
503
|
+
"CreateCompletionOrRouterCompletionsEqTypedDict", Union[str, float, bool]
|
|
504
|
+
)
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
CreateCompletionOrRouterCompletionsEq = TypeAliasType(
|
|
508
|
+
"CreateCompletionOrRouterCompletionsEq", Union[str, float, bool]
|
|
509
|
+
)
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
class CreateCompletionOrEqTypedDict(TypedDict):
|
|
513
|
+
r"""Equal to"""
|
|
514
|
+
|
|
515
|
+
eq: CreateCompletionOrRouterCompletionsEqTypedDict
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
class CreateCompletionOrEq(BaseModel):
|
|
519
|
+
r"""Equal to"""
|
|
520
|
+
|
|
521
|
+
eq: CreateCompletionOrRouterCompletionsEq
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
CreateCompletionFilterByRouterCompletionsOrTypedDict = TypeAliasType(
|
|
525
|
+
"CreateCompletionFilterByRouterCompletionsOrTypedDict",
|
|
526
|
+
Union[
|
|
527
|
+
CreateCompletionOrEqTypedDict,
|
|
528
|
+
CreateCompletionOrNeTypedDict,
|
|
529
|
+
CreateCompletionOrGtTypedDict,
|
|
530
|
+
CreateCompletionOrGteTypedDict,
|
|
531
|
+
CreateCompletionOrLtTypedDict,
|
|
532
|
+
CreateCompletionOrLteTypedDict,
|
|
533
|
+
CreateCompletionOrInTypedDict,
|
|
534
|
+
CreateCompletionOrNinTypedDict,
|
|
535
|
+
CreateCompletionOrExistsTypedDict,
|
|
536
|
+
],
|
|
537
|
+
)
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
CreateCompletionFilterByRouterCompletionsOr = TypeAliasType(
|
|
541
|
+
"CreateCompletionFilterByRouterCompletionsOr",
|
|
542
|
+
Union[
|
|
543
|
+
CreateCompletionOrEq,
|
|
544
|
+
CreateCompletionOrNe,
|
|
545
|
+
CreateCompletionOrGt,
|
|
546
|
+
CreateCompletionOrGte,
|
|
547
|
+
CreateCompletionOrLt,
|
|
548
|
+
CreateCompletionOrLte,
|
|
549
|
+
CreateCompletionOrIn,
|
|
550
|
+
CreateCompletionOrNin,
|
|
551
|
+
CreateCompletionOrExists,
|
|
552
|
+
],
|
|
553
|
+
)
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
class CreateCompletionFilterByOrTypedDict(TypedDict):
|
|
557
|
+
r"""Or"""
|
|
558
|
+
|
|
559
|
+
or_: List[Dict[str, CreateCompletionFilterByRouterCompletionsOrTypedDict]]
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
class CreateCompletionFilterByOr(BaseModel):
|
|
563
|
+
r"""Or"""
|
|
564
|
+
|
|
565
|
+
or_: Annotated[
|
|
566
|
+
List[Dict[str, CreateCompletionFilterByRouterCompletionsOr]],
|
|
567
|
+
pydantic.Field(alias="or"),
|
|
568
|
+
]
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
class CreateCompletionAndExistsTypedDict(TypedDict):
|
|
572
|
+
r"""Exists"""
|
|
573
|
+
|
|
574
|
+
exists: bool
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
class CreateCompletionAndExists(BaseModel):
|
|
578
|
+
r"""Exists"""
|
|
579
|
+
|
|
580
|
+
exists: bool
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
CreateCompletionAndRouterCompletionsNinTypedDict = TypeAliasType(
|
|
584
|
+
"CreateCompletionAndRouterCompletionsNinTypedDict", Union[str, float, bool]
|
|
585
|
+
)
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
CreateCompletionAndRouterCompletionsNin = TypeAliasType(
|
|
589
|
+
"CreateCompletionAndRouterCompletionsNin", Union[str, float, bool]
|
|
590
|
+
)
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
class CreateCompletionAndNinTypedDict(TypedDict):
|
|
594
|
+
r"""Not in"""
|
|
595
|
+
|
|
596
|
+
nin: List[CreateCompletionAndRouterCompletionsNinTypedDict]
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
class CreateCompletionAndNin(BaseModel):
|
|
600
|
+
r"""Not in"""
|
|
601
|
+
|
|
602
|
+
nin: List[CreateCompletionAndRouterCompletionsNin]
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
CreateCompletionAndRouterCompletionsInTypedDict = TypeAliasType(
|
|
606
|
+
"CreateCompletionAndRouterCompletionsInTypedDict", Union[str, float, bool]
|
|
607
|
+
)
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
CreateCompletionAndRouterCompletionsIn = TypeAliasType(
|
|
611
|
+
"CreateCompletionAndRouterCompletionsIn", Union[str, float, bool]
|
|
612
|
+
)
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
class CreateCompletionAndInTypedDict(TypedDict):
|
|
616
|
+
r"""In"""
|
|
617
|
+
|
|
618
|
+
in_: List[CreateCompletionAndRouterCompletionsInTypedDict]
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
class CreateCompletionAndIn(BaseModel):
|
|
622
|
+
r"""In"""
|
|
623
|
+
|
|
624
|
+
in_: Annotated[
|
|
625
|
+
List[CreateCompletionAndRouterCompletionsIn], pydantic.Field(alias="in")
|
|
626
|
+
]
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
class CreateCompletionAndLteTypedDict(TypedDict):
|
|
630
|
+
r"""Less than or equal to"""
|
|
631
|
+
|
|
632
|
+
lte: float
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
class CreateCompletionAndLte(BaseModel):
|
|
636
|
+
r"""Less than or equal to"""
|
|
637
|
+
|
|
638
|
+
lte: float
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
class CreateCompletionAndLtTypedDict(TypedDict):
|
|
642
|
+
r"""Less than"""
|
|
643
|
+
|
|
644
|
+
lt: float
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
class CreateCompletionAndLt(BaseModel):
|
|
648
|
+
r"""Less than"""
|
|
649
|
+
|
|
650
|
+
lt: float
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
class CreateCompletionAndGteTypedDict(TypedDict):
|
|
654
|
+
r"""Greater than or equal to"""
|
|
655
|
+
|
|
656
|
+
gte: float
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
class CreateCompletionAndGte(BaseModel):
|
|
660
|
+
r"""Greater than or equal to"""
|
|
661
|
+
|
|
662
|
+
gte: float
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
class CreateCompletionAndGtTypedDict(TypedDict):
|
|
666
|
+
r"""Greater than"""
|
|
667
|
+
|
|
668
|
+
gt: float
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
class CreateCompletionAndGt(BaseModel):
|
|
672
|
+
r"""Greater than"""
|
|
673
|
+
|
|
674
|
+
gt: float
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
CreateCompletionAndRouterCompletionsNeTypedDict = TypeAliasType(
|
|
678
|
+
"CreateCompletionAndRouterCompletionsNeTypedDict", Union[str, float, bool]
|
|
679
|
+
)
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
CreateCompletionAndRouterCompletionsNe = TypeAliasType(
|
|
683
|
+
"CreateCompletionAndRouterCompletionsNe", Union[str, float, bool]
|
|
684
|
+
)
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
class CreateCompletionAndNeTypedDict(TypedDict):
|
|
688
|
+
r"""Not equal to"""
|
|
689
|
+
|
|
690
|
+
ne: CreateCompletionAndRouterCompletionsNeTypedDict
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
class CreateCompletionAndNe(BaseModel):
|
|
694
|
+
r"""Not equal to"""
|
|
695
|
+
|
|
696
|
+
ne: CreateCompletionAndRouterCompletionsNe
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
CreateCompletionAndRouterCompletionsEqTypedDict = TypeAliasType(
|
|
700
|
+
"CreateCompletionAndRouterCompletionsEqTypedDict", Union[str, float, bool]
|
|
701
|
+
)
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
CreateCompletionAndRouterCompletionsEq = TypeAliasType(
|
|
705
|
+
"CreateCompletionAndRouterCompletionsEq", Union[str, float, bool]
|
|
706
|
+
)
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
class CreateCompletionAndEqTypedDict(TypedDict):
|
|
710
|
+
r"""Equal to"""
|
|
711
|
+
|
|
712
|
+
eq: CreateCompletionAndRouterCompletionsEqTypedDict
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
class CreateCompletionAndEq(BaseModel):
|
|
716
|
+
r"""Equal to"""
|
|
717
|
+
|
|
718
|
+
eq: CreateCompletionAndRouterCompletionsEq
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
CreateCompletionFilterByRouterCompletionsAndTypedDict = TypeAliasType(
|
|
722
|
+
"CreateCompletionFilterByRouterCompletionsAndTypedDict",
|
|
723
|
+
Union[
|
|
724
|
+
CreateCompletionAndEqTypedDict,
|
|
725
|
+
CreateCompletionAndNeTypedDict,
|
|
726
|
+
CreateCompletionAndGtTypedDict,
|
|
727
|
+
CreateCompletionAndGteTypedDict,
|
|
728
|
+
CreateCompletionAndLtTypedDict,
|
|
729
|
+
CreateCompletionAndLteTypedDict,
|
|
730
|
+
CreateCompletionAndInTypedDict,
|
|
731
|
+
CreateCompletionAndNinTypedDict,
|
|
732
|
+
CreateCompletionAndExistsTypedDict,
|
|
733
|
+
],
|
|
734
|
+
)
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
CreateCompletionFilterByRouterCompletionsAnd = TypeAliasType(
|
|
738
|
+
"CreateCompletionFilterByRouterCompletionsAnd",
|
|
739
|
+
Union[
|
|
740
|
+
CreateCompletionAndEq,
|
|
741
|
+
CreateCompletionAndNe,
|
|
742
|
+
CreateCompletionAndGt,
|
|
743
|
+
CreateCompletionAndGte,
|
|
744
|
+
CreateCompletionAndLt,
|
|
745
|
+
CreateCompletionAndLte,
|
|
746
|
+
CreateCompletionAndIn,
|
|
747
|
+
CreateCompletionAndNin,
|
|
748
|
+
CreateCompletionAndExists,
|
|
749
|
+
],
|
|
750
|
+
)
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
class CreateCompletionFilterByAndTypedDict(TypedDict):
|
|
754
|
+
r"""And"""
|
|
755
|
+
|
|
756
|
+
and_: List[Dict[str, CreateCompletionFilterByRouterCompletionsAndTypedDict]]
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
class CreateCompletionFilterByAnd(BaseModel):
|
|
760
|
+
r"""And"""
|
|
761
|
+
|
|
762
|
+
and_: Annotated[
|
|
763
|
+
List[Dict[str, CreateCompletionFilterByRouterCompletionsAnd]],
|
|
764
|
+
pydantic.Field(alias="and"),
|
|
765
|
+
]
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
class CreateCompletion1ExistsTypedDict(TypedDict):
|
|
769
|
+
r"""Exists"""
|
|
770
|
+
|
|
771
|
+
exists: bool
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
class CreateCompletion1Exists(BaseModel):
|
|
775
|
+
r"""Exists"""
|
|
776
|
+
|
|
777
|
+
exists: bool
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
CreateCompletion1RouterCompletionsNinTypedDict = TypeAliasType(
|
|
781
|
+
"CreateCompletion1RouterCompletionsNinTypedDict", Union[str, float, bool]
|
|
782
|
+
)
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
CreateCompletion1RouterCompletionsNin = TypeAliasType(
|
|
786
|
+
"CreateCompletion1RouterCompletionsNin", Union[str, float, bool]
|
|
787
|
+
)
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
class CreateCompletion1NinTypedDict(TypedDict):
|
|
791
|
+
r"""Not in"""
|
|
792
|
+
|
|
793
|
+
nin: List[CreateCompletion1RouterCompletionsNinTypedDict]
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
class CreateCompletion1Nin(BaseModel):
|
|
797
|
+
r"""Not in"""
|
|
798
|
+
|
|
799
|
+
nin: List[CreateCompletion1RouterCompletionsNin]
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
CreateCompletion1RouterCompletionsInTypedDict = TypeAliasType(
|
|
803
|
+
"CreateCompletion1RouterCompletionsInTypedDict", Union[str, float, bool]
|
|
804
|
+
)
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
CreateCompletion1RouterCompletionsIn = TypeAliasType(
|
|
808
|
+
"CreateCompletion1RouterCompletionsIn", Union[str, float, bool]
|
|
809
|
+
)
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
class CreateCompletion1InTypedDict(TypedDict):
|
|
813
|
+
r"""In"""
|
|
814
|
+
|
|
815
|
+
in_: List[CreateCompletion1RouterCompletionsInTypedDict]
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
class CreateCompletion1In(BaseModel):
|
|
819
|
+
r"""In"""
|
|
820
|
+
|
|
821
|
+
in_: Annotated[
|
|
822
|
+
List[CreateCompletion1RouterCompletionsIn], pydantic.Field(alias="in")
|
|
823
|
+
]
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
class CreateCompletion1LteTypedDict(TypedDict):
|
|
827
|
+
r"""Less than or equal to"""
|
|
828
|
+
|
|
829
|
+
lte: float
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
class CreateCompletion1Lte(BaseModel):
|
|
833
|
+
r"""Less than or equal to"""
|
|
834
|
+
|
|
835
|
+
lte: float
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
class CreateCompletion1LtTypedDict(TypedDict):
|
|
839
|
+
r"""Less than"""
|
|
840
|
+
|
|
841
|
+
lt: float
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
class CreateCompletion1Lt(BaseModel):
|
|
845
|
+
r"""Less than"""
|
|
846
|
+
|
|
847
|
+
lt: float
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
class CreateCompletion1GteTypedDict(TypedDict):
|
|
851
|
+
r"""Greater than or equal to"""
|
|
852
|
+
|
|
853
|
+
gte: float
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
class CreateCompletion1Gte(BaseModel):
|
|
857
|
+
r"""Greater than or equal to"""
|
|
858
|
+
|
|
859
|
+
gte: float
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
class CreateCompletion1GtTypedDict(TypedDict):
|
|
863
|
+
r"""Greater than"""
|
|
864
|
+
|
|
865
|
+
gt: float
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
class CreateCompletion1Gt(BaseModel):
|
|
869
|
+
r"""Greater than"""
|
|
870
|
+
|
|
871
|
+
gt: float
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
CreateCompletion1RouterCompletionsNeTypedDict = TypeAliasType(
|
|
875
|
+
"CreateCompletion1RouterCompletionsNeTypedDict", Union[str, float, bool]
|
|
876
|
+
)
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
CreateCompletion1RouterCompletionsNe = TypeAliasType(
|
|
880
|
+
"CreateCompletion1RouterCompletionsNe", Union[str, float, bool]
|
|
881
|
+
)
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
class CreateCompletion1NeTypedDict(TypedDict):
|
|
885
|
+
r"""Not equal to"""
|
|
886
|
+
|
|
887
|
+
ne: CreateCompletion1RouterCompletionsNeTypedDict
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
class CreateCompletion1Ne(BaseModel):
|
|
891
|
+
r"""Not equal to"""
|
|
892
|
+
|
|
893
|
+
ne: CreateCompletion1RouterCompletionsNe
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
CreateCompletion1RouterCompletionsEqTypedDict = TypeAliasType(
|
|
897
|
+
"CreateCompletion1RouterCompletionsEqTypedDict", Union[str, float, bool]
|
|
898
|
+
)
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
CreateCompletion1RouterCompletionsEq = TypeAliasType(
|
|
902
|
+
"CreateCompletion1RouterCompletionsEq", Union[str, float, bool]
|
|
903
|
+
)
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
class CreateCompletion1EqTypedDict(TypedDict):
|
|
907
|
+
r"""Equal to"""
|
|
908
|
+
|
|
909
|
+
eq: CreateCompletion1RouterCompletionsEqTypedDict
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
class CreateCompletion1Eq(BaseModel):
|
|
913
|
+
r"""Equal to"""
|
|
914
|
+
|
|
915
|
+
eq: CreateCompletion1RouterCompletionsEq
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
CreateCompletionFilterBy1TypedDict = TypeAliasType(
|
|
919
|
+
"CreateCompletionFilterBy1TypedDict",
|
|
920
|
+
Union[
|
|
921
|
+
CreateCompletion1EqTypedDict,
|
|
922
|
+
CreateCompletion1NeTypedDict,
|
|
923
|
+
CreateCompletion1GtTypedDict,
|
|
924
|
+
CreateCompletion1GteTypedDict,
|
|
925
|
+
CreateCompletion1LtTypedDict,
|
|
926
|
+
CreateCompletion1LteTypedDict,
|
|
927
|
+
CreateCompletion1InTypedDict,
|
|
928
|
+
CreateCompletion1NinTypedDict,
|
|
929
|
+
CreateCompletion1ExistsTypedDict,
|
|
930
|
+
],
|
|
931
|
+
)
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
CreateCompletionFilterBy1 = TypeAliasType(
|
|
935
|
+
"CreateCompletionFilterBy1",
|
|
936
|
+
Union[
|
|
937
|
+
CreateCompletion1Eq,
|
|
938
|
+
CreateCompletion1Ne,
|
|
939
|
+
CreateCompletion1Gt,
|
|
940
|
+
CreateCompletion1Gte,
|
|
941
|
+
CreateCompletion1Lt,
|
|
942
|
+
CreateCompletion1Lte,
|
|
943
|
+
CreateCompletion1In,
|
|
944
|
+
CreateCompletion1Nin,
|
|
945
|
+
CreateCompletion1Exists,
|
|
946
|
+
],
|
|
947
|
+
)
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
CreateCompletionFilterByTypedDict = TypeAliasType(
|
|
951
|
+
"CreateCompletionFilterByTypedDict",
|
|
952
|
+
Union[
|
|
953
|
+
CreateCompletionFilterByAndTypedDict,
|
|
954
|
+
CreateCompletionFilterByOrTypedDict,
|
|
955
|
+
Dict[str, CreateCompletionFilterBy1TypedDict],
|
|
956
|
+
],
|
|
957
|
+
)
|
|
958
|
+
r"""The metadata filter to apply to the search. Check the [Searching a Knowledge Base](https://dash.readme.com/project/orqai/v2.0/docs/searching-a-knowledge-base) for more information."""
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
CreateCompletionFilterBy = TypeAliasType(
|
|
962
|
+
"CreateCompletionFilterBy",
|
|
963
|
+
Union[
|
|
964
|
+
CreateCompletionFilterByAnd,
|
|
965
|
+
CreateCompletionFilterByOr,
|
|
966
|
+
Dict[str, CreateCompletionFilterBy1],
|
|
967
|
+
],
|
|
968
|
+
)
|
|
969
|
+
r"""The metadata filter to apply to the search. Check the [Searching a Knowledge Base](https://dash.readme.com/project/orqai/v2.0/docs/searching-a-knowledge-base) for more information."""
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
class CreateCompletionSearchOptionsTypedDict(TypedDict):
|
|
973
|
+
r"""Additional search options"""
|
|
974
|
+
|
|
975
|
+
include_vectors: NotRequired[bool]
|
|
976
|
+
r"""Whether to include the vector in the chunk"""
|
|
977
|
+
include_metadata: NotRequired[bool]
|
|
978
|
+
r"""Whether to include the metadata in the chunk"""
|
|
979
|
+
include_scores: NotRequired[bool]
|
|
980
|
+
r"""Whether to include the scores in the chunk"""
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
class CreateCompletionSearchOptions(BaseModel):
|
|
984
|
+
r"""Additional search options"""
|
|
985
|
+
|
|
986
|
+
include_vectors: Optional[bool] = None
|
|
987
|
+
r"""Whether to include the vector in the chunk"""
|
|
988
|
+
|
|
989
|
+
include_metadata: Optional[bool] = None
|
|
990
|
+
r"""Whether to include the metadata in the chunk"""
|
|
991
|
+
|
|
992
|
+
include_scores: Optional[bool] = None
|
|
993
|
+
r"""Whether to include the scores in the chunk"""
|
|
994
|
+
|
|
995
|
+
@model_serializer(mode="wrap")
|
|
996
|
+
def serialize_model(self, handler):
|
|
997
|
+
optional_fields = set(["include_vectors", "include_metadata", "include_scores"])
|
|
998
|
+
serialized = handler(self)
|
|
999
|
+
m = {}
|
|
1000
|
+
|
|
1001
|
+
for n, f in type(self).model_fields.items():
|
|
1002
|
+
k = f.alias or n
|
|
1003
|
+
val = serialized.get(k)
|
|
1004
|
+
|
|
1005
|
+
if val != UNSET_SENTINEL:
|
|
1006
|
+
if val is not None or k not in optional_fields:
|
|
1007
|
+
m[k] = val
|
|
1008
|
+
|
|
1009
|
+
return m
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
class CreateCompletionRerankConfigTypedDict(TypedDict):
|
|
1013
|
+
r"""Override the rerank configuration for this search. If not provided, will use the knowledge base configured rerank settings."""
|
|
1014
|
+
|
|
1015
|
+
model: str
|
|
1016
|
+
r"""The name of the rerank model to use. Refer to the [model list](https://docs.orq.ai/docs/proxy#/rerank-models)."""
|
|
1017
|
+
threshold: NotRequired[float]
|
|
1018
|
+
r"""The threshold value used to filter the rerank results, only documents with a relevance score greater than the threshold will be returned"""
|
|
1019
|
+
top_k: NotRequired[int]
|
|
1020
|
+
r"""The number of top results to return after reranking. If not provided, will default to the knowledge base configured `top_k`."""
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
class CreateCompletionRerankConfig(BaseModel):
|
|
1024
|
+
r"""Override the rerank configuration for this search. If not provided, will use the knowledge base configured rerank settings."""
|
|
1025
|
+
|
|
1026
|
+
model: str
|
|
1027
|
+
r"""The name of the rerank model to use. Refer to the [model list](https://docs.orq.ai/docs/proxy#/rerank-models)."""
|
|
1028
|
+
|
|
1029
|
+
threshold: Optional[float] = 0
|
|
1030
|
+
r"""The threshold value used to filter the rerank results, only documents with a relevance score greater than the threshold will be returned"""
|
|
1031
|
+
|
|
1032
|
+
top_k: Optional[int] = 10
|
|
1033
|
+
r"""The number of top results to return after reranking. If not provided, will default to the knowledge base configured `top_k`."""
|
|
1034
|
+
|
|
1035
|
+
@model_serializer(mode="wrap")
|
|
1036
|
+
def serialize_model(self, handler):
|
|
1037
|
+
optional_fields = set(["threshold", "top_k"])
|
|
1038
|
+
serialized = handler(self)
|
|
1039
|
+
m = {}
|
|
1040
|
+
|
|
1041
|
+
for n, f in type(self).model_fields.items():
|
|
1042
|
+
k = f.alias or n
|
|
1043
|
+
val = serialized.get(k)
|
|
1044
|
+
|
|
1045
|
+
if val != UNSET_SENTINEL:
|
|
1046
|
+
if val is not None or k not in optional_fields:
|
|
1047
|
+
m[k] = val
|
|
1048
|
+
|
|
1049
|
+
return m
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
class CreateCompletionAgenticRagConfigTypedDict(TypedDict):
|
|
1053
|
+
r"""Override the agentic RAG configuration for this search. If not provided, will use the knowledge base configured agentic RAG settings."""
|
|
1054
|
+
|
|
1055
|
+
model: str
|
|
1056
|
+
r"""The name of the model for the Agent to use. Refer to the [model list](https://docs.orq.ai/docs/proxy#/chat-models)."""
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
class CreateCompletionAgenticRagConfig(BaseModel):
|
|
1060
|
+
r"""Override the agentic RAG configuration for this search. If not provided, will use the knowledge base configured agentic RAG settings."""
|
|
1061
|
+
|
|
1062
|
+
model: str
|
|
1063
|
+
r"""The name of the model for the Agent to use. Refer to the [model list](https://docs.orq.ai/docs/proxy#/chat-models)."""
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
class CreateCompletionKnowledgeBasesTypedDict(TypedDict):
|
|
1067
|
+
knowledge_id: str
|
|
1068
|
+
r"""Unique identifier of the knowledge base to search"""
|
|
1069
|
+
top_k: NotRequired[int]
|
|
1070
|
+
r"""The number of results to return. If not provided, will default to the knowledge base configured `top_k`."""
|
|
1071
|
+
threshold: NotRequired[float]
|
|
1072
|
+
r"""The threshold to apply to the search. If not provided, will default to the knowledge base configured `threshold`"""
|
|
1073
|
+
search_type: NotRequired[CreateCompletionSearchType]
|
|
1074
|
+
r"""The type of search to perform. If not provided, will default to the knowledge base configured `retrieval_type`"""
|
|
1075
|
+
filter_by: NotRequired[CreateCompletionFilterByTypedDict]
|
|
1076
|
+
r"""The metadata filter to apply to the search. Check the [Searching a Knowledge Base](https://dash.readme.com/project/orqai/v2.0/docs/searching-a-knowledge-base) for more information."""
|
|
1077
|
+
search_options: NotRequired[CreateCompletionSearchOptionsTypedDict]
|
|
1078
|
+
r"""Additional search options"""
|
|
1079
|
+
rerank_config: NotRequired[CreateCompletionRerankConfigTypedDict]
|
|
1080
|
+
r"""Override the rerank configuration for this search. If not provided, will use the knowledge base configured rerank settings."""
|
|
1081
|
+
agentic_rag_config: NotRequired[CreateCompletionAgenticRagConfigTypedDict]
|
|
1082
|
+
r"""Override the agentic RAG configuration for this search. If not provided, will use the knowledge base configured agentic RAG settings."""
|
|
1083
|
+
query: NotRequired[str]
|
|
1084
|
+
r"""The query to use to search the knowledge base. If not provided we will use the last user message from the messages of the requests"""
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
class CreateCompletionKnowledgeBases(BaseModel):
|
|
1088
|
+
knowledge_id: str
|
|
1089
|
+
r"""Unique identifier of the knowledge base to search"""
|
|
1090
|
+
|
|
1091
|
+
top_k: Optional[int] = None
|
|
1092
|
+
r"""The number of results to return. If not provided, will default to the knowledge base configured `top_k`."""
|
|
1093
|
+
|
|
1094
|
+
threshold: Optional[float] = None
|
|
1095
|
+
r"""The threshold to apply to the search. If not provided, will default to the knowledge base configured `threshold`"""
|
|
1096
|
+
|
|
1097
|
+
search_type: Optional[CreateCompletionSearchType] = "hybrid_search"
|
|
1098
|
+
r"""The type of search to perform. If not provided, will default to the knowledge base configured `retrieval_type`"""
|
|
1099
|
+
|
|
1100
|
+
filter_by: Optional[CreateCompletionFilterBy] = None
|
|
1101
|
+
r"""The metadata filter to apply to the search. Check the [Searching a Knowledge Base](https://dash.readme.com/project/orqai/v2.0/docs/searching-a-knowledge-base) for more information."""
|
|
1102
|
+
|
|
1103
|
+
search_options: Optional[CreateCompletionSearchOptions] = None
|
|
1104
|
+
r"""Additional search options"""
|
|
1105
|
+
|
|
1106
|
+
rerank_config: Optional[CreateCompletionRerankConfig] = None
|
|
1107
|
+
r"""Override the rerank configuration for this search. If not provided, will use the knowledge base configured rerank settings."""
|
|
1108
|
+
|
|
1109
|
+
agentic_rag_config: Optional[CreateCompletionAgenticRagConfig] = None
|
|
1110
|
+
r"""Override the agentic RAG configuration for this search. If not provided, will use the knowledge base configured agentic RAG settings."""
|
|
1111
|
+
|
|
1112
|
+
query: Optional[str] = None
|
|
1113
|
+
r"""The query to use to search the knowledge base. If not provided we will use the last user message from the messages of the requests"""
|
|
1114
|
+
|
|
1115
|
+
@model_serializer(mode="wrap")
|
|
1116
|
+
def serialize_model(self, handler):
|
|
1117
|
+
optional_fields = set(
|
|
1118
|
+
[
|
|
1119
|
+
"top_k",
|
|
1120
|
+
"threshold",
|
|
1121
|
+
"search_type",
|
|
1122
|
+
"filter_by",
|
|
1123
|
+
"search_options",
|
|
1124
|
+
"rerank_config",
|
|
1125
|
+
"agentic_rag_config",
|
|
1126
|
+
"query",
|
|
1127
|
+
]
|
|
1128
|
+
)
|
|
1129
|
+
serialized = handler(self)
|
|
1130
|
+
m = {}
|
|
1131
|
+
|
|
1132
|
+
for n, f in type(self).model_fields.items():
|
|
1133
|
+
k = f.alias or n
|
|
1134
|
+
val = serialized.get(k)
|
|
1135
|
+
|
|
1136
|
+
if val != UNSET_SENTINEL:
|
|
1137
|
+
if val is not None or k not in optional_fields:
|
|
1138
|
+
m[k] = val
|
|
1139
|
+
|
|
1140
|
+
return m
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
CreateCompletionLoadBalancerRouterCompletionsType = Literal["weight_based",]
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
class CreateCompletionLoadBalancerRouterCompletionsModelsTypedDict(TypedDict):
|
|
1147
|
+
model: str
|
|
1148
|
+
r"""Model identifier for load balancing"""
|
|
1149
|
+
weight: NotRequired[float]
|
|
1150
|
+
r"""Weight assigned to this model for load balancing"""
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
class CreateCompletionLoadBalancerRouterCompletionsModels(BaseModel):
|
|
1154
|
+
model: str
|
|
1155
|
+
r"""Model identifier for load balancing"""
|
|
1156
|
+
|
|
1157
|
+
weight: Optional[float] = 0.5
|
|
1158
|
+
r"""Weight assigned to this model for load balancing"""
|
|
1159
|
+
|
|
1160
|
+
@model_serializer(mode="wrap")
|
|
1161
|
+
def serialize_model(self, handler):
|
|
1162
|
+
optional_fields = set(["weight"])
|
|
1163
|
+
serialized = handler(self)
|
|
1164
|
+
m = {}
|
|
1165
|
+
|
|
1166
|
+
for n, f in type(self).model_fields.items():
|
|
1167
|
+
k = f.alias or n
|
|
1168
|
+
val = serialized.get(k)
|
|
1169
|
+
|
|
1170
|
+
if val != UNSET_SENTINEL:
|
|
1171
|
+
if val is not None or k not in optional_fields:
|
|
1172
|
+
m[k] = val
|
|
1173
|
+
|
|
1174
|
+
return m
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
class CreateCompletionLoadBalancerRouterCompletions1TypedDict(TypedDict):
|
|
1178
|
+
type: CreateCompletionLoadBalancerRouterCompletionsType
|
|
1179
|
+
models: List[CreateCompletionLoadBalancerRouterCompletionsModelsTypedDict]
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
class CreateCompletionLoadBalancerRouterCompletions1(BaseModel):
|
|
1183
|
+
type: CreateCompletionLoadBalancerRouterCompletionsType
|
|
1184
|
+
|
|
1185
|
+
models: List[CreateCompletionLoadBalancerRouterCompletionsModels]
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
CreateCompletionRouterCompletionsLoadBalancerTypedDict = (
|
|
1189
|
+
CreateCompletionLoadBalancerRouterCompletions1TypedDict
|
|
1190
|
+
)
|
|
1191
|
+
r"""Array of models with weights for load balancing requests"""
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
CreateCompletionRouterCompletionsLoadBalancer = (
|
|
1195
|
+
CreateCompletionLoadBalancerRouterCompletions1
|
|
1196
|
+
)
|
|
1197
|
+
r"""Array of models with weights for load balancing requests"""
|
|
1198
|
+
|
|
1199
|
+
|
|
1200
|
+
class CreateCompletionRouterCompletionsTimeoutTypedDict(TypedDict):
|
|
1201
|
+
r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
|
|
1202
|
+
|
|
1203
|
+
call_timeout: float
|
|
1204
|
+
r"""Timeout value in milliseconds"""
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
class CreateCompletionRouterCompletionsTimeout(BaseModel):
|
|
1208
|
+
r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
|
|
1209
|
+
|
|
1210
|
+
call_timeout: float
|
|
1211
|
+
r"""Timeout value in milliseconds"""
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
@deprecated(
|
|
1215
|
+
"warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
|
|
1216
|
+
)
|
|
1217
|
+
class CreateCompletionOrqTypedDict(TypedDict):
|
|
1218
|
+
r"""Leverage Orq's intelligent routing capabilities to enhance your AI application with enterprise-grade reliability and observability. Orq provides automatic request management including retries on failures, model fallbacks for high availability, identity-level analytics tracking, conversation threading, and dynamic prompt templating with variable substitution."""
|
|
1219
|
+
|
|
1220
|
+
name: NotRequired[str]
|
|
1221
|
+
r"""The name to display on the trace. If not specified, the default system name will be used."""
|
|
1222
|
+
retry: NotRequired[CreateCompletionRouterCompletionsRetryTypedDict]
|
|
1223
|
+
r"""Retry configuration for the request"""
|
|
1224
|
+
fallbacks: NotRequired[List[CreateCompletionRouterCompletionsFallbacksTypedDict]]
|
|
1225
|
+
r"""Array of fallback models to use if primary model fails"""
|
|
1226
|
+
prompt: NotRequired[CreateCompletionPromptTypedDict]
|
|
1227
|
+
r"""Prompt configuration for the request"""
|
|
1228
|
+
identity: NotRequired[PublicIdentityTypedDict]
|
|
1229
|
+
r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
|
|
1230
|
+
contact: NotRequired[PublicContactTypedDict]
|
|
1231
|
+
r"""@deprecated Use identity instead. Information about the contact making the request."""
|
|
1232
|
+
thread: NotRequired[CreateCompletionThreadTypedDict]
|
|
1233
|
+
r"""Thread information to group related requests"""
|
|
1234
|
+
inputs: NotRequired[CreateCompletionInputsTypedDict]
|
|
1235
|
+
r"""Values to replace in the prompt messages using {{variableName}} syntax"""
|
|
1236
|
+
cache: NotRequired[CreateCompletionRouterCompletionsCacheTypedDict]
|
|
1237
|
+
r"""Cache configuration for the request."""
|
|
1238
|
+
knowledge_bases: NotRequired[List[CreateCompletionKnowledgeBasesTypedDict]]
|
|
1239
|
+
load_balancer: NotRequired[CreateCompletionRouterCompletionsLoadBalancerTypedDict]
|
|
1240
|
+
r"""Array of models with weights for load balancing requests"""
|
|
1241
|
+
timeout: NotRequired[CreateCompletionRouterCompletionsTimeoutTypedDict]
|
|
1242
|
+
r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
|
|
1243
|
+
|
|
1244
|
+
|
|
1245
|
+
@deprecated(
|
|
1246
|
+
"warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
|
|
1247
|
+
)
|
|
1248
|
+
class CreateCompletionOrq(BaseModel):
|
|
1249
|
+
r"""Leverage Orq's intelligent routing capabilities to enhance your AI application with enterprise-grade reliability and observability. Orq provides automatic request management including retries on failures, model fallbacks for high availability, identity-level analytics tracking, conversation threading, and dynamic prompt templating with variable substitution."""
|
|
1250
|
+
|
|
1251
|
+
name: Optional[str] = None
|
|
1252
|
+
r"""The name to display on the trace. If not specified, the default system name will be used."""
|
|
1253
|
+
|
|
1254
|
+
retry: Optional[CreateCompletionRouterCompletionsRetry] = None
|
|
1255
|
+
r"""Retry configuration for the request"""
|
|
1256
|
+
|
|
1257
|
+
fallbacks: Optional[List[CreateCompletionRouterCompletionsFallbacks]] = None
|
|
1258
|
+
r"""Array of fallback models to use if primary model fails"""
|
|
1259
|
+
|
|
1260
|
+
prompt: Optional[CreateCompletionPrompt] = None
|
|
1261
|
+
r"""Prompt configuration for the request"""
|
|
1262
|
+
|
|
1263
|
+
identity: Optional[PublicIdentity] = None
|
|
1264
|
+
r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
|
|
1265
|
+
|
|
1266
|
+
contact: Annotated[
|
|
1267
|
+
Optional[PublicContact],
|
|
1268
|
+
pydantic.Field(
|
|
1269
|
+
deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
|
|
1270
|
+
),
|
|
1271
|
+
] = None
|
|
1272
|
+
r"""@deprecated Use identity instead. Information about the contact making the request."""
|
|
1273
|
+
|
|
1274
|
+
thread: Optional[CreateCompletionThread] = None
|
|
1275
|
+
r"""Thread information to group related requests"""
|
|
1276
|
+
|
|
1277
|
+
inputs: Optional[CreateCompletionInputs] = None
|
|
1278
|
+
r"""Values to replace in the prompt messages using {{variableName}} syntax"""
|
|
1279
|
+
|
|
1280
|
+
cache: Optional[CreateCompletionRouterCompletionsCache] = None
|
|
1281
|
+
r"""Cache configuration for the request."""
|
|
1282
|
+
|
|
1283
|
+
knowledge_bases: Optional[List[CreateCompletionKnowledgeBases]] = None
|
|
1284
|
+
|
|
1285
|
+
load_balancer: Optional[CreateCompletionRouterCompletionsLoadBalancer] = None
|
|
1286
|
+
r"""Array of models with weights for load balancing requests"""
|
|
1287
|
+
|
|
1288
|
+
timeout: Optional[CreateCompletionRouterCompletionsTimeout] = None
|
|
1289
|
+
r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
|
|
1290
|
+
|
|
1291
|
+
@model_serializer(mode="wrap")
|
|
1292
|
+
def serialize_model(self, handler):
|
|
1293
|
+
optional_fields = set(
|
|
1294
|
+
[
|
|
1295
|
+
"name",
|
|
1296
|
+
"retry",
|
|
1297
|
+
"fallbacks",
|
|
1298
|
+
"prompt",
|
|
1299
|
+
"identity",
|
|
1300
|
+
"contact",
|
|
1301
|
+
"thread",
|
|
1302
|
+
"inputs",
|
|
1303
|
+
"cache",
|
|
1304
|
+
"knowledge_bases",
|
|
1305
|
+
"load_balancer",
|
|
1306
|
+
"timeout",
|
|
1307
|
+
]
|
|
1308
|
+
)
|
|
1309
|
+
serialized = handler(self)
|
|
1310
|
+
m = {}
|
|
1311
|
+
|
|
1312
|
+
for n, f in type(self).model_fields.items():
|
|
1313
|
+
k = f.alias or n
|
|
1314
|
+
val = serialized.get(k)
|
|
1315
|
+
|
|
1316
|
+
if val != UNSET_SENTINEL:
|
|
1317
|
+
if val is not None or k not in optional_fields:
|
|
1318
|
+
m[k] = val
|
|
1319
|
+
|
|
1320
|
+
return m
|
|
1321
|
+
|
|
1322
|
+
|
|
1323
|
+
class CreateCompletionRequestBodyTypedDict(TypedDict):
|
|
1324
|
+
model: str
|
|
1325
|
+
r"""ID of the model to use"""
|
|
1326
|
+
prompt: str
|
|
1327
|
+
r"""The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays."""
|
|
1328
|
+
echo: NotRequired[Nullable[bool]]
|
|
1329
|
+
r"""Echo back the prompt in addition to the completion"""
|
|
1330
|
+
frequency_penalty: NotRequired[Nullable[float]]
|
|
1331
|
+
r"""Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim."""
|
|
1332
|
+
max_tokens: NotRequired[Nullable[float]]
|
|
1333
|
+
r"""The maximum number of tokens that can be generated in the completion."""
|
|
1334
|
+
presence_penalty: NotRequired[Nullable[float]]
|
|
1335
|
+
r"""Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics."""
|
|
1336
|
+
seed: NotRequired[Nullable[float]]
|
|
1337
|
+
r"""If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result."""
|
|
1338
|
+
stop: NotRequired[Nullable[CreateCompletionStopTypedDict]]
|
|
1339
|
+
r"""Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence."""
|
|
1340
|
+
temperature: NotRequired[Nullable[float]]
|
|
1341
|
+
r"""What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic."""
|
|
1342
|
+
top_p: NotRequired[Nullable[float]]
|
|
1343
|
+
r"""An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered."""
|
|
1344
|
+
n: NotRequired[Nullable[float]]
|
|
1345
|
+
r"""How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly consume your token quota."""
|
|
1346
|
+
user: NotRequired[str]
|
|
1347
|
+
r"""A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse."""
|
|
1348
|
+
name: NotRequired[str]
|
|
1349
|
+
r"""The name to display on the trace. If not specified, the default system name will be used."""
|
|
1350
|
+
fallbacks: NotRequired[List[CreateCompletionFallbacksTypedDict]]
|
|
1351
|
+
r"""Array of fallback models to use if primary model fails"""
|
|
1352
|
+
retry: NotRequired[CreateCompletionRetryTypedDict]
|
|
1353
|
+
r"""Retry configuration for the request"""
|
|
1354
|
+
cache: NotRequired[CreateCompletionCacheTypedDict]
|
|
1355
|
+
r"""Cache configuration for the request."""
|
|
1356
|
+
load_balancer: NotRequired[CreateCompletionLoadBalancerTypedDict]
|
|
1357
|
+
r"""Load balancer configuration for the request."""
|
|
1358
|
+
timeout: NotRequired[CreateCompletionTimeoutTypedDict]
|
|
1359
|
+
r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
|
|
1360
|
+
orq: NotRequired[CreateCompletionOrqTypedDict]
|
|
1361
|
+
r"""Leverage Orq's intelligent routing capabilities to enhance your AI application with enterprise-grade reliability and observability. Orq provides automatic request management including retries on failures, model fallbacks for high availability, identity-level analytics tracking, conversation threading, and dynamic prompt templating with variable substitution."""
|
|
1362
|
+
stream: NotRequired[bool]
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
class CreateCompletionRequestBody(BaseModel):
|
|
1366
|
+
model: str
|
|
1367
|
+
r"""ID of the model to use"""
|
|
1368
|
+
|
|
1369
|
+
prompt: str
|
|
1370
|
+
r"""The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays."""
|
|
1371
|
+
|
|
1372
|
+
echo: OptionalNullable[bool] = False
|
|
1373
|
+
r"""Echo back the prompt in addition to the completion"""
|
|
1374
|
+
|
|
1375
|
+
frequency_penalty: OptionalNullable[float] = 0
|
|
1376
|
+
r"""Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim."""
|
|
1377
|
+
|
|
1378
|
+
max_tokens: OptionalNullable[float] = 16
|
|
1379
|
+
r"""The maximum number of tokens that can be generated in the completion."""
|
|
1380
|
+
|
|
1381
|
+
presence_penalty: OptionalNullable[float] = 0
|
|
1382
|
+
r"""Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics."""
|
|
1383
|
+
|
|
1384
|
+
seed: OptionalNullable[float] = UNSET
|
|
1385
|
+
r"""If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result."""
|
|
1386
|
+
|
|
1387
|
+
stop: OptionalNullable[CreateCompletionStop] = UNSET
|
|
1388
|
+
r"""Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence."""
|
|
1389
|
+
|
|
1390
|
+
temperature: OptionalNullable[float] = 1
|
|
1391
|
+
r"""What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic."""
|
|
1392
|
+
|
|
1393
|
+
top_p: OptionalNullable[float] = 1
|
|
1394
|
+
r"""An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered."""
|
|
1395
|
+
|
|
1396
|
+
n: OptionalNullable[float] = 1
|
|
1397
|
+
r"""How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly consume your token quota."""
|
|
1398
|
+
|
|
1399
|
+
user: Optional[str] = None
|
|
1400
|
+
r"""A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse."""
|
|
1401
|
+
|
|
1402
|
+
name: Optional[str] = None
|
|
1403
|
+
r"""The name to display on the trace. If not specified, the default system name will be used."""
|
|
1404
|
+
|
|
1405
|
+
fallbacks: Optional[List[CreateCompletionFallbacks]] = None
|
|
1406
|
+
r"""Array of fallback models to use if primary model fails"""
|
|
1407
|
+
|
|
1408
|
+
retry: Optional[CreateCompletionRetry] = None
|
|
1409
|
+
r"""Retry configuration for the request"""
|
|
1410
|
+
|
|
1411
|
+
cache: Optional[CreateCompletionCache] = None
|
|
1412
|
+
r"""Cache configuration for the request."""
|
|
1413
|
+
|
|
1414
|
+
load_balancer: Optional[CreateCompletionLoadBalancer] = None
|
|
1415
|
+
r"""Load balancer configuration for the request."""
|
|
1416
|
+
|
|
1417
|
+
timeout: Optional[CreateCompletionTimeout] = None
|
|
1418
|
+
r"""Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured."""
|
|
1419
|
+
|
|
1420
|
+
orq: Annotated[
|
|
1421
|
+
Optional[CreateCompletionOrq],
|
|
1422
|
+
pydantic.Field(
|
|
1423
|
+
deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
|
|
1424
|
+
),
|
|
1425
|
+
] = None
|
|
1426
|
+
r"""Leverage Orq's intelligent routing capabilities to enhance your AI application with enterprise-grade reliability and observability. Orq provides automatic request management including retries on failures, model fallbacks for high availability, identity-level analytics tracking, conversation threading, and dynamic prompt templating with variable substitution."""
|
|
1427
|
+
|
|
1428
|
+
stream: Optional[bool] = False
|
|
1429
|
+
|
|
1430
|
+
@model_serializer(mode="wrap")
|
|
1431
|
+
def serialize_model(self, handler):
|
|
1432
|
+
optional_fields = set(
|
|
1433
|
+
[
|
|
1434
|
+
"echo",
|
|
1435
|
+
"frequency_penalty",
|
|
1436
|
+
"max_tokens",
|
|
1437
|
+
"presence_penalty",
|
|
1438
|
+
"seed",
|
|
1439
|
+
"stop",
|
|
1440
|
+
"temperature",
|
|
1441
|
+
"top_p",
|
|
1442
|
+
"n",
|
|
1443
|
+
"user",
|
|
1444
|
+
"name",
|
|
1445
|
+
"fallbacks",
|
|
1446
|
+
"retry",
|
|
1447
|
+
"cache",
|
|
1448
|
+
"load_balancer",
|
|
1449
|
+
"timeout",
|
|
1450
|
+
"orq",
|
|
1451
|
+
"stream",
|
|
1452
|
+
]
|
|
1453
|
+
)
|
|
1454
|
+
nullable_fields = set(
|
|
1455
|
+
[
|
|
1456
|
+
"echo",
|
|
1457
|
+
"frequency_penalty",
|
|
1458
|
+
"max_tokens",
|
|
1459
|
+
"presence_penalty",
|
|
1460
|
+
"seed",
|
|
1461
|
+
"stop",
|
|
1462
|
+
"temperature",
|
|
1463
|
+
"top_p",
|
|
1464
|
+
"n",
|
|
1465
|
+
]
|
|
1466
|
+
)
|
|
1467
|
+
serialized = handler(self)
|
|
1468
|
+
m = {}
|
|
1469
|
+
|
|
1470
|
+
for n, f in type(self).model_fields.items():
|
|
1471
|
+
k = f.alias or n
|
|
1472
|
+
val = serialized.get(k)
|
|
1473
|
+
is_nullable_and_explicitly_set = (
|
|
1474
|
+
k in nullable_fields
|
|
1475
|
+
and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
|
|
1476
|
+
)
|
|
1477
|
+
|
|
1478
|
+
if val != UNSET_SENTINEL:
|
|
1479
|
+
if (
|
|
1480
|
+
val is not None
|
|
1481
|
+
or k not in optional_fields
|
|
1482
|
+
or is_nullable_and_explicitly_set
|
|
1483
|
+
):
|
|
1484
|
+
m[k] = val
|
|
1485
|
+
|
|
1486
|
+
return m
|
|
1487
|
+
|
|
1488
|
+
|
|
1489
|
+
CreateCompletionRouterCompletionsFinishReason = Literal[
|
|
1490
|
+
"stop",
|
|
1491
|
+
"length",
|
|
1492
|
+
"content_filter",
|
|
1493
|
+
"tool_calls",
|
|
1494
|
+
]
|
|
1495
|
+
r"""The reason the model stopped generating tokens."""
|
|
1496
|
+
|
|
1497
|
+
|
|
1498
|
+
class CreateCompletionRouterCompletionsChoicesTypedDict(TypedDict):
|
|
1499
|
+
finish_reason: CreateCompletionRouterCompletionsFinishReason
|
|
1500
|
+
r"""The reason the model stopped generating tokens."""
|
|
1501
|
+
index: float
|
|
1502
|
+
r"""The index of the choice in the list of choices."""
|
|
1503
|
+
text: str
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
class CreateCompletionRouterCompletionsChoices(BaseModel):
|
|
1507
|
+
finish_reason: CreateCompletionRouterCompletionsFinishReason
|
|
1508
|
+
r"""The reason the model stopped generating tokens."""
|
|
1509
|
+
|
|
1510
|
+
index: float
|
|
1511
|
+
r"""The index of the choice in the list of choices."""
|
|
1512
|
+
|
|
1513
|
+
text: str
|
|
1514
|
+
|
|
1515
|
+
|
|
1516
|
+
CreateCompletionCreatedTypedDict = TypeAliasType(
|
|
1517
|
+
"CreateCompletionCreatedTypedDict", Union[str, float]
|
|
1518
|
+
)
|
|
1519
|
+
r"""The Unix timestamp (in seconds) of when the chat completion was created."""
|
|
1520
|
+
|
|
1521
|
+
|
|
1522
|
+
CreateCompletionCreated = TypeAliasType("CreateCompletionCreated", Union[str, float])
|
|
1523
|
+
r"""The Unix timestamp (in seconds) of when the chat completion was created."""
|
|
1524
|
+
|
|
1525
|
+
|
|
1526
|
+
class CreateCompletionRouterCompletionsPromptTokensDetailsTypedDict(TypedDict):
|
|
1527
|
+
cached_tokens: NotRequired[Nullable[int]]
|
|
1528
|
+
cache_creation_tokens: NotRequired[Nullable[int]]
|
|
1529
|
+
audio_tokens: NotRequired[Nullable[int]]
|
|
1530
|
+
r"""The number of audio input tokens consumed by the request."""
|
|
1531
|
+
|
|
1532
|
+
|
|
1533
|
+
class CreateCompletionRouterCompletionsPromptTokensDetails(BaseModel):
|
|
1534
|
+
cached_tokens: OptionalNullable[int] = UNSET
|
|
1535
|
+
|
|
1536
|
+
cache_creation_tokens: OptionalNullable[int] = UNSET
|
|
1537
|
+
|
|
1538
|
+
audio_tokens: OptionalNullable[int] = UNSET
|
|
1539
|
+
r"""The number of audio input tokens consumed by the request."""
|
|
1540
|
+
|
|
1541
|
+
@model_serializer(mode="wrap")
|
|
1542
|
+
def serialize_model(self, handler):
|
|
1543
|
+
optional_fields = set(
|
|
1544
|
+
["cached_tokens", "cache_creation_tokens", "audio_tokens"]
|
|
1545
|
+
)
|
|
1546
|
+
nullable_fields = set(
|
|
1547
|
+
["cached_tokens", "cache_creation_tokens", "audio_tokens"]
|
|
1548
|
+
)
|
|
1549
|
+
serialized = handler(self)
|
|
1550
|
+
m = {}
|
|
1551
|
+
|
|
1552
|
+
for n, f in type(self).model_fields.items():
|
|
1553
|
+
k = f.alias or n
|
|
1554
|
+
val = serialized.get(k)
|
|
1555
|
+
is_nullable_and_explicitly_set = (
|
|
1556
|
+
k in nullable_fields
|
|
1557
|
+
and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
|
|
1558
|
+
)
|
|
1559
|
+
|
|
1560
|
+
if val != UNSET_SENTINEL:
|
|
1561
|
+
if (
|
|
1562
|
+
val is not None
|
|
1563
|
+
or k not in optional_fields
|
|
1564
|
+
or is_nullable_and_explicitly_set
|
|
1565
|
+
):
|
|
1566
|
+
m[k] = val
|
|
1567
|
+
|
|
1568
|
+
return m
|
|
1569
|
+
|
|
1570
|
+
|
|
1571
|
+
class CreateCompletionRouterCompletionsCompletionTokensDetailsTypedDict(TypedDict):
|
|
1572
|
+
reasoning_tokens: NotRequired[Nullable[float]]
|
|
1573
|
+
accepted_prediction_tokens: NotRequired[Nullable[float]]
|
|
1574
|
+
rejected_prediction_tokens: NotRequired[Nullable[float]]
|
|
1575
|
+
audio_tokens: NotRequired[Nullable[int]]
|
|
1576
|
+
r"""The number of audio output tokens produced by the response."""
|
|
1577
|
+
|
|
1578
|
+
|
|
1579
|
+
class CreateCompletionRouterCompletionsCompletionTokensDetails(BaseModel):
|
|
1580
|
+
reasoning_tokens: OptionalNullable[float] = UNSET
|
|
1581
|
+
|
|
1582
|
+
accepted_prediction_tokens: OptionalNullable[float] = UNSET
|
|
1583
|
+
|
|
1584
|
+
rejected_prediction_tokens: OptionalNullable[float] = UNSET
|
|
1585
|
+
|
|
1586
|
+
audio_tokens: OptionalNullable[int] = UNSET
|
|
1587
|
+
r"""The number of audio output tokens produced by the response."""
|
|
1588
|
+
|
|
1589
|
+
@model_serializer(mode="wrap")
|
|
1590
|
+
def serialize_model(self, handler):
|
|
1591
|
+
optional_fields = set(
|
|
1592
|
+
[
|
|
1593
|
+
"reasoning_tokens",
|
|
1594
|
+
"accepted_prediction_tokens",
|
|
1595
|
+
"rejected_prediction_tokens",
|
|
1596
|
+
"audio_tokens",
|
|
1597
|
+
]
|
|
1598
|
+
)
|
|
1599
|
+
nullable_fields = set(
|
|
1600
|
+
[
|
|
1601
|
+
"reasoning_tokens",
|
|
1602
|
+
"accepted_prediction_tokens",
|
|
1603
|
+
"rejected_prediction_tokens",
|
|
1604
|
+
"audio_tokens",
|
|
1605
|
+
]
|
|
1606
|
+
)
|
|
1607
|
+
serialized = handler(self)
|
|
1608
|
+
m = {}
|
|
1609
|
+
|
|
1610
|
+
for n, f in type(self).model_fields.items():
|
|
1611
|
+
k = f.alias or n
|
|
1612
|
+
val = serialized.get(k)
|
|
1613
|
+
is_nullable_and_explicitly_set = (
|
|
1614
|
+
k in nullable_fields
|
|
1615
|
+
and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
|
|
1616
|
+
)
|
|
1617
|
+
|
|
1618
|
+
if val != UNSET_SENTINEL:
|
|
1619
|
+
if (
|
|
1620
|
+
val is not None
|
|
1621
|
+
or k not in optional_fields
|
|
1622
|
+
or is_nullable_and_explicitly_set
|
|
1623
|
+
):
|
|
1624
|
+
m[k] = val
|
|
1625
|
+
|
|
1626
|
+
return m
|
|
1627
|
+
|
|
1628
|
+
|
|
1629
|
+
class CreateCompletionRouterCompletionsUsageTypedDict(TypedDict):
|
|
1630
|
+
r"""Usage statistics for the completion request."""
|
|
1631
|
+
|
|
1632
|
+
completion_tokens: NotRequired[float]
|
|
1633
|
+
r"""Number of tokens in the generated completion."""
|
|
1634
|
+
prompt_tokens: NotRequired[float]
|
|
1635
|
+
r"""Number of tokens in the prompt."""
|
|
1636
|
+
total_tokens: NotRequired[float]
|
|
1637
|
+
r"""Total number of tokens used in the request (prompt + completion)."""
|
|
1638
|
+
prompt_tokens_details: NotRequired[
|
|
1639
|
+
Nullable[CreateCompletionRouterCompletionsPromptTokensDetailsTypedDict]
|
|
1640
|
+
]
|
|
1641
|
+
completion_tokens_details: NotRequired[
|
|
1642
|
+
Nullable[CreateCompletionRouterCompletionsCompletionTokensDetailsTypedDict]
|
|
1643
|
+
]
|
|
1644
|
+
|
|
1645
|
+
|
|
1646
|
+
class CreateCompletionRouterCompletionsUsage(BaseModel):
|
|
1647
|
+
r"""Usage statistics for the completion request."""
|
|
1648
|
+
|
|
1649
|
+
completion_tokens: Optional[float] = None
|
|
1650
|
+
r"""Number of tokens in the generated completion."""
|
|
1651
|
+
|
|
1652
|
+
prompt_tokens: Optional[float] = None
|
|
1653
|
+
r"""Number of tokens in the prompt."""
|
|
1654
|
+
|
|
1655
|
+
total_tokens: Optional[float] = None
|
|
1656
|
+
r"""Total number of tokens used in the request (prompt + completion)."""
|
|
1657
|
+
|
|
1658
|
+
prompt_tokens_details: OptionalNullable[
|
|
1659
|
+
CreateCompletionRouterCompletionsPromptTokensDetails
|
|
1660
|
+
] = UNSET
|
|
1661
|
+
|
|
1662
|
+
completion_tokens_details: OptionalNullable[
|
|
1663
|
+
CreateCompletionRouterCompletionsCompletionTokensDetails
|
|
1664
|
+
] = UNSET
|
|
1665
|
+
|
|
1666
|
+
@model_serializer(mode="wrap")
|
|
1667
|
+
def serialize_model(self, handler):
|
|
1668
|
+
optional_fields = set(
|
|
1669
|
+
[
|
|
1670
|
+
"completion_tokens",
|
|
1671
|
+
"prompt_tokens",
|
|
1672
|
+
"total_tokens",
|
|
1673
|
+
"prompt_tokens_details",
|
|
1674
|
+
"completion_tokens_details",
|
|
1675
|
+
]
|
|
1676
|
+
)
|
|
1677
|
+
nullable_fields = set(["prompt_tokens_details", "completion_tokens_details"])
|
|
1678
|
+
serialized = handler(self)
|
|
1679
|
+
m = {}
|
|
1680
|
+
|
|
1681
|
+
for n, f in type(self).model_fields.items():
|
|
1682
|
+
k = f.alias or n
|
|
1683
|
+
val = serialized.get(k)
|
|
1684
|
+
is_nullable_and_explicitly_set = (
|
|
1685
|
+
k in nullable_fields
|
|
1686
|
+
and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
|
|
1687
|
+
)
|
|
1688
|
+
|
|
1689
|
+
if val != UNSET_SENTINEL:
|
|
1690
|
+
if (
|
|
1691
|
+
val is not None
|
|
1692
|
+
or k not in optional_fields
|
|
1693
|
+
or is_nullable_and_explicitly_set
|
|
1694
|
+
):
|
|
1695
|
+
m[k] = val
|
|
1696
|
+
|
|
1697
|
+
return m
|
|
1698
|
+
|
|
1699
|
+
|
|
1700
|
+
class CreateCompletionDataTypedDict(TypedDict):
|
|
1701
|
+
id: str
|
|
1702
|
+
r"""A unique identifier for the completion."""
|
|
1703
|
+
choices: List[CreateCompletionRouterCompletionsChoicesTypedDict]
|
|
1704
|
+
r"""The list of completion choices the model generated for the input prompt."""
|
|
1705
|
+
model: str
|
|
1706
|
+
r"""The model used for the chat completion."""
|
|
1707
|
+
object: str
|
|
1708
|
+
r"""The object type"""
|
|
1709
|
+
created: NotRequired[CreateCompletionCreatedTypedDict]
|
|
1710
|
+
r"""The Unix timestamp (in seconds) of when the chat completion was created."""
|
|
1711
|
+
system_fingerprint: NotRequired[str]
|
|
1712
|
+
r"""This fingerprint represents the backend configuration that the model runs with."""
|
|
1713
|
+
usage: NotRequired[CreateCompletionRouterCompletionsUsageTypedDict]
|
|
1714
|
+
r"""Usage statistics for the completion request."""
|
|
1715
|
+
|
|
1716
|
+
|
|
1717
|
+
class CreateCompletionData(BaseModel):
|
|
1718
|
+
id: str
|
|
1719
|
+
r"""A unique identifier for the completion."""
|
|
1720
|
+
|
|
1721
|
+
choices: List[CreateCompletionRouterCompletionsChoices]
|
|
1722
|
+
r"""The list of completion choices the model generated for the input prompt."""
|
|
1723
|
+
|
|
1724
|
+
model: str
|
|
1725
|
+
r"""The model used for the chat completion."""
|
|
1726
|
+
|
|
1727
|
+
object: str
|
|
1728
|
+
r"""The object type"""
|
|
1729
|
+
|
|
1730
|
+
created: Optional[CreateCompletionCreated] = None
|
|
1731
|
+
r"""The Unix timestamp (in seconds) of when the chat completion was created."""
|
|
1732
|
+
|
|
1733
|
+
system_fingerprint: Optional[str] = None
|
|
1734
|
+
r"""This fingerprint represents the backend configuration that the model runs with."""
|
|
1735
|
+
|
|
1736
|
+
usage: Optional[CreateCompletionRouterCompletionsUsage] = None
|
|
1737
|
+
r"""Usage statistics for the completion request."""
|
|
1738
|
+
|
|
1739
|
+
@model_serializer(mode="wrap")
|
|
1740
|
+
def serialize_model(self, handler):
|
|
1741
|
+
optional_fields = set(["created", "system_fingerprint", "usage"])
|
|
1742
|
+
serialized = handler(self)
|
|
1743
|
+
m = {}
|
|
1744
|
+
|
|
1745
|
+
for n, f in type(self).model_fields.items():
|
|
1746
|
+
k = f.alias or n
|
|
1747
|
+
val = serialized.get(k)
|
|
1748
|
+
|
|
1749
|
+
if val != UNSET_SENTINEL:
|
|
1750
|
+
if val is not None or k not in optional_fields:
|
|
1751
|
+
m[k] = val
|
|
1752
|
+
|
|
1753
|
+
return m
|
|
1754
|
+
|
|
1755
|
+
|
|
1756
|
+
class CreateCompletionRouterCompletionsResponseBodyTypedDict(TypedDict):
|
|
1757
|
+
r"""Represents a completion response from the API."""
|
|
1758
|
+
|
|
1759
|
+
data: NotRequired[CreateCompletionDataTypedDict]
|
|
1760
|
+
|
|
1761
|
+
|
|
1762
|
+
class CreateCompletionRouterCompletionsResponseBody(BaseModel):
|
|
1763
|
+
r"""Represents a completion response from the API."""
|
|
1764
|
+
|
|
1765
|
+
data: Optional[CreateCompletionData] = None
|
|
1766
|
+
|
|
1767
|
+
@model_serializer(mode="wrap")
|
|
1768
|
+
def serialize_model(self, handler):
|
|
1769
|
+
optional_fields = set(["data"])
|
|
1770
|
+
serialized = handler(self)
|
|
1771
|
+
m = {}
|
|
1772
|
+
|
|
1773
|
+
for n, f in type(self).model_fields.items():
|
|
1774
|
+
k = f.alias or n
|
|
1775
|
+
val = serialized.get(k)
|
|
1776
|
+
|
|
1777
|
+
if val != UNSET_SENTINEL:
|
|
1778
|
+
if val is not None or k not in optional_fields:
|
|
1779
|
+
m[k] = val
|
|
1780
|
+
|
|
1781
|
+
return m
|
|
1782
|
+
|
|
1783
|
+
|
|
1784
|
+
CreateCompletionFinishReason = Literal[
|
|
1785
|
+
"stop",
|
|
1786
|
+
"length",
|
|
1787
|
+
"content_filter",
|
|
1788
|
+
"tool_calls",
|
|
1789
|
+
]
|
|
1790
|
+
r"""The reason the model stopped generating tokens."""
|
|
1791
|
+
|
|
1792
|
+
|
|
1793
|
+
class CreateCompletionChoicesTypedDict(TypedDict):
|
|
1794
|
+
finish_reason: CreateCompletionFinishReason
|
|
1795
|
+
r"""The reason the model stopped generating tokens."""
|
|
1796
|
+
index: float
|
|
1797
|
+
r"""The index of the choice in the list of choices."""
|
|
1798
|
+
text: str
|
|
1799
|
+
|
|
1800
|
+
|
|
1801
|
+
class CreateCompletionChoices(BaseModel):
|
|
1802
|
+
finish_reason: CreateCompletionFinishReason
|
|
1803
|
+
r"""The reason the model stopped generating tokens."""
|
|
1804
|
+
|
|
1805
|
+
index: float
|
|
1806
|
+
r"""The index of the choice in the list of choices."""
|
|
1807
|
+
|
|
1808
|
+
text: str
|
|
1809
|
+
|
|
1810
|
+
|
|
1811
|
+
CreatedTypedDict = TypeAliasType("CreatedTypedDict", Union[str, float])
|
|
1812
|
+
r"""The Unix timestamp (in seconds) of when the chat completion was created."""
|
|
1813
|
+
|
|
1814
|
+
|
|
1815
|
+
Created = TypeAliasType("Created", Union[str, float])
|
|
1816
|
+
r"""The Unix timestamp (in seconds) of when the chat completion was created."""
|
|
1817
|
+
|
|
1818
|
+
|
|
1819
|
+
class CreateCompletionPromptTokensDetailsTypedDict(TypedDict):
|
|
1820
|
+
cached_tokens: NotRequired[Nullable[int]]
|
|
1821
|
+
cache_creation_tokens: NotRequired[Nullable[int]]
|
|
1822
|
+
audio_tokens: NotRequired[Nullable[int]]
|
|
1823
|
+
r"""The number of audio input tokens consumed by the request."""
|
|
1824
|
+
|
|
1825
|
+
|
|
1826
|
+
class CreateCompletionPromptTokensDetails(BaseModel):
|
|
1827
|
+
cached_tokens: OptionalNullable[int] = UNSET
|
|
1828
|
+
|
|
1829
|
+
cache_creation_tokens: OptionalNullable[int] = UNSET
|
|
1830
|
+
|
|
1831
|
+
audio_tokens: OptionalNullable[int] = UNSET
|
|
1832
|
+
r"""The number of audio input tokens consumed by the request."""
|
|
1833
|
+
|
|
1834
|
+
@model_serializer(mode="wrap")
|
|
1835
|
+
def serialize_model(self, handler):
|
|
1836
|
+
optional_fields = set(
|
|
1837
|
+
["cached_tokens", "cache_creation_tokens", "audio_tokens"]
|
|
1838
|
+
)
|
|
1839
|
+
nullable_fields = set(
|
|
1840
|
+
["cached_tokens", "cache_creation_tokens", "audio_tokens"]
|
|
1841
|
+
)
|
|
1842
|
+
serialized = handler(self)
|
|
1843
|
+
m = {}
|
|
1844
|
+
|
|
1845
|
+
for n, f in type(self).model_fields.items():
|
|
1846
|
+
k = f.alias or n
|
|
1847
|
+
val = serialized.get(k)
|
|
1848
|
+
is_nullable_and_explicitly_set = (
|
|
1849
|
+
k in nullable_fields
|
|
1850
|
+
and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
|
|
1851
|
+
)
|
|
1852
|
+
|
|
1853
|
+
if val != UNSET_SENTINEL:
|
|
1854
|
+
if (
|
|
1855
|
+
val is not None
|
|
1856
|
+
or k not in optional_fields
|
|
1857
|
+
or is_nullable_and_explicitly_set
|
|
1858
|
+
):
|
|
1859
|
+
m[k] = val
|
|
1860
|
+
|
|
1861
|
+
return m
|
|
1862
|
+
|
|
1863
|
+
|
|
1864
|
+
class CreateCompletionCompletionTokensDetailsTypedDict(TypedDict):
|
|
1865
|
+
reasoning_tokens: NotRequired[Nullable[float]]
|
|
1866
|
+
accepted_prediction_tokens: NotRequired[Nullable[float]]
|
|
1867
|
+
rejected_prediction_tokens: NotRequired[Nullable[float]]
|
|
1868
|
+
audio_tokens: NotRequired[Nullable[int]]
|
|
1869
|
+
r"""The number of audio output tokens produced by the response."""
|
|
1870
|
+
|
|
1871
|
+
|
|
1872
|
+
class CreateCompletionCompletionTokensDetails(BaseModel):
|
|
1873
|
+
reasoning_tokens: OptionalNullable[float] = UNSET
|
|
1874
|
+
|
|
1875
|
+
accepted_prediction_tokens: OptionalNullable[float] = UNSET
|
|
1876
|
+
|
|
1877
|
+
rejected_prediction_tokens: OptionalNullable[float] = UNSET
|
|
1878
|
+
|
|
1879
|
+
audio_tokens: OptionalNullable[int] = UNSET
|
|
1880
|
+
r"""The number of audio output tokens produced by the response."""
|
|
1881
|
+
|
|
1882
|
+
@model_serializer(mode="wrap")
|
|
1883
|
+
def serialize_model(self, handler):
|
|
1884
|
+
optional_fields = set(
|
|
1885
|
+
[
|
|
1886
|
+
"reasoning_tokens",
|
|
1887
|
+
"accepted_prediction_tokens",
|
|
1888
|
+
"rejected_prediction_tokens",
|
|
1889
|
+
"audio_tokens",
|
|
1890
|
+
]
|
|
1891
|
+
)
|
|
1892
|
+
nullable_fields = set(
|
|
1893
|
+
[
|
|
1894
|
+
"reasoning_tokens",
|
|
1895
|
+
"accepted_prediction_tokens",
|
|
1896
|
+
"rejected_prediction_tokens",
|
|
1897
|
+
"audio_tokens",
|
|
1898
|
+
]
|
|
1899
|
+
)
|
|
1900
|
+
serialized = handler(self)
|
|
1901
|
+
m = {}
|
|
1902
|
+
|
|
1903
|
+
for n, f in type(self).model_fields.items():
|
|
1904
|
+
k = f.alias or n
|
|
1905
|
+
val = serialized.get(k)
|
|
1906
|
+
is_nullable_and_explicitly_set = (
|
|
1907
|
+
k in nullable_fields
|
|
1908
|
+
and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
|
|
1909
|
+
)
|
|
1910
|
+
|
|
1911
|
+
if val != UNSET_SENTINEL:
|
|
1912
|
+
if (
|
|
1913
|
+
val is not None
|
|
1914
|
+
or k not in optional_fields
|
|
1915
|
+
or is_nullable_and_explicitly_set
|
|
1916
|
+
):
|
|
1917
|
+
m[k] = val
|
|
1918
|
+
|
|
1919
|
+
return m
|
|
1920
|
+
|
|
1921
|
+
|
|
1922
|
+
class CreateCompletionUsageTypedDict(TypedDict):
|
|
1923
|
+
r"""Usage statistics for the completion request."""
|
|
1924
|
+
|
|
1925
|
+
completion_tokens: NotRequired[float]
|
|
1926
|
+
r"""Number of tokens in the generated completion."""
|
|
1927
|
+
prompt_tokens: NotRequired[float]
|
|
1928
|
+
r"""Number of tokens in the prompt."""
|
|
1929
|
+
total_tokens: NotRequired[float]
|
|
1930
|
+
r"""Total number of tokens used in the request (prompt + completion)."""
|
|
1931
|
+
prompt_tokens_details: NotRequired[
|
|
1932
|
+
Nullable[CreateCompletionPromptTokensDetailsTypedDict]
|
|
1933
|
+
]
|
|
1934
|
+
completion_tokens_details: NotRequired[
|
|
1935
|
+
Nullable[CreateCompletionCompletionTokensDetailsTypedDict]
|
|
1936
|
+
]
|
|
1937
|
+
|
|
1938
|
+
|
|
1939
|
+
class CreateCompletionUsage(BaseModel):
|
|
1940
|
+
r"""Usage statistics for the completion request."""
|
|
1941
|
+
|
|
1942
|
+
completion_tokens: Optional[float] = None
|
|
1943
|
+
r"""Number of tokens in the generated completion."""
|
|
1944
|
+
|
|
1945
|
+
prompt_tokens: Optional[float] = None
|
|
1946
|
+
r"""Number of tokens in the prompt."""
|
|
1947
|
+
|
|
1948
|
+
total_tokens: Optional[float] = None
|
|
1949
|
+
r"""Total number of tokens used in the request (prompt + completion)."""
|
|
1950
|
+
|
|
1951
|
+
prompt_tokens_details: OptionalNullable[CreateCompletionPromptTokensDetails] = UNSET
|
|
1952
|
+
|
|
1953
|
+
completion_tokens_details: OptionalNullable[
|
|
1954
|
+
CreateCompletionCompletionTokensDetails
|
|
1955
|
+
] = UNSET
|
|
1956
|
+
|
|
1957
|
+
@model_serializer(mode="wrap")
|
|
1958
|
+
def serialize_model(self, handler):
|
|
1959
|
+
optional_fields = set(
|
|
1960
|
+
[
|
|
1961
|
+
"completion_tokens",
|
|
1962
|
+
"prompt_tokens",
|
|
1963
|
+
"total_tokens",
|
|
1964
|
+
"prompt_tokens_details",
|
|
1965
|
+
"completion_tokens_details",
|
|
1966
|
+
]
|
|
1967
|
+
)
|
|
1968
|
+
nullable_fields = set(["prompt_tokens_details", "completion_tokens_details"])
|
|
1969
|
+
serialized = handler(self)
|
|
1970
|
+
m = {}
|
|
1971
|
+
|
|
1972
|
+
for n, f in type(self).model_fields.items():
|
|
1973
|
+
k = f.alias or n
|
|
1974
|
+
val = serialized.get(k)
|
|
1975
|
+
is_nullable_and_explicitly_set = (
|
|
1976
|
+
k in nullable_fields
|
|
1977
|
+
and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
|
|
1978
|
+
)
|
|
1979
|
+
|
|
1980
|
+
if val != UNSET_SENTINEL:
|
|
1981
|
+
if (
|
|
1982
|
+
val is not None
|
|
1983
|
+
or k not in optional_fields
|
|
1984
|
+
or is_nullable_and_explicitly_set
|
|
1985
|
+
):
|
|
1986
|
+
m[k] = val
|
|
1987
|
+
|
|
1988
|
+
return m
|
|
1989
|
+
|
|
1990
|
+
|
|
1991
|
+
class CreateCompletionResponseBodyTypedDict(TypedDict):
|
|
1992
|
+
r"""Represents a completion response from the API."""
|
|
1993
|
+
|
|
1994
|
+
id: str
|
|
1995
|
+
r"""A unique identifier for the completion."""
|
|
1996
|
+
choices: List[CreateCompletionChoicesTypedDict]
|
|
1997
|
+
r"""The list of completion choices the model generated for the input prompt."""
|
|
1998
|
+
model: str
|
|
1999
|
+
r"""The model used for the chat completion."""
|
|
2000
|
+
object: str
|
|
2001
|
+
r"""The object type"""
|
|
2002
|
+
created: NotRequired[CreatedTypedDict]
|
|
2003
|
+
r"""The Unix timestamp (in seconds) of when the chat completion was created."""
|
|
2004
|
+
system_fingerprint: NotRequired[str]
|
|
2005
|
+
r"""This fingerprint represents the backend configuration that the model runs with."""
|
|
2006
|
+
usage: NotRequired[CreateCompletionUsageTypedDict]
|
|
2007
|
+
r"""Usage statistics for the completion request."""
|
|
2008
|
+
|
|
2009
|
+
|
|
2010
|
+
class CreateCompletionResponseBody(BaseModel):
|
|
2011
|
+
r"""Represents a completion response from the API."""
|
|
2012
|
+
|
|
2013
|
+
id: str
|
|
2014
|
+
r"""A unique identifier for the completion."""
|
|
2015
|
+
|
|
2016
|
+
choices: List[CreateCompletionChoices]
|
|
2017
|
+
r"""The list of completion choices the model generated for the input prompt."""
|
|
2018
|
+
|
|
2019
|
+
model: str
|
|
2020
|
+
r"""The model used for the chat completion."""
|
|
2021
|
+
|
|
2022
|
+
object: str
|
|
2023
|
+
r"""The object type"""
|
|
2024
|
+
|
|
2025
|
+
created: Optional[Created] = None
|
|
2026
|
+
r"""The Unix timestamp (in seconds) of when the chat completion was created."""
|
|
2027
|
+
|
|
2028
|
+
system_fingerprint: Optional[str] = None
|
|
2029
|
+
r"""This fingerprint represents the backend configuration that the model runs with."""
|
|
2030
|
+
|
|
2031
|
+
usage: Optional[CreateCompletionUsage] = None
|
|
2032
|
+
r"""Usage statistics for the completion request."""
|
|
2033
|
+
|
|
2034
|
+
@model_serializer(mode="wrap")
|
|
2035
|
+
def serialize_model(self, handler):
|
|
2036
|
+
optional_fields = set(["created", "system_fingerprint", "usage"])
|
|
2037
|
+
serialized = handler(self)
|
|
2038
|
+
m = {}
|
|
2039
|
+
|
|
2040
|
+
for n, f in type(self).model_fields.items():
|
|
2041
|
+
k = f.alias or n
|
|
2042
|
+
val = serialized.get(k)
|
|
2043
|
+
|
|
2044
|
+
if val != UNSET_SENTINEL:
|
|
2045
|
+
if val is not None or k not in optional_fields:
|
|
2046
|
+
m[k] = val
|
|
2047
|
+
|
|
2048
|
+
return m
|
|
2049
|
+
|
|
2050
|
+
|
|
2051
|
+
CreateCompletionResponseTypedDict = TypeAliasType(
|
|
2052
|
+
"CreateCompletionResponseTypedDict",
|
|
2053
|
+
Union[
|
|
2054
|
+
CreateCompletionResponseBodyTypedDict,
|
|
2055
|
+
Union[
|
|
2056
|
+
eventstreaming.EventStream[
|
|
2057
|
+
CreateCompletionRouterCompletionsResponseBodyTypedDict
|
|
2058
|
+
],
|
|
2059
|
+
eventstreaming.EventStreamAsync[
|
|
2060
|
+
CreateCompletionRouterCompletionsResponseBodyTypedDict
|
|
2061
|
+
],
|
|
2062
|
+
],
|
|
2063
|
+
],
|
|
2064
|
+
)
|
|
2065
|
+
|
|
2066
|
+
|
|
2067
|
+
CreateCompletionResponse = TypeAliasType(
|
|
2068
|
+
"CreateCompletionResponse",
|
|
2069
|
+
Union[
|
|
2070
|
+
CreateCompletionResponseBody,
|
|
2071
|
+
Union[
|
|
2072
|
+
eventstreaming.EventStream[CreateCompletionRouterCompletionsResponseBody],
|
|
2073
|
+
eventstreaming.EventStreamAsync[
|
|
2074
|
+
CreateCompletionRouterCompletionsResponseBody
|
|
2075
|
+
],
|
|
2076
|
+
],
|
|
2077
|
+
],
|
|
2078
|
+
)
|