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
@@ -46,6 +46,22 @@ class UpdateKnowledgeRequestBodyRerankConfig(BaseModel):
46
46
  rerank_threshold: Optional[float] = 0.5
47
47
  r"""The threshold value used to filter the rerank results, only documents with a relevance score greater than the threshold will be returned"""
48
48
 
49
+ @model_serializer(mode="wrap")
50
+ def serialize_model(self, handler):
51
+ optional_fields = set(["top_k", "rerank_threshold"])
52
+ serialized = handler(self)
53
+ m = {}
54
+
55
+ for n, f in type(self).model_fields.items():
56
+ k = f.alias or n
57
+ val = serialized.get(k)
58
+
59
+ if val != UNSET_SENTINEL:
60
+ if val is not None or k not in optional_fields:
61
+ m[k] = val
62
+
63
+ return m
64
+
49
65
 
50
66
  class UpdateKnowledgeRequestBodyAgenticRagConfigTypedDict(TypedDict):
51
67
  r"""The Agentic RAG configuration for the knowledge base. If `null` is provided, Agentic RAG will be disabled."""
@@ -102,37 +118,34 @@ class UpdateKnowledgeRequestBodyRetrievalSettings(BaseModel):
102
118
 
103
119
  @model_serializer(mode="wrap")
104
120
  def serialize_model(self, handler):
105
- optional_fields = [
106
- "retrieval_type",
107
- "top_k",
108
- "threshold",
109
- "rerank_config",
110
- "agentic_rag_config",
111
- ]
112
- nullable_fields = ["rerank_config", "agentic_rag_config"]
113
- null_default_fields = []
114
-
121
+ optional_fields = set(
122
+ [
123
+ "retrieval_type",
124
+ "top_k",
125
+ "threshold",
126
+ "rerank_config",
127
+ "agentic_rag_config",
128
+ ]
129
+ )
130
+ nullable_fields = set(["rerank_config", "agentic_rag_config"])
115
131
  serialized = handler(self)
116
-
117
132
  m = {}
118
133
 
119
134
  for n, f in type(self).model_fields.items():
120
135
  k = f.alias or n
121
136
  val = serialized.get(k)
122
- serialized.pop(k, None)
123
-
124
- optional_nullable = k in optional_fields and k in nullable_fields
125
- is_set = (
126
- self.__pydantic_fields_set__.intersection({n})
127
- or k in null_default_fields
128
- ) # pylint: disable=no-member
129
-
130
- if val is not None and val != UNSET_SENTINEL:
131
- m[k] = val
132
- elif val != UNSET_SENTINEL and (
133
- not k in optional_fields or (optional_nullable and is_set)
134
- ):
135
- m[k] = val
137
+ is_nullable_and_explicitly_set = (
138
+ k in nullable_fields
139
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
140
+ )
141
+
142
+ if val != UNSET_SENTINEL:
143
+ if (
144
+ val is not None
145
+ or k not in optional_fields
146
+ or is_nullable_and_explicitly_set
147
+ ):
148
+ m[k] = val
136
149
 
137
150
  return m
138
151
 
@@ -181,37 +194,28 @@ class UpdateKnowledgeRequestBody2(BaseModel):
181
194
 
182
195
  @model_serializer(mode="wrap")
183
196
  def serialize_model(self, handler):
184
- optional_fields = [
185
- "description",
186
- "embedding_model",
187
- "path",
188
- "retrieval_settings",
189
- "type",
190
- ]
191
- nullable_fields = ["description"]
192
- null_default_fields = []
193
-
197
+ optional_fields = set(
198
+ ["description", "embedding_model", "path", "retrieval_settings", "type"]
199
+ )
200
+ nullable_fields = set(["description"])
194
201
  serialized = handler(self)
195
-
196
202
  m = {}
197
203
 
198
204
  for n, f in type(self).model_fields.items():
199
205
  k = f.alias or n
200
206
  val = serialized.get(k)
201
- serialized.pop(k, None)
202
-
203
- optional_nullable = k in optional_fields and k in nullable_fields
204
- is_set = (
205
- self.__pydantic_fields_set__.intersection({n})
206
- or k in null_default_fields
207
- ) # pylint: disable=no-member
208
-
209
- if val is not None and val != UNSET_SENTINEL:
210
- m[k] = val
211
- elif val != UNSET_SENTINEL and (
212
- not k in optional_fields or (optional_nullable and is_set)
213
- ):
214
- m[k] = val
207
+ is_nullable_and_explicitly_set = (
208
+ k in nullable_fields
209
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
210
+ )
211
+
212
+ if val != UNSET_SENTINEL:
213
+ if (
214
+ val is not None
215
+ or k not in optional_fields
216
+ or is_nullable_and_explicitly_set
217
+ ):
218
+ m[k] = val
215
219
 
216
220
  return m
217
221
 
@@ -239,6 +243,22 @@ class RequestBodyRerankConfig(BaseModel):
239
243
  rerank_threshold: Optional[float] = 0.5
240
244
  r"""The threshold value used to filter the rerank results, only documents with a relevance score greater than the threshold will be returned"""
241
245
 
246
+ @model_serializer(mode="wrap")
247
+ def serialize_model(self, handler):
248
+ optional_fields = set(["top_k", "rerank_threshold"])
249
+ serialized = handler(self)
250
+ m = {}
251
+
252
+ for n, f in type(self).model_fields.items():
253
+ k = f.alias or n
254
+ val = serialized.get(k)
255
+
256
+ if val != UNSET_SENTINEL:
257
+ if val is not None or k not in optional_fields:
258
+ m[k] = val
259
+
260
+ return m
261
+
242
262
 
243
263
  class RequestBodyAgenticRagConfigTypedDict(TypedDict):
244
264
  r"""The Agentic RAG configuration for the knowledge base. If `null` is provided, Agentic RAG will be disabled."""
@@ -284,31 +304,28 @@ class RequestBodyRetrievalSettings(BaseModel):
284
304
 
285
305
  @model_serializer(mode="wrap")
286
306
  def serialize_model(self, handler):
287
- optional_fields = ["top_k", "threshold", "rerank_config", "agentic_rag_config"]
288
- nullable_fields = ["rerank_config", "agentic_rag_config"]
289
- null_default_fields = []
290
-
307
+ optional_fields = set(
308
+ ["top_k", "threshold", "rerank_config", "agentic_rag_config"]
309
+ )
310
+ nullable_fields = set(["rerank_config", "agentic_rag_config"])
291
311
  serialized = handler(self)
292
-
293
312
  m = {}
294
313
 
295
314
  for n, f in type(self).model_fields.items():
296
315
  k = f.alias or n
297
316
  val = serialized.get(k)
298
- serialized.pop(k, None)
299
-
300
- optional_nullable = k in optional_fields and k in nullable_fields
301
- is_set = (
302
- self.__pydantic_fields_set__.intersection({n})
303
- or k in null_default_fields
304
- ) # pylint: disable=no-member
305
-
306
- if val is not None and val != UNSET_SENTINEL:
307
- m[k] = val
308
- elif val != UNSET_SENTINEL and (
309
- not k in optional_fields or (optional_nullable and is_set)
310
- ):
311
- m[k] = val
317
+ is_nullable_and_explicitly_set = (
318
+ k in nullable_fields
319
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
320
+ )
321
+
322
+ if val != UNSET_SENTINEL:
323
+ if (
324
+ val is not None
325
+ or k not in optional_fields
326
+ or is_nullable_and_explicitly_set
327
+ ):
328
+ m[k] = val
312
329
 
313
330
  return m
314
331
 
@@ -336,6 +353,22 @@ class RequestBodyExternalConfig(BaseModel):
336
353
  api_key: Optional[str] = None
337
354
  r"""The API key for the external knowledge base."""
338
355
 
356
+ @model_serializer(mode="wrap")
357
+ def serialize_model(self, handler):
358
+ optional_fields = set(["name", "api_url", "api_key"])
359
+ serialized = handler(self)
360
+ m = {}
361
+
362
+ for n, f in type(self).model_fields.items():
363
+ k = f.alias or n
364
+ val = serialized.get(k)
365
+
366
+ if val != UNSET_SENTINEL:
367
+ if val is not None or k not in optional_fields:
368
+ m[k] = val
369
+
370
+ return m
371
+
339
372
 
340
373
  UpdateKnowledgeRequestBodyType = Literal["external",]
341
374
 
@@ -379,37 +412,28 @@ class UpdateKnowledgeRequestBody1(BaseModel):
379
412
 
380
413
  @model_serializer(mode="wrap")
381
414
  def serialize_model(self, handler):
382
- optional_fields = [
383
- "description",
384
- "path",
385
- "retrieval_settings",
386
- "external_config",
387
- "type",
388
- ]
389
- nullable_fields = ["description"]
390
- null_default_fields = []
391
-
415
+ optional_fields = set(
416
+ ["description", "path", "retrieval_settings", "external_config", "type"]
417
+ )
418
+ nullable_fields = set(["description"])
392
419
  serialized = handler(self)
393
-
394
420
  m = {}
395
421
 
396
422
  for n, f in type(self).model_fields.items():
397
423
  k = f.alias or n
398
424
  val = serialized.get(k)
399
- serialized.pop(k, None)
400
-
401
- optional_nullable = k in optional_fields and k in nullable_fields
402
- is_set = (
403
- self.__pydantic_fields_set__.intersection({n})
404
- or k in null_default_fields
405
- ) # pylint: disable=no-member
406
-
407
- if val is not None and val != UNSET_SENTINEL:
408
- m[k] = val
409
- elif val != UNSET_SENTINEL and (
410
- not k in optional_fields or (optional_nullable and is_set)
411
- ):
412
- m[k] = val
425
+ is_nullable_and_explicitly_set = (
426
+ k in nullable_fields
427
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
428
+ )
429
+
430
+ if val != UNSET_SENTINEL:
431
+ if (
432
+ val is not None
433
+ or k not in optional_fields
434
+ or is_nullable_and_explicitly_set
435
+ ):
436
+ m[k] = val
413
437
 
414
438
  return m
415
439
 
@@ -470,6 +494,22 @@ class UpdateKnowledgeResponseBodyKnowledgeRerankConfig(BaseModel):
470
494
  rerank_threshold: Optional[float] = 0.5
471
495
  r"""The threshold value used to filter the rerank results, only documents with a relevance score greater than the threshold will be returned"""
472
496
 
497
+ @model_serializer(mode="wrap")
498
+ def serialize_model(self, handler):
499
+ optional_fields = set(["top_k", "rerank_threshold"])
500
+ serialized = handler(self)
501
+ m = {}
502
+
503
+ for n, f in type(self).model_fields.items():
504
+ k = f.alias or n
505
+ val = serialized.get(k)
506
+
507
+ if val != UNSET_SENTINEL:
508
+ if val is not None or k not in optional_fields:
509
+ m[k] = val
510
+
511
+ return m
512
+
473
513
 
474
514
  class UpdateKnowledgeResponseBodyKnowledgeAgenticRagConfigTypedDict(TypedDict):
475
515
  r"""The Agentic RAG configuration for the knowledge base. If `null` is provided, Agentic RAG will be disabled."""
@@ -523,31 +563,28 @@ class UpdateKnowledgeResponseBodyKnowledgeRetrievalSettings(BaseModel):
523
563
 
524
564
  @model_serializer(mode="wrap")
525
565
  def serialize_model(self, handler):
526
- optional_fields = ["top_k", "threshold", "rerank_config", "agentic_rag_config"]
527
- nullable_fields = ["rerank_config", "agentic_rag_config"]
528
- null_default_fields = []
529
-
566
+ optional_fields = set(
567
+ ["top_k", "threshold", "rerank_config", "agentic_rag_config"]
568
+ )
569
+ nullable_fields = set(["rerank_config", "agentic_rag_config"])
530
570
  serialized = handler(self)
531
-
532
571
  m = {}
533
572
 
534
573
  for n, f in type(self).model_fields.items():
535
574
  k = f.alias or n
536
575
  val = serialized.get(k)
537
- serialized.pop(k, None)
538
-
539
- optional_nullable = k in optional_fields and k in nullable_fields
540
- is_set = (
541
- self.__pydantic_fields_set__.intersection({n})
542
- or k in null_default_fields
543
- ) # pylint: disable=no-member
544
-
545
- if val is not None and val != UNSET_SENTINEL:
546
- m[k] = val
547
- elif val != UNSET_SENTINEL and (
548
- not k in optional_fields or (optional_nullable and is_set)
549
- ):
550
- m[k] = val
576
+ is_nullable_and_explicitly_set = (
577
+ k in nullable_fields
578
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
579
+ )
580
+
581
+ if val != UNSET_SENTINEL:
582
+ if (
583
+ val is not None
584
+ or k not in optional_fields
585
+ or is_nullable_and_explicitly_set
586
+ ):
587
+ m[k] = val
551
588
 
552
589
  return m
553
590
 
@@ -639,38 +676,35 @@ class UpdateKnowledgeResponseBody2(BaseModel):
639
676
 
640
677
  @model_serializer(mode="wrap")
641
678
  def serialize_model(self, handler):
642
- optional_fields = [
643
- "description",
644
- "path",
645
- "created_by_id",
646
- "updated_by_id",
647
- "type",
648
- "retrieval_settings",
649
- ]
650
- nullable_fields = ["created_by_id", "updated_by_id"]
651
- null_default_fields = []
652
-
679
+ optional_fields = set(
680
+ [
681
+ "description",
682
+ "path",
683
+ "created_by_id",
684
+ "updated_by_id",
685
+ "type",
686
+ "retrieval_settings",
687
+ ]
688
+ )
689
+ nullable_fields = set(["created_by_id", "updated_by_id"])
653
690
  serialized = handler(self)
654
-
655
691
  m = {}
656
692
 
657
693
  for n, f in type(self).model_fields.items():
658
694
  k = f.alias or n
659
695
  val = serialized.get(k)
660
- serialized.pop(k, None)
661
-
662
- optional_nullable = k in optional_fields and k in nullable_fields
663
- is_set = (
664
- self.__pydantic_fields_set__.intersection({n})
665
- or k in null_default_fields
666
- ) # pylint: disable=no-member
667
-
668
- if val is not None and val != UNSET_SENTINEL:
669
- m[k] = val
670
- elif val != UNSET_SENTINEL and (
671
- not k in optional_fields or (optional_nullable and is_set)
672
- ):
673
- m[k] = val
696
+ is_nullable_and_explicitly_set = (
697
+ k in nullable_fields
698
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
699
+ )
700
+
701
+ if val != UNSET_SENTINEL:
702
+ if (
703
+ val is not None
704
+ or k not in optional_fields
705
+ or is_nullable_and_explicitly_set
706
+ ):
707
+ m[k] = val
674
708
 
675
709
  return m
676
710
 
@@ -709,6 +743,22 @@ class UpdateKnowledgeResponseBodyRerankConfig(BaseModel):
709
743
  rerank_threshold: Optional[float] = 0.5
710
744
  r"""The threshold value used to filter the rerank results, only documents with a relevance score greater than the threshold will be returned"""
711
745
 
746
+ @model_serializer(mode="wrap")
747
+ def serialize_model(self, handler):
748
+ optional_fields = set(["top_k", "rerank_threshold"])
749
+ serialized = handler(self)
750
+ m = {}
751
+
752
+ for n, f in type(self).model_fields.items():
753
+ k = f.alias or n
754
+ val = serialized.get(k)
755
+
756
+ if val != UNSET_SENTINEL:
757
+ if val is not None or k not in optional_fields:
758
+ m[k] = val
759
+
760
+ return m
761
+
712
762
 
713
763
  class UpdateKnowledgeResponseBodyAgenticRagConfigTypedDict(TypedDict):
714
764
  r"""The Agentic RAG configuration for the knowledge base. If `null` is provided, Agentic RAG will be disabled."""
@@ -765,37 +815,34 @@ class UpdateKnowledgeResponseBodyRetrievalSettings(BaseModel):
765
815
 
766
816
  @model_serializer(mode="wrap")
767
817
  def serialize_model(self, handler):
768
- optional_fields = [
769
- "retrieval_type",
770
- "top_k",
771
- "threshold",
772
- "rerank_config",
773
- "agentic_rag_config",
774
- ]
775
- nullable_fields = ["rerank_config", "agentic_rag_config"]
776
- null_default_fields = []
777
-
818
+ optional_fields = set(
819
+ [
820
+ "retrieval_type",
821
+ "top_k",
822
+ "threshold",
823
+ "rerank_config",
824
+ "agentic_rag_config",
825
+ ]
826
+ )
827
+ nullable_fields = set(["rerank_config", "agentic_rag_config"])
778
828
  serialized = handler(self)
779
-
780
829
  m = {}
781
830
 
782
831
  for n, f in type(self).model_fields.items():
783
832
  k = f.alias or n
784
833
  val = serialized.get(k)
785
- serialized.pop(k, None)
786
-
787
- optional_nullable = k in optional_fields and k in nullable_fields
788
- is_set = (
789
- self.__pydantic_fields_set__.intersection({n})
790
- or k in null_default_fields
791
- ) # pylint: disable=no-member
792
-
793
- if val is not None and val != UNSET_SENTINEL:
794
- m[k] = val
795
- elif val != UNSET_SENTINEL and (
796
- not k in optional_fields or (optional_nullable and is_set)
797
- ):
798
- m[k] = val
834
+ is_nullable_and_explicitly_set = (
835
+ k in nullable_fields
836
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
837
+ )
838
+
839
+ if val != UNSET_SENTINEL:
840
+ if (
841
+ val is not None
842
+ or k not in optional_fields
843
+ or is_nullable_and_explicitly_set
844
+ ):
845
+ m[k] = val
799
846
 
800
847
  return m
801
848
 
@@ -872,38 +919,35 @@ class UpdateKnowledgeResponseBody1(BaseModel):
872
919
 
873
920
  @model_serializer(mode="wrap")
874
921
  def serialize_model(self, handler):
875
- optional_fields = [
876
- "description",
877
- "path",
878
- "created_by_id",
879
- "updated_by_id",
880
- "type",
881
- "retrieval_settings",
882
- ]
883
- nullable_fields = ["created_by_id", "updated_by_id"]
884
- null_default_fields = []
885
-
922
+ optional_fields = set(
923
+ [
924
+ "description",
925
+ "path",
926
+ "created_by_id",
927
+ "updated_by_id",
928
+ "type",
929
+ "retrieval_settings",
930
+ ]
931
+ )
932
+ nullable_fields = set(["created_by_id", "updated_by_id"])
886
933
  serialized = handler(self)
887
-
888
934
  m = {}
889
935
 
890
936
  for n, f in type(self).model_fields.items():
891
937
  k = f.alias or n
892
938
  val = serialized.get(k)
893
- serialized.pop(k, None)
894
-
895
- optional_nullable = k in optional_fields and k in nullable_fields
896
- is_set = (
897
- self.__pydantic_fields_set__.intersection({n})
898
- or k in null_default_fields
899
- ) # pylint: disable=no-member
900
-
901
- if val is not None and val != UNSET_SENTINEL:
902
- m[k] = val
903
- elif val != UNSET_SENTINEL and (
904
- not k in optional_fields or (optional_nullable and is_set)
905
- ):
906
- m[k] = val
939
+ is_nullable_and_explicitly_set = (
940
+ k in nullable_fields
941
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
942
+ )
943
+
944
+ if val != UNSET_SENTINEL:
945
+ if (
946
+ val is not None
947
+ or k not in optional_fields
948
+ or is_nullable_and_explicitly_set
949
+ ):
950
+ m[k] = val
907
951
 
908
952
  return m
909
953
 
@@ -1,9 +1,10 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from orq_ai_sdk.types import BaseModel
4
+ from orq_ai_sdk.types import BaseModel, UNSET_SENTINEL
5
5
  from orq_ai_sdk.utils import FieldMetadata, PathParamMetadata, RequestMetadata
6
6
  import pydantic
7
+ from pydantic import model_serializer
7
8
  from typing import Dict, Optional
8
9
  from typing_extensions import Annotated, NotRequired, TypedDict
9
10
 
@@ -22,6 +23,22 @@ class UpdateMemoryDocumentRequestBody(BaseModel):
22
23
  metadata: Optional[Dict[str, str]] = None
23
24
  r"""Flexible key-value pairs for custom filtering and categorization. Clients can add arbitrary string metadata to enable future filtering of memory documents based on their specific needs (e.g., document type, source, topic, relevance score, or any custom taxonomy)."""
24
25
 
26
+ @model_serializer(mode="wrap")
27
+ def serialize_model(self, handler):
28
+ optional_fields = set(["metadata"])
29
+ serialized = handler(self)
30
+ m = {}
31
+
32
+ for n, f in type(self).model_fields.items():
33
+ k = f.alias or n
34
+ val = serialized.get(k)
35
+
36
+ if val != UNSET_SENTINEL:
37
+ if val is not None or k not in optional_fields:
38
+ m[k] = val
39
+
40
+ return m
41
+
25
42
 
26
43
  class UpdateMemoryDocumentRequestTypedDict(TypedDict):
27
44
  memory_store_key: str
@@ -54,6 +71,22 @@ class UpdateMemoryDocumentRequest(BaseModel):
54
71
  FieldMetadata(request=RequestMetadata(media_type="application/json")),
55
72
  ] = None
56
73
 
74
+ @model_serializer(mode="wrap")
75
+ def serialize_model(self, handler):
76
+ optional_fields = set(["RequestBody"])
77
+ serialized = handler(self)
78
+ m = {}
79
+
80
+ for n, f in type(self).model_fields.items():
81
+ k = f.alias or n
82
+ val = serialized.get(k)
83
+
84
+ if val != UNSET_SENTINEL:
85
+ if val is not None or k not in optional_fields:
86
+ m[k] = val
87
+
88
+ return m
89
+
57
90
 
58
91
  class UpdateMemoryDocumentResponseBodyTypedDict(TypedDict):
59
92
  r"""Memory document successfully updated."""
@@ -96,3 +129,19 @@ class UpdateMemoryDocumentResponseBody(BaseModel):
96
129
 
97
130
  metadata: Optional[Dict[str, str]] = None
98
131
  r"""Flexible key-value pairs for custom filtering and categorization. Clients can add arbitrary string metadata to enable future filtering of memory documents based on their specific needs (e.g., document type, source, topic, relevance score, or any custom taxonomy)."""
132
+
133
+ @model_serializer(mode="wrap")
134
+ def serialize_model(self, handler):
135
+ optional_fields = set(["created_by_id", "updated_by_id", "metadata"])
136
+ serialized = handler(self)
137
+ m = {}
138
+
139
+ for n, f in type(self).model_fields.items():
140
+ k = f.alias or n
141
+ val = serialized.get(k)
142
+
143
+ if val != UNSET_SENTINEL:
144
+ if val is not None or k not in optional_fields:
145
+ m[k] = val
146
+
147
+ return m