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,
@@ -98,6 +99,22 @@ class DeploymentGetConfigPrefixMessagesCacheControl(BaseModel):
98
99
  Defaults to `5m`. Only supported by `Anthropic` Claude models.
99
100
  """
100
101
 
102
+ @model_serializer(mode="wrap")
103
+ def serialize_model(self, handler):
104
+ optional_fields = set(["ttl"])
105
+ serialized = handler(self)
106
+ m = {}
107
+
108
+ for n, f in type(self).model_fields.items():
109
+ k = f.alias or n
110
+ val = serialized.get(k)
111
+
112
+ if val != UNSET_SENTINEL:
113
+ if val is not None or k not in optional_fields:
114
+ m[k] = val
115
+
116
+ return m
117
+
101
118
 
102
119
  class PrefixMessagesToolMessageTypedDict(TypedDict):
103
120
  role: DeploymentGetConfigPrefixMessagesDeploymentsRequestRequestBody5Role
@@ -125,31 +142,26 @@ class PrefixMessagesToolMessage(BaseModel):
125
142
 
126
143
  @model_serializer(mode="wrap")
127
144
  def serialize_model(self, handler):
128
- optional_fields = ["cache_control"]
129
- nullable_fields = ["tool_call_id"]
130
- null_default_fields = []
131
-
145
+ optional_fields = set(["cache_control"])
146
+ nullable_fields = set(["tool_call_id"])
132
147
  serialized = handler(self)
133
-
134
148
  m = {}
135
149
 
136
150
  for n, f in type(self).model_fields.items():
137
151
  k = f.alias or n
138
152
  val = serialized.get(k)
139
- serialized.pop(k, None)
140
-
141
- optional_nullable = k in optional_fields and k in nullable_fields
142
- is_set = (
143
- self.__pydantic_fields_set__.intersection({n})
144
- or k in null_default_fields
145
- ) # pylint: disable=no-member
146
-
147
- if val is not None and val != UNSET_SENTINEL:
148
- m[k] = val
149
- elif val != UNSET_SENTINEL and (
150
- not k in optional_fields or (optional_nullable and is_set)
151
- ):
152
- m[k] = val
153
+ is_nullable_and_explicitly_set = (
154
+ k in nullable_fields
155
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
156
+ )
157
+
158
+ if val != UNSET_SENTINEL:
159
+ if (
160
+ val is not None
161
+ or k not in optional_fields
162
+ or is_nullable_and_explicitly_set
163
+ ):
164
+ m[k] = val
153
165
 
154
166
  return m
155
167
 
@@ -228,6 +240,22 @@ class DeploymentGetConfigPrefixMessagesFunction(BaseModel):
228
240
  arguments: Optional[str] = None
229
241
  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."""
230
242
 
243
+ @model_serializer(mode="wrap")
244
+ def serialize_model(self, handler):
245
+ optional_fields = set(["name", "arguments"])
246
+ serialized = handler(self)
247
+ m = {}
248
+
249
+ for n, f in type(self).model_fields.items():
250
+ k = f.alias or n
251
+ val = serialized.get(k)
252
+
253
+ if val != UNSET_SENTINEL:
254
+ if val is not None or k not in optional_fields:
255
+ m[k] = val
256
+
257
+ return m
258
+
231
259
 
232
260
  class PrefixMessagesToolCallsTypedDict(TypedDict):
233
261
  id: str
@@ -251,6 +279,22 @@ class PrefixMessagesToolCalls(BaseModel):
251
279
  thought_signature: Optional[str] = None
252
280
  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."""
253
281
 
282
+ @model_serializer(mode="wrap")
283
+ def serialize_model(self, handler):
284
+ optional_fields = set(["thought_signature"])
285
+ serialized = handler(self)
286
+ m = {}
287
+
288
+ for n, f in type(self).model_fields.items():
289
+ k = f.alias or n
290
+ val = serialized.get(k)
291
+
292
+ if val != UNSET_SENTINEL:
293
+ if val is not None or k not in optional_fields:
294
+ m[k] = val
295
+
296
+ return m
297
+
254
298
 
255
299
  class PrefixMessagesAssistantMessageTypedDict(TypedDict):
256
300
  role: DeploymentGetConfigPrefixMessagesDeploymentsRequestRequestBodyRole
@@ -294,31 +338,26 @@ class PrefixMessagesAssistantMessage(BaseModel):
294
338
 
295
339
  @model_serializer(mode="wrap")
296
340
  def serialize_model(self, handler):
297
- optional_fields = ["content", "refusal", "name", "audio", "tool_calls"]
298
- nullable_fields = ["content", "refusal", "audio"]
299
- null_default_fields = []
300
-
341
+ optional_fields = set(["content", "refusal", "name", "audio", "tool_calls"])
342
+ nullable_fields = set(["content", "refusal", "audio"])
301
343
  serialized = handler(self)
302
-
303
344
  m = {}
304
345
 
305
346
  for n, f in type(self).model_fields.items():
306
347
  k = f.alias or n
307
348
  val = serialized.get(k)
308
- serialized.pop(k, None)
309
-
310
- optional_nullable = k in optional_fields and k in nullable_fields
311
- is_set = (
312
- self.__pydantic_fields_set__.intersection({n})
313
- or k in null_default_fields
314
- ) # pylint: disable=no-member
315
-
316
- if val is not None and val != UNSET_SENTINEL:
317
- m[k] = val
318
- elif val != UNSET_SENTINEL and (
319
- not k in optional_fields or (optional_nullable and is_set)
320
- ):
321
- m[k] = val
349
+ is_nullable_and_explicitly_set = (
350
+ k in nullable_fields
351
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
352
+ )
353
+
354
+ if val != UNSET_SENTINEL:
355
+ if (
356
+ val is not None
357
+ or k not in optional_fields
358
+ or is_nullable_and_explicitly_set
359
+ ):
360
+ m[k] = val
322
361
 
323
362
  return m
324
363
 
@@ -374,6 +413,22 @@ class DeploymentGetConfig2CacheControl(BaseModel):
374
413
  Defaults to `5m`. Only supported by `Anthropic` Claude models.
375
414
  """
376
415
 
416
+ @model_serializer(mode="wrap")
417
+ def serialize_model(self, handler):
418
+ optional_fields = set(["ttl"])
419
+ serialized = handler(self)
420
+ m = {}
421
+
422
+ for n, f in type(self).model_fields.items():
423
+ k = f.alias or n
424
+ val = serialized.get(k)
425
+
426
+ if val != UNSET_SENTINEL:
427
+ if val is not None or k not in optional_fields:
428
+ m[k] = val
429
+
430
+ return m
431
+
377
432
 
378
433
  class DeploymentGetConfig24TypedDict(TypedDict):
379
434
  type: DeploymentGetConfig2Type
@@ -392,6 +447,22 @@ class DeploymentGetConfig24(BaseModel):
392
447
 
393
448
  cache_control: Optional[DeploymentGetConfig2CacheControl] = None
394
449
 
450
+ @model_serializer(mode="wrap")
451
+ def serialize_model(self, handler):
452
+ optional_fields = set(["cache_control"])
453
+ serialized = handler(self)
454
+ m = {}
455
+
456
+ for n, f in type(self).model_fields.items():
457
+ k = f.alias or n
458
+ val = serialized.get(k)
459
+
460
+ if val != UNSET_SENTINEL:
461
+ if val is not None or k not in optional_fields:
462
+ m[k] = val
463
+
464
+ return m
465
+
395
466
 
396
467
  DeploymentGetConfigContent2TypedDict = TypeAliasType(
397
468
  "DeploymentGetConfigContent2TypedDict",
@@ -448,6 +519,22 @@ class PrefixMessagesUserMessage(BaseModel):
448
519
  name: Optional[str] = None
449
520
  r"""An optional name for the participant. Provides the model information to differentiate between participants of the same role."""
450
521
 
522
+ @model_serializer(mode="wrap")
523
+ def serialize_model(self, handler):
524
+ optional_fields = set(["name"])
525
+ serialized = handler(self)
526
+ m = {}
527
+
528
+ for n, f in type(self).model_fields.items():
529
+ k = f.alias or n
530
+ val = serialized.get(k)
531
+
532
+ if val != UNSET_SENTINEL:
533
+ if val is not None or k not in optional_fields:
534
+ m[k] = val
535
+
536
+ return m
537
+
451
538
 
452
539
  DeploymentGetConfigPrefixMessagesDeploymentsRole = Literal["developer",]
453
540
  r"""The role of the messages author, in this case `developer`."""
@@ -486,6 +573,22 @@ class PrefixMessagesDeveloperMessage(BaseModel):
486
573
  name: Optional[str] = None
487
574
  r"""An optional name for the participant. Provides the model information to differentiate between participants of the same role."""
488
575
 
576
+ @model_serializer(mode="wrap")
577
+ def serialize_model(self, handler):
578
+ optional_fields = set(["name"])
579
+ serialized = handler(self)
580
+ m = {}
581
+
582
+ for n, f in type(self).model_fields.items():
583
+ k = f.alias or n
584
+ val = serialized.get(k)
585
+
586
+ if val != UNSET_SENTINEL:
587
+ if val is not None or k not in optional_fields:
588
+ m[k] = val
589
+
590
+ return m
591
+
489
592
 
490
593
  DeploymentGetConfigPrefixMessagesRole = Literal["system",]
491
594
  r"""The role of the messages author, in this case `system`."""
@@ -527,6 +630,22 @@ class PrefixMessagesSystemMessage(BaseModel):
527
630
  name: Optional[str] = None
528
631
  r"""An optional name for the participant. Provides the model information to differentiate between participants of the same role."""
529
632
 
633
+ @model_serializer(mode="wrap")
634
+ def serialize_model(self, handler):
635
+ optional_fields = set(["name"])
636
+ serialized = handler(self)
637
+ m = {}
638
+
639
+ for n, f in type(self).model_fields.items():
640
+ k = f.alias or n
641
+ val = serialized.get(k)
642
+
643
+ if val != UNSET_SENTINEL:
644
+ if val is not None or k not in optional_fields:
645
+ m[k] = val
646
+
647
+ return m
648
+
530
649
 
531
650
  DeploymentGetConfigPrefixMessagesTypedDict = TypeAliasType(
532
651
  "DeploymentGetConfigPrefixMessagesTypedDict",
@@ -628,6 +747,22 @@ class DeploymentGetConfigMessagesCacheControl(BaseModel):
628
747
  Defaults to `5m`. Only supported by `Anthropic` Claude models.
629
748
  """
630
749
 
750
+ @model_serializer(mode="wrap")
751
+ def serialize_model(self, handler):
752
+ optional_fields = set(["ttl"])
753
+ serialized = handler(self)
754
+ m = {}
755
+
756
+ for n, f in type(self).model_fields.items():
757
+ k = f.alias or n
758
+ val = serialized.get(k)
759
+
760
+ if val != UNSET_SENTINEL:
761
+ if val is not None or k not in optional_fields:
762
+ m[k] = val
763
+
764
+ return m
765
+
631
766
 
632
767
  class DeploymentGetConfigMessagesToolMessageTypedDict(TypedDict):
633
768
  role: DeploymentGetConfigMessagesDeploymentsRequestRequestBody5Role
@@ -653,31 +788,26 @@ class DeploymentGetConfigMessagesToolMessage(BaseModel):
653
788
 
654
789
  @model_serializer(mode="wrap")
655
790
  def serialize_model(self, handler):
656
- optional_fields = ["cache_control"]
657
- nullable_fields = ["tool_call_id"]
658
- null_default_fields = []
659
-
791
+ optional_fields = set(["cache_control"])
792
+ nullable_fields = set(["tool_call_id"])
660
793
  serialized = handler(self)
661
-
662
794
  m = {}
663
795
 
664
796
  for n, f in type(self).model_fields.items():
665
797
  k = f.alias or n
666
798
  val = serialized.get(k)
667
- serialized.pop(k, None)
668
-
669
- optional_nullable = k in optional_fields and k in nullable_fields
670
- is_set = (
671
- self.__pydantic_fields_set__.intersection({n})
672
- or k in null_default_fields
673
- ) # pylint: disable=no-member
674
-
675
- if val is not None and val != UNSET_SENTINEL:
676
- m[k] = val
677
- elif val != UNSET_SENTINEL and (
678
- not k in optional_fields or (optional_nullable and is_set)
679
- ):
680
- m[k] = val
799
+ is_nullable_and_explicitly_set = (
800
+ k in nullable_fields
801
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
802
+ )
803
+
804
+ if val != UNSET_SENTINEL:
805
+ if (
806
+ val is not None
807
+ or k not in optional_fields
808
+ or is_nullable_and_explicitly_set
809
+ ):
810
+ m[k] = val
681
811
 
682
812
  return m
683
813
 
@@ -759,6 +889,22 @@ class DeploymentGetConfigMessagesFunction(BaseModel):
759
889
  arguments: Optional[str] = None
760
890
  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."""
761
891
 
892
+ @model_serializer(mode="wrap")
893
+ def serialize_model(self, handler):
894
+ optional_fields = set(["name", "arguments"])
895
+ serialized = handler(self)
896
+ m = {}
897
+
898
+ for n, f in type(self).model_fields.items():
899
+ k = f.alias or n
900
+ val = serialized.get(k)
901
+
902
+ if val != UNSET_SENTINEL:
903
+ if val is not None or k not in optional_fields:
904
+ m[k] = val
905
+
906
+ return m
907
+
762
908
 
763
909
  class DeploymentGetConfigMessagesToolCallsTypedDict(TypedDict):
764
910
  id: str
@@ -782,6 +928,22 @@ class DeploymentGetConfigMessagesToolCalls(BaseModel):
782
928
  thought_signature: Optional[str] = None
783
929
  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."""
784
930
 
931
+ @model_serializer(mode="wrap")
932
+ def serialize_model(self, handler):
933
+ optional_fields = set(["thought_signature"])
934
+ serialized = handler(self)
935
+ m = {}
936
+
937
+ for n, f in type(self).model_fields.items():
938
+ k = f.alias or n
939
+ val = serialized.get(k)
940
+
941
+ if val != UNSET_SENTINEL:
942
+ if val is not None or k not in optional_fields:
943
+ m[k] = val
944
+
945
+ return m
946
+
785
947
 
786
948
  class DeploymentGetConfigMessagesAssistantMessageTypedDict(TypedDict):
787
949
  role: DeploymentGetConfigMessagesDeploymentsRequestRequestBodyRole
@@ -825,31 +987,26 @@ class DeploymentGetConfigMessagesAssistantMessage(BaseModel):
825
987
 
826
988
  @model_serializer(mode="wrap")
827
989
  def serialize_model(self, handler):
828
- optional_fields = ["content", "refusal", "name", "audio", "tool_calls"]
829
- nullable_fields = ["content", "refusal", "audio"]
830
- null_default_fields = []
831
-
990
+ optional_fields = set(["content", "refusal", "name", "audio", "tool_calls"])
991
+ nullable_fields = set(["content", "refusal", "audio"])
832
992
  serialized = handler(self)
833
-
834
993
  m = {}
835
994
 
836
995
  for n, f in type(self).model_fields.items():
837
996
  k = f.alias or n
838
997
  val = serialized.get(k)
839
- serialized.pop(k, None)
840
-
841
- optional_nullable = k in optional_fields and k in nullable_fields
842
- is_set = (
843
- self.__pydantic_fields_set__.intersection({n})
844
- or k in null_default_fields
845
- ) # pylint: disable=no-member
846
-
847
- if val is not None and val != UNSET_SENTINEL:
848
- m[k] = val
849
- elif val != UNSET_SENTINEL and (
850
- not k in optional_fields or (optional_nullable and is_set)
851
- ):
852
- m[k] = val
998
+ is_nullable_and_explicitly_set = (
999
+ k in nullable_fields
1000
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
1001
+ )
1002
+
1003
+ if val != UNSET_SENTINEL:
1004
+ if (
1005
+ val is not None
1006
+ or k not in optional_fields
1007
+ or is_nullable_and_explicitly_set
1008
+ ):
1009
+ m[k] = val
853
1010
 
854
1011
  return m
855
1012
 
@@ -905,6 +1062,22 @@ class DeploymentGetConfig2DeploymentsCacheControl(BaseModel):
905
1062
  Defaults to `5m`. Only supported by `Anthropic` Claude models.
906
1063
  """
907
1064
 
1065
+ @model_serializer(mode="wrap")
1066
+ def serialize_model(self, handler):
1067
+ optional_fields = set(["ttl"])
1068
+ serialized = handler(self)
1069
+ m = {}
1070
+
1071
+ for n, f in type(self).model_fields.items():
1072
+ k = f.alias or n
1073
+ val = serialized.get(k)
1074
+
1075
+ if val != UNSET_SENTINEL:
1076
+ if val is not None or k not in optional_fields:
1077
+ m[k] = val
1078
+
1079
+ return m
1080
+
908
1081
 
909
1082
  class DeploymentGetConfig2Deployments4TypedDict(TypedDict):
910
1083
  type: DeploymentGetConfig2DeploymentsRequestType
@@ -923,6 +1096,22 @@ class DeploymentGetConfig2Deployments4(BaseModel):
923
1096
 
924
1097
  cache_control: Optional[DeploymentGetConfig2DeploymentsCacheControl] = None
925
1098
 
1099
+ @model_serializer(mode="wrap")
1100
+ def serialize_model(self, handler):
1101
+ optional_fields = set(["cache_control"])
1102
+ serialized = handler(self)
1103
+ m = {}
1104
+
1105
+ for n, f in type(self).model_fields.items():
1106
+ k = f.alias or n
1107
+ val = serialized.get(k)
1108
+
1109
+ if val != UNSET_SENTINEL:
1110
+ if val is not None or k not in optional_fields:
1111
+ m[k] = val
1112
+
1113
+ return m
1114
+
926
1115
 
927
1116
  DeploymentGetConfigContentDeploymentsRequestRequestBody2TypedDict = TypeAliasType(
928
1117
  "DeploymentGetConfigContentDeploymentsRequestRequestBody2TypedDict",
@@ -979,6 +1168,22 @@ class DeploymentGetConfigMessagesUserMessage(BaseModel):
979
1168
  name: Optional[str] = None
980
1169
  r"""An optional name for the participant. Provides the model information to differentiate between participants of the same role."""
981
1170
 
1171
+ @model_serializer(mode="wrap")
1172
+ def serialize_model(self, handler):
1173
+ optional_fields = set(["name"])
1174
+ serialized = handler(self)
1175
+ m = {}
1176
+
1177
+ for n, f in type(self).model_fields.items():
1178
+ k = f.alias or n
1179
+ val = serialized.get(k)
1180
+
1181
+ if val != UNSET_SENTINEL:
1182
+ if val is not None or k not in optional_fields:
1183
+ m[k] = val
1184
+
1185
+ return m
1186
+
982
1187
 
983
1188
  DeploymentGetConfigMessagesDeploymentsRole = Literal["developer",]
984
1189
  r"""The role of the messages author, in this case `developer`."""
@@ -1017,6 +1222,22 @@ class DeploymentGetConfigMessagesDeveloperMessage(BaseModel):
1017
1222
  name: Optional[str] = None
1018
1223
  r"""An optional name for the participant. Provides the model information to differentiate between participants of the same role."""
1019
1224
 
1225
+ @model_serializer(mode="wrap")
1226
+ def serialize_model(self, handler):
1227
+ optional_fields = set(["name"])
1228
+ serialized = handler(self)
1229
+ m = {}
1230
+
1231
+ for n, f in type(self).model_fields.items():
1232
+ k = f.alias or n
1233
+ val = serialized.get(k)
1234
+
1235
+ if val != UNSET_SENTINEL:
1236
+ if val is not None or k not in optional_fields:
1237
+ m[k] = val
1238
+
1239
+ return m
1240
+
1020
1241
 
1021
1242
  DeploymentGetConfigMessagesRole = Literal["system",]
1022
1243
  r"""The role of the messages author, in this case `system`."""
@@ -1058,6 +1279,22 @@ class DeploymentGetConfigMessagesSystemMessage(BaseModel):
1058
1279
  name: Optional[str] = None
1059
1280
  r"""An optional name for the participant. Provides the model information to differentiate between participants of the same role."""
1060
1281
 
1282
+ @model_serializer(mode="wrap")
1283
+ def serialize_model(self, handler):
1284
+ optional_fields = set(["name"])
1285
+ serialized = handler(self)
1286
+ m = {}
1287
+
1288
+ for n, f in type(self).model_fields.items():
1289
+ k = f.alias or n
1290
+ val = serialized.get(k)
1291
+
1292
+ if val != UNSET_SENTINEL:
1293
+ if val is not None or k not in optional_fields:
1294
+ m[k] = val
1295
+
1296
+ return m
1297
+
1061
1298
 
1062
1299
  DeploymentGetConfigMessagesTypedDict = TypeAliasType(
1063
1300
  "DeploymentGetConfigMessagesTypedDict",
@@ -1106,6 +1343,22 @@ class DeploymentGetConfigMetadata(BaseModel):
1106
1343
  page_number: Optional[float] = None
1107
1344
  r"""The page number the text is from."""
1108
1345
 
1346
+ @model_serializer(mode="wrap")
1347
+ def serialize_model(self, handler):
1348
+ optional_fields = set(["file_name", "file_type", "page_number"])
1349
+ serialized = handler(self)
1350
+ m = {}
1351
+
1352
+ for n, f in type(self).model_fields.items():
1353
+ k = f.alias or n
1354
+ val = serialized.get(k)
1355
+
1356
+ if val != UNSET_SENTINEL:
1357
+ if val is not None or k not in optional_fields:
1358
+ m[k] = val
1359
+
1360
+ return m
1361
+
1109
1362
 
1110
1363
  class DeploymentGetConfigDocumentsTypedDict(TypedDict):
1111
1364
  text: str
@@ -1121,6 +1374,22 @@ class DeploymentGetConfigDocuments(BaseModel):
1121
1374
  metadata: Optional[DeploymentGetConfigMetadata] = None
1122
1375
  r"""Metadata about the document"""
1123
1376
 
1377
+ @model_serializer(mode="wrap")
1378
+ def serialize_model(self, handler):
1379
+ optional_fields = set(["metadata"])
1380
+ serialized = handler(self)
1381
+ m = {}
1382
+
1383
+ for n, f in type(self).model_fields.items():
1384
+ k = f.alias or n
1385
+ val = serialized.get(k)
1386
+
1387
+ if val != UNSET_SENTINEL:
1388
+ if val is not None or k not in optional_fields:
1389
+ m[k] = val
1390
+
1391
+ return m
1392
+
1124
1393
 
1125
1394
  class DeploymentGetConfigInvokeOptionsTypedDict(TypedDict):
1126
1395
  include_retrievals: NotRequired[bool]
@@ -1141,6 +1410,22 @@ class DeploymentGetConfigInvokeOptions(BaseModel):
1141
1410
  mock_response: Optional[str] = None
1142
1411
  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."""
1143
1412
 
1413
+ @model_serializer(mode="wrap")
1414
+ def serialize_model(self, handler):
1415
+ optional_fields = set(["include_retrievals", "include_usage", "mock_response"])
1416
+ serialized = handler(self)
1417
+ m = {}
1418
+
1419
+ for n, f in type(self).model_fields.items():
1420
+ k = f.alias or n
1421
+ val = serialized.get(k)
1422
+
1423
+ if val != UNSET_SENTINEL:
1424
+ if val is not None or k not in optional_fields:
1425
+ m[k] = val
1426
+
1427
+ return m
1428
+
1144
1429
 
1145
1430
  class DeploymentGetConfigThreadTypedDict(TypedDict):
1146
1431
  id: str
@@ -1156,6 +1441,22 @@ class DeploymentGetConfigThread(BaseModel):
1156
1441
  tags: Optional[List[str]] = None
1157
1442
  r"""Optional tags to differentiate or categorize threads"""
1158
1443
 
1444
+ @model_serializer(mode="wrap")
1445
+ def serialize_model(self, handler):
1446
+ optional_fields = set(["tags"])
1447
+ serialized = handler(self)
1448
+ m = {}
1449
+
1450
+ for n, f in type(self).model_fields.items():
1451
+ k = f.alias or n
1452
+ val = serialized.get(k)
1453
+
1454
+ if val != UNSET_SENTINEL:
1455
+ if val is not None or k not in optional_fields:
1456
+ m[k] = val
1457
+
1458
+ return m
1459
+
1159
1460
 
1160
1461
  class DeploymentGetConfigOrExistsTypedDict(TypedDict):
1161
1462
  r"""Exists"""
@@ -1305,38 +1606,6 @@ class DeploymentGetConfigOrEq(BaseModel):
1305
1606
  eq: DeploymentGetConfigOrDeploymentsEq
1306
1607
 
1307
1608
 
1308
- DeploymentGetConfigKnowledgeFilterDeploymentsOrTypedDict = TypeAliasType(
1309
- "DeploymentGetConfigKnowledgeFilterDeploymentsOrTypedDict",
1310
- Union[
1311
- DeploymentGetConfigOrEqTypedDict,
1312
- DeploymentGetConfigOrNeTypedDict,
1313
- DeploymentGetConfigOrGtTypedDict,
1314
- DeploymentGetConfigOrGteTypedDict,
1315
- DeploymentGetConfigOrLtTypedDict,
1316
- DeploymentGetConfigOrLteTypedDict,
1317
- DeploymentGetConfigOrInTypedDict,
1318
- DeploymentGetConfigOrNinTypedDict,
1319
- DeploymentGetConfigOrExistsTypedDict,
1320
- ],
1321
- )
1322
-
1323
-
1324
- DeploymentGetConfigKnowledgeFilterDeploymentsOr = TypeAliasType(
1325
- "DeploymentGetConfigKnowledgeFilterDeploymentsOr",
1326
- Union[
1327
- DeploymentGetConfigOrEq,
1328
- DeploymentGetConfigOrNe,
1329
- DeploymentGetConfigOrGt,
1330
- DeploymentGetConfigOrGte,
1331
- DeploymentGetConfigOrLt,
1332
- DeploymentGetConfigOrLte,
1333
- DeploymentGetConfigOrIn,
1334
- DeploymentGetConfigOrNin,
1335
- DeploymentGetConfigOrExists,
1336
- ],
1337
- )
1338
-
1339
-
1340
1609
  class DeploymentGetConfigKnowledgeFilterOrTypedDict(TypedDict):
1341
1610
  r"""Or"""
1342
1611
 
@@ -1697,6 +1966,38 @@ class DeploymentGetConfig1Eq(BaseModel):
1697
1966
  eq: DeploymentGetConfig1DeploymentsEq
1698
1967
 
1699
1968
 
1969
+ DeploymentGetConfigKnowledgeFilterDeploymentsOrTypedDict = TypeAliasType(
1970
+ "DeploymentGetConfigKnowledgeFilterDeploymentsOrTypedDict",
1971
+ Union[
1972
+ DeploymentGetConfigOrEqTypedDict,
1973
+ DeploymentGetConfigOrNeTypedDict,
1974
+ DeploymentGetConfigOrGtTypedDict,
1975
+ DeploymentGetConfigOrGteTypedDict,
1976
+ DeploymentGetConfigOrLtTypedDict,
1977
+ DeploymentGetConfigOrLteTypedDict,
1978
+ DeploymentGetConfigOrInTypedDict,
1979
+ DeploymentGetConfigOrNinTypedDict,
1980
+ DeploymentGetConfigOrExistsTypedDict,
1981
+ ],
1982
+ )
1983
+
1984
+
1985
+ DeploymentGetConfigKnowledgeFilterDeploymentsOr = TypeAliasType(
1986
+ "DeploymentGetConfigKnowledgeFilterDeploymentsOr",
1987
+ Union[
1988
+ DeploymentGetConfigOrEq,
1989
+ DeploymentGetConfigOrNe,
1990
+ DeploymentGetConfigOrGt,
1991
+ DeploymentGetConfigOrGte,
1992
+ DeploymentGetConfigOrLt,
1993
+ DeploymentGetConfigOrLte,
1994
+ DeploymentGetConfigOrIn,
1995
+ DeploymentGetConfigOrNin,
1996
+ DeploymentGetConfigOrExists,
1997
+ ],
1998
+ )
1999
+
2000
+
1700
2001
  KnowledgeFilter1TypedDict = TypeAliasType(
1701
2002
  "KnowledgeFilter1TypedDict",
1702
2003
  Union[
@@ -1762,6 +2063,8 @@ class DeploymentGetConfigRequestBodyTypedDict(TypedDict):
1762
2063
  r"""A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment."""
1763
2064
  messages: NotRequired[List[DeploymentGetConfigMessagesTypedDict]]
1764
2065
  r"""A list of messages to send to the deployment."""
2066
+ identity: NotRequired[PublicIdentityTypedDict]
2067
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
1765
2068
  file_ids: NotRequired[List[str]]
1766
2069
  r"""A list of file IDs that are associated with the deployment request."""
1767
2070
  metadata: NotRequired[Dict[str, Any]]
@@ -1792,6 +2095,9 @@ class DeploymentGetConfigRequestBody(BaseModel):
1792
2095
  messages: Optional[List[DeploymentGetConfigMessages]] = None
1793
2096
  r"""A list of messages to send to the deployment."""
1794
2097
 
2098
+ identity: Optional[PublicIdentity] = None
2099
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
2100
+
1795
2101
  file_ids: Optional[List[str]] = None
1796
2102
  r"""A list of file IDs that are associated with the deployment request."""
1797
2103
 
@@ -1811,6 +2117,37 @@ class DeploymentGetConfigRequestBody(BaseModel):
1811
2117
  knowledge_filter: Optional[DeploymentGetConfigKnowledgeFilter] = None
1812
2118
  r"""A filter to apply to the knowledge base chunk metadata when using knowledge bases in the deployment."""
1813
2119
 
2120
+ @model_serializer(mode="wrap")
2121
+ def serialize_model(self, handler):
2122
+ optional_fields = set(
2123
+ [
2124
+ "inputs",
2125
+ "context",
2126
+ "prefix_messages",
2127
+ "messages",
2128
+ "identity",
2129
+ "file_ids",
2130
+ "metadata",
2131
+ "extra_params",
2132
+ "documents",
2133
+ "invoke_options",
2134
+ "thread",
2135
+ "knowledge_filter",
2136
+ ]
2137
+ )
2138
+ serialized = handler(self)
2139
+ m = {}
2140
+
2141
+ for n, f in type(self).model_fields.items():
2142
+ k = f.alias or n
2143
+ val = serialized.get(k)
2144
+
2145
+ if val != UNSET_SENTINEL:
2146
+ if val is not None or k not in optional_fields:
2147
+ m[k] = val
2148
+
2149
+ return m
2150
+
1814
2151
 
1815
2152
  DeploymentGetConfigType = Literal[
1816
2153
  "chat",
@@ -1820,6 +2157,7 @@ DeploymentGetConfigType = Literal[
1820
2157
  "tts",
1821
2158
  "stt",
1822
2159
  "rerank",
2160
+ "ocr",
1823
2161
  "moderation",
1824
2162
  "vision",
1825
2163
  ]
@@ -1867,6 +2205,22 @@ class DeploymentGetConfig2File(BaseModel):
1867
2205
  filename: Optional[str] = None
1868
2206
  r"""The name of the file, used when passing the file to the model as a string."""
1869
2207
 
2208
+ @model_serializer(mode="wrap")
2209
+ def serialize_model(self, handler):
2210
+ optional_fields = set(["file_data", "uri", "mimeType", "filename"])
2211
+ serialized = handler(self)
2212
+ m = {}
2213
+
2214
+ for n, f in type(self).model_fields.items():
2215
+ k = f.alias or n
2216
+ val = serialized.get(k)
2217
+
2218
+ if val != UNSET_SENTINEL:
2219
+ if val is not None or k not in optional_fields:
2220
+ m[k] = val
2221
+
2222
+ return m
2223
+
1870
2224
 
1871
2225
  class DeploymentGetConfig23TypedDict(TypedDict):
1872
2226
  type: DeploymentGetConfig2DeploymentsResponse200ApplicationJSONType
@@ -1903,6 +2257,22 @@ class DeploymentGetConfig2ImageURL(BaseModel):
1903
2257
  detail: Optional[str] = None
1904
2258
  r"""Specifies the detail level of the image. Currently only supported with OpenAI models"""
1905
2259
 
2260
+ @model_serializer(mode="wrap")
2261
+ def serialize_model(self, handler):
2262
+ optional_fields = set(["id", "detail"])
2263
+ serialized = handler(self)
2264
+ m = {}
2265
+
2266
+ for n, f in type(self).model_fields.items():
2267
+ k = f.alias or n
2268
+ val = serialized.get(k)
2269
+
2270
+ if val != UNSET_SENTINEL:
2271
+ if val is not None or k not in optional_fields:
2272
+ m[k] = val
2273
+
2274
+ return m
2275
+
1906
2276
 
1907
2277
  class DeploymentGetConfig22TypedDict(TypedDict):
1908
2278
  r"""The image part of the prompt message. Only supported with vision models."""
@@ -2003,6 +2373,22 @@ class DeploymentGetConfigToolCalls(BaseModel):
2003
2373
 
2004
2374
  index: Optional[float] = None
2005
2375
 
2376
+ @model_serializer(mode="wrap")
2377
+ def serialize_model(self, handler):
2378
+ optional_fields = set(["id", "index"])
2379
+ serialized = handler(self)
2380
+ m = {}
2381
+
2382
+ for n, f in type(self).model_fields.items():
2383
+ k = f.alias or n
2384
+ val = serialized.get(k)
2385
+
2386
+ if val != UNSET_SENTINEL:
2387
+ if val is not None or k not in optional_fields:
2388
+ m[k] = val
2389
+
2390
+ return m
2391
+
2006
2392
 
2007
2393
  class DeploymentGetConfigDeploymentsMessagesTypedDict(TypedDict):
2008
2394
  role: DeploymentGetConfigRole
@@ -2026,31 +2412,26 @@ class DeploymentGetConfigDeploymentsMessages(BaseModel):
2026
2412
 
2027
2413
  @model_serializer(mode="wrap")
2028
2414
  def serialize_model(self, handler):
2029
- optional_fields = ["tool_calls", "tool_call_id"]
2030
- nullable_fields = ["content", "tool_call_id"]
2031
- null_default_fields = []
2032
-
2415
+ optional_fields = set(["tool_calls", "tool_call_id"])
2416
+ nullable_fields = set(["content", "tool_call_id"])
2033
2417
  serialized = handler(self)
2034
-
2035
2418
  m = {}
2036
2419
 
2037
2420
  for n, f in type(self).model_fields.items():
2038
2421
  k = f.alias or n
2039
2422
  val = serialized.get(k)
2040
- serialized.pop(k, None)
2041
-
2042
- optional_nullable = k in optional_fields and k in nullable_fields
2043
- is_set = (
2044
- self.__pydantic_fields_set__.intersection({n})
2045
- or k in null_default_fields
2046
- ) # pylint: disable=no-member
2047
-
2048
- if val is not None and val != UNSET_SENTINEL:
2049
- m[k] = val
2050
- elif val != UNSET_SENTINEL and (
2051
- not k in optional_fields or (optional_nullable and is_set)
2052
- ):
2053
- m[k] = val
2423
+ is_nullable_and_explicitly_set = (
2424
+ k in nullable_fields
2425
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
2426
+ )
2427
+
2428
+ if val != UNSET_SENTINEL:
2429
+ if (
2430
+ val is not None
2431
+ or k not in optional_fields
2432
+ or is_nullable_and_explicitly_set
2433
+ ):
2434
+ m[k] = val
2054
2435
 
2055
2436
  return m
2056
2437
 
@@ -2064,7 +2445,7 @@ DeploymentGetConfigFormat = Literal[
2064
2445
  r"""Only supported on `image` models."""
2065
2446
 
2066
2447
 
2067
- DeploymentGetConfigResponseFormat6 = Literal[
2448
+ ResponseFormat6 = Literal[
2068
2449
  "json",
2069
2450
  "text",
2070
2451
  "srt",
@@ -2073,13 +2454,13 @@ DeploymentGetConfigResponseFormat6 = Literal[
2073
2454
  ]
2074
2455
 
2075
2456
 
2076
- DeploymentGetConfigResponseFormat5 = Literal[
2457
+ ResponseFormat5 = Literal[
2077
2458
  "url",
2078
2459
  "base64_json",
2079
2460
  ]
2080
2461
 
2081
2462
 
2082
- DeploymentGetConfigResponseFormat4 = Literal[
2463
+ ResponseFormat4 = Literal[
2083
2464
  "mp3",
2084
2465
  "opus",
2085
2466
  "aac",
@@ -2092,22 +2473,22 @@ DeploymentGetConfigResponseFormat4 = Literal[
2092
2473
  DeploymentGetConfigResponseFormatDeploymentsType = Literal["text",]
2093
2474
 
2094
2475
 
2095
- class DeploymentGetConfigResponseFormat3TypedDict(TypedDict):
2476
+ class ResponseFormat3TypedDict(TypedDict):
2096
2477
  type: DeploymentGetConfigResponseFormatDeploymentsType
2097
2478
 
2098
2479
 
2099
- class DeploymentGetConfigResponseFormat3(BaseModel):
2480
+ class ResponseFormat3(BaseModel):
2100
2481
  type: DeploymentGetConfigResponseFormatDeploymentsType
2101
2482
 
2102
2483
 
2103
2484
  DeploymentGetConfigResponseFormatType = Literal["json_object",]
2104
2485
 
2105
2486
 
2106
- class DeploymentGetConfigResponseFormat2TypedDict(TypedDict):
2487
+ class ResponseFormat2TypedDict(TypedDict):
2107
2488
  type: DeploymentGetConfigResponseFormatType
2108
2489
 
2109
2490
 
2110
- class DeploymentGetConfigResponseFormat2(BaseModel):
2491
+ class ResponseFormat2(BaseModel):
2111
2492
  type: DeploymentGetConfigResponseFormatType
2112
2493
 
2113
2494
 
@@ -2130,30 +2511,62 @@ class DeploymentGetConfigResponseFormatJSONSchema(BaseModel):
2130
2511
 
2131
2512
  strict: Optional[bool] = None
2132
2513
 
2514
+ @model_serializer(mode="wrap")
2515
+ def serialize_model(self, handler):
2516
+ optional_fields = set(["description", "strict"])
2517
+ serialized = handler(self)
2518
+ m = {}
2519
+
2520
+ for n, f in type(self).model_fields.items():
2521
+ k = f.alias or n
2522
+ val = serialized.get(k)
2523
+
2524
+ if val != UNSET_SENTINEL:
2525
+ if val is not None or k not in optional_fields:
2526
+ m[k] = val
2527
+
2528
+ return m
2133
2529
 
2134
- class DeploymentGetConfigResponseFormat1TypedDict(TypedDict):
2530
+
2531
+ class ResponseFormat1TypedDict(TypedDict):
2135
2532
  type: DeploymentGetConfigResponseFormatDeploymentsResponseType
2136
2533
  json_schema: DeploymentGetConfigResponseFormatJSONSchemaTypedDict
2137
2534
  display_name: NotRequired[str]
2138
2535
 
2139
2536
 
2140
- class DeploymentGetConfigResponseFormat1(BaseModel):
2537
+ class ResponseFormat1(BaseModel):
2141
2538
  type: DeploymentGetConfigResponseFormatDeploymentsResponseType
2142
2539
 
2143
2540
  json_schema: DeploymentGetConfigResponseFormatJSONSchema
2144
2541
 
2145
2542
  display_name: Optional[str] = None
2146
2543
 
2544
+ @model_serializer(mode="wrap")
2545
+ def serialize_model(self, handler):
2546
+ optional_fields = set(["display_name"])
2547
+ serialized = handler(self)
2548
+ m = {}
2549
+
2550
+ for n, f in type(self).model_fields.items():
2551
+ k = f.alias or n
2552
+ val = serialized.get(k)
2553
+
2554
+ if val != UNSET_SENTINEL:
2555
+ if val is not None or k not in optional_fields:
2556
+ m[k] = val
2557
+
2558
+ return m
2559
+
2147
2560
 
2148
2561
  DeploymentGetConfigResponseFormatTypedDict = TypeAliasType(
2149
2562
  "DeploymentGetConfigResponseFormatTypedDict",
2150
2563
  Union[
2151
- DeploymentGetConfigResponseFormat2TypedDict,
2152
- DeploymentGetConfigResponseFormat3TypedDict,
2153
- DeploymentGetConfigResponseFormat1TypedDict,
2154
- DeploymentGetConfigResponseFormat4,
2155
- DeploymentGetConfigResponseFormat5,
2156
- DeploymentGetConfigResponseFormat6,
2564
+ ResponseFormat2TypedDict,
2565
+ ResponseFormat3TypedDict,
2566
+ ResponseFormat1TypedDict,
2567
+ ResponseFormat4,
2568
+ ResponseFormat5,
2569
+ ResponseFormat6,
2157
2570
  ],
2158
2571
  )
2159
2572
  r"""An object specifying the format that the model must output.
@@ -2169,12 +2582,12 @@ Important: when using JSON mode, you must also instruct the model to produce JSO
2169
2582
  DeploymentGetConfigResponseFormat = TypeAliasType(
2170
2583
  "DeploymentGetConfigResponseFormat",
2171
2584
  Union[
2172
- DeploymentGetConfigResponseFormat2,
2173
- DeploymentGetConfigResponseFormat3,
2174
- DeploymentGetConfigResponseFormat1,
2175
- DeploymentGetConfigResponseFormat4,
2176
- DeploymentGetConfigResponseFormat5,
2177
- DeploymentGetConfigResponseFormat6,
2585
+ ResponseFormat2,
2586
+ ResponseFormat3,
2587
+ ResponseFormat1,
2588
+ ResponseFormat4,
2589
+ ResponseFormat5,
2590
+ ResponseFormat6,
2178
2591
  ],
2179
2592
  )
2180
2593
  r"""An object specifying the format that the model must output.
@@ -2187,7 +2600,7 @@ Important: when using JSON mode, you must also instruct the model to produce JSO
2187
2600
  """
2188
2601
 
2189
2602
 
2190
- DeploymentGetConfigPhotoRealVersion = Literal[
2603
+ PhotoRealVersion = Literal[
2191
2604
  "v1",
2192
2605
  "v2",
2193
2606
  ]
@@ -2212,7 +2625,7 @@ DeploymentGetConfigReasoningEffort = Literal[
2212
2625
  r"""Constrains effort on reasoning for reasoning models. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response."""
2213
2626
 
2214
2627
 
2215
- DeploymentGetConfigVerbosity = Literal[
2628
+ Verbosity = Literal[
2216
2629
  "low",
2217
2630
  "medium",
2218
2631
  "high",
@@ -2263,7 +2676,7 @@ class DeploymentGetConfigParametersTypedDict(TypedDict):
2263
2676
 
2264
2677
  Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if finish_reason=\"length\", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.
2265
2678
  """
2266
- photo_real_version: NotRequired[DeploymentGetConfigPhotoRealVersion]
2679
+ photo_real_version: NotRequired[PhotoRealVersion]
2267
2680
  r"""The version of photoReal to use. Must be v1 or v2. Only available for `leonardoai` provider"""
2268
2681
  encoding_format: NotRequired[DeploymentGetConfigEncodingFormat]
2269
2682
  r"""The format to return the embeddings"""
@@ -2271,7 +2684,7 @@ class DeploymentGetConfigParametersTypedDict(TypedDict):
2271
2684
  r"""Constrains effort on reasoning for reasoning models. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response."""
2272
2685
  budget_tokens: NotRequired[float]
2273
2686
  r"""Gives the model enhanced reasoning capabilities for complex tasks. A value of 0 disables thinking. The minimum budget tokens for thinking are 1024. The Budget Tokens should never exceed the Max Tokens parameter. Only supported by `Anthropic`"""
2274
- verbosity: NotRequired[DeploymentGetConfigVerbosity]
2687
+ verbosity: NotRequired[Verbosity]
2275
2688
  r"""Controls the verbosity of the model output."""
2276
2689
  thinking_level: NotRequired[DeploymentGetConfigThinkingLevel]
2277
2690
  r"""The level of thinking to use for the model. Only supported by `Google AI`"""
@@ -2336,8 +2749,7 @@ class DeploymentGetConfigParameters(BaseModel):
2336
2749
  """
2337
2750
 
2338
2751
  photo_real_version: Annotated[
2339
- Optional[DeploymentGetConfigPhotoRealVersion],
2340
- pydantic.Field(alias="photoRealVersion"),
2752
+ Optional[PhotoRealVersion], pydantic.Field(alias="photoRealVersion")
2341
2753
  ] = None
2342
2754
  r"""The version of photoReal to use. Must be v1 or v2. Only available for `leonardoai` provider"""
2343
2755
 
@@ -2355,7 +2767,7 @@ class DeploymentGetConfigParameters(BaseModel):
2355
2767
  )
2356
2768
  r"""Gives the model enhanced reasoning capabilities for complex tasks. A value of 0 disables thinking. The minimum budget tokens for thinking are 1024. The Budget Tokens should never exceed the Max Tokens parameter. Only supported by `Anthropic`"""
2357
2769
 
2358
- verbosity: Optional[DeploymentGetConfigVerbosity] = None
2770
+ verbosity: Optional[Verbosity] = None
2359
2771
  r"""Controls the verbosity of the model output."""
2360
2772
 
2361
2773
  thinking_level: Annotated[
@@ -2366,51 +2778,48 @@ class DeploymentGetConfigParameters(BaseModel):
2366
2778
 
2367
2779
  @model_serializer(mode="wrap")
2368
2780
  def serialize_model(self, handler):
2369
- optional_fields = [
2370
- "temperature",
2371
- "maxTokens",
2372
- "topK",
2373
- "topP",
2374
- "frequencyPenalty",
2375
- "presencePenalty",
2376
- "numImages",
2377
- "seed",
2378
- "format",
2379
- "dimensions",
2380
- "quality",
2381
- "style",
2382
- "responseFormat",
2383
- "photoRealVersion",
2384
- "encoding_format",
2385
- "reasoningEffort",
2386
- "budgetTokens",
2387
- "verbosity",
2388
- "thinkingLevel",
2389
- ]
2390
- nullable_fields = ["responseFormat"]
2391
- null_default_fields = []
2392
-
2781
+ optional_fields = set(
2782
+ [
2783
+ "temperature",
2784
+ "maxTokens",
2785
+ "topK",
2786
+ "topP",
2787
+ "frequencyPenalty",
2788
+ "presencePenalty",
2789
+ "numImages",
2790
+ "seed",
2791
+ "format",
2792
+ "dimensions",
2793
+ "quality",
2794
+ "style",
2795
+ "responseFormat",
2796
+ "photoRealVersion",
2797
+ "encoding_format",
2798
+ "reasoningEffort",
2799
+ "budgetTokens",
2800
+ "verbosity",
2801
+ "thinkingLevel",
2802
+ ]
2803
+ )
2804
+ nullable_fields = set(["responseFormat"])
2393
2805
  serialized = handler(self)
2394
-
2395
2806
  m = {}
2396
2807
 
2397
2808
  for n, f in type(self).model_fields.items():
2398
2809
  k = f.alias or n
2399
2810
  val = serialized.get(k)
2400
- serialized.pop(k, None)
2401
-
2402
- optional_nullable = k in optional_fields and k in nullable_fields
2403
- is_set = (
2404
- self.__pydantic_fields_set__.intersection({n})
2405
- or k in null_default_fields
2406
- ) # pylint: disable=no-member
2407
-
2408
- if val is not None and val != UNSET_SENTINEL:
2409
- m[k] = val
2410
- elif val != UNSET_SENTINEL and (
2411
- not k in optional_fields or (optional_nullable and is_set)
2412
- ):
2413
- m[k] = val
2811
+ is_nullable_and_explicitly_set = (
2812
+ k in nullable_fields
2813
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
2814
+ )
2815
+
2816
+ if val != UNSET_SENTINEL:
2817
+ if (
2818
+ val is not None
2819
+ or k not in optional_fields
2820
+ or is_nullable_and_explicitly_set
2821
+ ):
2822
+ m[k] = val
2414
2823
 
2415
2824
  return m
2416
2825
 
@@ -2444,6 +2853,22 @@ class DeploymentGetConfigFunction(BaseModel):
2444
2853
  Omitting `parameters` defines a function with an empty parameter list.
2445
2854
  """
2446
2855
 
2856
+ @model_serializer(mode="wrap")
2857
+ def serialize_model(self, handler):
2858
+ optional_fields = set(["description", "parameters"])
2859
+ serialized = handler(self)
2860
+ m = {}
2861
+
2862
+ for n, f in type(self).model_fields.items():
2863
+ k = f.alias or n
2864
+ val = serialized.get(k)
2865
+
2866
+ if val != UNSET_SENTINEL:
2867
+ if val is not None or k not in optional_fields:
2868
+ m[k] = val
2869
+
2870
+ return m
2871
+
2447
2872
 
2448
2873
  class DeploymentGetConfigToolsTypedDict(TypedDict):
2449
2874
  type: DeploymentGetConfigDeploymentsType
@@ -2503,3 +2928,19 @@ class DeploymentGetConfigResponseBody(BaseModel):
2503
2928
 
2504
2929
  tools: Optional[List[DeploymentGetConfigTools]] = None
2505
2930
  r"""A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for."""
2931
+
2932
+ @model_serializer(mode="wrap")
2933
+ def serialize_model(self, handler):
2934
+ optional_fields = set(["type", "tools"])
2935
+ serialized = handler(self)
2936
+ m = {}
2937
+
2938
+ for n, f in type(self).model_fields.items():
2939
+ k = f.alias or n
2940
+ val = serialized.get(k)
2941
+
2942
+ if val != UNSET_SENTINEL:
2943
+ if val is not None or k not in optional_fields:
2944
+ m[k] = val
2945
+
2946
+ return m