orq-ai-sdk 4.2.0rc48__py3-none-any.whl → 4.2.12__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.
Files changed (103) hide show
  1. orq_ai_sdk/_hooks/globalhook.py +0 -1
  2. orq_ai_sdk/_version.py +3 -3
  3. orq_ai_sdk/audio.py +30 -0
  4. orq_ai_sdk/chat.py +22 -0
  5. orq_ai_sdk/completions.py +438 -0
  6. orq_ai_sdk/contacts.py +43 -886
  7. orq_ai_sdk/deployments.py +61 -0
  8. orq_ai_sdk/edits.py +364 -0
  9. orq_ai_sdk/embeddings.py +344 -0
  10. orq_ai_sdk/generations.py +370 -0
  11. orq_ai_sdk/images.py +28 -0
  12. orq_ai_sdk/models/__init__.py +3839 -424
  13. orq_ai_sdk/models/conversationresponse.py +1 -1
  14. orq_ai_sdk/models/conversationwithmessagesresponse.py +1 -1
  15. orq_ai_sdk/models/createagentrequestop.py +768 -12
  16. orq_ai_sdk/models/createagentresponse.py +68 -2
  17. orq_ai_sdk/models/createchatcompletionop.py +538 -313
  18. orq_ai_sdk/models/createcompletionop.py +2078 -0
  19. orq_ai_sdk/models/createcontactop.py +5 -10
  20. orq_ai_sdk/models/createconversationop.py +1 -1
  21. orq_ai_sdk/models/createconversationresponseop.py +2 -2
  22. orq_ai_sdk/models/createdatasetitemop.py +4 -4
  23. orq_ai_sdk/models/createdatasetop.py +1 -1
  24. orq_ai_sdk/models/createdatasourceop.py +1 -1
  25. orq_ai_sdk/models/createembeddingop.py +579 -0
  26. orq_ai_sdk/models/createevalop.py +14 -14
  27. orq_ai_sdk/models/createidentityop.py +1 -1
  28. orq_ai_sdk/models/createimageeditop.py +715 -0
  29. orq_ai_sdk/models/createimageop.py +228 -82
  30. orq_ai_sdk/models/createimagevariationop.py +706 -0
  31. orq_ai_sdk/models/creatememoryop.py +4 -2
  32. orq_ai_sdk/models/createmoderationop.py +521 -0
  33. orq_ai_sdk/models/createpromptop.py +375 -6
  34. orq_ai_sdk/models/creatererankop.py +608 -0
  35. orq_ai_sdk/models/createresponseop.py +2567 -0
  36. orq_ai_sdk/models/createspeechop.py +466 -0
  37. orq_ai_sdk/models/createtoolop.py +6 -6
  38. orq_ai_sdk/models/createtranscriptionop.py +732 -0
  39. orq_ai_sdk/models/createtranslationop.py +702 -0
  40. orq_ai_sdk/models/deploymentgetconfigop.py +17 -7
  41. orq_ai_sdk/models/deploymentsop.py +1 -0
  42. orq_ai_sdk/models/deploymentstreamop.py +7 -0
  43. orq_ai_sdk/models/filegetop.py +1 -1
  44. orq_ai_sdk/models/filelistop.py +1 -1
  45. orq_ai_sdk/models/fileuploadop.py +1 -1
  46. orq_ai_sdk/models/generateconversationnameop.py +1 -1
  47. orq_ai_sdk/models/getallmemoriesop.py +4 -2
  48. orq_ai_sdk/models/getallpromptsop.py +188 -3
  49. orq_ai_sdk/models/getalltoolsop.py +6 -6
  50. orq_ai_sdk/models/getevalsop.py +17 -17
  51. orq_ai_sdk/models/getonepromptop.py +188 -3
  52. orq_ai_sdk/models/getpromptversionop.py +188 -3
  53. orq_ai_sdk/models/invokedeploymentrequest.py +11 -4
  54. orq_ai_sdk/models/listagentsop.py +372 -0
  55. orq_ai_sdk/models/listdatasetdatapointsop.py +4 -4
  56. orq_ai_sdk/models/listdatasetsop.py +1 -1
  57. orq_ai_sdk/models/listdatasourcesop.py +1 -1
  58. orq_ai_sdk/models/listidentitiesop.py +1 -1
  59. orq_ai_sdk/models/listmodelsop.py +1 -0
  60. orq_ai_sdk/models/listpromptversionsop.py +188 -3
  61. orq_ai_sdk/models/partdoneevent.py +1 -1
  62. orq_ai_sdk/models/post_v2_router_ocrop.py +408 -0
  63. orq_ai_sdk/models/publiccontact.py +9 -3
  64. orq_ai_sdk/models/publicidentity.py +62 -0
  65. orq_ai_sdk/models/reasoningpart.py +1 -1
  66. orq_ai_sdk/models/responsedoneevent.py +14 -11
  67. orq_ai_sdk/models/retrieveagentrequestop.py +382 -0
  68. orq_ai_sdk/models/retrievedatapointop.py +4 -4
  69. orq_ai_sdk/models/retrievedatasetop.py +1 -1
  70. orq_ai_sdk/models/retrievedatasourceop.py +1 -1
  71. orq_ai_sdk/models/retrieveidentityop.py +1 -1
  72. orq_ai_sdk/models/retrievememoryop.py +4 -2
  73. orq_ai_sdk/models/retrievetoolop.py +6 -6
  74. orq_ai_sdk/models/runagentop.py +379 -9
  75. orq_ai_sdk/models/streamrunagentop.py +385 -9
  76. orq_ai_sdk/models/updateagentop.py +770 -12
  77. orq_ai_sdk/models/updateconversationop.py +1 -1
  78. orq_ai_sdk/models/updatedatapointop.py +4 -4
  79. orq_ai_sdk/models/updatedatasetop.py +1 -1
  80. orq_ai_sdk/models/updatedatasourceop.py +1 -1
  81. orq_ai_sdk/models/updateevalop.py +14 -14
  82. orq_ai_sdk/models/updateidentityop.py +1 -1
  83. orq_ai_sdk/models/updatememoryop.py +4 -2
  84. orq_ai_sdk/models/updatepromptop.py +375 -6
  85. orq_ai_sdk/models/updatetoolop.py +7 -7
  86. orq_ai_sdk/moderations.py +218 -0
  87. orq_ai_sdk/orq_completions.py +666 -0
  88. orq_ai_sdk/orq_responses.py +398 -0
  89. orq_ai_sdk/rerank.py +330 -0
  90. orq_ai_sdk/router.py +89 -641
  91. orq_ai_sdk/speech.py +333 -0
  92. orq_ai_sdk/transcriptions.py +416 -0
  93. orq_ai_sdk/translations.py +384 -0
  94. orq_ai_sdk/variations.py +364 -0
  95. orq_ai_sdk-4.2.12.dist-info/METADATA +888 -0
  96. {orq_ai_sdk-4.2.0rc48.dist-info → orq_ai_sdk-4.2.12.dist-info}/RECORD +98 -75
  97. {orq_ai_sdk-4.2.0rc48.dist-info → orq_ai_sdk-4.2.12.dist-info}/WHEEL +1 -1
  98. orq_ai_sdk/models/deletecontactop.py +0 -44
  99. orq_ai_sdk/models/listcontactsop.py +0 -265
  100. orq_ai_sdk/models/retrievecontactop.py +0 -142
  101. orq_ai_sdk/models/updatecontactop.py +0 -233
  102. orq_ai_sdk-4.2.0rc48.dist-info/METADATA +0 -788
  103. {orq_ai_sdk-4.2.0rc48.dist-info → orq_ai_sdk-4.2.12.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,608 @@
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
+ import pydantic
14
+ from pydantic import model_serializer
15
+ from typing import List, Literal, Optional
16
+ from typing_extensions import Annotated, NotRequired, TypedDict
17
+
18
+
19
+ class CreateRerankFallbacksTypedDict(TypedDict):
20
+ model: str
21
+ r"""Fallback model identifier"""
22
+
23
+
24
+ class CreateRerankFallbacks(BaseModel):
25
+ model: str
26
+ r"""Fallback model identifier"""
27
+
28
+
29
+ class CreateRerankRetryTypedDict(TypedDict):
30
+ r"""Retry configuration for the request"""
31
+
32
+ count: NotRequired[float]
33
+ r"""Number of retry attempts (1-5)"""
34
+ on_codes: NotRequired[List[float]]
35
+ r"""HTTP status codes that trigger retry logic"""
36
+
37
+
38
+ class CreateRerankRetry(BaseModel):
39
+ r"""Retry configuration for the request"""
40
+
41
+ count: Optional[float] = 3
42
+ r"""Number of retry attempts (1-5)"""
43
+
44
+ on_codes: Optional[List[float]] = None
45
+ r"""HTTP status codes that trigger retry logic"""
46
+
47
+ @model_serializer(mode="wrap")
48
+ def serialize_model(self, handler):
49
+ optional_fields = set(["count", "on_codes"])
50
+ serialized = handler(self)
51
+ m = {}
52
+
53
+ for n, f in type(self).model_fields.items():
54
+ k = f.alias or n
55
+ val = serialized.get(k)
56
+
57
+ if val != UNSET_SENTINEL:
58
+ if val is not None or k not in optional_fields:
59
+ m[k] = val
60
+
61
+ return m
62
+
63
+
64
+ CreateRerankType = Literal["exact_match",]
65
+
66
+
67
+ class CreateRerankCacheTypedDict(TypedDict):
68
+ r"""Cache configuration for the request."""
69
+
70
+ type: CreateRerankType
71
+ ttl: NotRequired[float]
72
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
73
+
74
+
75
+ class CreateRerankCache(BaseModel):
76
+ r"""Cache configuration for the request."""
77
+
78
+ type: CreateRerankType
79
+
80
+ ttl: Optional[float] = 1800
81
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
82
+
83
+ @model_serializer(mode="wrap")
84
+ def serialize_model(self, handler):
85
+ optional_fields = set(["ttl"])
86
+ serialized = handler(self)
87
+ m = {}
88
+
89
+ for n, f in type(self).model_fields.items():
90
+ k = f.alias or n
91
+ val = serialized.get(k)
92
+
93
+ if val != UNSET_SENTINEL:
94
+ if val is not None or k not in optional_fields:
95
+ m[k] = val
96
+
97
+ return m
98
+
99
+
100
+ CreateRerankLoadBalancerType = Literal["weight_based",]
101
+
102
+
103
+ class CreateRerankLoadBalancerModelsTypedDict(TypedDict):
104
+ model: str
105
+ r"""Model identifier for load balancing"""
106
+ weight: NotRequired[float]
107
+ r"""Weight assigned to this model for load balancing"""
108
+
109
+
110
+ class CreateRerankLoadBalancerModels(BaseModel):
111
+ model: str
112
+ r"""Model identifier for load balancing"""
113
+
114
+ weight: Optional[float] = 0.5
115
+ r"""Weight assigned to this model for load balancing"""
116
+
117
+ @model_serializer(mode="wrap")
118
+ def serialize_model(self, handler):
119
+ optional_fields = set(["weight"])
120
+ serialized = handler(self)
121
+ m = {}
122
+
123
+ for n, f in type(self).model_fields.items():
124
+ k = f.alias or n
125
+ val = serialized.get(k)
126
+
127
+ if val != UNSET_SENTINEL:
128
+ if val is not None or k not in optional_fields:
129
+ m[k] = val
130
+
131
+ return m
132
+
133
+
134
+ class CreateRerankLoadBalancer1TypedDict(TypedDict):
135
+ type: CreateRerankLoadBalancerType
136
+ models: List[CreateRerankLoadBalancerModelsTypedDict]
137
+
138
+
139
+ class CreateRerankLoadBalancer1(BaseModel):
140
+ type: CreateRerankLoadBalancerType
141
+
142
+ models: List[CreateRerankLoadBalancerModels]
143
+
144
+
145
+ CreateRerankLoadBalancerTypedDict = CreateRerankLoadBalancer1TypedDict
146
+ r"""Load balancer configuration for the request."""
147
+
148
+
149
+ CreateRerankLoadBalancer = CreateRerankLoadBalancer1
150
+ r"""Load balancer configuration for the request."""
151
+
152
+
153
+ class CreateRerankTimeoutTypedDict(TypedDict):
154
+ 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."""
155
+
156
+ call_timeout: float
157
+ r"""Timeout value in milliseconds"""
158
+
159
+
160
+ class CreateRerankTimeout(BaseModel):
161
+ 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."""
162
+
163
+ call_timeout: float
164
+ r"""Timeout value in milliseconds"""
165
+
166
+
167
+ class CreateRerankRouterRerankFallbacksTypedDict(TypedDict):
168
+ model: str
169
+ r"""Fallback model identifier"""
170
+
171
+
172
+ class CreateRerankRouterRerankFallbacks(BaseModel):
173
+ model: str
174
+ r"""Fallback model identifier"""
175
+
176
+
177
+ CreateRerankRouterRerankType = Literal["exact_match",]
178
+
179
+
180
+ class CreateRerankRouterRerankCacheTypedDict(TypedDict):
181
+ r"""Cache configuration for the request."""
182
+
183
+ type: CreateRerankRouterRerankType
184
+ ttl: NotRequired[float]
185
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
186
+
187
+
188
+ class CreateRerankRouterRerankCache(BaseModel):
189
+ r"""Cache configuration for the request."""
190
+
191
+ type: CreateRerankRouterRerankType
192
+
193
+ ttl: Optional[float] = 1800
194
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
195
+
196
+ @model_serializer(mode="wrap")
197
+ def serialize_model(self, handler):
198
+ optional_fields = set(["ttl"])
199
+ serialized = handler(self)
200
+ m = {}
201
+
202
+ for n, f in type(self).model_fields.items():
203
+ k = f.alias or n
204
+ val = serialized.get(k)
205
+
206
+ if val != UNSET_SENTINEL:
207
+ if val is not None or k not in optional_fields:
208
+ m[k] = val
209
+
210
+ return m
211
+
212
+
213
+ class CreateRerankRouterRerankRetryTypedDict(TypedDict):
214
+ r"""Retry configuration for the request"""
215
+
216
+ count: NotRequired[float]
217
+ r"""Number of retry attempts (1-5)"""
218
+ on_codes: NotRequired[List[float]]
219
+ r"""HTTP status codes that trigger retry logic"""
220
+
221
+
222
+ class CreateRerankRouterRerankRetry(BaseModel):
223
+ r"""Retry configuration for the request"""
224
+
225
+ count: Optional[float] = 3
226
+ r"""Number of retry attempts (1-5)"""
227
+
228
+ on_codes: Optional[List[float]] = None
229
+ r"""HTTP status codes that trigger retry logic"""
230
+
231
+ @model_serializer(mode="wrap")
232
+ def serialize_model(self, handler):
233
+ optional_fields = set(["count", "on_codes"])
234
+ serialized = handler(self)
235
+ m = {}
236
+
237
+ for n, f in type(self).model_fields.items():
238
+ k = f.alias or n
239
+ val = serialized.get(k)
240
+
241
+ if val != UNSET_SENTINEL:
242
+ if val is not None or k not in optional_fields:
243
+ m[k] = val
244
+
245
+ return m
246
+
247
+
248
+ CreateRerankLoadBalancerRouterRerankType = Literal["weight_based",]
249
+
250
+
251
+ class CreateRerankLoadBalancerRouterRerankModelsTypedDict(TypedDict):
252
+ model: str
253
+ r"""Model identifier for load balancing"""
254
+ weight: NotRequired[float]
255
+ r"""Weight assigned to this model for load balancing"""
256
+
257
+
258
+ class CreateRerankLoadBalancerRouterRerankModels(BaseModel):
259
+ model: str
260
+ r"""Model identifier for load balancing"""
261
+
262
+ weight: Optional[float] = 0.5
263
+ r"""Weight assigned to this model for load balancing"""
264
+
265
+ @model_serializer(mode="wrap")
266
+ def serialize_model(self, handler):
267
+ optional_fields = set(["weight"])
268
+ serialized = handler(self)
269
+ m = {}
270
+
271
+ for n, f in type(self).model_fields.items():
272
+ k = f.alias or n
273
+ val = serialized.get(k)
274
+
275
+ if val != UNSET_SENTINEL:
276
+ if val is not None or k not in optional_fields:
277
+ m[k] = val
278
+
279
+ return m
280
+
281
+
282
+ class CreateRerankLoadBalancerRouterRerank1TypedDict(TypedDict):
283
+ type: CreateRerankLoadBalancerRouterRerankType
284
+ models: List[CreateRerankLoadBalancerRouterRerankModelsTypedDict]
285
+
286
+
287
+ class CreateRerankLoadBalancerRouterRerank1(BaseModel):
288
+ type: CreateRerankLoadBalancerRouterRerankType
289
+
290
+ models: List[CreateRerankLoadBalancerRouterRerankModels]
291
+
292
+
293
+ CreateRerankRouterRerankLoadBalancerTypedDict = (
294
+ CreateRerankLoadBalancerRouterRerank1TypedDict
295
+ )
296
+ r"""Array of models with weights for load balancing requests"""
297
+
298
+
299
+ CreateRerankRouterRerankLoadBalancer = CreateRerankLoadBalancerRouterRerank1
300
+ r"""Array of models with weights for load balancing requests"""
301
+
302
+
303
+ class CreateRerankRouterRerankTimeoutTypedDict(TypedDict):
304
+ 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."""
305
+
306
+ call_timeout: float
307
+ r"""Timeout value in milliseconds"""
308
+
309
+
310
+ class CreateRerankRouterRerankTimeout(BaseModel):
311
+ 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."""
312
+
313
+ call_timeout: float
314
+ r"""Timeout value in milliseconds"""
315
+
316
+
317
+ class CreateRerankOrqTypedDict(TypedDict):
318
+ name: NotRequired[str]
319
+ r"""The name to display on the trace. If not specified, the default system name will be used."""
320
+ fallbacks: NotRequired[List[CreateRerankRouterRerankFallbacksTypedDict]]
321
+ r"""Array of fallback models to use if primary model fails"""
322
+ cache: NotRequired[CreateRerankRouterRerankCacheTypedDict]
323
+ r"""Cache configuration for the request."""
324
+ retry: NotRequired[CreateRerankRouterRerankRetryTypedDict]
325
+ r"""Retry configuration for the request"""
326
+ identity: NotRequired[PublicIdentityTypedDict]
327
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
328
+ contact: NotRequired[PublicContactTypedDict]
329
+ r"""@deprecated Use identity instead. Information about the contact making the request."""
330
+ load_balancer: NotRequired[CreateRerankRouterRerankLoadBalancerTypedDict]
331
+ r"""Array of models with weights for load balancing requests"""
332
+ timeout: NotRequired[CreateRerankRouterRerankTimeoutTypedDict]
333
+ 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."""
334
+
335
+
336
+ class CreateRerankOrq(BaseModel):
337
+ name: Optional[str] = None
338
+ r"""The name to display on the trace. If not specified, the default system name will be used."""
339
+
340
+ fallbacks: Optional[List[CreateRerankRouterRerankFallbacks]] = None
341
+ r"""Array of fallback models to use if primary model fails"""
342
+
343
+ cache: Optional[CreateRerankRouterRerankCache] = None
344
+ r"""Cache configuration for the request."""
345
+
346
+ retry: Optional[CreateRerankRouterRerankRetry] = None
347
+ r"""Retry configuration for the request"""
348
+
349
+ identity: Optional[PublicIdentity] = None
350
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
351
+
352
+ contact: Annotated[
353
+ Optional[PublicContact],
354
+ pydantic.Field(
355
+ deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
356
+ ),
357
+ ] = None
358
+ r"""@deprecated Use identity instead. Information about the contact making the request."""
359
+
360
+ load_balancer: Optional[CreateRerankRouterRerankLoadBalancer] = None
361
+ r"""Array of models with weights for load balancing requests"""
362
+
363
+ timeout: Optional[CreateRerankRouterRerankTimeout] = None
364
+ 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."""
365
+
366
+ @model_serializer(mode="wrap")
367
+ def serialize_model(self, handler):
368
+ optional_fields = set(
369
+ [
370
+ "name",
371
+ "fallbacks",
372
+ "cache",
373
+ "retry",
374
+ "identity",
375
+ "contact",
376
+ "load_balancer",
377
+ "timeout",
378
+ ]
379
+ )
380
+ serialized = handler(self)
381
+ m = {}
382
+
383
+ for n, f in type(self).model_fields.items():
384
+ k = f.alias or n
385
+ val = serialized.get(k)
386
+
387
+ if val != UNSET_SENTINEL:
388
+ if val is not None or k not in optional_fields:
389
+ m[k] = val
390
+
391
+ return m
392
+
393
+
394
+ class CreateRerankRequestBodyTypedDict(TypedDict):
395
+ r"""input"""
396
+
397
+ query: str
398
+ r"""The search query"""
399
+ documents: List[str]
400
+ r"""A list of texts that will be compared to the `query`. For optimal performance we recommend against sending more than 1,000 documents in a single request."""
401
+ model: str
402
+ r"""The identifier of the model to use"""
403
+ top_n: NotRequired[float]
404
+ r"""The number of most relevant documents or indices to return, defaults to the length of the documents"""
405
+ filename: NotRequired[Nullable[str]]
406
+ r"""The filename of the document to rerank"""
407
+ name: NotRequired[str]
408
+ r"""The name to display on the trace. If not specified, the default system name will be used."""
409
+ fallbacks: NotRequired[List[CreateRerankFallbacksTypedDict]]
410
+ r"""Array of fallback models to use if primary model fails"""
411
+ retry: NotRequired[CreateRerankRetryTypedDict]
412
+ r"""Retry configuration for the request"""
413
+ cache: NotRequired[CreateRerankCacheTypedDict]
414
+ r"""Cache configuration for the request."""
415
+ load_balancer: NotRequired[CreateRerankLoadBalancerTypedDict]
416
+ r"""Load balancer configuration for the request."""
417
+ timeout: NotRequired[CreateRerankTimeoutTypedDict]
418
+ 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."""
419
+ orq: NotRequired[CreateRerankOrqTypedDict]
420
+
421
+
422
+ class CreateRerankRequestBody(BaseModel):
423
+ r"""input"""
424
+
425
+ query: str
426
+ r"""The search query"""
427
+
428
+ documents: List[str]
429
+ r"""A list of texts that will be compared to the `query`. For optimal performance we recommend against sending more than 1,000 documents in a single request."""
430
+
431
+ model: str
432
+ r"""The identifier of the model to use"""
433
+
434
+ top_n: Optional[float] = None
435
+ r"""The number of most relevant documents or indices to return, defaults to the length of the documents"""
436
+
437
+ filename: OptionalNullable[str] = UNSET
438
+ r"""The filename of the document to rerank"""
439
+
440
+ name: Optional[str] = None
441
+ r"""The name to display on the trace. If not specified, the default system name will be used."""
442
+
443
+ fallbacks: Optional[List[CreateRerankFallbacks]] = None
444
+ r"""Array of fallback models to use if primary model fails"""
445
+
446
+ retry: Optional[CreateRerankRetry] = None
447
+ r"""Retry configuration for the request"""
448
+
449
+ cache: Optional[CreateRerankCache] = None
450
+ r"""Cache configuration for the request."""
451
+
452
+ load_balancer: Optional[CreateRerankLoadBalancer] = None
453
+ r"""Load balancer configuration for the request."""
454
+
455
+ timeout: Optional[CreateRerankTimeout] = None
456
+ 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."""
457
+
458
+ orq: Optional[CreateRerankOrq] = None
459
+
460
+ @model_serializer(mode="wrap")
461
+ def serialize_model(self, handler):
462
+ optional_fields = set(
463
+ [
464
+ "top_n",
465
+ "filename",
466
+ "name",
467
+ "fallbacks",
468
+ "retry",
469
+ "cache",
470
+ "load_balancer",
471
+ "timeout",
472
+ "orq",
473
+ ]
474
+ )
475
+ nullable_fields = set(["filename"])
476
+ serialized = handler(self)
477
+ m = {}
478
+
479
+ for n, f in type(self).model_fields.items():
480
+ k = f.alias or n
481
+ val = serialized.get(k)
482
+ is_nullable_and_explicitly_set = (
483
+ k in nullable_fields
484
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
485
+ )
486
+
487
+ if val != UNSET_SENTINEL:
488
+ if (
489
+ val is not None
490
+ or k not in optional_fields
491
+ or is_nullable_and_explicitly_set
492
+ ):
493
+ m[k] = val
494
+
495
+ return m
496
+
497
+
498
+ CreateRerankObject = Literal["list",]
499
+
500
+
501
+ CreateRerankRouterRerankObject = Literal["rerank",]
502
+ r"""The object type, which is always `rerank`."""
503
+
504
+
505
+ class CreateRerankDocumentTypedDict(TypedDict):
506
+ r"""If return_documents is set as false this will return none, if true it will return the documents passed in"""
507
+
508
+ text: str
509
+ r"""The text of the document to rerank"""
510
+
511
+
512
+ class CreateRerankDocument(BaseModel):
513
+ r"""If return_documents is set as false this will return none, if true it will return the documents passed in"""
514
+
515
+ text: str
516
+ r"""The text of the document to rerank"""
517
+
518
+
519
+ class CreateRerankResultsTypedDict(TypedDict):
520
+ object: CreateRerankRouterRerankObject
521
+ r"""The object type, which is always `rerank`."""
522
+ index: float
523
+ r"""Corresponds to the index in the original list of documents to which the ranked document belongs."""
524
+ relevance_score: float
525
+ r"""Relevance scores are normalized to be in the range [0, 1]. Scores close to 1 indicate a high relevance to the query, and scores closer to 0 indicate low relevance."""
526
+ document: NotRequired[CreateRerankDocumentTypedDict]
527
+ r"""If return_documents is set as false this will return none, if true it will return the documents passed in"""
528
+
529
+
530
+ class CreateRerankResults(BaseModel):
531
+ object: CreateRerankRouterRerankObject
532
+ r"""The object type, which is always `rerank`."""
533
+
534
+ index: float
535
+ r"""Corresponds to the index in the original list of documents to which the ranked document belongs."""
536
+
537
+ relevance_score: float
538
+ r"""Relevance scores are normalized to be in the range [0, 1]. Scores close to 1 indicate a high relevance to the query, and scores closer to 0 indicate low relevance."""
539
+
540
+ document: Optional[CreateRerankDocument] = None
541
+ r"""If return_documents is set as false this will return none, if true it will return the documents passed in"""
542
+
543
+ @model_serializer(mode="wrap")
544
+ def serialize_model(self, handler):
545
+ optional_fields = set(["document"])
546
+ serialized = handler(self)
547
+ m = {}
548
+
549
+ for n, f in type(self).model_fields.items():
550
+ k = f.alias or n
551
+ val = serialized.get(k)
552
+
553
+ if val != UNSET_SENTINEL:
554
+ if val is not None or k not in optional_fields:
555
+ m[k] = val
556
+
557
+ return m
558
+
559
+
560
+ class CreateRerankUsageTypedDict(TypedDict):
561
+ total_tokens: float
562
+ r"""The total number of tokens used in the rerank"""
563
+
564
+
565
+ class CreateRerankUsage(BaseModel):
566
+ total_tokens: float
567
+ r"""The total number of tokens used in the rerank"""
568
+
569
+
570
+ class CreateRerankResponseBodyTypedDict(TypedDict):
571
+ r"""Returns the reranked documents."""
572
+
573
+ object: CreateRerankObject
574
+ results: List[CreateRerankResultsTypedDict]
575
+ r"""An ordered list of ranked documents"""
576
+ id: NotRequired[str]
577
+ r"""A unique identifier for the rerank."""
578
+ usage: NotRequired[CreateRerankUsageTypedDict]
579
+
580
+
581
+ class CreateRerankResponseBody(BaseModel):
582
+ r"""Returns the reranked documents."""
583
+
584
+ object: CreateRerankObject
585
+
586
+ results: List[CreateRerankResults]
587
+ r"""An ordered list of ranked documents"""
588
+
589
+ id: Optional[str] = None
590
+ r"""A unique identifier for the rerank."""
591
+
592
+ usage: Optional[CreateRerankUsage] = None
593
+
594
+ @model_serializer(mode="wrap")
595
+ def serialize_model(self, handler):
596
+ optional_fields = set(["id", "usage"])
597
+ serialized = handler(self)
598
+ m = {}
599
+
600
+ for n, f in type(self).model_fields.items():
601
+ k = f.alias or n
602
+ val = serialized.get(k)
603
+
604
+ if val != UNSET_SENTINEL:
605
+ if val is not None or k not in optional_fields:
606
+ m[k] = val
607
+
608
+ return m