orq-ai-sdk 4.2.0rc28__py3-none-any.whl → 4.2.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. orq_ai_sdk/_hooks/globalhook.py +0 -1
  2. orq_ai_sdk/_version.py +3 -3
  3. orq_ai_sdk/audio.py +30 -0
  4. orq_ai_sdk/basesdk.py +20 -6
  5. orq_ai_sdk/chat.py +22 -0
  6. orq_ai_sdk/completions.py +332 -0
  7. orq_ai_sdk/contacts.py +43 -855
  8. orq_ai_sdk/deployments.py +61 -0
  9. orq_ai_sdk/edits.py +258 -0
  10. orq_ai_sdk/embeddings.py +238 -0
  11. orq_ai_sdk/generations.py +272 -0
  12. orq_ai_sdk/identities.py +1037 -0
  13. orq_ai_sdk/images.py +28 -0
  14. orq_ai_sdk/models/__init__.py +5341 -737
  15. orq_ai_sdk/models/actionreviewedstreamingevent.py +18 -1
  16. orq_ai_sdk/models/actionreviewrequestedstreamingevent.py +44 -1
  17. orq_ai_sdk/models/agenterroredstreamingevent.py +18 -1
  18. orq_ai_sdk/models/agentinactivestreamingevent.py +168 -70
  19. orq_ai_sdk/models/agentmessagecreatedstreamingevent.py +18 -2
  20. orq_ai_sdk/models/agentresponsemessage.py +18 -2
  21. orq_ai_sdk/models/agentstartedstreamingevent.py +127 -2
  22. orq_ai_sdk/models/agentthoughtstreamingevent.py +178 -211
  23. orq_ai_sdk/models/conversationresponse.py +31 -20
  24. orq_ai_sdk/models/conversationwithmessagesresponse.py +31 -20
  25. orq_ai_sdk/models/createagentrequestop.py +1922 -384
  26. orq_ai_sdk/models/createagentresponse.py +147 -91
  27. orq_ai_sdk/models/createagentresponserequestop.py +111 -2
  28. orq_ai_sdk/models/createchatcompletionop.py +1375 -861
  29. orq_ai_sdk/models/createchunkop.py +46 -19
  30. orq_ai_sdk/models/createcompletionop.py +1890 -0
  31. orq_ai_sdk/models/createcontactop.py +45 -56
  32. orq_ai_sdk/models/createconversationop.py +61 -39
  33. orq_ai_sdk/models/createconversationresponseop.py +68 -4
  34. orq_ai_sdk/models/createdatasetitemop.py +424 -80
  35. orq_ai_sdk/models/createdatasetop.py +19 -2
  36. orq_ai_sdk/models/createdatasourceop.py +92 -26
  37. orq_ai_sdk/models/createembeddingop.py +384 -0
  38. orq_ai_sdk/models/createevalop.py +552 -24
  39. orq_ai_sdk/models/createidentityop.py +176 -0
  40. orq_ai_sdk/models/createimageeditop.py +504 -0
  41. orq_ai_sdk/models/createimageop.py +208 -117
  42. orq_ai_sdk/models/createimagevariationop.py +486 -0
  43. orq_ai_sdk/models/createknowledgeop.py +186 -121
  44. orq_ai_sdk/models/creatememorydocumentop.py +50 -1
  45. orq_ai_sdk/models/creatememoryop.py +34 -21
  46. orq_ai_sdk/models/creatememorystoreop.py +34 -1
  47. orq_ai_sdk/models/createmoderationop.py +521 -0
  48. orq_ai_sdk/models/createpromptop.py +2748 -1252
  49. orq_ai_sdk/models/creatererankop.py +416 -0
  50. orq_ai_sdk/models/createresponseop.py +2567 -0
  51. orq_ai_sdk/models/createspeechop.py +316 -0
  52. orq_ai_sdk/models/createtoolop.py +537 -12
  53. orq_ai_sdk/models/createtranscriptionop.py +562 -0
  54. orq_ai_sdk/models/createtranslationop.py +540 -0
  55. orq_ai_sdk/models/datapart.py +18 -1
  56. orq_ai_sdk/models/deletechunksop.py +34 -1
  57. orq_ai_sdk/models/{deletecontactop.py → deleteidentityop.py} +9 -9
  58. orq_ai_sdk/models/deletepromptop.py +26 -0
  59. orq_ai_sdk/models/deploymentcreatemetricop.py +362 -76
  60. orq_ai_sdk/models/deploymentgetconfigop.py +635 -194
  61. orq_ai_sdk/models/deploymentinvokeop.py +168 -173
  62. orq_ai_sdk/models/deploymentsop.py +195 -58
  63. orq_ai_sdk/models/deploymentstreamop.py +652 -304
  64. orq_ai_sdk/models/errorpart.py +18 -1
  65. orq_ai_sdk/models/filecontentpartschema.py +18 -1
  66. orq_ai_sdk/models/filegetop.py +19 -2
  67. orq_ai_sdk/models/filelistop.py +35 -2
  68. orq_ai_sdk/models/filepart.py +50 -1
  69. orq_ai_sdk/models/fileuploadop.py +51 -2
  70. orq_ai_sdk/models/generateconversationnameop.py +31 -20
  71. orq_ai_sdk/models/get_v2_evaluators_id_versionsop.py +34 -1
  72. orq_ai_sdk/models/get_v2_tools_tool_id_versions_version_id_op.py +18 -1
  73. orq_ai_sdk/models/get_v2_tools_tool_id_versionsop.py +34 -1
  74. orq_ai_sdk/models/getallmemoriesop.py +34 -21
  75. orq_ai_sdk/models/getallmemorydocumentsop.py +42 -1
  76. orq_ai_sdk/models/getallmemorystoresop.py +34 -1
  77. orq_ai_sdk/models/getallpromptsop.py +1690 -230
  78. orq_ai_sdk/models/getalltoolsop.py +325 -8
  79. orq_ai_sdk/models/getchunkscountop.py +34 -1
  80. orq_ai_sdk/models/getevalsop.py +395 -43
  81. orq_ai_sdk/models/getonechunkop.py +14 -19
  82. orq_ai_sdk/models/getoneknowledgeop.py +116 -96
  83. orq_ai_sdk/models/getonepromptop.py +1673 -230
  84. orq_ai_sdk/models/getpromptversionop.py +1670 -216
  85. orq_ai_sdk/models/imagecontentpartschema.py +50 -1
  86. orq_ai_sdk/models/internal/globals.py +18 -1
  87. orq_ai_sdk/models/invokeagentop.py +140 -2
  88. orq_ai_sdk/models/invokedeploymentrequest.py +418 -80
  89. orq_ai_sdk/models/invokeevalop.py +160 -131
  90. orq_ai_sdk/models/listagentsop.py +793 -166
  91. orq_ai_sdk/models/listchunksop.py +32 -19
  92. orq_ai_sdk/models/listchunkspaginatedop.py +46 -19
  93. orq_ai_sdk/models/listconversationsop.py +18 -1
  94. orq_ai_sdk/models/listdatasetdatapointsop.py +252 -42
  95. orq_ai_sdk/models/listdatasetsop.py +35 -2
  96. orq_ai_sdk/models/listdatasourcesop.py +35 -26
  97. orq_ai_sdk/models/{listcontactsop.py → listidentitiesop.py} +89 -79
  98. orq_ai_sdk/models/listknowledgebasesop.py +132 -96
  99. orq_ai_sdk/models/listmodelsop.py +1 -0
  100. orq_ai_sdk/models/listpromptversionsop.py +1684 -216
  101. orq_ai_sdk/models/parseop.py +161 -17
  102. orq_ai_sdk/models/partdoneevent.py +19 -2
  103. orq_ai_sdk/models/post_v2_router_ocrop.py +408 -0
  104. orq_ai_sdk/models/publiccontact.py +27 -4
  105. orq_ai_sdk/models/publicidentity.py +62 -0
  106. orq_ai_sdk/models/reasoningpart.py +19 -2
  107. orq_ai_sdk/models/refusalpartschema.py +18 -1
  108. orq_ai_sdk/models/remoteconfigsgetconfigop.py +34 -1
  109. orq_ai_sdk/models/responsedoneevent.py +114 -84
  110. orq_ai_sdk/models/responsestartedevent.py +18 -1
  111. orq_ai_sdk/models/retrieveagentrequestop.py +787 -166
  112. orq_ai_sdk/models/retrievedatapointop.py +236 -42
  113. orq_ai_sdk/models/retrievedatasetop.py +19 -2
  114. orq_ai_sdk/models/retrievedatasourceop.py +17 -26
  115. orq_ai_sdk/models/{retrievecontactop.py → retrieveidentityop.py} +38 -41
  116. orq_ai_sdk/models/retrievememorydocumentop.py +18 -1
  117. orq_ai_sdk/models/retrievememoryop.py +18 -21
  118. orq_ai_sdk/models/retrievememorystoreop.py +18 -1
  119. orq_ai_sdk/models/retrievetoolop.py +309 -8
  120. orq_ai_sdk/models/runagentop.py +1451 -197
  121. orq_ai_sdk/models/searchknowledgeop.py +108 -1
  122. orq_ai_sdk/models/security.py +18 -1
  123. orq_ai_sdk/models/streamagentop.py +93 -2
  124. orq_ai_sdk/models/streamrunagentop.py +1428 -195
  125. orq_ai_sdk/models/textcontentpartschema.py +34 -1
  126. orq_ai_sdk/models/thinkingconfigenabledschema.py +18 -1
  127. orq_ai_sdk/models/toolcallpart.py +18 -1
  128. orq_ai_sdk/models/tooldoneevent.py +18 -1
  129. orq_ai_sdk/models/toolexecutionfailedstreamingevent.py +50 -1
  130. orq_ai_sdk/models/toolexecutionfinishedstreamingevent.py +34 -1
  131. orq_ai_sdk/models/toolexecutionstartedstreamingevent.py +34 -1
  132. orq_ai_sdk/models/toolresultpart.py +18 -1
  133. orq_ai_sdk/models/toolreviewrequestedevent.py +18 -1
  134. orq_ai_sdk/models/toolstartedevent.py +18 -1
  135. orq_ai_sdk/models/updateagentop.py +1951 -404
  136. orq_ai_sdk/models/updatechunkop.py +46 -19
  137. orq_ai_sdk/models/updateconversationop.py +61 -39
  138. orq_ai_sdk/models/updatedatapointop.py +424 -80
  139. orq_ai_sdk/models/updatedatasetop.py +51 -2
  140. orq_ai_sdk/models/updatedatasourceop.py +17 -26
  141. orq_ai_sdk/models/updateevalop.py +577 -16
  142. orq_ai_sdk/models/{updatecontactop.py → updateidentityop.py} +78 -68
  143. orq_ai_sdk/models/updateknowledgeop.py +234 -190
  144. orq_ai_sdk/models/updatememorydocumentop.py +50 -1
  145. orq_ai_sdk/models/updatememoryop.py +50 -21
  146. orq_ai_sdk/models/updatememorystoreop.py +66 -1
  147. orq_ai_sdk/models/updatepromptop.py +2844 -1450
  148. orq_ai_sdk/models/updatetoolop.py +592 -9
  149. orq_ai_sdk/models/usermessagerequest.py +18 -2
  150. orq_ai_sdk/moderations.py +218 -0
  151. orq_ai_sdk/orq_completions.py +660 -0
  152. orq_ai_sdk/orq_responses.py +398 -0
  153. orq_ai_sdk/prompts.py +28 -36
  154. orq_ai_sdk/rerank.py +232 -0
  155. orq_ai_sdk/router.py +89 -641
  156. orq_ai_sdk/sdk.py +3 -0
  157. orq_ai_sdk/speech.py +251 -0
  158. orq_ai_sdk/transcriptions.py +326 -0
  159. orq_ai_sdk/translations.py +298 -0
  160. orq_ai_sdk/utils/__init__.py +13 -1
  161. orq_ai_sdk/variations.py +254 -0
  162. orq_ai_sdk-4.2.6.dist-info/METADATA +888 -0
  163. orq_ai_sdk-4.2.6.dist-info/RECORD +263 -0
  164. {orq_ai_sdk-4.2.0rc28.dist-info → orq_ai_sdk-4.2.6.dist-info}/WHEEL +2 -1
  165. orq_ai_sdk-4.2.6.dist-info/top_level.txt +1 -0
  166. orq_ai_sdk-4.2.0rc28.dist-info/METADATA +0 -867
  167. orq_ai_sdk-4.2.0rc28.dist-info/RECORD +0 -233
@@ -0,0 +1,398 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basesdk import BaseSDK
4
+ from enum import Enum
5
+ from orq_ai_sdk import models, utils
6
+ from orq_ai_sdk._hooks import HookContext
7
+ from orq_ai_sdk.models import createresponseop as models_createresponseop
8
+ from orq_ai_sdk.types import OptionalNullable, UNSET
9
+ from orq_ai_sdk.utils import eventstreaming, get_security_from_env
10
+ from orq_ai_sdk.utils.unmarshal_json_response import unmarshal_json_response
11
+ from typing import Dict, List, Mapping, Optional, Union
12
+
13
+
14
+ class CreateAcceptEnum(str, Enum):
15
+ APPLICATION_JSON = "application/json"
16
+ TEXT_EVENT_STREAM = "text/event-stream"
17
+
18
+
19
+ class OrqResponses(BaseSDK):
20
+ def create(
21
+ self,
22
+ *,
23
+ model: str,
24
+ input_: Union[
25
+ models_createresponseop.CreateResponseInput,
26
+ models_createresponseop.CreateResponseInputTypedDict,
27
+ ],
28
+ metadata: Optional[Dict[str, str]] = None,
29
+ temperature: OptionalNullable[float] = UNSET,
30
+ top_p: OptionalNullable[float] = UNSET,
31
+ previous_response_id: OptionalNullable[str] = UNSET,
32
+ instructions: OptionalNullable[str] = UNSET,
33
+ reasoning: OptionalNullable[
34
+ Union[
35
+ models_createresponseop.Reasoning,
36
+ models_createresponseop.ReasoningTypedDict,
37
+ ]
38
+ ] = UNSET,
39
+ max_output_tokens: OptionalNullable[int] = UNSET,
40
+ text: OptionalNullable[
41
+ Union[
42
+ models_createresponseop.CreateResponseText,
43
+ models_createresponseop.CreateResponseTextTypedDict,
44
+ ]
45
+ ] = UNSET,
46
+ include: OptionalNullable[List[models_createresponseop.Include]] = UNSET,
47
+ parallel_tool_calls: OptionalNullable[bool] = UNSET,
48
+ store: OptionalNullable[bool] = True,
49
+ tools: Optional[
50
+ Union[
51
+ List[models_createresponseop.CreateResponseTools],
52
+ List[models_createresponseop.CreateResponseToolsTypedDict],
53
+ ]
54
+ ] = None,
55
+ tool_choice: Optional[
56
+ Union[
57
+ models_createresponseop.CreateResponseToolChoice,
58
+ models_createresponseop.CreateResponseToolChoiceTypedDict,
59
+ ]
60
+ ] = None,
61
+ stream: Optional[bool] = False,
62
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
63
+ server_url: Optional[str] = None,
64
+ timeout_ms: Optional[int] = None,
65
+ accept_header_override: Optional[CreateAcceptEnum] = None,
66
+ http_headers: Optional[Mapping[str, str]] = None,
67
+ ) -> models.CreateResponseResponse:
68
+ r"""Create response
69
+
70
+ Creates a model response for the given input.
71
+
72
+ :param model: ID of the model to use. You can use the List models API to see all of your available models.
73
+ :param input: The actual user input(s) for the model. Can be a simple string, or an array of structured input items (messages, tool outputs) representing a conversation history or complex input.
74
+ :param metadata: Developer-defined key-value pairs that will be included in response objects
75
+ :param temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
76
+ :param top_p: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
77
+ :param previous_response_id: The ID of a previous response to continue the conversation from. The model will have access to the previous response context.
78
+ :param instructions: Developer-provided instructions that the model should follow. Overwrites the default system message.
79
+ :param reasoning: Configuration for reasoning models
80
+ :param max_output_tokens: The maximum number of tokens that can be generated in the response
81
+ :param text:
82
+ :param include: Specifies which (potentially large) fields to include in the response. By default, the results of Code Interpreter and file searches are excluded. Available options:
83
+ - code_interpreter_call.outputs: Include the outputs of Code Interpreter tool calls
84
+ - computer_call_output.output.image_url: Include the image URLs from computer use tool calls
85
+ - file_search_call.results: Include the results of file search tool calls
86
+ - message.input_image.image_url: Include URLs of input images
87
+ - message.output_text.logprobs: Include log probabilities for output text (when logprobs is enabled)
88
+ - reasoning.encrypted_content: Include encrypted reasoning content for reasoning models
89
+ :param parallel_tool_calls: Whether to enable parallel function calling during tool use.
90
+ :param store: Whether to store this response for use in distillations or evals.
91
+ :param tools: A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for.
92
+ :param tool_choice: How the model should select which tool (or tools) to use when generating a response. Can be a string (`none`, `auto`, `required`) or an object to force a specific tool.
93
+ :param stream:
94
+ :param retries: Override the default retry configuration for this method
95
+ :param server_url: Override the default server URL for this method
96
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
97
+ :param accept_header_override: Override the default accept header for this method
98
+ :param http_headers: Additional headers to set or replace on requests.
99
+ """
100
+ base_url = None
101
+ url_variables = None
102
+ if timeout_ms is None:
103
+ timeout_ms = self.sdk_configuration.timeout_ms
104
+
105
+ if timeout_ms is None:
106
+ timeout_ms = 600000
107
+
108
+ if server_url is not None:
109
+ base_url = server_url
110
+ else:
111
+ base_url = self._get_url(base_url, url_variables)
112
+
113
+ request = models.CreateResponseRequestBody(
114
+ model=model,
115
+ metadata=metadata,
116
+ temperature=temperature,
117
+ top_p=top_p,
118
+ previous_response_id=previous_response_id,
119
+ instructions=instructions,
120
+ reasoning=utils.get_pydantic_model(
121
+ reasoning, OptionalNullable[models.Reasoning]
122
+ ),
123
+ max_output_tokens=max_output_tokens,
124
+ text=utils.get_pydantic_model(
125
+ text, OptionalNullable[models.CreateResponseText]
126
+ ),
127
+ input=utils.get_pydantic_model(input_, models.CreateResponseInput),
128
+ include=include,
129
+ parallel_tool_calls=parallel_tool_calls,
130
+ store=store,
131
+ tools=utils.get_pydantic_model(
132
+ tools, Optional[List[models.CreateResponseTools]]
133
+ ),
134
+ tool_choice=utils.get_pydantic_model(
135
+ tool_choice, Optional[models.CreateResponseToolChoice]
136
+ ),
137
+ stream=stream,
138
+ )
139
+
140
+ req = self._build_request(
141
+ method="POST",
142
+ path="/v2/router/responses",
143
+ base_url=base_url,
144
+ url_variables=url_variables,
145
+ request=request,
146
+ request_body_required=True,
147
+ request_has_path_params=False,
148
+ request_has_query_params=True,
149
+ user_agent_header="user-agent",
150
+ accept_header_value=accept_header_override.value
151
+ if accept_header_override is not None
152
+ else "application/json;q=1, text/event-stream;q=0",
153
+ http_headers=http_headers,
154
+ security=self.sdk_configuration.security,
155
+ get_serialized_body=lambda: utils.serialize_request_body(
156
+ request, False, False, "json", models.CreateResponseRequestBody
157
+ ),
158
+ allow_empty_value=None,
159
+ timeout_ms=timeout_ms,
160
+ )
161
+
162
+ if retries == UNSET:
163
+ if self.sdk_configuration.retry_config is not UNSET:
164
+ retries = self.sdk_configuration.retry_config
165
+
166
+ retry_config = None
167
+ if isinstance(retries, utils.RetryConfig):
168
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
169
+
170
+ http_res = self.do_request(
171
+ hook_ctx=HookContext(
172
+ config=self.sdk_configuration,
173
+ base_url=base_url or "",
174
+ operation_id="createResponse",
175
+ oauth2_scopes=None,
176
+ security_source=get_security_from_env(
177
+ self.sdk_configuration.security, models.Security
178
+ ),
179
+ ),
180
+ request=req,
181
+ error_status_codes=["4XX", "5XX"],
182
+ stream=True,
183
+ retry_config=retry_config,
184
+ )
185
+
186
+ if utils.match_response(http_res, "200", "application/json"):
187
+ http_res_text = utils.stream_to_text(http_res)
188
+ return unmarshal_json_response(
189
+ models.CreateResponseResponseBody, http_res, http_res_text
190
+ )
191
+ if utils.match_response(http_res, "200", "text/event-stream"):
192
+ return eventstreaming.EventStream(
193
+ http_res,
194
+ lambda raw: utils.unmarshal_json(
195
+ raw, models.CreateResponseRouterResponsesResponseBody
196
+ ),
197
+ sentinel="[DONE]",
198
+ client_ref=self,
199
+ )
200
+ if utils.match_response(http_res, "4XX", "*"):
201
+ http_res_text = utils.stream_to_text(http_res)
202
+ raise models.APIError("API error occurred", http_res, http_res_text)
203
+ if utils.match_response(http_res, "5XX", "*"):
204
+ http_res_text = utils.stream_to_text(http_res)
205
+ raise models.APIError("API error occurred", http_res, http_res_text)
206
+
207
+ http_res_text = utils.stream_to_text(http_res)
208
+ raise models.APIError("Unexpected response received", http_res, http_res_text)
209
+
210
+ async def create_async(
211
+ self,
212
+ *,
213
+ model: str,
214
+ input_: Union[
215
+ models_createresponseop.CreateResponseInput,
216
+ models_createresponseop.CreateResponseInputTypedDict,
217
+ ],
218
+ metadata: Optional[Dict[str, str]] = None,
219
+ temperature: OptionalNullable[float] = UNSET,
220
+ top_p: OptionalNullable[float] = UNSET,
221
+ previous_response_id: OptionalNullable[str] = UNSET,
222
+ instructions: OptionalNullable[str] = UNSET,
223
+ reasoning: OptionalNullable[
224
+ Union[
225
+ models_createresponseop.Reasoning,
226
+ models_createresponseop.ReasoningTypedDict,
227
+ ]
228
+ ] = UNSET,
229
+ max_output_tokens: OptionalNullable[int] = UNSET,
230
+ text: OptionalNullable[
231
+ Union[
232
+ models_createresponseop.CreateResponseText,
233
+ models_createresponseop.CreateResponseTextTypedDict,
234
+ ]
235
+ ] = UNSET,
236
+ include: OptionalNullable[List[models_createresponseop.Include]] = UNSET,
237
+ parallel_tool_calls: OptionalNullable[bool] = UNSET,
238
+ store: OptionalNullable[bool] = True,
239
+ tools: Optional[
240
+ Union[
241
+ List[models_createresponseop.CreateResponseTools],
242
+ List[models_createresponseop.CreateResponseToolsTypedDict],
243
+ ]
244
+ ] = None,
245
+ tool_choice: Optional[
246
+ Union[
247
+ models_createresponseop.CreateResponseToolChoice,
248
+ models_createresponseop.CreateResponseToolChoiceTypedDict,
249
+ ]
250
+ ] = None,
251
+ stream: Optional[bool] = False,
252
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
253
+ server_url: Optional[str] = None,
254
+ timeout_ms: Optional[int] = None,
255
+ accept_header_override: Optional[CreateAcceptEnum] = None,
256
+ http_headers: Optional[Mapping[str, str]] = None,
257
+ ) -> models.CreateResponseResponse:
258
+ r"""Create response
259
+
260
+ Creates a model response for the given input.
261
+
262
+ :param model: ID of the model to use. You can use the List models API to see all of your available models.
263
+ :param input: The actual user input(s) for the model. Can be a simple string, or an array of structured input items (messages, tool outputs) representing a conversation history or complex input.
264
+ :param metadata: Developer-defined key-value pairs that will be included in response objects
265
+ :param temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
266
+ :param top_p: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
267
+ :param previous_response_id: The ID of a previous response to continue the conversation from. The model will have access to the previous response context.
268
+ :param instructions: Developer-provided instructions that the model should follow. Overwrites the default system message.
269
+ :param reasoning: Configuration for reasoning models
270
+ :param max_output_tokens: The maximum number of tokens that can be generated in the response
271
+ :param text:
272
+ :param include: Specifies which (potentially large) fields to include in the response. By default, the results of Code Interpreter and file searches are excluded. Available options:
273
+ - code_interpreter_call.outputs: Include the outputs of Code Interpreter tool calls
274
+ - computer_call_output.output.image_url: Include the image URLs from computer use tool calls
275
+ - file_search_call.results: Include the results of file search tool calls
276
+ - message.input_image.image_url: Include URLs of input images
277
+ - message.output_text.logprobs: Include log probabilities for output text (when logprobs is enabled)
278
+ - reasoning.encrypted_content: Include encrypted reasoning content for reasoning models
279
+ :param parallel_tool_calls: Whether to enable parallel function calling during tool use.
280
+ :param store: Whether to store this response for use in distillations or evals.
281
+ :param tools: A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for.
282
+ :param tool_choice: How the model should select which tool (or tools) to use when generating a response. Can be a string (`none`, `auto`, `required`) or an object to force a specific tool.
283
+ :param stream:
284
+ :param retries: Override the default retry configuration for this method
285
+ :param server_url: Override the default server URL for this method
286
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
287
+ :param accept_header_override: Override the default accept header for this method
288
+ :param http_headers: Additional headers to set or replace on requests.
289
+ """
290
+ base_url = None
291
+ url_variables = None
292
+ if timeout_ms is None:
293
+ timeout_ms = self.sdk_configuration.timeout_ms
294
+
295
+ if timeout_ms is None:
296
+ timeout_ms = 600000
297
+
298
+ if server_url is not None:
299
+ base_url = server_url
300
+ else:
301
+ base_url = self._get_url(base_url, url_variables)
302
+
303
+ request = models.CreateResponseRequestBody(
304
+ model=model,
305
+ metadata=metadata,
306
+ temperature=temperature,
307
+ top_p=top_p,
308
+ previous_response_id=previous_response_id,
309
+ instructions=instructions,
310
+ reasoning=utils.get_pydantic_model(
311
+ reasoning, OptionalNullable[models.Reasoning]
312
+ ),
313
+ max_output_tokens=max_output_tokens,
314
+ text=utils.get_pydantic_model(
315
+ text, OptionalNullable[models.CreateResponseText]
316
+ ),
317
+ input=utils.get_pydantic_model(input_, models.CreateResponseInput),
318
+ include=include,
319
+ parallel_tool_calls=parallel_tool_calls,
320
+ store=store,
321
+ tools=utils.get_pydantic_model(
322
+ tools, Optional[List[models.CreateResponseTools]]
323
+ ),
324
+ tool_choice=utils.get_pydantic_model(
325
+ tool_choice, Optional[models.CreateResponseToolChoice]
326
+ ),
327
+ stream=stream,
328
+ )
329
+
330
+ req = self._build_request_async(
331
+ method="POST",
332
+ path="/v2/router/responses",
333
+ base_url=base_url,
334
+ url_variables=url_variables,
335
+ request=request,
336
+ request_body_required=True,
337
+ request_has_path_params=False,
338
+ request_has_query_params=True,
339
+ user_agent_header="user-agent",
340
+ accept_header_value=accept_header_override.value
341
+ if accept_header_override is not None
342
+ else "application/json;q=1, text/event-stream;q=0",
343
+ http_headers=http_headers,
344
+ security=self.sdk_configuration.security,
345
+ get_serialized_body=lambda: utils.serialize_request_body(
346
+ request, False, False, "json", models.CreateResponseRequestBody
347
+ ),
348
+ allow_empty_value=None,
349
+ timeout_ms=timeout_ms,
350
+ )
351
+
352
+ if retries == UNSET:
353
+ if self.sdk_configuration.retry_config is not UNSET:
354
+ retries = self.sdk_configuration.retry_config
355
+
356
+ retry_config = None
357
+ if isinstance(retries, utils.RetryConfig):
358
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
359
+
360
+ http_res = await self.do_request_async(
361
+ hook_ctx=HookContext(
362
+ config=self.sdk_configuration,
363
+ base_url=base_url or "",
364
+ operation_id="createResponse",
365
+ oauth2_scopes=None,
366
+ security_source=get_security_from_env(
367
+ self.sdk_configuration.security, models.Security
368
+ ),
369
+ ),
370
+ request=req,
371
+ error_status_codes=["4XX", "5XX"],
372
+ stream=True,
373
+ retry_config=retry_config,
374
+ )
375
+
376
+ if utils.match_response(http_res, "200", "application/json"):
377
+ http_res_text = await utils.stream_to_text_async(http_res)
378
+ return unmarshal_json_response(
379
+ models.CreateResponseResponseBody, http_res, http_res_text
380
+ )
381
+ if utils.match_response(http_res, "200", "text/event-stream"):
382
+ return eventstreaming.EventStreamAsync(
383
+ http_res,
384
+ lambda raw: utils.unmarshal_json(
385
+ raw, models.CreateResponseRouterResponsesResponseBody
386
+ ),
387
+ sentinel="[DONE]",
388
+ client_ref=self,
389
+ )
390
+ if utils.match_response(http_res, "4XX", "*"):
391
+ http_res_text = await utils.stream_to_text_async(http_res)
392
+ raise models.APIError("API error occurred", http_res, http_res_text)
393
+ if utils.match_response(http_res, "5XX", "*"):
394
+ http_res_text = await utils.stream_to_text_async(http_res)
395
+ raise models.APIError("API error occurred", http_res, http_res_text)
396
+
397
+ http_res_text = await utils.stream_to_text_async(http_res)
398
+ raise models.APIError("Unexpected response received", http_res, http_res_text)
orq_ai_sdk/prompts.py CHANGED
@@ -572,10 +572,10 @@ class Prompts(BaseSDK):
572
572
  updated_by_id: OptionalNullable[str] = UNSET,
573
573
  display_name: Optional[str] = None,
574
574
  description: OptionalNullable[str] = UNSET,
575
- prompt_config: Optional[
575
+ prompt: Optional[
576
576
  Union[
577
- models_updatepromptop.PromptConfig,
578
- models_updatepromptop.PromptConfigTypedDict,
577
+ models_updatepromptop.UpdatePromptPromptInput,
578
+ models_updatepromptop.UpdatePromptPromptInputTypedDict,
579
579
  ]
580
580
  ] = None,
581
581
  metadata: Optional[
@@ -585,12 +585,6 @@ class Prompts(BaseSDK):
585
585
  ]
586
586
  ] = None,
587
587
  path: Optional[str] = None,
588
- prompt: Optional[
589
- Union[
590
- models_updatepromptop.UpdatePromptPromptInput,
591
- models_updatepromptop.UpdatePromptPromptInputTypedDict,
592
- ]
593
- ] = None,
594
588
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
595
589
  server_url: Optional[str] = None,
596
590
  timeout_ms: Optional[int] = None,
@@ -607,14 +601,13 @@ class Prompts(BaseSDK):
607
601
  :param updated_by_id:
608
602
  :param display_name: The prompt’s name, meant to be displayable in the UI.
609
603
  :param description: The prompt’s description, meant to be displayable in the UI. Use this field to optionally store a long form explanation of the prompt for your own purpose
610
- :param prompt_config: [DEPRECATED]. Please use the `prompt` property instead.
604
+ :param prompt: Prompt configuration with model and messages. Use this to update the prompt.
611
605
  :param metadata:
612
606
  :param path: Entity storage path in the format: `project/folder/subfolder/...`
613
607
 
614
608
  The first element identifies the project, followed by nested folders (auto-created as needed).
615
609
 
616
610
  With project-based API keys, the first element is treated as a folder name, as the project is predetermined by the API key.
617
- :param prompt: Prompt configuration with model and messages. Use this to update the prompt.
618
611
  :param retries: Override the default retry configuration for this method
619
612
  :param server_url: Override the default server URL for this method
620
613
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -644,16 +637,13 @@ class Prompts(BaseSDK):
644
637
  updated_by_id=updated_by_id,
645
638
  display_name=display_name,
646
639
  description=description,
647
- prompt_config=utils.get_pydantic_model(
648
- prompt_config, Optional[models.PromptConfig]
640
+ prompt=utils.get_pydantic_model(
641
+ prompt, Optional[models.UpdatePromptPromptInput]
649
642
  ),
650
643
  metadata=utils.get_pydantic_model(
651
644
  metadata, Optional[models.UpdatePromptMetadata]
652
645
  ),
653
646
  path=path,
654
- prompt=utils.get_pydantic_model(
655
- prompt, Optional[models.UpdatePromptPromptInput]
656
- ),
657
647
  ),
658
648
  )
659
649
 
@@ -733,10 +723,10 @@ class Prompts(BaseSDK):
733
723
  updated_by_id: OptionalNullable[str] = UNSET,
734
724
  display_name: Optional[str] = None,
735
725
  description: OptionalNullable[str] = UNSET,
736
- prompt_config: Optional[
726
+ prompt: Optional[
737
727
  Union[
738
- models_updatepromptop.PromptConfig,
739
- models_updatepromptop.PromptConfigTypedDict,
728
+ models_updatepromptop.UpdatePromptPromptInput,
729
+ models_updatepromptop.UpdatePromptPromptInputTypedDict,
740
730
  ]
741
731
  ] = None,
742
732
  metadata: Optional[
@@ -746,12 +736,6 @@ class Prompts(BaseSDK):
746
736
  ]
747
737
  ] = None,
748
738
  path: Optional[str] = None,
749
- prompt: Optional[
750
- Union[
751
- models_updatepromptop.UpdatePromptPromptInput,
752
- models_updatepromptop.UpdatePromptPromptInputTypedDict,
753
- ]
754
- ] = None,
755
739
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
756
740
  server_url: Optional[str] = None,
757
741
  timeout_ms: Optional[int] = None,
@@ -768,14 +752,13 @@ class Prompts(BaseSDK):
768
752
  :param updated_by_id:
769
753
  :param display_name: The prompt’s name, meant to be displayable in the UI.
770
754
  :param description: The prompt’s description, meant to be displayable in the UI. Use this field to optionally store a long form explanation of the prompt for your own purpose
771
- :param prompt_config: [DEPRECATED]. Please use the `prompt` property instead.
755
+ :param prompt: Prompt configuration with model and messages. Use this to update the prompt.
772
756
  :param metadata:
773
757
  :param path: Entity storage path in the format: `project/folder/subfolder/...`
774
758
 
775
759
  The first element identifies the project, followed by nested folders (auto-created as needed).
776
760
 
777
761
  With project-based API keys, the first element is treated as a folder name, as the project is predetermined by the API key.
778
- :param prompt: Prompt configuration with model and messages. Use this to update the prompt.
779
762
  :param retries: Override the default retry configuration for this method
780
763
  :param server_url: Override the default server URL for this method
781
764
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -805,16 +788,13 @@ class Prompts(BaseSDK):
805
788
  updated_by_id=updated_by_id,
806
789
  display_name=display_name,
807
790
  description=description,
808
- prompt_config=utils.get_pydantic_model(
809
- prompt_config, Optional[models.PromptConfig]
791
+ prompt=utils.get_pydantic_model(
792
+ prompt, Optional[models.UpdatePromptPromptInput]
810
793
  ),
811
794
  metadata=utils.get_pydantic_model(
812
795
  metadata, Optional[models.UpdatePromptMetadata]
813
796
  ),
814
797
  path=path,
815
- prompt=utils.get_pydantic_model(
816
- prompt, Optional[models.UpdatePromptPromptInput]
817
- ),
818
798
  ),
819
799
  )
820
800
 
@@ -926,7 +906,7 @@ class Prompts(BaseSDK):
926
906
  request_has_path_params=True,
927
907
  request_has_query_params=True,
928
908
  user_agent_header="user-agent",
929
- accept_header_value="*/*",
909
+ accept_header_value="application/json",
930
910
  http_headers=http_headers,
931
911
  security=self.sdk_configuration.security,
932
912
  allow_empty_value=None,
@@ -952,12 +932,18 @@ class Prompts(BaseSDK):
952
932
  ),
953
933
  ),
954
934
  request=req,
955
- error_status_codes=["4XX", "5XX"],
935
+ error_status_codes=["404", "4XX", "5XX"],
956
936
  retry_config=retry_config,
957
937
  )
958
938
 
939
+ response_data: Any = None
959
940
  if utils.match_response(http_res, "200", "*"):
960
941
  return
942
+ if utils.match_response(http_res, "404", "application/json"):
943
+ response_data = unmarshal_json_response(
944
+ models.DeletePromptResponseBodyData, http_res
945
+ )
946
+ raise models.DeletePromptResponseBody(response_data, http_res)
961
947
  if utils.match_response(http_res, "4XX", "*"):
962
948
  http_res_text = utils.stream_to_text(http_res)
963
949
  raise models.APIError("API error occurred", http_res, http_res_text)
@@ -1011,7 +997,7 @@ class Prompts(BaseSDK):
1011
997
  request_has_path_params=True,
1012
998
  request_has_query_params=True,
1013
999
  user_agent_header="user-agent",
1014
- accept_header_value="*/*",
1000
+ accept_header_value="application/json",
1015
1001
  http_headers=http_headers,
1016
1002
  security=self.sdk_configuration.security,
1017
1003
  allow_empty_value=None,
@@ -1037,12 +1023,18 @@ class Prompts(BaseSDK):
1037
1023
  ),
1038
1024
  ),
1039
1025
  request=req,
1040
- error_status_codes=["4XX", "5XX"],
1026
+ error_status_codes=["404", "4XX", "5XX"],
1041
1027
  retry_config=retry_config,
1042
1028
  )
1043
1029
 
1030
+ response_data: Any = None
1044
1031
  if utils.match_response(http_res, "200", "*"):
1045
1032
  return
1033
+ if utils.match_response(http_res, "404", "application/json"):
1034
+ response_data = unmarshal_json_response(
1035
+ models.DeletePromptResponseBodyData, http_res
1036
+ )
1037
+ raise models.DeletePromptResponseBody(response_data, http_res)
1046
1038
  if utils.match_response(http_res, "4XX", "*"):
1047
1039
  http_res_text = await utils.stream_to_text_async(http_res)
1048
1040
  raise models.APIError("API error occurred", http_res, http_res_text)