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
@@ -1,13 +1,17 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from orq_ai_sdk.types import BaseModel
4
+ from orq_ai_sdk.types import BaseModel, UNSET_SENTINEL
5
+ from pydantic import model_serializer
5
6
  from typing import Any, Dict, List, Optional
6
- from typing_extensions import NotRequired, TypedDict
7
+ from typing_extensions import NotRequired, TypedDict, deprecated
7
8
 
8
9
 
10
+ @deprecated(
11
+ "warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
12
+ )
9
13
  class PublicContactTypedDict(TypedDict):
10
- r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
14
+ r"""@deprecated Use identity instead. Information about the contact making the request."""
11
15
 
12
16
  id: str
13
17
  r"""Unique identifier for the contact"""
@@ -23,8 +27,11 @@ class PublicContactTypedDict(TypedDict):
23
27
  r"""A list of tags associated with the contact"""
24
28
 
25
29
 
30
+ @deprecated(
31
+ "warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
32
+ )
26
33
  class PublicContact(BaseModel):
27
- r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
34
+ r"""@deprecated Use identity instead. Information about the contact making the request."""
28
35
 
29
36
  id: str
30
37
  r"""Unique identifier for the contact"""
@@ -43,3 +50,19 @@ class PublicContact(BaseModel):
43
50
 
44
51
  tags: Optional[List[str]] = None
45
52
  r"""A list of tags associated with the contact"""
53
+
54
+ @model_serializer(mode="wrap")
55
+ def serialize_model(self, handler):
56
+ optional_fields = set(["display_name", "email", "metadata", "logo_url", "tags"])
57
+ serialized = handler(self)
58
+ m = {}
59
+
60
+ for n, f in type(self).model_fields.items():
61
+ k = f.alias or n
62
+ val = serialized.get(k)
63
+
64
+ if val != UNSET_SENTINEL:
65
+ if val is not None or k not in optional_fields:
66
+ m[k] = val
67
+
68
+ return m
@@ -0,0 +1,62 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from orq_ai_sdk.types import BaseModel, UNSET_SENTINEL
5
+ from pydantic import model_serializer
6
+ from typing import Any, Dict, List, Optional
7
+ from typing_extensions import NotRequired, TypedDict
8
+
9
+
10
+ class PublicIdentityTypedDict(TypedDict):
11
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
12
+
13
+ id: str
14
+ r"""Unique identifier for the contact"""
15
+ display_name: NotRequired[str]
16
+ r"""Display name of the contact"""
17
+ email: NotRequired[str]
18
+ r"""Email address of the contact"""
19
+ metadata: NotRequired[List[Dict[str, Any]]]
20
+ r"""A hash of key/value pairs containing any other data about the contact"""
21
+ logo_url: NotRequired[str]
22
+ r"""URL to the contact's avatar or logo"""
23
+ tags: NotRequired[List[str]]
24
+ r"""A list of tags associated with the contact"""
25
+
26
+
27
+ class PublicIdentity(BaseModel):
28
+ r"""Information about the identity making the request. If the identity does not exist, it will be created automatically."""
29
+
30
+ id: str
31
+ r"""Unique identifier for the contact"""
32
+
33
+ display_name: Optional[str] = None
34
+ r"""Display name of the contact"""
35
+
36
+ email: Optional[str] = None
37
+ r"""Email address of the contact"""
38
+
39
+ metadata: Optional[List[Dict[str, Any]]] = None
40
+ r"""A hash of key/value pairs containing any other data about the contact"""
41
+
42
+ logo_url: Optional[str] = None
43
+ r"""URL to the contact's avatar or logo"""
44
+
45
+ tags: Optional[List[str]] = None
46
+ r"""A list of tags associated with the contact"""
47
+
48
+ @model_serializer(mode="wrap")
49
+ def serialize_model(self, handler):
50
+ optional_fields = set(["display_name", "email", "metadata", "logo_url", "tags"])
51
+ serialized = handler(self)
52
+ m = {}
53
+
54
+ for n, f in type(self).model_fields.items():
55
+ k = f.alias or n
56
+ val = serialized.get(k)
57
+
58
+ if val != UNSET_SENTINEL:
59
+ if val is not None or k not in optional_fields:
60
+ m[k] = val
61
+
62
+ return m
@@ -1,8 +1,9 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from orq_ai_sdk.types import BaseModel
4
+ from orq_ai_sdk.types import BaseModel, UNSET_SENTINEL
5
5
  import pydantic
6
+ from pydantic import model_serializer
6
7
  from typing import Any, Dict, Literal, Optional
7
8
  from typing_extensions import Annotated, NotRequired, TypedDict
8
9
 
@@ -36,7 +37,7 @@ class ReasoningPart(BaseModel):
36
37
  r"""The reasoning or thought process behind the response. Used for chain-of-thought or extended thinking."""
37
38
 
38
39
  id: Annotated[Optional[str], pydantic.Field(alias="_id")] = (
39
- "reasoning_01kexrj7d0czkmbw9a0wjyr6d4"
40
+ "reasoning_01kftttqrsjfpz1fk19h5qh6zm"
40
41
  )
41
42
  r"""Unique identifier for the part. Format: reasoning_{ulid} (e.g., reasoning_01hxyz...)"""
42
43
 
@@ -45,3 +46,19 @@ class ReasoningPart(BaseModel):
45
46
 
46
47
  signature: Optional[str] = None
47
48
  r"""Optional cryptographic signature to verify the authenticity and integrity of the reasoning content"""
49
+
50
+ @model_serializer(mode="wrap")
51
+ def serialize_model(self, handler):
52
+ optional_fields = set(["_id", "metadata", "signature"])
53
+ serialized = handler(self)
54
+ m = {}
55
+
56
+ for n, f in type(self).model_fields.items():
57
+ k = f.alias or n
58
+ val = serialized.get(k)
59
+
60
+ if val != UNSET_SENTINEL:
61
+ if val is not None or k not in optional_fields:
62
+ m[k] = val
63
+
64
+ return m
@@ -1,7 +1,8 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from orq_ai_sdk.types import BaseModel
4
+ from orq_ai_sdk.types import BaseModel, UNSET_SENTINEL
5
+ from pydantic import model_serializer
5
6
  from typing import Literal, Optional
6
7
  from typing_extensions import NotRequired, TypedDict
7
8
 
@@ -27,3 +28,19 @@ class RefusalPartSchema(BaseModel):
27
28
 
28
29
  refusal: Optional[str] = None
29
30
  r"""The refusal message generated by the model."""
31
+
32
+ @model_serializer(mode="wrap")
33
+ def serialize_model(self, handler):
34
+ optional_fields = set(["refusal"])
35
+ serialized = handler(self)
36
+ m = {}
37
+
38
+ for n, f in type(self).model_fields.items():
39
+ k = f.alias or n
40
+ val = serialized.get(k)
41
+
42
+ if val != UNSET_SENTINEL:
43
+ if val is not None or k not in optional_fields:
44
+ m[k] = val
45
+
46
+ return m
@@ -1,7 +1,8 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from orq_ai_sdk.types import BaseModel
4
+ from orq_ai_sdk.types import BaseModel, UNSET_SENTINEL
5
+ from pydantic import model_serializer
5
6
  from typing import Any, Dict, Literal, Optional
6
7
  from typing_extensions import NotRequired, TypedDict
7
8
 
@@ -25,6 +26,22 @@ class RemoteConfigsGetConfigRequestBody(BaseModel):
25
26
  metadata: Optional[Dict[str, Any]] = None
26
27
  r"""Key-value pairs to attach to the log generated by this request."""
27
28
 
29
+ @model_serializer(mode="wrap")
30
+ def serialize_model(self, handler):
31
+ optional_fields = set(["context", "metadata"])
32
+ serialized = handler(self)
33
+ m = {}
34
+
35
+ for n, f in type(self).model_fields.items():
36
+ k = f.alias or n
37
+ val = serialized.get(k)
38
+
39
+ if val != UNSET_SENTINEL:
40
+ if val is not None or k not in optional_fields:
41
+ m[k] = val
42
+
43
+ return m
44
+
28
45
 
29
46
  RemoteConfigsGetConfigType = Literal[
30
47
  "boolean",
@@ -53,3 +70,19 @@ class RemoteConfigsGetConfigResponseBody(BaseModel):
53
70
  r"""The return type of the rule"""
54
71
 
55
72
  value: Optional[Any] = None
73
+
74
+ @model_serializer(mode="wrap")
75
+ def serialize_model(self, handler):
76
+ optional_fields = set(["value"])
77
+ serialized = handler(self)
78
+ m = {}
79
+
80
+ for n, f in type(self).model_fields.items():
81
+ k = f.alias or n
82
+ val = serialized.get(k)
83
+
84
+ if val != UNSET_SENTINEL:
85
+ if val is not None or k not in optional_fields:
86
+ m[k] = val
87
+
88
+ return m
@@ -17,7 +17,7 @@ from typing_extensions import Annotated, NotRequired, TypedDict
17
17
  ResponseDoneEventType = Literal["response.done",]
18
18
 
19
19
 
20
- FinishReason = Literal[
20
+ ResponseDoneEventFinishReason = Literal[
21
21
  "stop",
22
22
  "length",
23
23
  "tool_calls",
@@ -46,31 +46,30 @@ class ResponseDoneEventPromptTokensDetails(BaseModel):
46
46
 
47
47
  @model_serializer(mode="wrap")
48
48
  def serialize_model(self, handler):
49
- optional_fields = ["cached_tokens", "cache_creation_tokens", "audio_tokens"]
50
- nullable_fields = ["cached_tokens", "cache_creation_tokens", "audio_tokens"]
51
- null_default_fields = []
52
-
49
+ optional_fields = set(
50
+ ["cached_tokens", "cache_creation_tokens", "audio_tokens"]
51
+ )
52
+ nullable_fields = set(
53
+ ["cached_tokens", "cache_creation_tokens", "audio_tokens"]
54
+ )
53
55
  serialized = handler(self)
54
-
55
56
  m = {}
56
57
 
57
58
  for n, f in type(self).model_fields.items():
58
59
  k = f.alias or n
59
60
  val = serialized.get(k)
60
- serialized.pop(k, None)
61
-
62
- optional_nullable = k in optional_fields and k in nullable_fields
63
- is_set = (
64
- self.__pydantic_fields_set__.intersection({n})
65
- or k in null_default_fields
66
- ) # pylint: disable=no-member
67
-
68
- if val is not None and val != UNSET_SENTINEL:
69
- m[k] = val
70
- elif val != UNSET_SENTINEL and (
71
- not k in optional_fields or (optional_nullable and is_set)
72
- ):
73
- m[k] = val
61
+ is_nullable_and_explicitly_set = (
62
+ k in nullable_fields
63
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
64
+ )
65
+
66
+ if val != UNSET_SENTINEL:
67
+ if (
68
+ val is not None
69
+ or k not in optional_fields
70
+ or is_nullable_and_explicitly_set
71
+ ):
72
+ m[k] = val
74
73
 
75
74
  return m
76
75
 
@@ -95,41 +94,40 @@ class ResponseDoneEventCompletionTokensDetails(BaseModel):
95
94
 
96
95
  @model_serializer(mode="wrap")
97
96
  def serialize_model(self, handler):
98
- optional_fields = [
99
- "reasoning_tokens",
100
- "accepted_prediction_tokens",
101
- "rejected_prediction_tokens",
102
- "audio_tokens",
103
- ]
104
- nullable_fields = [
105
- "reasoning_tokens",
106
- "accepted_prediction_tokens",
107
- "rejected_prediction_tokens",
108
- "audio_tokens",
109
- ]
110
- null_default_fields = []
111
-
97
+ optional_fields = set(
98
+ [
99
+ "reasoning_tokens",
100
+ "accepted_prediction_tokens",
101
+ "rejected_prediction_tokens",
102
+ "audio_tokens",
103
+ ]
104
+ )
105
+ nullable_fields = set(
106
+ [
107
+ "reasoning_tokens",
108
+ "accepted_prediction_tokens",
109
+ "rejected_prediction_tokens",
110
+ "audio_tokens",
111
+ ]
112
+ )
112
113
  serialized = handler(self)
113
-
114
114
  m = {}
115
115
 
116
116
  for n, f in type(self).model_fields.items():
117
117
  k = f.alias or n
118
118
  val = serialized.get(k)
119
- serialized.pop(k, None)
120
-
121
- optional_nullable = k in optional_fields and k in nullable_fields
122
- is_set = (
123
- self.__pydantic_fields_set__.intersection({n})
124
- or k in null_default_fields
125
- ) # pylint: disable=no-member
126
-
127
- if val is not None and val != UNSET_SENTINEL:
128
- m[k] = val
129
- elif val != UNSET_SENTINEL and (
130
- not k in optional_fields or (optional_nullable and is_set)
131
- ):
132
- m[k] = val
119
+ is_nullable_and_explicitly_set = (
120
+ k in nullable_fields
121
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
122
+ )
123
+
124
+ if val != UNSET_SENTINEL:
125
+ if (
126
+ val is not None
127
+ or k not in optional_fields
128
+ or is_nullable_and_explicitly_set
129
+ ):
130
+ m[k] = val
133
131
 
134
132
  return m
135
133
 
@@ -173,37 +171,34 @@ class ResponseDoneEventUsage(BaseModel):
173
171
 
174
172
  @model_serializer(mode="wrap")
175
173
  def serialize_model(self, handler):
176
- optional_fields = [
177
- "completion_tokens",
178
- "prompt_tokens",
179
- "total_tokens",
180
- "prompt_tokens_details",
181
- "completion_tokens_details",
182
- ]
183
- nullable_fields = ["prompt_tokens_details", "completion_tokens_details"]
184
- null_default_fields = []
185
-
174
+ optional_fields = set(
175
+ [
176
+ "completion_tokens",
177
+ "prompt_tokens",
178
+ "total_tokens",
179
+ "prompt_tokens_details",
180
+ "completion_tokens_details",
181
+ ]
182
+ )
183
+ nullable_fields = set(["prompt_tokens_details", "completion_tokens_details"])
186
184
  serialized = handler(self)
187
-
188
185
  m = {}
189
186
 
190
187
  for n, f in type(self).model_fields.items():
191
188
  k = f.alias or n
192
189
  val = serialized.get(k)
193
- serialized.pop(k, None)
194
-
195
- optional_nullable = k in optional_fields and k in nullable_fields
196
- is_set = (
197
- self.__pydantic_fields_set__.intersection({n})
198
- or k in null_default_fields
199
- ) # pylint: disable=no-member
200
-
201
- if val is not None and val != UNSET_SENTINEL:
202
- m[k] = val
203
- elif val != UNSET_SENTINEL and (
204
- not k in optional_fields or (optional_nullable and is_set)
205
- ):
206
- 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
207
202
 
208
203
  return m
209
204
 
@@ -211,58 +206,93 @@ class ResponseDoneEventUsage(BaseModel):
211
206
  ResponseDoneEventDataType = Literal["function",]
212
207
 
213
208
 
214
- class FunctionTypedDict(TypedDict):
209
+ class ResponseDoneEventFunctionTypedDict(TypedDict):
215
210
  name: NotRequired[str]
216
211
  r"""The name of the function to call"""
217
212
  arguments: NotRequired[str]
218
213
  r"""The arguments to pass to the function as JSON string"""
219
214
 
220
215
 
221
- class Function(BaseModel):
216
+ class ResponseDoneEventFunction(BaseModel):
222
217
  name: Optional[str] = None
223
218
  r"""The name of the function to call"""
224
219
 
225
220
  arguments: Optional[str] = None
226
221
  r"""The arguments to pass to the function as JSON string"""
227
222
 
223
+ @model_serializer(mode="wrap")
224
+ def serialize_model(self, handler):
225
+ optional_fields = set(["name", "arguments"])
226
+ serialized = handler(self)
227
+ m = {}
228
228
 
229
- class PendingToolCallsTypedDict(TypedDict):
229
+ for n, f in type(self).model_fields.items():
230
+ k = f.alias or n
231
+ val = serialized.get(k)
232
+
233
+ if val != UNSET_SENTINEL:
234
+ if val is not None or k not in optional_fields:
235
+ m[k] = val
236
+
237
+ return m
238
+
239
+
240
+ class ResponseDoneEventPendingToolCallsTypedDict(TypedDict):
230
241
  id: str
231
242
  r"""Unique identifier for the tool call"""
232
243
  type: ResponseDoneEventDataType
233
- function: FunctionTypedDict
244
+ function: ResponseDoneEventFunctionTypedDict
234
245
 
235
246
 
236
- class PendingToolCalls(BaseModel):
247
+ class ResponseDoneEventPendingToolCalls(BaseModel):
237
248
  id: str
238
249
  r"""Unique identifier for the tool call"""
239
250
 
240
251
  type: ResponseDoneEventDataType
241
252
 
242
- function: Function
253
+ function: ResponseDoneEventFunction
243
254
 
244
255
 
245
256
  class ResponseDoneEventDataTypedDict(TypedDict):
246
- finish_reason: FinishReason
257
+ finish_reason: ResponseDoneEventFinishReason
247
258
  r"""The reason why the agent stopped generating"""
248
259
  usage: NotRequired[ResponseDoneEventUsageTypedDict]
249
260
  r"""Token usage statistics for the complete response"""
250
- pending_tool_calls: NotRequired[List[PendingToolCallsTypedDict]]
261
+ pending_tool_calls: NotRequired[List[ResponseDoneEventPendingToolCallsTypedDict]]
251
262
  r"""Tool calls awaiting user response (when finishReason is function_call)"""
252
263
 
253
264
 
254
265
  class ResponseDoneEventData(BaseModel):
255
- finish_reason: Annotated[FinishReason, pydantic.Field(alias="finishReason")]
266
+ finish_reason: Annotated[
267
+ ResponseDoneEventFinishReason, pydantic.Field(alias="finishReason")
268
+ ]
256
269
  r"""The reason why the agent stopped generating"""
257
270
 
258
271
  usage: Optional[ResponseDoneEventUsage] = None
259
272
  r"""Token usage statistics for the complete response"""
260
273
 
261
274
  pending_tool_calls: Annotated[
262
- Optional[List[PendingToolCalls]], pydantic.Field(alias="pendingToolCalls")
275
+ Optional[List[ResponseDoneEventPendingToolCalls]],
276
+ pydantic.Field(alias="pendingToolCalls"),
263
277
  ] = None
264
278
  r"""Tool calls awaiting user response (when finishReason is function_call)"""
265
279
 
280
+ @model_serializer(mode="wrap")
281
+ def serialize_model(self, handler):
282
+ optional_fields = set(["usage", "pendingToolCalls"])
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
+
266
296
 
267
297
  class ResponseDoneEventTypedDict(TypedDict):
268
298
  r"""Emitted when the agent completes processing. Contains the finish reason and usage statistics."""
@@ -1,8 +1,9 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from orq_ai_sdk.types import BaseModel
4
+ from orq_ai_sdk.types import BaseModel, UNSET_SENTINEL
5
5
  import pydantic
6
+ from pydantic import model_serializer
6
7
  from typing import Literal, Optional
7
8
  from typing_extensions import Annotated, NotRequired, TypedDict
8
9
 
@@ -54,6 +55,22 @@ class Data(BaseModel):
54
55
  ] = None
55
56
  r"""Server-generated ID for the assistant message. Use this ID for frontend state consistency."""
56
57
 
58
+ @model_serializer(mode="wrap")
59
+ def serialize_model(self, handler):
60
+ optional_fields = set(["userMessageId", "assistantMessageId"])
61
+ serialized = handler(self)
62
+ m = {}
63
+
64
+ for n, f in type(self).model_fields.items():
65
+ k = f.alias or n
66
+ val = serialized.get(k)
67
+
68
+ if val != UNSET_SENTINEL:
69
+ if val is not None or k not in optional_fields:
70
+ m[k] = val
71
+
72
+ return m
73
+
57
74
 
58
75
  class ResponseStartedEventTypedDict(TypedDict):
59
76
  r"""Emitted when the agent begins processing. Contains identifiers for tracking the response."""