orq-ai-sdk 4.2.0rc28__py3-none-any.whl → 4.2.6__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 (167) 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/basesdk.py +20 -6
  5. orq_ai_sdk/chat.py +22 -0
  6. orq_ai_sdk/completions.py +332 -0
  7. orq_ai_sdk/contacts.py +43 -855
  8. orq_ai_sdk/deployments.py +61 -0
  9. orq_ai_sdk/edits.py +258 -0
  10. orq_ai_sdk/embeddings.py +238 -0
  11. orq_ai_sdk/generations.py +272 -0
  12. orq_ai_sdk/identities.py +1037 -0
  13. orq_ai_sdk/images.py +28 -0
  14. orq_ai_sdk/models/__init__.py +5341 -737
  15. orq_ai_sdk/models/actionreviewedstreamingevent.py +18 -1
  16. orq_ai_sdk/models/actionreviewrequestedstreamingevent.py +44 -1
  17. orq_ai_sdk/models/agenterroredstreamingevent.py +18 -1
  18. orq_ai_sdk/models/agentinactivestreamingevent.py +168 -70
  19. orq_ai_sdk/models/agentmessagecreatedstreamingevent.py +18 -2
  20. orq_ai_sdk/models/agentresponsemessage.py +18 -2
  21. orq_ai_sdk/models/agentstartedstreamingevent.py +127 -2
  22. orq_ai_sdk/models/agentthoughtstreamingevent.py +178 -211
  23. orq_ai_sdk/models/conversationresponse.py +31 -20
  24. orq_ai_sdk/models/conversationwithmessagesresponse.py +31 -20
  25. orq_ai_sdk/models/createagentrequestop.py +1922 -384
  26. orq_ai_sdk/models/createagentresponse.py +147 -91
  27. orq_ai_sdk/models/createagentresponserequestop.py +111 -2
  28. orq_ai_sdk/models/createchatcompletionop.py +1375 -861
  29. orq_ai_sdk/models/createchunkop.py +46 -19
  30. orq_ai_sdk/models/createcompletionop.py +1890 -0
  31. orq_ai_sdk/models/createcontactop.py +45 -56
  32. orq_ai_sdk/models/createconversationop.py +61 -39
  33. orq_ai_sdk/models/createconversationresponseop.py +68 -4
  34. orq_ai_sdk/models/createdatasetitemop.py +424 -80
  35. orq_ai_sdk/models/createdatasetop.py +19 -2
  36. orq_ai_sdk/models/createdatasourceop.py +92 -26
  37. orq_ai_sdk/models/createembeddingop.py +384 -0
  38. orq_ai_sdk/models/createevalop.py +552 -24
  39. orq_ai_sdk/models/createidentityop.py +176 -0
  40. orq_ai_sdk/models/createimageeditop.py +504 -0
  41. orq_ai_sdk/models/createimageop.py +208 -117
  42. orq_ai_sdk/models/createimagevariationop.py +486 -0
  43. orq_ai_sdk/models/createknowledgeop.py +186 -121
  44. orq_ai_sdk/models/creatememorydocumentop.py +50 -1
  45. orq_ai_sdk/models/creatememoryop.py +34 -21
  46. orq_ai_sdk/models/creatememorystoreop.py +34 -1
  47. orq_ai_sdk/models/createmoderationop.py +521 -0
  48. orq_ai_sdk/models/createpromptop.py +2748 -1252
  49. orq_ai_sdk/models/creatererankop.py +416 -0
  50. orq_ai_sdk/models/createresponseop.py +2567 -0
  51. orq_ai_sdk/models/createspeechop.py +316 -0
  52. orq_ai_sdk/models/createtoolop.py +537 -12
  53. orq_ai_sdk/models/createtranscriptionop.py +562 -0
  54. orq_ai_sdk/models/createtranslationop.py +540 -0
  55. orq_ai_sdk/models/datapart.py +18 -1
  56. orq_ai_sdk/models/deletechunksop.py +34 -1
  57. orq_ai_sdk/models/{deletecontactop.py → deleteidentityop.py} +9 -9
  58. orq_ai_sdk/models/deletepromptop.py +26 -0
  59. orq_ai_sdk/models/deploymentcreatemetricop.py +362 -76
  60. orq_ai_sdk/models/deploymentgetconfigop.py +635 -194
  61. orq_ai_sdk/models/deploymentinvokeop.py +168 -173
  62. orq_ai_sdk/models/deploymentsop.py +195 -58
  63. orq_ai_sdk/models/deploymentstreamop.py +652 -304
  64. orq_ai_sdk/models/errorpart.py +18 -1
  65. orq_ai_sdk/models/filecontentpartschema.py +18 -1
  66. orq_ai_sdk/models/filegetop.py +19 -2
  67. orq_ai_sdk/models/filelistop.py +35 -2
  68. orq_ai_sdk/models/filepart.py +50 -1
  69. orq_ai_sdk/models/fileuploadop.py +51 -2
  70. orq_ai_sdk/models/generateconversationnameop.py +31 -20
  71. orq_ai_sdk/models/get_v2_evaluators_id_versionsop.py +34 -1
  72. orq_ai_sdk/models/get_v2_tools_tool_id_versions_version_id_op.py +18 -1
  73. orq_ai_sdk/models/get_v2_tools_tool_id_versionsop.py +34 -1
  74. orq_ai_sdk/models/getallmemoriesop.py +34 -21
  75. orq_ai_sdk/models/getallmemorydocumentsop.py +42 -1
  76. orq_ai_sdk/models/getallmemorystoresop.py +34 -1
  77. orq_ai_sdk/models/getallpromptsop.py +1690 -230
  78. orq_ai_sdk/models/getalltoolsop.py +325 -8
  79. orq_ai_sdk/models/getchunkscountop.py +34 -1
  80. orq_ai_sdk/models/getevalsop.py +395 -43
  81. orq_ai_sdk/models/getonechunkop.py +14 -19
  82. orq_ai_sdk/models/getoneknowledgeop.py +116 -96
  83. orq_ai_sdk/models/getonepromptop.py +1673 -230
  84. orq_ai_sdk/models/getpromptversionop.py +1670 -216
  85. orq_ai_sdk/models/imagecontentpartschema.py +50 -1
  86. orq_ai_sdk/models/internal/globals.py +18 -1
  87. orq_ai_sdk/models/invokeagentop.py +140 -2
  88. orq_ai_sdk/models/invokedeploymentrequest.py +418 -80
  89. orq_ai_sdk/models/invokeevalop.py +160 -131
  90. orq_ai_sdk/models/listagentsop.py +793 -166
  91. orq_ai_sdk/models/listchunksop.py +32 -19
  92. orq_ai_sdk/models/listchunkspaginatedop.py +46 -19
  93. orq_ai_sdk/models/listconversationsop.py +18 -1
  94. orq_ai_sdk/models/listdatasetdatapointsop.py +252 -42
  95. orq_ai_sdk/models/listdatasetsop.py +35 -2
  96. orq_ai_sdk/models/listdatasourcesop.py +35 -26
  97. orq_ai_sdk/models/{listcontactsop.py → listidentitiesop.py} +89 -79
  98. orq_ai_sdk/models/listknowledgebasesop.py +132 -96
  99. orq_ai_sdk/models/listmodelsop.py +1 -0
  100. orq_ai_sdk/models/listpromptversionsop.py +1684 -216
  101. orq_ai_sdk/models/parseop.py +161 -17
  102. orq_ai_sdk/models/partdoneevent.py +19 -2
  103. orq_ai_sdk/models/post_v2_router_ocrop.py +408 -0
  104. orq_ai_sdk/models/publiccontact.py +27 -4
  105. orq_ai_sdk/models/publicidentity.py +62 -0
  106. orq_ai_sdk/models/reasoningpart.py +19 -2
  107. orq_ai_sdk/models/refusalpartschema.py +18 -1
  108. orq_ai_sdk/models/remoteconfigsgetconfigop.py +34 -1
  109. orq_ai_sdk/models/responsedoneevent.py +114 -84
  110. orq_ai_sdk/models/responsestartedevent.py +18 -1
  111. orq_ai_sdk/models/retrieveagentrequestop.py +787 -166
  112. orq_ai_sdk/models/retrievedatapointop.py +236 -42
  113. orq_ai_sdk/models/retrievedatasetop.py +19 -2
  114. orq_ai_sdk/models/retrievedatasourceop.py +17 -26
  115. orq_ai_sdk/models/{retrievecontactop.py → retrieveidentityop.py} +38 -41
  116. orq_ai_sdk/models/retrievememorydocumentop.py +18 -1
  117. orq_ai_sdk/models/retrievememoryop.py +18 -21
  118. orq_ai_sdk/models/retrievememorystoreop.py +18 -1
  119. orq_ai_sdk/models/retrievetoolop.py +309 -8
  120. orq_ai_sdk/models/runagentop.py +1451 -197
  121. orq_ai_sdk/models/searchknowledgeop.py +108 -1
  122. orq_ai_sdk/models/security.py +18 -1
  123. orq_ai_sdk/models/streamagentop.py +93 -2
  124. orq_ai_sdk/models/streamrunagentop.py +1428 -195
  125. orq_ai_sdk/models/textcontentpartschema.py +34 -1
  126. orq_ai_sdk/models/thinkingconfigenabledschema.py +18 -1
  127. orq_ai_sdk/models/toolcallpart.py +18 -1
  128. orq_ai_sdk/models/tooldoneevent.py +18 -1
  129. orq_ai_sdk/models/toolexecutionfailedstreamingevent.py +50 -1
  130. orq_ai_sdk/models/toolexecutionfinishedstreamingevent.py +34 -1
  131. orq_ai_sdk/models/toolexecutionstartedstreamingevent.py +34 -1
  132. orq_ai_sdk/models/toolresultpart.py +18 -1
  133. orq_ai_sdk/models/toolreviewrequestedevent.py +18 -1
  134. orq_ai_sdk/models/toolstartedevent.py +18 -1
  135. orq_ai_sdk/models/updateagentop.py +1951 -404
  136. orq_ai_sdk/models/updatechunkop.py +46 -19
  137. orq_ai_sdk/models/updateconversationop.py +61 -39
  138. orq_ai_sdk/models/updatedatapointop.py +424 -80
  139. orq_ai_sdk/models/updatedatasetop.py +51 -2
  140. orq_ai_sdk/models/updatedatasourceop.py +17 -26
  141. orq_ai_sdk/models/updateevalop.py +577 -16
  142. orq_ai_sdk/models/{updatecontactop.py → updateidentityop.py} +78 -68
  143. orq_ai_sdk/models/updateknowledgeop.py +234 -190
  144. orq_ai_sdk/models/updatememorydocumentop.py +50 -1
  145. orq_ai_sdk/models/updatememoryop.py +50 -21
  146. orq_ai_sdk/models/updatememorystoreop.py +66 -1
  147. orq_ai_sdk/models/updatepromptop.py +2844 -1450
  148. orq_ai_sdk/models/updatetoolop.py +592 -9
  149. orq_ai_sdk/models/usermessagerequest.py +18 -2
  150. orq_ai_sdk/moderations.py +218 -0
  151. orq_ai_sdk/orq_completions.py +660 -0
  152. orq_ai_sdk/orq_responses.py +398 -0
  153. orq_ai_sdk/prompts.py +28 -36
  154. orq_ai_sdk/rerank.py +232 -0
  155. orq_ai_sdk/router.py +89 -641
  156. orq_ai_sdk/sdk.py +3 -0
  157. orq_ai_sdk/speech.py +251 -0
  158. orq_ai_sdk/transcriptions.py +326 -0
  159. orq_ai_sdk/translations.py +298 -0
  160. orq_ai_sdk/utils/__init__.py +13 -1
  161. orq_ai_sdk/variations.py +254 -0
  162. orq_ai_sdk-4.2.6.dist-info/METADATA +888 -0
  163. orq_ai_sdk-4.2.6.dist-info/RECORD +263 -0
  164. {orq_ai_sdk-4.2.0rc28.dist-info → orq_ai_sdk-4.2.6.dist-info}/WHEEL +2 -1
  165. orq_ai_sdk-4.2.6.dist-info/top_level.txt +1 -0
  166. orq_ai_sdk-4.2.0rc28.dist-info/METADATA +0 -867
  167. orq_ai_sdk-4.2.0rc28.dist-info/RECORD +0 -233
@@ -0,0 +1,416 @@
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
+ CreateRerankType = Literal["exact_match",]
30
+
31
+
32
+ class CreateRerankCacheTypedDict(TypedDict):
33
+ r"""Cache configuration for the request."""
34
+
35
+ type: CreateRerankType
36
+ ttl: NotRequired[float]
37
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
38
+
39
+
40
+ class CreateRerankCache(BaseModel):
41
+ r"""Cache configuration for the request."""
42
+
43
+ type: CreateRerankType
44
+
45
+ ttl: Optional[float] = 1800
46
+ r"""Time to live for cached responses in seconds. Maximum 259200 seconds (3 days)."""
47
+
48
+ @model_serializer(mode="wrap")
49
+ def serialize_model(self, handler):
50
+ optional_fields = set(["ttl"])
51
+ serialized = handler(self)
52
+ m = {}
53
+
54
+ for n, f in type(self).model_fields.items():
55
+ k = f.alias or n
56
+ val = serialized.get(k)
57
+
58
+ if val != UNSET_SENTINEL:
59
+ if val is not None or k not in optional_fields:
60
+ m[k] = val
61
+
62
+ return m
63
+
64
+
65
+ class CreateRerankRetryTypedDict(TypedDict):
66
+ r"""Retry configuration for the request"""
67
+
68
+ count: NotRequired[float]
69
+ r"""Number of retry attempts (1-5)"""
70
+ on_codes: NotRequired[List[float]]
71
+ r"""HTTP status codes that trigger retry logic"""
72
+
73
+
74
+ class CreateRerankRetry(BaseModel):
75
+ r"""Retry configuration for the request"""
76
+
77
+ count: Optional[float] = 3
78
+ r"""Number of retry attempts (1-5)"""
79
+
80
+ on_codes: Optional[List[float]] = None
81
+ r"""HTTP status codes that trigger retry logic"""
82
+
83
+ @model_serializer(mode="wrap")
84
+ def serialize_model(self, handler):
85
+ optional_fields = set(["count", "on_codes"])
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"""Array of models with weights for load balancing requests"""
147
+
148
+
149
+ CreateRerankLoadBalancer = CreateRerankLoadBalancer1
150
+ r"""Array of models with weights for load balancing requests"""
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 CreateRerankOrqTypedDict(TypedDict):
168
+ name: NotRequired[str]
169
+ r"""The name to display on the trace. If not specified, the default system name will be used."""
170
+ fallbacks: NotRequired[List[CreateRerankFallbacksTypedDict]]
171
+ r"""Array of fallback models to use if primary model fails"""
172
+ cache: NotRequired[CreateRerankCacheTypedDict]
173
+ r"""Cache configuration for the request."""
174
+ retry: NotRequired[CreateRerankRetryTypedDict]
175
+ r"""Retry configuration for the request"""
176
+ identity: NotRequired[PublicIdentityTypedDict]
177
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
178
+ contact: NotRequired[PublicContactTypedDict]
179
+ r"""@deprecated Use identity instead. Information about the contact making the request."""
180
+ load_balancer: NotRequired[CreateRerankLoadBalancerTypedDict]
181
+ r"""Array of models with weights for load balancing requests"""
182
+ timeout: NotRequired[CreateRerankTimeoutTypedDict]
183
+ 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."""
184
+
185
+
186
+ class CreateRerankOrq(BaseModel):
187
+ name: Optional[str] = None
188
+ r"""The name to display on the trace. If not specified, the default system name will be used."""
189
+
190
+ fallbacks: Optional[List[CreateRerankFallbacks]] = None
191
+ r"""Array of fallback models to use if primary model fails"""
192
+
193
+ cache: Optional[CreateRerankCache] = None
194
+ r"""Cache configuration for the request."""
195
+
196
+ retry: Optional[CreateRerankRetry] = None
197
+ r"""Retry configuration for the request"""
198
+
199
+ identity: Optional[PublicIdentity] = None
200
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
201
+
202
+ contact: Annotated[
203
+ Optional[PublicContact],
204
+ pydantic.Field(
205
+ deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
206
+ ),
207
+ ] = None
208
+ r"""@deprecated Use identity instead. Information about the contact making the request."""
209
+
210
+ load_balancer: Optional[CreateRerankLoadBalancer] = None
211
+ r"""Array of models with weights for load balancing requests"""
212
+
213
+ timeout: Optional[CreateRerankTimeout] = None
214
+ 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."""
215
+
216
+ @model_serializer(mode="wrap")
217
+ def serialize_model(self, handler):
218
+ optional_fields = set(
219
+ [
220
+ "name",
221
+ "fallbacks",
222
+ "cache",
223
+ "retry",
224
+ "identity",
225
+ "contact",
226
+ "load_balancer",
227
+ "timeout",
228
+ ]
229
+ )
230
+ serialized = handler(self)
231
+ m = {}
232
+
233
+ for n, f in type(self).model_fields.items():
234
+ k = f.alias or n
235
+ val = serialized.get(k)
236
+
237
+ if val != UNSET_SENTINEL:
238
+ if val is not None or k not in optional_fields:
239
+ m[k] = val
240
+
241
+ return m
242
+
243
+
244
+ class CreateRerankRequestBodyTypedDict(TypedDict):
245
+ r"""input"""
246
+
247
+ query: str
248
+ r"""The search query"""
249
+ documents: List[str]
250
+ 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."""
251
+ model: str
252
+ r"""The identifier of the model to use"""
253
+ top_n: NotRequired[float]
254
+ r"""The number of most relevant documents or indices to return, defaults to the length of the documents"""
255
+ filename: NotRequired[Nullable[str]]
256
+ r"""The filename of the document to rerank"""
257
+ orq: NotRequired[CreateRerankOrqTypedDict]
258
+
259
+
260
+ class CreateRerankRequestBody(BaseModel):
261
+ r"""input"""
262
+
263
+ query: str
264
+ r"""The search query"""
265
+
266
+ documents: List[str]
267
+ 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."""
268
+
269
+ model: str
270
+ r"""The identifier of the model to use"""
271
+
272
+ top_n: Optional[float] = None
273
+ r"""The number of most relevant documents or indices to return, defaults to the length of the documents"""
274
+
275
+ filename: OptionalNullable[str] = UNSET
276
+ r"""The filename of the document to rerank"""
277
+
278
+ orq: Optional[CreateRerankOrq] = None
279
+
280
+ @model_serializer(mode="wrap")
281
+ def serialize_model(self, handler):
282
+ optional_fields = set(["top_n", "filename", "orq"])
283
+ nullable_fields = set(["filename"])
284
+ serialized = handler(self)
285
+ m = {}
286
+
287
+ for n, f in type(self).model_fields.items():
288
+ k = f.alias or n
289
+ val = serialized.get(k)
290
+ is_nullable_and_explicitly_set = (
291
+ k in nullable_fields
292
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
293
+ )
294
+
295
+ if val != UNSET_SENTINEL:
296
+ if (
297
+ val is not None
298
+ or k not in optional_fields
299
+ or is_nullable_and_explicitly_set
300
+ ):
301
+ m[k] = val
302
+
303
+ return m
304
+
305
+
306
+ CreateRerankObject = Literal["list",]
307
+
308
+
309
+ CreateRerankRouterRerankObject = Literal["rerank",]
310
+ r"""The object type, which is always `rerank`."""
311
+
312
+
313
+ class CreateRerankDocumentTypedDict(TypedDict):
314
+ r"""If return_documents is set as false this will return none, if true it will return the documents passed in"""
315
+
316
+ text: str
317
+ r"""The text of the document to rerank"""
318
+
319
+
320
+ class CreateRerankDocument(BaseModel):
321
+ r"""If return_documents is set as false this will return none, if true it will return the documents passed in"""
322
+
323
+ text: str
324
+ r"""The text of the document to rerank"""
325
+
326
+
327
+ class CreateRerankResultsTypedDict(TypedDict):
328
+ object: CreateRerankRouterRerankObject
329
+ r"""The object type, which is always `rerank`."""
330
+ index: float
331
+ r"""Corresponds to the index in the original list of documents to which the ranked document belongs."""
332
+ relevance_score: float
333
+ 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."""
334
+ document: NotRequired[CreateRerankDocumentTypedDict]
335
+ r"""If return_documents is set as false this will return none, if true it will return the documents passed in"""
336
+
337
+
338
+ class CreateRerankResults(BaseModel):
339
+ object: CreateRerankRouterRerankObject
340
+ r"""The object type, which is always `rerank`."""
341
+
342
+ index: float
343
+ r"""Corresponds to the index in the original list of documents to which the ranked document belongs."""
344
+
345
+ relevance_score: float
346
+ 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."""
347
+
348
+ document: Optional[CreateRerankDocument] = None
349
+ r"""If return_documents is set as false this will return none, if true it will return the documents passed in"""
350
+
351
+ @model_serializer(mode="wrap")
352
+ def serialize_model(self, handler):
353
+ optional_fields = set(["document"])
354
+ serialized = handler(self)
355
+ m = {}
356
+
357
+ for n, f in type(self).model_fields.items():
358
+ k = f.alias or n
359
+ val = serialized.get(k)
360
+
361
+ if val != UNSET_SENTINEL:
362
+ if val is not None or k not in optional_fields:
363
+ m[k] = val
364
+
365
+ return m
366
+
367
+
368
+ class CreateRerankUsageTypedDict(TypedDict):
369
+ total_tokens: float
370
+ r"""The total number of tokens used in the rerank"""
371
+
372
+
373
+ class CreateRerankUsage(BaseModel):
374
+ total_tokens: float
375
+ r"""The total number of tokens used in the rerank"""
376
+
377
+
378
+ class CreateRerankResponseBodyTypedDict(TypedDict):
379
+ r"""Returns the reranked documents."""
380
+
381
+ object: CreateRerankObject
382
+ results: List[CreateRerankResultsTypedDict]
383
+ r"""An ordered list of ranked documents"""
384
+ id: NotRequired[str]
385
+ r"""A unique identifier for the rerank."""
386
+ usage: NotRequired[CreateRerankUsageTypedDict]
387
+
388
+
389
+ class CreateRerankResponseBody(BaseModel):
390
+ r"""Returns the reranked documents."""
391
+
392
+ object: CreateRerankObject
393
+
394
+ results: List[CreateRerankResults]
395
+ r"""An ordered list of ranked documents"""
396
+
397
+ id: Optional[str] = None
398
+ r"""A unique identifier for the rerank."""
399
+
400
+ usage: Optional[CreateRerankUsage] = None
401
+
402
+ @model_serializer(mode="wrap")
403
+ def serialize_model(self, handler):
404
+ optional_fields = set(["id", "usage"])
405
+ serialized = handler(self)
406
+ m = {}
407
+
408
+ for n, f in type(self).model_fields.items():
409
+ k = f.alias or n
410
+ val = serialized.get(k)
411
+
412
+ if val != UNSET_SENTINEL:
413
+ if val is not None or k not in optional_fields:
414
+ m[k] = val
415
+
416
+ return m