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,298 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basesdk import BaseSDK
4
+ from orq_ai_sdk import models, utils
5
+ from orq_ai_sdk._hooks import HookContext
6
+ from orq_ai_sdk.models import createtranslationop as models_createtranslationop
7
+ from orq_ai_sdk.types import OptionalNullable, UNSET
8
+ from orq_ai_sdk.utils import get_security_from_env
9
+ from orq_ai_sdk.utils.unmarshal_json_response import unmarshal_json_response
10
+ from typing import Any, Mapping, Optional, Union
11
+
12
+
13
+ class Translations(BaseSDK):
14
+ def create(
15
+ self,
16
+ *,
17
+ model: str,
18
+ prompt: Optional[str] = None,
19
+ enable_logging: Optional[bool] = True,
20
+ diarize: Optional[bool] = False,
21
+ response_format: Optional[
22
+ models_createtranslationop.CreateTranslationResponseFormat
23
+ ] = None,
24
+ tag_audio_events: Optional[bool] = True,
25
+ num_speakers: Optional[float] = None,
26
+ timestamps_granularity: Optional[
27
+ models_createtranslationop.CreateTranslationTimestampsGranularity
28
+ ] = "word",
29
+ temperature: Optional[float] = None,
30
+ orq: Optional[
31
+ Union[
32
+ models_createtranslationop.CreateTranslationOrq,
33
+ models_createtranslationop.CreateTranslationOrqTypedDict,
34
+ ]
35
+ ] = None,
36
+ file: Optional[
37
+ Union[
38
+ models_createtranslationop.CreateTranslationFile,
39
+ models_createtranslationop.CreateTranslationFileTypedDict,
40
+ ]
41
+ ] = None,
42
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
43
+ server_url: Optional[str] = None,
44
+ timeout_ms: Optional[int] = None,
45
+ http_headers: Optional[Mapping[str, str]] = None,
46
+ ) -> models.CreateTranslationResponseBody:
47
+ r"""Create translation
48
+
49
+ :param model: ID of the model to use
50
+ :param prompt: An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language.
51
+ :param enable_logging: When enable_logging is set to false, zero retention mode is used. This disables history features like request stitching and is only available to enterprise customers.
52
+ :param diarize: Whether to annotate which speaker is currently talking in the uploaded file.
53
+ :param response_format: The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
54
+ :param tag_audio_events: Whether to tag audio events like (laughter), (footsteps), etc. in the transcription.
55
+ :param num_speakers: The maximum amount of speakers talking in the uploaded file. Helps with predicting who speaks when, the maximum is 32.
56
+ :param timestamps_granularity: The granularity of the timestamps in the transcription. Word provides word-level timestamps and character provides character-level timestamps per word.
57
+ :param temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.
58
+ :param orq:
59
+ :param file: The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
60
+ :param retries: Override the default retry configuration for this method
61
+ :param server_url: Override the default server URL for this method
62
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
63
+ :param http_headers: Additional headers to set or replace on requests.
64
+ """
65
+ base_url = None
66
+ url_variables = None
67
+ if timeout_ms is None:
68
+ timeout_ms = self.sdk_configuration.timeout_ms
69
+
70
+ if timeout_ms is None:
71
+ timeout_ms = 600000
72
+
73
+ if server_url is not None:
74
+ base_url = server_url
75
+ else:
76
+ base_url = self._get_url(base_url, url_variables)
77
+
78
+ request = models.CreateTranslationRequestBody(
79
+ model=model,
80
+ prompt=prompt,
81
+ enable_logging=enable_logging,
82
+ diarize=diarize,
83
+ response_format=response_format,
84
+ tag_audio_events=tag_audio_events,
85
+ num_speakers=num_speakers,
86
+ timestamps_granularity=timestamps_granularity,
87
+ temperature=temperature,
88
+ orq=utils.get_pydantic_model(orq, Optional[models.CreateTranslationOrq]),
89
+ file=utils.get_pydantic_model(file, Optional[models.CreateTranslationFile]),
90
+ )
91
+
92
+ req = self._build_request(
93
+ method="POST",
94
+ path="/v2/router/audio/translations",
95
+ base_url=base_url,
96
+ url_variables=url_variables,
97
+ request=request,
98
+ request_body_required=True,
99
+ request_has_path_params=False,
100
+ request_has_query_params=True,
101
+ user_agent_header="user-agent",
102
+ accept_header_value="application/json",
103
+ http_headers=http_headers,
104
+ security=self.sdk_configuration.security,
105
+ get_serialized_body=lambda: utils.serialize_request_body(
106
+ request, False, False, "multipart", models.CreateTranslationRequestBody
107
+ ),
108
+ allow_empty_value=None,
109
+ timeout_ms=timeout_ms,
110
+ )
111
+
112
+ if retries == UNSET:
113
+ if self.sdk_configuration.retry_config is not UNSET:
114
+ retries = self.sdk_configuration.retry_config
115
+
116
+ retry_config = None
117
+ if isinstance(retries, utils.RetryConfig):
118
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
119
+
120
+ http_res = self.do_request(
121
+ hook_ctx=HookContext(
122
+ config=self.sdk_configuration,
123
+ base_url=base_url or "",
124
+ operation_id="createTranslation",
125
+ oauth2_scopes=None,
126
+ security_source=get_security_from_env(
127
+ self.sdk_configuration.security, models.Security
128
+ ),
129
+ ),
130
+ request=req,
131
+ error_status_codes=["422", "4XX", "5XX"],
132
+ retry_config=retry_config,
133
+ )
134
+
135
+ response_data: Any = None
136
+ if utils.match_response(http_res, "200", "application/json"):
137
+ return unmarshal_json_response(
138
+ models.CreateTranslationResponseBody, http_res
139
+ )
140
+ if utils.match_response(http_res, "422", "application/json"):
141
+ response_data = unmarshal_json_response(
142
+ models.CreateTranslationRouterAudioTranslationsResponseBodyData,
143
+ http_res,
144
+ )
145
+ raise models.CreateTranslationRouterAudioTranslationsResponseBody(
146
+ response_data, http_res
147
+ )
148
+ if utils.match_response(http_res, "4XX", "*"):
149
+ http_res_text = utils.stream_to_text(http_res)
150
+ raise models.APIError("API error occurred", http_res, http_res_text)
151
+ if utils.match_response(http_res, "5XX", "*"):
152
+ http_res_text = utils.stream_to_text(http_res)
153
+ raise models.APIError("API error occurred", http_res, http_res_text)
154
+
155
+ raise models.APIError("Unexpected response received", http_res)
156
+
157
+ async def create_async(
158
+ self,
159
+ *,
160
+ model: str,
161
+ prompt: Optional[str] = None,
162
+ enable_logging: Optional[bool] = True,
163
+ diarize: Optional[bool] = False,
164
+ response_format: Optional[
165
+ models_createtranslationop.CreateTranslationResponseFormat
166
+ ] = None,
167
+ tag_audio_events: Optional[bool] = True,
168
+ num_speakers: Optional[float] = None,
169
+ timestamps_granularity: Optional[
170
+ models_createtranslationop.CreateTranslationTimestampsGranularity
171
+ ] = "word",
172
+ temperature: Optional[float] = None,
173
+ orq: Optional[
174
+ Union[
175
+ models_createtranslationop.CreateTranslationOrq,
176
+ models_createtranslationop.CreateTranslationOrqTypedDict,
177
+ ]
178
+ ] = None,
179
+ file: Optional[
180
+ Union[
181
+ models_createtranslationop.CreateTranslationFile,
182
+ models_createtranslationop.CreateTranslationFileTypedDict,
183
+ ]
184
+ ] = None,
185
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
186
+ server_url: Optional[str] = None,
187
+ timeout_ms: Optional[int] = None,
188
+ http_headers: Optional[Mapping[str, str]] = None,
189
+ ) -> models.CreateTranslationResponseBody:
190
+ r"""Create translation
191
+
192
+ :param model: ID of the model to use
193
+ :param prompt: An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language.
194
+ :param enable_logging: When enable_logging is set to false, zero retention mode is used. This disables history features like request stitching and is only available to enterprise customers.
195
+ :param diarize: Whether to annotate which speaker is currently talking in the uploaded file.
196
+ :param response_format: The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
197
+ :param tag_audio_events: Whether to tag audio events like (laughter), (footsteps), etc. in the transcription.
198
+ :param num_speakers: The maximum amount of speakers talking in the uploaded file. Helps with predicting who speaks when, the maximum is 32.
199
+ :param timestamps_granularity: The granularity of the timestamps in the transcription. Word provides word-level timestamps and character provides character-level timestamps per word.
200
+ :param temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.
201
+ :param orq:
202
+ :param file: The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
203
+ :param retries: Override the default retry configuration for this method
204
+ :param server_url: Override the default server URL for this method
205
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
206
+ :param http_headers: Additional headers to set or replace on requests.
207
+ """
208
+ base_url = None
209
+ url_variables = None
210
+ if timeout_ms is None:
211
+ timeout_ms = self.sdk_configuration.timeout_ms
212
+
213
+ if timeout_ms is None:
214
+ timeout_ms = 600000
215
+
216
+ if server_url is not None:
217
+ base_url = server_url
218
+ else:
219
+ base_url = self._get_url(base_url, url_variables)
220
+
221
+ request = models.CreateTranslationRequestBody(
222
+ model=model,
223
+ prompt=prompt,
224
+ enable_logging=enable_logging,
225
+ diarize=diarize,
226
+ response_format=response_format,
227
+ tag_audio_events=tag_audio_events,
228
+ num_speakers=num_speakers,
229
+ timestamps_granularity=timestamps_granularity,
230
+ temperature=temperature,
231
+ orq=utils.get_pydantic_model(orq, Optional[models.CreateTranslationOrq]),
232
+ file=utils.get_pydantic_model(file, Optional[models.CreateTranslationFile]),
233
+ )
234
+
235
+ req = self._build_request_async(
236
+ method="POST",
237
+ path="/v2/router/audio/translations",
238
+ base_url=base_url,
239
+ url_variables=url_variables,
240
+ request=request,
241
+ request_body_required=True,
242
+ request_has_path_params=False,
243
+ request_has_query_params=True,
244
+ user_agent_header="user-agent",
245
+ accept_header_value="application/json",
246
+ http_headers=http_headers,
247
+ security=self.sdk_configuration.security,
248
+ get_serialized_body=lambda: utils.serialize_request_body(
249
+ request, False, False, "multipart", models.CreateTranslationRequestBody
250
+ ),
251
+ allow_empty_value=None,
252
+ timeout_ms=timeout_ms,
253
+ )
254
+
255
+ if retries == UNSET:
256
+ if self.sdk_configuration.retry_config is not UNSET:
257
+ retries = self.sdk_configuration.retry_config
258
+
259
+ retry_config = None
260
+ if isinstance(retries, utils.RetryConfig):
261
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
262
+
263
+ http_res = await self.do_request_async(
264
+ hook_ctx=HookContext(
265
+ config=self.sdk_configuration,
266
+ base_url=base_url or "",
267
+ operation_id="createTranslation",
268
+ oauth2_scopes=None,
269
+ security_source=get_security_from_env(
270
+ self.sdk_configuration.security, models.Security
271
+ ),
272
+ ),
273
+ request=req,
274
+ error_status_codes=["422", "4XX", "5XX"],
275
+ retry_config=retry_config,
276
+ )
277
+
278
+ response_data: Any = None
279
+ if utils.match_response(http_res, "200", "application/json"):
280
+ return unmarshal_json_response(
281
+ models.CreateTranslationResponseBody, http_res
282
+ )
283
+ if utils.match_response(http_res, "422", "application/json"):
284
+ response_data = unmarshal_json_response(
285
+ models.CreateTranslationRouterAudioTranslationsResponseBodyData,
286
+ http_res,
287
+ )
288
+ raise models.CreateTranslationRouterAudioTranslationsResponseBody(
289
+ response_data, http_res
290
+ )
291
+ if utils.match_response(http_res, "4XX", "*"):
292
+ http_res_text = await utils.stream_to_text_async(http_res)
293
+ raise models.APIError("API error occurred", http_res, http_res_text)
294
+ if utils.match_response(http_res, "5XX", "*"):
295
+ http_res_text = await utils.stream_to_text_async(http_res)
296
+ raise models.APIError("API error occurred", http_res, http_res_text)
297
+
298
+ raise models.APIError("Unexpected response received", http_res)
@@ -1,10 +1,22 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
- from typing import TYPE_CHECKING
3
+ from typing import TYPE_CHECKING, Callable, TypeVar
4
4
  from importlib import import_module
5
+ import asyncio
5
6
  import builtins
6
7
  import sys
7
8
 
9
+ _T = TypeVar("_T")
10
+
11
+
12
+ async def run_sync_in_thread(func: Callable[..., _T], *args) -> _T:
13
+ """Run a synchronous function in a thread pool to avoid blocking the event loop."""
14
+ if sys.version_info >= (3, 9):
15
+ return await asyncio.to_thread(func, *args)
16
+ loop = asyncio.get_event_loop()
17
+ return await loop.run_in_executor(None, func, *args)
18
+
19
+
8
20
  if TYPE_CHECKING:
9
21
  from .annotations import get_discriminator
10
22
  from .datetimes import parse_datetime
@@ -0,0 +1,254 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basesdk import BaseSDK
4
+ from orq_ai_sdk import models, utils
5
+ from orq_ai_sdk._hooks import HookContext
6
+ from orq_ai_sdk.models import createimagevariationop as models_createimagevariationop
7
+ from orq_ai_sdk.types import OptionalNullable, UNSET
8
+ from orq_ai_sdk.utils import get_security_from_env
9
+ from orq_ai_sdk.utils.unmarshal_json_response import unmarshal_json_response
10
+ from typing import Any, Mapping, Optional, Union
11
+
12
+
13
+ class Variations(BaseSDK):
14
+ def create(
15
+ self,
16
+ *,
17
+ model: str,
18
+ image: Optional[Any] = None,
19
+ n: OptionalNullable[int] = 1,
20
+ response_format: Optional[
21
+ models_createimagevariationop.CreateImageVariationResponseFormat
22
+ ] = "url",
23
+ size: Optional[models_createimagevariationop.Size] = "1024x1024",
24
+ user: Optional[str] = None,
25
+ orq: Optional[
26
+ Union[
27
+ models_createimagevariationop.CreateImageVariationOrq,
28
+ models_createimagevariationop.CreateImageVariationOrqTypedDict,
29
+ ]
30
+ ] = None,
31
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
32
+ server_url: Optional[str] = None,
33
+ timeout_ms: Optional[int] = None,
34
+ http_headers: Optional[Mapping[str, str]] = None,
35
+ ) -> models.CreateImageVariationResponseBody:
36
+ r"""Create image variation
37
+
38
+ Create an Image Variation
39
+
40
+ :param model: The model to use for image generation.
41
+ :param image: The image to edit. Must be a supported image file. It should be a png, webp, or jpg file less than 50MB.
42
+ :param n: The number of images to generate. Must be between 1 and 10.
43
+ :param response_format: The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated.
44
+ :param size: The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.
45
+ :param user: A unique identifier representing your end-user, which can help to monitor and detect abuse.
46
+ :param orq:
47
+ :param retries: Override the default retry configuration for this method
48
+ :param server_url: Override the default server URL for this method
49
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
50
+ :param http_headers: Additional headers to set or replace on requests.
51
+ """
52
+ base_url = None
53
+ url_variables = None
54
+ if timeout_ms is None:
55
+ timeout_ms = self.sdk_configuration.timeout_ms
56
+
57
+ if timeout_ms is None:
58
+ timeout_ms = 600000
59
+
60
+ if server_url is not None:
61
+ base_url = server_url
62
+ else:
63
+ base_url = self._get_url(base_url, url_variables)
64
+
65
+ request = models.CreateImageVariationRequestBody(
66
+ image=image,
67
+ model=model,
68
+ n=n,
69
+ response_format=response_format,
70
+ size=size,
71
+ user=user,
72
+ orq=utils.get_pydantic_model(orq, Optional[models.CreateImageVariationOrq]),
73
+ )
74
+
75
+ req = self._build_request(
76
+ method="POST",
77
+ path="/v2/router/images/variations",
78
+ base_url=base_url,
79
+ url_variables=url_variables,
80
+ request=request,
81
+ request_body_required=True,
82
+ request_has_path_params=False,
83
+ request_has_query_params=True,
84
+ user_agent_header="user-agent",
85
+ accept_header_value="application/json",
86
+ http_headers=http_headers,
87
+ security=self.sdk_configuration.security,
88
+ get_serialized_body=lambda: utils.serialize_request_body(
89
+ request,
90
+ False,
91
+ False,
92
+ "multipart",
93
+ models.CreateImageVariationRequestBody,
94
+ ),
95
+ allow_empty_value=None,
96
+ timeout_ms=timeout_ms,
97
+ )
98
+
99
+ if retries == UNSET:
100
+ if self.sdk_configuration.retry_config is not UNSET:
101
+ retries = self.sdk_configuration.retry_config
102
+
103
+ retry_config = None
104
+ if isinstance(retries, utils.RetryConfig):
105
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
106
+
107
+ http_res = self.do_request(
108
+ hook_ctx=HookContext(
109
+ config=self.sdk_configuration,
110
+ base_url=base_url or "",
111
+ operation_id="createImageVariation",
112
+ oauth2_scopes=None,
113
+ security_source=get_security_from_env(
114
+ self.sdk_configuration.security, models.Security
115
+ ),
116
+ ),
117
+ request=req,
118
+ error_status_codes=["4XX", "5XX"],
119
+ retry_config=retry_config,
120
+ )
121
+
122
+ if utils.match_response(http_res, "200", "application/json"):
123
+ return unmarshal_json_response(
124
+ models.CreateImageVariationResponseBody, http_res
125
+ )
126
+ if utils.match_response(http_res, "4XX", "*"):
127
+ http_res_text = utils.stream_to_text(http_res)
128
+ raise models.APIError("API error occurred", http_res, http_res_text)
129
+ if utils.match_response(http_res, "5XX", "*"):
130
+ http_res_text = utils.stream_to_text(http_res)
131
+ raise models.APIError("API error occurred", http_res, http_res_text)
132
+
133
+ raise models.APIError("Unexpected response received", http_res)
134
+
135
+ async def create_async(
136
+ self,
137
+ *,
138
+ model: str,
139
+ image: Optional[Any] = None,
140
+ n: OptionalNullable[int] = 1,
141
+ response_format: Optional[
142
+ models_createimagevariationop.CreateImageVariationResponseFormat
143
+ ] = "url",
144
+ size: Optional[models_createimagevariationop.Size] = "1024x1024",
145
+ user: Optional[str] = None,
146
+ orq: Optional[
147
+ Union[
148
+ models_createimagevariationop.CreateImageVariationOrq,
149
+ models_createimagevariationop.CreateImageVariationOrqTypedDict,
150
+ ]
151
+ ] = None,
152
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
153
+ server_url: Optional[str] = None,
154
+ timeout_ms: Optional[int] = None,
155
+ http_headers: Optional[Mapping[str, str]] = None,
156
+ ) -> models.CreateImageVariationResponseBody:
157
+ r"""Create image variation
158
+
159
+ Create an Image Variation
160
+
161
+ :param model: The model to use for image generation.
162
+ :param image: The image to edit. Must be a supported image file. It should be a png, webp, or jpg file less than 50MB.
163
+ :param n: The number of images to generate. Must be between 1 and 10.
164
+ :param response_format: The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated.
165
+ :param size: The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.
166
+ :param user: A unique identifier representing your end-user, which can help to monitor and detect abuse.
167
+ :param orq:
168
+ :param retries: Override the default retry configuration for this method
169
+ :param server_url: Override the default server URL for this method
170
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
171
+ :param http_headers: Additional headers to set or replace on requests.
172
+ """
173
+ base_url = None
174
+ url_variables = None
175
+ if timeout_ms is None:
176
+ timeout_ms = self.sdk_configuration.timeout_ms
177
+
178
+ if timeout_ms is None:
179
+ timeout_ms = 600000
180
+
181
+ if server_url is not None:
182
+ base_url = server_url
183
+ else:
184
+ base_url = self._get_url(base_url, url_variables)
185
+
186
+ request = models.CreateImageVariationRequestBody(
187
+ image=image,
188
+ model=model,
189
+ n=n,
190
+ response_format=response_format,
191
+ size=size,
192
+ user=user,
193
+ orq=utils.get_pydantic_model(orq, Optional[models.CreateImageVariationOrq]),
194
+ )
195
+
196
+ req = self._build_request_async(
197
+ method="POST",
198
+ path="/v2/router/images/variations",
199
+ base_url=base_url,
200
+ url_variables=url_variables,
201
+ request=request,
202
+ request_body_required=True,
203
+ request_has_path_params=False,
204
+ request_has_query_params=True,
205
+ user_agent_header="user-agent",
206
+ accept_header_value="application/json",
207
+ http_headers=http_headers,
208
+ security=self.sdk_configuration.security,
209
+ get_serialized_body=lambda: utils.serialize_request_body(
210
+ request,
211
+ False,
212
+ False,
213
+ "multipart",
214
+ models.CreateImageVariationRequestBody,
215
+ ),
216
+ allow_empty_value=None,
217
+ timeout_ms=timeout_ms,
218
+ )
219
+
220
+ if retries == UNSET:
221
+ if self.sdk_configuration.retry_config is not UNSET:
222
+ retries = self.sdk_configuration.retry_config
223
+
224
+ retry_config = None
225
+ if isinstance(retries, utils.RetryConfig):
226
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
227
+
228
+ http_res = await self.do_request_async(
229
+ hook_ctx=HookContext(
230
+ config=self.sdk_configuration,
231
+ base_url=base_url or "",
232
+ operation_id="createImageVariation",
233
+ oauth2_scopes=None,
234
+ security_source=get_security_from_env(
235
+ self.sdk_configuration.security, models.Security
236
+ ),
237
+ ),
238
+ request=req,
239
+ error_status_codes=["4XX", "5XX"],
240
+ retry_config=retry_config,
241
+ )
242
+
243
+ if utils.match_response(http_res, "200", "application/json"):
244
+ return unmarshal_json_response(
245
+ models.CreateImageVariationResponseBody, http_res
246
+ )
247
+ if utils.match_response(http_res, "4XX", "*"):
248
+ http_res_text = await utils.stream_to_text_async(http_res)
249
+ raise models.APIError("API error occurred", http_res, http_res_text)
250
+ if utils.match_response(http_res, "5XX", "*"):
251
+ http_res_text = await utils.stream_to_text_async(http_res)
252
+ raise models.APIError("API error occurred", http_res, http_res_text)
253
+
254
+ raise models.APIError("Unexpected response received", http_res)