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
@@ -10,6 +10,7 @@ from .imagecontentpartschema import (
10
10
  ImageContentPartSchema,
11
11
  ImageContentPartSchemaTypedDict,
12
12
  )
13
+ from .publicidentity import PublicIdentity, PublicIdentityTypedDict
13
14
  from .reasoningpartschema import ReasoningPartSchema, ReasoningPartSchemaTypedDict
14
15
  from .redactedreasoningpartschema import (
15
16
  RedactedReasoningPartSchema,
@@ -49,6 +50,22 @@ class DeploymentStreamGlobals(BaseModel):
49
50
  FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
50
51
  ] = None
51
52
 
53
+ @model_serializer(mode="wrap")
54
+ def serialize_model(self, handler):
55
+ optional_fields = set(["environment", "contactId"])
56
+ serialized = handler(self)
57
+ m = {}
58
+
59
+ for n, f in type(self).model_fields.items():
60
+ k = f.alias or n
61
+ val = serialized.get(k)
62
+
63
+ if val != UNSET_SENTINEL:
64
+ if val is not None or k not in optional_fields:
65
+ m[k] = val
66
+
67
+ return m
68
+
52
69
 
53
70
  DeploymentStreamPrefixMessagesDeploymentsRequestRequestBody5Role = Literal["tool",]
54
71
  r"""The role of the messages author, in this case tool."""
@@ -119,6 +136,22 @@ class DeploymentStreamPrefixMessagesCacheControl(BaseModel):
119
136
  Defaults to `5m`. Only supported by `Anthropic` Claude models.
120
137
  """
121
138
 
139
+ @model_serializer(mode="wrap")
140
+ def serialize_model(self, handler):
141
+ optional_fields = set(["ttl"])
142
+ serialized = handler(self)
143
+ m = {}
144
+
145
+ for n, f in type(self).model_fields.items():
146
+ k = f.alias or n
147
+ val = serialized.get(k)
148
+
149
+ if val != UNSET_SENTINEL:
150
+ if val is not None or k not in optional_fields:
151
+ m[k] = val
152
+
153
+ return m
154
+
122
155
 
123
156
  class DeploymentStreamPrefixMessagesToolMessageTypedDict(TypedDict):
124
157
  role: DeploymentStreamPrefixMessagesDeploymentsRequestRequestBody5Role
@@ -146,31 +179,26 @@ class DeploymentStreamPrefixMessagesToolMessage(BaseModel):
146
179
 
147
180
  @model_serializer(mode="wrap")
148
181
  def serialize_model(self, handler):
149
- optional_fields = ["cache_control"]
150
- nullable_fields = ["tool_call_id"]
151
- null_default_fields = []
152
-
182
+ optional_fields = set(["cache_control"])
183
+ nullable_fields = set(["tool_call_id"])
153
184
  serialized = handler(self)
154
-
155
185
  m = {}
156
186
 
157
187
  for n, f in type(self).model_fields.items():
158
188
  k = f.alias or n
159
189
  val = serialized.get(k)
160
- serialized.pop(k, None)
161
-
162
- optional_nullable = k in optional_fields and k in nullable_fields
163
- is_set = (
164
- self.__pydantic_fields_set__.intersection({n})
165
- or k in null_default_fields
166
- ) # pylint: disable=no-member
167
-
168
- if val is not None and val != UNSET_SENTINEL:
169
- m[k] = val
170
- elif val != UNSET_SENTINEL and (
171
- not k in optional_fields or (optional_nullable and is_set)
172
- ):
173
- m[k] = val
190
+ is_nullable_and_explicitly_set = (
191
+ k in nullable_fields
192
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
193
+ )
194
+
195
+ if val != UNSET_SENTINEL:
196
+ if (
197
+ val is not None
198
+ or k not in optional_fields
199
+ or is_nullable_and_explicitly_set
200
+ ):
201
+ m[k] = val
174
202
 
175
203
  return m
176
204
 
@@ -249,6 +277,22 @@ class DeploymentStreamPrefixMessagesFunction(BaseModel):
249
277
  arguments: Optional[str] = None
250
278
  r"""The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."""
251
279
 
280
+ @model_serializer(mode="wrap")
281
+ def serialize_model(self, handler):
282
+ optional_fields = set(["name", "arguments"])
283
+ serialized = handler(self)
284
+ m = {}
285
+
286
+ for n, f in type(self).model_fields.items():
287
+ k = f.alias or n
288
+ val = serialized.get(k)
289
+
290
+ if val != UNSET_SENTINEL:
291
+ if val is not None or k not in optional_fields:
292
+ m[k] = val
293
+
294
+ return m
295
+
252
296
 
253
297
  class DeploymentStreamPrefixMessagesToolCallsTypedDict(TypedDict):
254
298
  id: str
@@ -272,6 +316,22 @@ class DeploymentStreamPrefixMessagesToolCalls(BaseModel):
272
316
  thought_signature: Optional[str] = None
273
317
  r"""Encrypted representation of the model internal reasoning state during function calling. Required by Gemini 3 models when continuing a conversation after a tool call."""
274
318
 
319
+ @model_serializer(mode="wrap")
320
+ def serialize_model(self, handler):
321
+ optional_fields = set(["thought_signature"])
322
+ serialized = handler(self)
323
+ m = {}
324
+
325
+ for n, f in type(self).model_fields.items():
326
+ k = f.alias or n
327
+ val = serialized.get(k)
328
+
329
+ if val != UNSET_SENTINEL:
330
+ if val is not None or k not in optional_fields:
331
+ m[k] = val
332
+
333
+ return m
334
+
275
335
 
276
336
  class DeploymentStreamPrefixMessagesAssistantMessageTypedDict(TypedDict):
277
337
  role: DeploymentStreamPrefixMessagesDeploymentsRequestRequestBodyRole
@@ -315,31 +375,26 @@ class DeploymentStreamPrefixMessagesAssistantMessage(BaseModel):
315
375
 
316
376
  @model_serializer(mode="wrap")
317
377
  def serialize_model(self, handler):
318
- optional_fields = ["content", "refusal", "name", "audio", "tool_calls"]
319
- nullable_fields = ["content", "refusal", "audio"]
320
- null_default_fields = []
321
-
378
+ optional_fields = set(["content", "refusal", "name", "audio", "tool_calls"])
379
+ nullable_fields = set(["content", "refusal", "audio"])
322
380
  serialized = handler(self)
323
-
324
381
  m = {}
325
382
 
326
383
  for n, f in type(self).model_fields.items():
327
384
  k = f.alias or n
328
385
  val = serialized.get(k)
329
- serialized.pop(k, None)
330
-
331
- optional_nullable = k in optional_fields and k in nullable_fields
332
- is_set = (
333
- self.__pydantic_fields_set__.intersection({n})
334
- or k in null_default_fields
335
- ) # pylint: disable=no-member
336
-
337
- if val is not None and val != UNSET_SENTINEL:
338
- m[k] = val
339
- elif val != UNSET_SENTINEL and (
340
- not k in optional_fields or (optional_nullable and is_set)
341
- ):
342
- m[k] = val
386
+ is_nullable_and_explicitly_set = (
387
+ k in nullable_fields
388
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
389
+ )
390
+
391
+ if val != UNSET_SENTINEL:
392
+ if (
393
+ val is not None
394
+ or k not in optional_fields
395
+ or is_nullable_and_explicitly_set
396
+ ):
397
+ m[k] = val
343
398
 
344
399
  return m
345
400
 
@@ -395,6 +450,22 @@ class DeploymentStream2CacheControl(BaseModel):
395
450
  Defaults to `5m`. Only supported by `Anthropic` Claude models.
396
451
  """
397
452
 
453
+ @model_serializer(mode="wrap")
454
+ def serialize_model(self, handler):
455
+ optional_fields = set(["ttl"])
456
+ serialized = handler(self)
457
+ m = {}
458
+
459
+ for n, f in type(self).model_fields.items():
460
+ k = f.alias or n
461
+ val = serialized.get(k)
462
+
463
+ if val != UNSET_SENTINEL:
464
+ if val is not None or k not in optional_fields:
465
+ m[k] = val
466
+
467
+ return m
468
+
398
469
 
399
470
  class DeploymentStream24TypedDict(TypedDict):
400
471
  type: DeploymentStream2Type
@@ -413,6 +484,22 @@ class DeploymentStream24(BaseModel):
413
484
 
414
485
  cache_control: Optional[DeploymentStream2CacheControl] = None
415
486
 
487
+ @model_serializer(mode="wrap")
488
+ def serialize_model(self, handler):
489
+ optional_fields = set(["cache_control"])
490
+ serialized = handler(self)
491
+ m = {}
492
+
493
+ for n, f in type(self).model_fields.items():
494
+ k = f.alias or n
495
+ val = serialized.get(k)
496
+
497
+ if val != UNSET_SENTINEL:
498
+ if val is not None or k not in optional_fields:
499
+ m[k] = val
500
+
501
+ return m
502
+
416
503
 
417
504
  DeploymentStreamContent2TypedDict = TypeAliasType(
418
505
  "DeploymentStreamContent2TypedDict",
@@ -469,6 +556,22 @@ class DeploymentStreamPrefixMessagesUserMessage(BaseModel):
469
556
  name: Optional[str] = None
470
557
  r"""An optional name for the participant. Provides the model information to differentiate between participants of the same role."""
471
558
 
559
+ @model_serializer(mode="wrap")
560
+ def serialize_model(self, handler):
561
+ optional_fields = set(["name"])
562
+ serialized = handler(self)
563
+ m = {}
564
+
565
+ for n, f in type(self).model_fields.items():
566
+ k = f.alias or n
567
+ val = serialized.get(k)
568
+
569
+ if val != UNSET_SENTINEL:
570
+ if val is not None or k not in optional_fields:
571
+ m[k] = val
572
+
573
+ return m
574
+
472
575
 
473
576
  DeploymentStreamPrefixMessagesDeploymentsRole = Literal["developer",]
474
577
  r"""The role of the messages author, in this case `developer`."""
@@ -507,6 +610,22 @@ class DeploymentStreamPrefixMessagesDeveloperMessage(BaseModel):
507
610
  name: Optional[str] = None
508
611
  r"""An optional name for the participant. Provides the model information to differentiate between participants of the same role."""
509
612
 
613
+ @model_serializer(mode="wrap")
614
+ def serialize_model(self, handler):
615
+ optional_fields = set(["name"])
616
+ serialized = handler(self)
617
+ m = {}
618
+
619
+ for n, f in type(self).model_fields.items():
620
+ k = f.alias or n
621
+ val = serialized.get(k)
622
+
623
+ if val != UNSET_SENTINEL:
624
+ if val is not None or k not in optional_fields:
625
+ m[k] = val
626
+
627
+ return m
628
+
510
629
 
511
630
  DeploymentStreamPrefixMessagesRole = Literal["system",]
512
631
  r"""The role of the messages author, in this case `system`."""
@@ -548,6 +667,22 @@ class DeploymentStreamPrefixMessagesSystemMessage(BaseModel):
548
667
  name: Optional[str] = None
549
668
  r"""An optional name for the participant. Provides the model information to differentiate between participants of the same role."""
550
669
 
670
+ @model_serializer(mode="wrap")
671
+ def serialize_model(self, handler):
672
+ optional_fields = set(["name"])
673
+ serialized = handler(self)
674
+ m = {}
675
+
676
+ for n, f in type(self).model_fields.items():
677
+ k = f.alias or n
678
+ val = serialized.get(k)
679
+
680
+ if val != UNSET_SENTINEL:
681
+ if val is not None or k not in optional_fields:
682
+ m[k] = val
683
+
684
+ return m
685
+
551
686
 
552
687
  DeploymentStreamPrefixMessagesTypedDict = TypeAliasType(
553
688
  "DeploymentStreamPrefixMessagesTypedDict",
@@ -645,6 +780,22 @@ class DeploymentStreamMessagesCacheControl(BaseModel):
645
780
  Defaults to `5m`. Only supported by `Anthropic` Claude models.
646
781
  """
647
782
 
783
+ @model_serializer(mode="wrap")
784
+ def serialize_model(self, handler):
785
+ optional_fields = set(["ttl"])
786
+ serialized = handler(self)
787
+ m = {}
788
+
789
+ for n, f in type(self).model_fields.items():
790
+ k = f.alias or n
791
+ val = serialized.get(k)
792
+
793
+ if val != UNSET_SENTINEL:
794
+ if val is not None or k not in optional_fields:
795
+ m[k] = val
796
+
797
+ return m
798
+
648
799
 
649
800
  class DeploymentStreamMessagesToolMessageTypedDict(TypedDict):
650
801
  role: DeploymentStreamMessagesDeploymentsRequestRequestBody5Role
@@ -670,31 +821,26 @@ class DeploymentStreamMessagesToolMessage(BaseModel):
670
821
 
671
822
  @model_serializer(mode="wrap")
672
823
  def serialize_model(self, handler):
673
- optional_fields = ["cache_control"]
674
- nullable_fields = ["tool_call_id"]
675
- null_default_fields = []
676
-
824
+ optional_fields = set(["cache_control"])
825
+ nullable_fields = set(["tool_call_id"])
677
826
  serialized = handler(self)
678
-
679
827
  m = {}
680
828
 
681
829
  for n, f in type(self).model_fields.items():
682
830
  k = f.alias or n
683
831
  val = serialized.get(k)
684
- serialized.pop(k, None)
685
-
686
- optional_nullable = k in optional_fields and k in nullable_fields
687
- is_set = (
688
- self.__pydantic_fields_set__.intersection({n})
689
- or k in null_default_fields
690
- ) # pylint: disable=no-member
691
-
692
- if val is not None and val != UNSET_SENTINEL:
693
- m[k] = val
694
- elif val != UNSET_SENTINEL and (
695
- not k in optional_fields or (optional_nullable and is_set)
696
- ):
697
- m[k] = val
832
+ is_nullable_and_explicitly_set = (
833
+ k in nullable_fields
834
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
835
+ )
836
+
837
+ if val != UNSET_SENTINEL:
838
+ if (
839
+ val is not None
840
+ or k not in optional_fields
841
+ or is_nullable_and_explicitly_set
842
+ ):
843
+ m[k] = val
698
844
 
699
845
  return m
700
846
 
@@ -774,6 +920,22 @@ class DeploymentStreamMessagesFunction(BaseModel):
774
920
  arguments: Optional[str] = None
775
921
  r"""The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."""
776
922
 
923
+ @model_serializer(mode="wrap")
924
+ def serialize_model(self, handler):
925
+ optional_fields = set(["name", "arguments"])
926
+ serialized = handler(self)
927
+ m = {}
928
+
929
+ for n, f in type(self).model_fields.items():
930
+ k = f.alias or n
931
+ val = serialized.get(k)
932
+
933
+ if val != UNSET_SENTINEL:
934
+ if val is not None or k not in optional_fields:
935
+ m[k] = val
936
+
937
+ return m
938
+
777
939
 
778
940
  class DeploymentStreamMessagesToolCallsTypedDict(TypedDict):
779
941
  id: str
@@ -797,6 +959,22 @@ class DeploymentStreamMessagesToolCalls(BaseModel):
797
959
  thought_signature: Optional[str] = None
798
960
  r"""Encrypted representation of the model internal reasoning state during function calling. Required by Gemini 3 models when continuing a conversation after a tool call."""
799
961
 
962
+ @model_serializer(mode="wrap")
963
+ def serialize_model(self, handler):
964
+ optional_fields = set(["thought_signature"])
965
+ serialized = handler(self)
966
+ m = {}
967
+
968
+ for n, f in type(self).model_fields.items():
969
+ k = f.alias or n
970
+ val = serialized.get(k)
971
+
972
+ if val != UNSET_SENTINEL:
973
+ if val is not None or k not in optional_fields:
974
+ m[k] = val
975
+
976
+ return m
977
+
800
978
 
801
979
  class DeploymentStreamMessagesAssistantMessageTypedDict(TypedDict):
802
980
  role: DeploymentStreamMessagesDeploymentsRequestRequestBodyRole
@@ -838,31 +1016,26 @@ class DeploymentStreamMessagesAssistantMessage(BaseModel):
838
1016
 
839
1017
  @model_serializer(mode="wrap")
840
1018
  def serialize_model(self, handler):
841
- optional_fields = ["content", "refusal", "name", "audio", "tool_calls"]
842
- nullable_fields = ["content", "refusal", "audio"]
843
- null_default_fields = []
844
-
1019
+ optional_fields = set(["content", "refusal", "name", "audio", "tool_calls"])
1020
+ nullable_fields = set(["content", "refusal", "audio"])
845
1021
  serialized = handler(self)
846
-
847
1022
  m = {}
848
1023
 
849
1024
  for n, f in type(self).model_fields.items():
850
1025
  k = f.alias or n
851
1026
  val = serialized.get(k)
852
- serialized.pop(k, None)
853
-
854
- optional_nullable = k in optional_fields and k in nullable_fields
855
- is_set = (
856
- self.__pydantic_fields_set__.intersection({n})
857
- or k in null_default_fields
858
- ) # pylint: disable=no-member
859
-
860
- if val is not None and val != UNSET_SENTINEL:
861
- m[k] = val
862
- elif val != UNSET_SENTINEL and (
863
- not k in optional_fields or (optional_nullable and is_set)
864
- ):
865
- m[k] = val
1027
+ is_nullable_and_explicitly_set = (
1028
+ k in nullable_fields
1029
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
1030
+ )
1031
+
1032
+ if val != UNSET_SENTINEL:
1033
+ if (
1034
+ val is not None
1035
+ or k not in optional_fields
1036
+ or is_nullable_and_explicitly_set
1037
+ ):
1038
+ m[k] = val
866
1039
 
867
1040
  return m
868
1041
 
@@ -918,6 +1091,22 @@ class DeploymentStream2DeploymentsCacheControl(BaseModel):
918
1091
  Defaults to `5m`. Only supported by `Anthropic` Claude models.
919
1092
  """
920
1093
 
1094
+ @model_serializer(mode="wrap")
1095
+ def serialize_model(self, handler):
1096
+ optional_fields = set(["ttl"])
1097
+ serialized = handler(self)
1098
+ m = {}
1099
+
1100
+ for n, f in type(self).model_fields.items():
1101
+ k = f.alias or n
1102
+ val = serialized.get(k)
1103
+
1104
+ if val != UNSET_SENTINEL:
1105
+ if val is not None or k not in optional_fields:
1106
+ m[k] = val
1107
+
1108
+ return m
1109
+
921
1110
 
922
1111
  class DeploymentStream2Deployments4TypedDict(TypedDict):
923
1112
  type: DeploymentStream2DeploymentsRequestType
@@ -936,6 +1125,22 @@ class DeploymentStream2Deployments4(BaseModel):
936
1125
 
937
1126
  cache_control: Optional[DeploymentStream2DeploymentsCacheControl] = None
938
1127
 
1128
+ @model_serializer(mode="wrap")
1129
+ def serialize_model(self, handler):
1130
+ optional_fields = set(["cache_control"])
1131
+ serialized = handler(self)
1132
+ m = {}
1133
+
1134
+ for n, f in type(self).model_fields.items():
1135
+ k = f.alias or n
1136
+ val = serialized.get(k)
1137
+
1138
+ if val != UNSET_SENTINEL:
1139
+ if val is not None or k not in optional_fields:
1140
+ m[k] = val
1141
+
1142
+ return m
1143
+
939
1144
 
940
1145
  DeploymentStreamContentDeploymentsRequestRequestBody2TypedDict = TypeAliasType(
941
1146
  "DeploymentStreamContentDeploymentsRequestRequestBody2TypedDict",
@@ -992,6 +1197,22 @@ class DeploymentStreamMessagesUserMessage(BaseModel):
992
1197
  name: Optional[str] = None
993
1198
  r"""An optional name for the participant. Provides the model information to differentiate between participants of the same role."""
994
1199
 
1200
+ @model_serializer(mode="wrap")
1201
+ def serialize_model(self, handler):
1202
+ optional_fields = set(["name"])
1203
+ serialized = handler(self)
1204
+ m = {}
1205
+
1206
+ for n, f in type(self).model_fields.items():
1207
+ k = f.alias or n
1208
+ val = serialized.get(k)
1209
+
1210
+ if val != UNSET_SENTINEL:
1211
+ if val is not None or k not in optional_fields:
1212
+ m[k] = val
1213
+
1214
+ return m
1215
+
995
1216
 
996
1217
  DeploymentStreamMessagesDeploymentsRole = Literal["developer",]
997
1218
  r"""The role of the messages author, in this case `developer`."""
@@ -1030,6 +1251,22 @@ class DeploymentStreamMessagesDeveloperMessage(BaseModel):
1030
1251
  name: Optional[str] = None
1031
1252
  r"""An optional name for the participant. Provides the model information to differentiate between participants of the same role."""
1032
1253
 
1254
+ @model_serializer(mode="wrap")
1255
+ def serialize_model(self, handler):
1256
+ optional_fields = set(["name"])
1257
+ serialized = handler(self)
1258
+ m = {}
1259
+
1260
+ for n, f in type(self).model_fields.items():
1261
+ k = f.alias or n
1262
+ val = serialized.get(k)
1263
+
1264
+ if val != UNSET_SENTINEL:
1265
+ if val is not None or k not in optional_fields:
1266
+ m[k] = val
1267
+
1268
+ return m
1269
+
1033
1270
 
1034
1271
  DeploymentStreamMessagesRole = Literal["system",]
1035
1272
  r"""The role of the messages author, in this case `system`."""
@@ -1071,6 +1308,22 @@ class DeploymentStreamMessagesSystemMessage(BaseModel):
1071
1308
  name: Optional[str] = None
1072
1309
  r"""An optional name for the participant. Provides the model information to differentiate between participants of the same role."""
1073
1310
 
1311
+ @model_serializer(mode="wrap")
1312
+ def serialize_model(self, handler):
1313
+ optional_fields = set(["name"])
1314
+ serialized = handler(self)
1315
+ m = {}
1316
+
1317
+ for n, f in type(self).model_fields.items():
1318
+ k = f.alias or n
1319
+ val = serialized.get(k)
1320
+
1321
+ if val != UNSET_SENTINEL:
1322
+ if val is not None or k not in optional_fields:
1323
+ m[k] = val
1324
+
1325
+ return m
1326
+
1074
1327
 
1075
1328
  DeploymentStreamMessagesTypedDict = TypeAliasType(
1076
1329
  "DeploymentStreamMessagesTypedDict",
@@ -1119,6 +1372,22 @@ class DeploymentStreamMetadata(BaseModel):
1119
1372
  page_number: Optional[float] = None
1120
1373
  r"""The page number the text is from."""
1121
1374
 
1375
+ @model_serializer(mode="wrap")
1376
+ def serialize_model(self, handler):
1377
+ optional_fields = set(["file_name", "file_type", "page_number"])
1378
+ serialized = handler(self)
1379
+ m = {}
1380
+
1381
+ for n, f in type(self).model_fields.items():
1382
+ k = f.alias or n
1383
+ val = serialized.get(k)
1384
+
1385
+ if val != UNSET_SENTINEL:
1386
+ if val is not None or k not in optional_fields:
1387
+ m[k] = val
1388
+
1389
+ return m
1390
+
1122
1391
 
1123
1392
  class DeploymentStreamDocumentsTypedDict(TypedDict):
1124
1393
  text: str
@@ -1134,6 +1403,22 @@ class DeploymentStreamDocuments(BaseModel):
1134
1403
  metadata: Optional[DeploymentStreamMetadata] = None
1135
1404
  r"""Metadata about the document"""
1136
1405
 
1406
+ @model_serializer(mode="wrap")
1407
+ def serialize_model(self, handler):
1408
+ optional_fields = set(["metadata"])
1409
+ serialized = handler(self)
1410
+ m = {}
1411
+
1412
+ for n, f in type(self).model_fields.items():
1413
+ k = f.alias or n
1414
+ val = serialized.get(k)
1415
+
1416
+ if val != UNSET_SENTINEL:
1417
+ if val is not None or k not in optional_fields:
1418
+ m[k] = val
1419
+
1420
+ return m
1421
+
1137
1422
 
1138
1423
  class DeploymentStreamInvokeOptionsTypedDict(TypedDict):
1139
1424
  include_retrievals: NotRequired[bool]
@@ -1154,6 +1439,22 @@ class DeploymentStreamInvokeOptions(BaseModel):
1154
1439
  mock_response: Optional[str] = None
1155
1440
  r"""A mock response to use instead of calling the LLM API. This is useful for testing purposes. When provided, the system will return a response object with this content as the completion, without making an actual API call to the LLM provider. This works for both streaming and non-streaming requests. Mock responses will not generate logs, traces or be counted for your plan usage."""
1156
1441
 
1442
+ @model_serializer(mode="wrap")
1443
+ def serialize_model(self, handler):
1444
+ optional_fields = set(["include_retrievals", "include_usage", "mock_response"])
1445
+ serialized = handler(self)
1446
+ m = {}
1447
+
1448
+ for n, f in type(self).model_fields.items():
1449
+ k = f.alias or n
1450
+ val = serialized.get(k)
1451
+
1452
+ if val != UNSET_SENTINEL:
1453
+ if val is not None or k not in optional_fields:
1454
+ m[k] = val
1455
+
1456
+ return m
1457
+
1157
1458
 
1158
1459
  class DeploymentStreamThreadTypedDict(TypedDict):
1159
1460
  id: str
@@ -1169,6 +1470,22 @@ class DeploymentStreamThread(BaseModel):
1169
1470
  tags: Optional[List[str]] = None
1170
1471
  r"""Optional tags to differentiate or categorize threads"""
1171
1472
 
1473
+ @model_serializer(mode="wrap")
1474
+ def serialize_model(self, handler):
1475
+ optional_fields = set(["tags"])
1476
+ serialized = handler(self)
1477
+ m = {}
1478
+
1479
+ for n, f in type(self).model_fields.items():
1480
+ k = f.alias or n
1481
+ val = serialized.get(k)
1482
+
1483
+ if val != UNSET_SENTINEL:
1484
+ if val is not None or k not in optional_fields:
1485
+ m[k] = val
1486
+
1487
+ return m
1488
+
1172
1489
 
1173
1490
  class DeploymentStreamOrExistsTypedDict(TypedDict):
1174
1491
  r"""Exists"""
@@ -1513,6 +1830,64 @@ class DeploymentStreamAndEq(BaseModel):
1513
1830
  eq: DeploymentStreamAndDeploymentsEq
1514
1831
 
1515
1832
 
1833
+ DeploymentStream1DeploymentsInTypedDict = TypeAliasType(
1834
+ "DeploymentStream1DeploymentsInTypedDict", Union[str, float, bool]
1835
+ )
1836
+
1837
+
1838
+ DeploymentStream1DeploymentsIn = TypeAliasType(
1839
+ "DeploymentStream1DeploymentsIn", Union[str, float, bool]
1840
+ )
1841
+
1842
+
1843
+ class DeploymentStream1InTypedDict(TypedDict):
1844
+ r"""In"""
1845
+
1846
+ in_: List[DeploymentStream1DeploymentsInTypedDict]
1847
+
1848
+
1849
+ class DeploymentStream1In(BaseModel):
1850
+ r"""In"""
1851
+
1852
+ in_: Annotated[List[DeploymentStream1DeploymentsIn], pydantic.Field(alias="in")]
1853
+
1854
+
1855
+ class DeploymentStream1LteTypedDict(TypedDict):
1856
+ r"""Less than or equal to"""
1857
+
1858
+ lte: float
1859
+
1860
+
1861
+ class DeploymentStream1Lte(BaseModel):
1862
+ r"""Less than or equal to"""
1863
+
1864
+ lte: float
1865
+
1866
+
1867
+ class DeploymentStream1LtTypedDict(TypedDict):
1868
+ r"""Less than"""
1869
+
1870
+ lt: float
1871
+
1872
+
1873
+ class DeploymentStream1Lt(BaseModel):
1874
+ r"""Less than"""
1875
+
1876
+ lt: float
1877
+
1878
+
1879
+ class DeploymentStream1GteTypedDict(TypedDict):
1880
+ r"""Greater than or equal to"""
1881
+
1882
+ gte: float
1883
+
1884
+
1885
+ class DeploymentStream1Gte(BaseModel):
1886
+ r"""Greater than or equal to"""
1887
+
1888
+ gte: float
1889
+
1890
+
1516
1891
  DeploymentStreamKnowledgeFilterDeploymentsAndTypedDict = TypeAliasType(
1517
1892
  "DeploymentStreamKnowledgeFilterDeploymentsAndTypedDict",
1518
1893
  Union[
@@ -1594,64 +1969,6 @@ class DeploymentStream1Nin(BaseModel):
1594
1969
  nin: List[DeploymentStream1DeploymentsNin]
1595
1970
 
1596
1971
 
1597
- DeploymentStream1DeploymentsInTypedDict = TypeAliasType(
1598
- "DeploymentStream1DeploymentsInTypedDict", Union[str, float, bool]
1599
- )
1600
-
1601
-
1602
- DeploymentStream1DeploymentsIn = TypeAliasType(
1603
- "DeploymentStream1DeploymentsIn", Union[str, float, bool]
1604
- )
1605
-
1606
-
1607
- class DeploymentStream1InTypedDict(TypedDict):
1608
- r"""In"""
1609
-
1610
- in_: List[DeploymentStream1DeploymentsInTypedDict]
1611
-
1612
-
1613
- class DeploymentStream1In(BaseModel):
1614
- r"""In"""
1615
-
1616
- in_: Annotated[List[DeploymentStream1DeploymentsIn], pydantic.Field(alias="in")]
1617
-
1618
-
1619
- class DeploymentStream1LteTypedDict(TypedDict):
1620
- r"""Less than or equal to"""
1621
-
1622
- lte: float
1623
-
1624
-
1625
- class DeploymentStream1Lte(BaseModel):
1626
- r"""Less than or equal to"""
1627
-
1628
- lte: float
1629
-
1630
-
1631
- class DeploymentStream1LtTypedDict(TypedDict):
1632
- r"""Less than"""
1633
-
1634
- lt: float
1635
-
1636
-
1637
- class DeploymentStream1Lt(BaseModel):
1638
- r"""Less than"""
1639
-
1640
- lt: float
1641
-
1642
-
1643
- class DeploymentStream1GteTypedDict(TypedDict):
1644
- r"""Greater than or equal to"""
1645
-
1646
- gte: float
1647
-
1648
-
1649
- class DeploymentStream1Gte(BaseModel):
1650
- r"""Greater than or equal to"""
1651
-
1652
- gte: float
1653
-
1654
-
1655
1972
  class DeploymentStream1GtTypedDict(TypedDict):
1656
1973
  r"""Greater than"""
1657
1974
 
@@ -1773,6 +2090,8 @@ class DeploymentStreamRequestBodyTypedDict(TypedDict):
1773
2090
  r"""A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment."""
1774
2091
  messages: NotRequired[List[DeploymentStreamMessagesTypedDict]]
1775
2092
  r"""A list of messages to send to the deployment."""
2093
+ identity: NotRequired[PublicIdentityTypedDict]
2094
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
1776
2095
  file_ids: NotRequired[List[str]]
1777
2096
  r"""A list of file IDs that are associated with the deployment request."""
1778
2097
  metadata: NotRequired[Dict[str, Any]]
@@ -1803,6 +2122,9 @@ class DeploymentStreamRequestBody(BaseModel):
1803
2122
  messages: Optional[List[DeploymentStreamMessages]] = None
1804
2123
  r"""A list of messages to send to the deployment."""
1805
2124
 
2125
+ identity: Optional[PublicIdentity] = None
2126
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
2127
+
1806
2128
  file_ids: Optional[List[str]] = None
1807
2129
  r"""A list of file IDs that are associated with the deployment request."""
1808
2130
 
@@ -1822,6 +2144,37 @@ class DeploymentStreamRequestBody(BaseModel):
1822
2144
  knowledge_filter: Optional[DeploymentStreamKnowledgeFilter] = None
1823
2145
  r"""A filter to apply to the knowledge base chunk metadata when using knowledge bases in the deployment."""
1824
2146
 
2147
+ @model_serializer(mode="wrap")
2148
+ def serialize_model(self, handler):
2149
+ optional_fields = set(
2150
+ [
2151
+ "inputs",
2152
+ "context",
2153
+ "prefix_messages",
2154
+ "messages",
2155
+ "identity",
2156
+ "file_ids",
2157
+ "metadata",
2158
+ "extra_params",
2159
+ "documents",
2160
+ "invoke_options",
2161
+ "thread",
2162
+ "knowledge_filter",
2163
+ ]
2164
+ )
2165
+ serialized = handler(self)
2166
+ m = {}
2167
+
2168
+ for n, f in type(self).model_fields.items():
2169
+ k = f.alias or n
2170
+ val = serialized.get(k)
2171
+
2172
+ if val != UNSET_SENTINEL:
2173
+ if val is not None or k not in optional_fields:
2174
+ m[k] = val
2175
+
2176
+ return m
2177
+
1825
2178
 
1826
2179
  DeploymentStreamObject = Literal[
1827
2180
  "chat",
@@ -1897,31 +2250,26 @@ class DeploymentStreamDeploymentsMetadata(BaseModel):
1897
2250
 
1898
2251
  @model_serializer(mode="wrap")
1899
2252
  def serialize_model(self, handler):
1900
- optional_fields = ["rerank_score"]
1901
- nullable_fields = ["page_number"]
1902
- null_default_fields = []
1903
-
2253
+ optional_fields = set(["rerank_score"])
2254
+ nullable_fields = set(["page_number"])
1904
2255
  serialized = handler(self)
1905
-
1906
2256
  m = {}
1907
2257
 
1908
2258
  for n, f in type(self).model_fields.items():
1909
2259
  k = f.alias or n
1910
2260
  val = serialized.get(k)
1911
- serialized.pop(k, None)
1912
-
1913
- optional_nullable = k in optional_fields and k in nullable_fields
1914
- is_set = (
1915
- self.__pydantic_fields_set__.intersection({n})
1916
- or k in null_default_fields
1917
- ) # pylint: disable=no-member
1918
-
1919
- if val is not None and val != UNSET_SENTINEL:
1920
- m[k] = val
1921
- elif val != UNSET_SENTINEL and (
1922
- not k in optional_fields or (optional_nullable and is_set)
1923
- ):
1924
- m[k] = val
2261
+ is_nullable_and_explicitly_set = (
2262
+ k in nullable_fields
2263
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
2264
+ )
2265
+
2266
+ if val != UNSET_SENTINEL:
2267
+ if (
2268
+ val is not None
2269
+ or k not in optional_fields
2270
+ or is_nullable_and_explicitly_set
2271
+ ):
2272
+ m[k] = val
1925
2273
 
1926
2274
  return m
1927
2275
 
@@ -1950,31 +2298,26 @@ class DeploymentStreamPromptTokensDetails(BaseModel):
1950
2298
 
1951
2299
  @model_serializer(mode="wrap")
1952
2300
  def serialize_model(self, handler):
1953
- optional_fields = ["cached_tokens"]
1954
- nullable_fields = ["cached_tokens"]
1955
- null_default_fields = []
1956
-
2301
+ optional_fields = set(["cached_tokens"])
2302
+ nullable_fields = set(["cached_tokens"])
1957
2303
  serialized = handler(self)
1958
-
1959
2304
  m = {}
1960
2305
 
1961
2306
  for n, f in type(self).model_fields.items():
1962
2307
  k = f.alias or n
1963
2308
  val = serialized.get(k)
1964
- serialized.pop(k, None)
1965
-
1966
- optional_nullable = k in optional_fields and k in nullable_fields
1967
- is_set = (
1968
- self.__pydantic_fields_set__.intersection({n})
1969
- or k in null_default_fields
1970
- ) # pylint: disable=no-member
1971
-
1972
- if val is not None and val != UNSET_SENTINEL:
1973
- m[k] = val
1974
- elif val != UNSET_SENTINEL and (
1975
- not k in optional_fields or (optional_nullable and is_set)
1976
- ):
1977
- m[k] = val
2309
+ is_nullable_and_explicitly_set = (
2310
+ k in nullable_fields
2311
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
2312
+ )
2313
+
2314
+ if val != UNSET_SENTINEL:
2315
+ if (
2316
+ val is not None
2317
+ or k not in optional_fields
2318
+ or is_nullable_and_explicitly_set
2319
+ ):
2320
+ m[k] = val
1978
2321
 
1979
2322
  return m
1980
2323
 
@@ -1988,31 +2331,26 @@ class DeploymentStreamCompletionTokensDetails(BaseModel):
1988
2331
 
1989
2332
  @model_serializer(mode="wrap")
1990
2333
  def serialize_model(self, handler):
1991
- optional_fields = ["reasoning_tokens"]
1992
- nullable_fields = ["reasoning_tokens"]
1993
- null_default_fields = []
1994
-
2334
+ optional_fields = set(["reasoning_tokens"])
2335
+ nullable_fields = set(["reasoning_tokens"])
1995
2336
  serialized = handler(self)
1996
-
1997
2337
  m = {}
1998
2338
 
1999
2339
  for n, f in type(self).model_fields.items():
2000
2340
  k = f.alias or n
2001
2341
  val = serialized.get(k)
2002
- serialized.pop(k, None)
2003
-
2004
- optional_nullable = k in optional_fields and k in nullable_fields
2005
- is_set = (
2006
- self.__pydantic_fields_set__.intersection({n})
2007
- or k in null_default_fields
2008
- ) # pylint: disable=no-member
2009
-
2010
- if val is not None and val != UNSET_SENTINEL:
2011
- m[k] = val
2012
- elif val != UNSET_SENTINEL and (
2013
- not k in optional_fields or (optional_nullable and is_set)
2014
- ):
2015
- m[k] = val
2342
+ is_nullable_and_explicitly_set = (
2343
+ k in nullable_fields
2344
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
2345
+ )
2346
+
2347
+ if val != UNSET_SENTINEL:
2348
+ if (
2349
+ val is not None
2350
+ or k not in optional_fields
2351
+ or is_nullable_and_explicitly_set
2352
+ ):
2353
+ m[k] = val
2016
2354
 
2017
2355
  return m
2018
2356
 
@@ -2046,37 +2384,34 @@ class DeploymentStreamUsage(BaseModel):
2046
2384
 
2047
2385
  @model_serializer(mode="wrap")
2048
2386
  def serialize_model(self, handler):
2049
- optional_fields = [
2050
- "total_tokens",
2051
- "prompt_tokens",
2052
- "completion_tokens",
2053
- "prompt_tokens_details",
2054
- "completion_tokens_details",
2055
- ]
2056
- nullable_fields = ["completion_tokens_details"]
2057
- null_default_fields = []
2058
-
2387
+ optional_fields = set(
2388
+ [
2389
+ "total_tokens",
2390
+ "prompt_tokens",
2391
+ "completion_tokens",
2392
+ "prompt_tokens_details",
2393
+ "completion_tokens_details",
2394
+ ]
2395
+ )
2396
+ nullable_fields = set(["completion_tokens_details"])
2059
2397
  serialized = handler(self)
2060
-
2061
2398
  m = {}
2062
2399
 
2063
2400
  for n, f in type(self).model_fields.items():
2064
2401
  k = f.alias or n
2065
2402
  val = serialized.get(k)
2066
- serialized.pop(k, None)
2067
-
2068
- optional_nullable = k in optional_fields and k in nullable_fields
2069
- is_set = (
2070
- self.__pydantic_fields_set__.intersection({n})
2071
- or k in null_default_fields
2072
- ) # pylint: disable=no-member
2073
-
2074
- if val is not None and val != UNSET_SENTINEL:
2075
- m[k] = val
2076
- elif val != UNSET_SENTINEL and (
2077
- not k in optional_fields or (optional_nullable and is_set)
2078
- ):
2079
- m[k] = val
2403
+ is_nullable_and_explicitly_set = (
2404
+ k in nullable_fields
2405
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
2406
+ )
2407
+
2408
+ if val != UNSET_SENTINEL:
2409
+ if (
2410
+ val is not None
2411
+ or k not in optional_fields
2412
+ or is_nullable_and_explicitly_set
2413
+ ):
2414
+ m[k] = val
2080
2415
 
2081
2416
  return m
2082
2417
 
@@ -2161,31 +2496,28 @@ class DeploymentStreamMessage2(BaseModel):
2161
2496
 
2162
2497
  @model_serializer(mode="wrap")
2163
2498
  def serialize_model(self, handler):
2164
- optional_fields = ["reasoning", "reasoning_signature", "redacted_reasoning"]
2165
- nullable_fields = ["content"]
2166
- null_default_fields = []
2167
-
2499
+ optional_fields = set(
2500
+ ["reasoning", "reasoning_signature", "redacted_reasoning"]
2501
+ )
2502
+ nullable_fields = set(["content"])
2168
2503
  serialized = handler(self)
2169
-
2170
2504
  m = {}
2171
2505
 
2172
2506
  for n, f in type(self).model_fields.items():
2173
2507
  k = f.alias or n
2174
2508
  val = serialized.get(k)
2175
- serialized.pop(k, None)
2176
-
2177
- optional_nullable = k in optional_fields and k in nullable_fields
2178
- is_set = (
2179
- self.__pydantic_fields_set__.intersection({n})
2180
- or k in null_default_fields
2181
- ) # pylint: disable=no-member
2182
-
2183
- if val is not None and val != UNSET_SENTINEL:
2184
- m[k] = val
2185
- elif val != UNSET_SENTINEL and (
2186
- not k in optional_fields or (optional_nullable and is_set)
2187
- ):
2188
- m[k] = val
2509
+ is_nullable_and_explicitly_set = (
2510
+ k in nullable_fields
2511
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
2512
+ )
2513
+
2514
+ if val != UNSET_SENTINEL:
2515
+ if (
2516
+ val is not None
2517
+ or k not in optional_fields
2518
+ or is_nullable_and_explicitly_set
2519
+ ):
2520
+ m[k] = val
2189
2521
 
2190
2522
  return m
2191
2523
 
@@ -2238,6 +2570,22 @@ class DeploymentStreamMessageToolCalls(BaseModel):
2238
2570
 
2239
2571
  index: Optional[float] = None
2240
2572
 
2573
+ @model_serializer(mode="wrap")
2574
+ def serialize_model(self, handler):
2575
+ optional_fields = set(["id", "index"])
2576
+ serialized = handler(self)
2577
+ m = {}
2578
+
2579
+ for n, f in type(self).model_fields.items():
2580
+ k = f.alias or n
2581
+ val = serialized.get(k)
2582
+
2583
+ if val != UNSET_SENTINEL:
2584
+ if val is not None or k not in optional_fields:
2585
+ m[k] = val
2586
+
2587
+ return m
2588
+
2241
2589
 
2242
2590
  class DeploymentStreamMessage1TypedDict(TypedDict):
2243
2591
  type: DeploymentStreamMessageType
@@ -2274,36 +2622,28 @@ class DeploymentStreamMessage1(BaseModel):
2274
2622
 
2275
2623
  @model_serializer(mode="wrap")
2276
2624
  def serialize_model(self, handler):
2277
- optional_fields = [
2278
- "content",
2279
- "reasoning",
2280
- "reasoning_signature",
2281
- "redacted_reasoning",
2282
- ]
2283
- nullable_fields = ["content"]
2284
- null_default_fields = []
2285
-
2625
+ optional_fields = set(
2626
+ ["content", "reasoning", "reasoning_signature", "redacted_reasoning"]
2627
+ )
2628
+ nullable_fields = set(["content"])
2286
2629
  serialized = handler(self)
2287
-
2288
2630
  m = {}
2289
2631
 
2290
2632
  for n, f in type(self).model_fields.items():
2291
2633
  k = f.alias or n
2292
2634
  val = serialized.get(k)
2293
- serialized.pop(k, None)
2294
-
2295
- optional_nullable = k in optional_fields and k in nullable_fields
2296
- is_set = (
2297
- self.__pydantic_fields_set__.intersection({n})
2298
- or k in null_default_fields
2299
- ) # pylint: disable=no-member
2300
-
2301
- if val is not None and val != UNSET_SENTINEL:
2302
- m[k] = val
2303
- elif val != UNSET_SENTINEL and (
2304
- not k in optional_fields or (optional_nullable and is_set)
2305
- ):
2306
- m[k] = val
2635
+ is_nullable_and_explicitly_set = (
2636
+ k in nullable_fields
2637
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
2638
+ )
2639
+
2640
+ if val != UNSET_SENTINEL:
2641
+ if (
2642
+ val is not None
2643
+ or k not in optional_fields
2644
+ or is_nullable_and_explicitly_set
2645
+ ):
2646
+ m[k] = val
2307
2647
 
2308
2648
  return m
2309
2649
 
@@ -2343,31 +2683,26 @@ class DeploymentStreamChoices(BaseModel):
2343
2683
 
2344
2684
  @model_serializer(mode="wrap")
2345
2685
  def serialize_model(self, handler):
2346
- optional_fields = ["finish_reason"]
2347
- nullable_fields = ["finish_reason"]
2348
- null_default_fields = []
2349
-
2686
+ optional_fields = set(["finish_reason"])
2687
+ nullable_fields = set(["finish_reason"])
2350
2688
  serialized = handler(self)
2351
-
2352
2689
  m = {}
2353
2690
 
2354
2691
  for n, f in type(self).model_fields.items():
2355
2692
  k = f.alias or n
2356
2693
  val = serialized.get(k)
2357
- serialized.pop(k, None)
2358
-
2359
- optional_nullable = k in optional_fields and k in nullable_fields
2360
- is_set = (
2361
- self.__pydantic_fields_set__.intersection({n})
2362
- or k in null_default_fields
2363
- ) # pylint: disable=no-member
2364
-
2365
- if val is not None and val != UNSET_SENTINEL:
2366
- m[k] = val
2367
- elif val != UNSET_SENTINEL and (
2368
- not k in optional_fields or (optional_nullable and is_set)
2369
- ):
2370
- m[k] = val
2694
+ is_nullable_and_explicitly_set = (
2695
+ k in nullable_fields
2696
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
2697
+ )
2698
+
2699
+ if val != UNSET_SENTINEL:
2700
+ if (
2701
+ val is not None
2702
+ or k not in optional_fields
2703
+ or is_nullable_and_explicitly_set
2704
+ ):
2705
+ m[k] = val
2371
2706
 
2372
2707
  return m
2373
2708
 
@@ -2443,38 +2778,35 @@ class DeploymentStreamData(BaseModel):
2443
2778
 
2444
2779
  @model_serializer(mode="wrap")
2445
2780
  def serialize_model(self, handler):
2446
- optional_fields = [
2447
- "integration_id",
2448
- "finalized",
2449
- "system_fingerprint",
2450
- "retrievals",
2451
- "provider_response",
2452
- "usage",
2453
- ]
2454
- nullable_fields = ["system_fingerprint", "usage"]
2455
- null_default_fields = []
2456
-
2781
+ optional_fields = set(
2782
+ [
2783
+ "integration_id",
2784
+ "finalized",
2785
+ "system_fingerprint",
2786
+ "retrievals",
2787
+ "provider_response",
2788
+ "usage",
2789
+ ]
2790
+ )
2791
+ nullable_fields = set(["system_fingerprint", "usage"])
2457
2792
  serialized = handler(self)
2458
-
2459
2793
  m = {}
2460
2794
 
2461
2795
  for n, f in type(self).model_fields.items():
2462
2796
  k = f.alias or n
2463
2797
  val = serialized.get(k)
2464
- serialized.pop(k, None)
2465
-
2466
- optional_nullable = k in optional_fields and k in nullable_fields
2467
- is_set = (
2468
- self.__pydantic_fields_set__.intersection({n})
2469
- or k in null_default_fields
2470
- ) # pylint: disable=no-member
2471
-
2472
- if val is not None and val != UNSET_SENTINEL:
2473
- m[k] = val
2474
- elif val != UNSET_SENTINEL and (
2475
- not k in optional_fields or (optional_nullable and is_set)
2476
- ):
2477
- m[k] = val
2798
+ is_nullable_and_explicitly_set = (
2799
+ k in nullable_fields
2800
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
2801
+ )
2802
+
2803
+ if val != UNSET_SENTINEL:
2804
+ if (
2805
+ val is not None
2806
+ or k not in optional_fields
2807
+ or is_nullable_and_explicitly_set
2808
+ ):
2809
+ m[k] = val
2478
2810
 
2479
2811
  return m
2480
2812
 
@@ -2489,3 +2821,19 @@ class DeploymentStreamResponseBody(BaseModel):
2489
2821
  r"""Successful operation"""
2490
2822
 
2491
2823
  data: Optional[DeploymentStreamData] = None
2824
+
2825
+ @model_serializer(mode="wrap")
2826
+ def serialize_model(self, handler):
2827
+ optional_fields = set(["data"])
2828
+ serialized = handler(self)
2829
+ m = {}
2830
+
2831
+ for n, f in type(self).model_fields.items():
2832
+ k = f.alias or n
2833
+ val = serialized.get(k)
2834
+
2835
+ if val != UNSET_SENTINEL:
2836
+ if val is not None or k not in optional_fields:
2837
+ m[k] = val
2838
+
2839
+ return m