camb-sdk 1.5.4__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. camb/__init__.py +335 -0
  2. camb/audio_separation/__init__.py +4 -0
  3. camb/audio_separation/client.py +406 -0
  4. camb/audio_separation/raw_client.py +534 -0
  5. camb/client.py +717 -0
  6. camb/core/__init__.py +105 -0
  7. camb/core/api_error.py +23 -0
  8. camb/core/client_wrapper.py +113 -0
  9. camb/core/datetime_utils.py +28 -0
  10. camb/core/file.py +67 -0
  11. camb/core/force_multipart.py +18 -0
  12. camb/core/http_client.py +663 -0
  13. camb/core/http_response.py +55 -0
  14. camb/core/http_sse/__init__.py +42 -0
  15. camb/core/http_sse/_api.py +112 -0
  16. camb/core/http_sse/_decoders.py +61 -0
  17. camb/core/http_sse/_exceptions.py +7 -0
  18. camb/core/http_sse/_models.py +17 -0
  19. camb/core/jsonable_encoder.py +100 -0
  20. camb/core/pydantic_utilities.py +260 -0
  21. camb/core/query_encoder.py +58 -0
  22. camb/core/remove_none_from_dict.py +11 -0
  23. camb/core/request_options.py +35 -0
  24. camb/core/serialization.py +276 -0
  25. camb/deprecated_streaming/__init__.py +4 -0
  26. camb/deprecated_streaming/client.py +532 -0
  27. camb/deprecated_streaming/raw_client.py +639 -0
  28. camb/dictionaries/__init__.py +4 -0
  29. camb/dictionaries/client.py +785 -0
  30. camb/dictionaries/raw_client.py +1048 -0
  31. camb/dub/__init__.py +49 -0
  32. camb/dub/client.py +846 -0
  33. camb/dub/raw_client.py +1194 -0
  34. camb/dub/types/__init__.py +53 -0
  35. camb/dub/types/dubbed_output_in_alt_format_request_payload_output_format.py +8 -0
  36. camb/dub/types/get_dubbed_output_in_alt_format_dub_alt_format_run_id_language_post_response.py +9 -0
  37. camb/dub/types/get_dubbed_run_info_dub_result_run_id_get_response.py +7 -0
  38. camb/dub/types/get_dubbing_runs_results_dubbing_results_post_response_value.py +7 -0
  39. camb/environment.py +7 -0
  40. camb/errors/__init__.py +34 -0
  41. camb/errors/unprocessable_entity_error.py +11 -0
  42. camb/folders/__init__.py +4 -0
  43. camb/folders/client.py +213 -0
  44. camb/folders/raw_client.py +278 -0
  45. camb/languages/__init__.py +4 -0
  46. camb/languages/client.py +168 -0
  47. camb/languages/raw_client.py +223 -0
  48. camb/project_setup/__init__.py +4 -0
  49. camb/project_setup/client.py +537 -0
  50. camb/project_setup/raw_client.py +655 -0
  51. camb/py.typed +0 -0
  52. camb/raw_client.py +236 -0
  53. camb/story/__init__.py +37 -0
  54. camb/story/client.py +579 -0
  55. camb/story/raw_client.py +743 -0
  56. camb/story/types/__init__.py +38 -0
  57. camb/story/types/create_story_story_post_response.py +8 -0
  58. camb/story/types/setup_story_story_setup_post_response.py +8 -0
  59. camb/streaming/__init__.py +4 -0
  60. camb/streaming/client.py +645 -0
  61. camb/streaming/raw_client.py +796 -0
  62. camb/text_to_audio/__init__.py +4 -0
  63. camb/text_to_audio/client.py +469 -0
  64. camb/text_to_audio/raw_client.py +610 -0
  65. camb/text_to_speech/__init__.py +49 -0
  66. camb/text_to_speech/baseten.py +214 -0
  67. camb/text_to_speech/client.py +742 -0
  68. camb/text_to_speech/raw_client.py +995 -0
  69. camb/text_to_speech/types/__init__.py +47 -0
  70. camb/text_to_speech/types/create_stream_tts_request_payload_language.py +71 -0
  71. camb/text_to_speech/types/create_stream_tts_request_payload_speech_model.py +7 -0
  72. camb/text_to_speech/types/get_tts_results_tts_results_post_response_value.py +7 -0
  73. camb/text_to_speech/types/get_tts_run_info_tts_result_run_id_get_response.py +7 -0
  74. camb/text_to_voice/__init__.py +4 -0
  75. camb/text_to_voice/client.py +329 -0
  76. camb/text_to_voice/raw_client.py +405 -0
  77. camb/transcription/__init__.py +4 -0
  78. camb/transcription/client.py +465 -0
  79. camb/transcription/raw_client.py +587 -0
  80. camb/translated_story/__init__.py +4 -0
  81. camb/translated_story/client.py +309 -0
  82. camb/translated_story/raw_client.py +381 -0
  83. camb/translated_tts/__init__.py +4 -0
  84. camb/translated_tts/client.py +313 -0
  85. camb/translated_tts/raw_client.py +357 -0
  86. camb/translation/__init__.py +4 -0
  87. camb/translation/client.py +631 -0
  88. camb/translation/raw_client.py +787 -0
  89. camb/types/__init__.py +236 -0
  90. camb/types/add_target_language_out.py +20 -0
  91. camb/types/audio_output_type.py +5 -0
  92. camb/types/audio_stream.py +31 -0
  93. camb/types/config_stream.py +22 -0
  94. camb/types/config_stream_pipeline.py +28 -0
  95. camb/types/create_custom_voice_out.py +19 -0
  96. camb/types/create_project_setup_out.py +19 -0
  97. camb/types/create_stream_out.py +22 -0
  98. camb/types/create_stream_request_payload.py +70 -0
  99. camb/types/create_translated_tts_out.py +19 -0
  100. camb/types/create_tts_out.py +19 -0
  101. camb/types/data_stream.py +24 -0
  102. camb/types/demixing_option.py +10 -0
  103. camb/types/dictionary_term.py +21 -0
  104. camb/types/dictionary_with_terms.py +28 -0
  105. camb/types/dubbing_result.py +22 -0
  106. camb/types/exception_reasons.py +30 -0
  107. camb/types/folder.py +20 -0
  108. camb/types/formalities.py +3 -0
  109. camb/types/gender.py +3 -0
  110. camb/types/get_audio_separation_result_out.py +20 -0
  111. camb/types/get_create_project_setup_response.py +21 -0
  112. camb/types/get_probe_stream_in.py +21 -0
  113. camb/types/get_probe_stream_out.py +24 -0
  114. camb/types/get_setup_story_result_response.py +21 -0
  115. camb/types/get_text_to_voice_result_out.py +19 -0
  116. camb/types/get_tts_result_out_file_url.py +19 -0
  117. camb/types/http_validation_error.py +20 -0
  118. camb/types/language_enums.py +154 -0
  119. camb/types/language_pydantic_model.py +21 -0
  120. camb/types/languages.py +3 -0
  121. camb/types/orchestrator_pipeline_call_result.py +19 -0
  122. camb/types/orchestrator_pipeline_result.py +25 -0
  123. camb/types/orchestrator_pipeline_result_exception_reason.py +7 -0
  124. camb/types/orchestrator_pipeline_result_message.py +5 -0
  125. camb/types/output_format.py +10 -0
  126. camb/types/overdub_config.py +37 -0
  127. camb/types/project_details.py +28 -0
  128. camb/types/revoicing_option.py +5 -0
  129. camb/types/run_i_ds_request_payload.py +19 -0
  130. camb/types/segmenting_option.py +5 -0
  131. camb/types/source_stream.py +30 -0
  132. camb/types/story_details.py +27 -0
  133. camb/types/stream_category.py +3 -0
  134. camb/types/stream_tts_inference_options.py +38 -0
  135. camb/types/stream_tts_output_configuration.py +33 -0
  136. camb/types/stream_tts_voice_settings.py +28 -0
  137. camb/types/stream_type.py +3 -0
  138. camb/types/stream_url_for_languages.py +21 -0
  139. camb/types/target_stream.py +34 -0
  140. camb/types/task_status.py +5 -0
  141. camb/types/term_translation_input.py +21 -0
  142. camb/types/term_translation_output.py +20 -0
  143. camb/types/text_to_audio_result.py +19 -0
  144. camb/types/text_to_audio_type.py +5 -0
  145. camb/types/transcribing_option.py +5 -0
  146. camb/types/transcript.py +22 -0
  147. camb/types/transcript_data_type.py +5 -0
  148. camb/types/transcript_file_format.py +5 -0
  149. camb/types/transcription_result.py +20 -0
  150. camb/types/translating_option.py +5 -0
  151. camb/types/translation_result.py +19 -0
  152. camb/types/tts_provider.py +3 -0
  153. camb/types/validation_error.py +22 -0
  154. camb/types/validation_error_loc_item.py +5 -0
  155. camb/types/video_output_type_without_avi.py +5 -0
  156. camb/types/video_stream.py +28 -0
  157. camb/types/voice.py +28 -0
  158. camb/voice_cloning/__init__.py +34 -0
  159. camb/voice_cloning/client.py +265 -0
  160. camb/voice_cloning/raw_client.py +320 -0
  161. camb/voice_cloning/types/__init__.py +36 -0
  162. camb/voice_cloning/types/list_voices_list_voices_get_response_item.py +7 -0
  163. camb_sdk-1.5.4.dist-info/METADATA +282 -0
  164. camb_sdk-1.5.4.dist-info/RECORD +167 -0
  165. camb_sdk-1.5.4.dist-info/WHEEL +5 -0
  166. camb_sdk-1.5.4.dist-info/licenses/LICENSE +21 -0
  167. camb_sdk-1.5.4.dist-info/top_level.txt +1 -0
@@ -0,0 +1,787 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from json.decoder import JSONDecodeError
5
+
6
+ from ..core.api_error import ApiError
7
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
9
+ from ..core.jsonable_encoder import jsonable_encoder
10
+ from ..core.pydantic_utilities import parse_obj_as
11
+ from ..core.request_options import RequestOptions
12
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
13
+ from ..types.formalities import Formalities
14
+ from ..types.gender import Gender
15
+ from ..types.http_validation_error import HttpValidationError
16
+ from ..types.languages import Languages
17
+ from ..types.orchestrator_pipeline_result import OrchestratorPipelineResult
18
+ from ..types.translation_result import TranslationResult
19
+
20
+ # this is used as the default value for optional parameters
21
+ OMIT = typing.cast(typing.Any, ...)
22
+
23
+
24
+ class RawTranslationClient:
25
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
26
+ self._client_wrapper = client_wrapper
27
+
28
+ def translation_stream(
29
+ self,
30
+ *,
31
+ source_language: Languages,
32
+ target_language: Languages,
33
+ text: str,
34
+ traceparent: typing.Optional[str] = None,
35
+ formality: typing.Optional[Formalities] = OMIT,
36
+ gender: typing.Optional[Gender] = OMIT,
37
+ team_id: typing.Optional[int] = OMIT,
38
+ project_name: typing.Optional[str] = OMIT,
39
+ project_description: typing.Optional[str] = OMIT,
40
+ folder_id: typing.Optional[int] = OMIT,
41
+ request_options: typing.Optional[RequestOptions] = None,
42
+ ) -> HttpResponse[typing.Any]:
43
+ """
44
+ Parameters
45
+ ----------
46
+ source_language : Languages
47
+
48
+ target_language : Languages
49
+
50
+ text : str
51
+
52
+ traceparent : typing.Optional[str]
53
+
54
+ formality : typing.Optional[Formalities]
55
+
56
+ gender : typing.Optional[Gender]
57
+
58
+ team_id : typing.Optional[int]
59
+
60
+ project_name : typing.Optional[str]
61
+
62
+ project_description : typing.Optional[str]
63
+
64
+ folder_id : typing.Optional[int]
65
+
66
+ request_options : typing.Optional[RequestOptions]
67
+ Request-specific configuration.
68
+
69
+ Returns
70
+ -------
71
+ HttpResponse[typing.Any]
72
+ Text translation stream
73
+ """
74
+ _response = self._client_wrapper.httpx_client.request(
75
+ "translation/stream",
76
+ method="POST",
77
+ json={
78
+ "source_language": source_language,
79
+ "target_language": target_language,
80
+ "text": text,
81
+ "formality": formality,
82
+ "gender": gender,
83
+ "team_id": team_id,
84
+ "project_name": project_name,
85
+ "project_description": project_description,
86
+ "folder_id": folder_id,
87
+ },
88
+ headers={
89
+ "content-type": "application/json",
90
+ "traceparent": str(traceparent) if traceparent is not None else None,
91
+ },
92
+ request_options=request_options,
93
+ omit=OMIT,
94
+ )
95
+ try:
96
+ if _response is None or not _response.text.strip():
97
+ return HttpResponse(response=_response, data=None)
98
+ if 200 <= _response.status_code < 300:
99
+ _data = typing.cast(
100
+ typing.Any,
101
+ parse_obj_as(
102
+ type_=typing.Any, # type: ignore
103
+ object_=_response.json(),
104
+ ),
105
+ )
106
+ return HttpResponse(response=_response, data=_data)
107
+ if _response.status_code == 422:
108
+ raise UnprocessableEntityError(
109
+ headers=dict(_response.headers),
110
+ body=typing.cast(
111
+ HttpValidationError,
112
+ parse_obj_as(
113
+ type_=HttpValidationError, # type: ignore
114
+ object_=_response.json(),
115
+ ),
116
+ ),
117
+ )
118
+ _response_json = _response.json()
119
+ except JSONDecodeError:
120
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
121
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
122
+
123
+ def create_translation(
124
+ self,
125
+ *,
126
+ texts: typing.Sequence[str],
127
+ source_language: Languages,
128
+ target_language: Languages,
129
+ run_id: typing.Optional[int] = None,
130
+ project_name: typing.Optional[str] = OMIT,
131
+ project_description: typing.Optional[str] = OMIT,
132
+ folder_id: typing.Optional[int] = OMIT,
133
+ age: typing.Optional[int] = OMIT,
134
+ formality: typing.Optional[Formalities] = OMIT,
135
+ gender: typing.Optional[Gender] = OMIT,
136
+ chosen_dictionaries: typing.Optional[typing.Sequence[int]] = OMIT,
137
+ request_options: typing.Optional[RequestOptions] = None,
138
+ ) -> HttpResponse[typing.Any]:
139
+ """
140
+ Parameters
141
+ ----------
142
+ texts : typing.Sequence[str]
143
+
144
+ source_language : Languages
145
+
146
+ target_language : Languages
147
+
148
+ run_id : typing.Optional[int]
149
+
150
+ project_name : typing.Optional[str]
151
+
152
+ project_description : typing.Optional[str]
153
+
154
+ folder_id : typing.Optional[int]
155
+
156
+ age : typing.Optional[int]
157
+
158
+ formality : typing.Optional[Formalities]
159
+
160
+ gender : typing.Optional[Gender]
161
+
162
+ chosen_dictionaries : typing.Optional[typing.Sequence[int]]
163
+
164
+ request_options : typing.Optional[RequestOptions]
165
+ Request-specific configuration.
166
+
167
+ Returns
168
+ -------
169
+ HttpResponse[typing.Any]
170
+ Successful Response
171
+ """
172
+ _response = self._client_wrapper.httpx_client.request(
173
+ "translate",
174
+ method="POST",
175
+ params={
176
+ "run_id": run_id,
177
+ },
178
+ json={
179
+ "project_name": project_name,
180
+ "project_description": project_description,
181
+ "folder_id": folder_id,
182
+ "texts": texts,
183
+ "age": age,
184
+ "formality": formality,
185
+ "gender": gender,
186
+ "source_language": source_language,
187
+ "target_language": target_language,
188
+ "chosen_dictionaries": chosen_dictionaries,
189
+ },
190
+ headers={
191
+ "content-type": "application/json",
192
+ },
193
+ request_options=request_options,
194
+ omit=OMIT,
195
+ )
196
+ try:
197
+ if _response is None or not _response.text.strip():
198
+ return HttpResponse(response=_response, data=None)
199
+ if 200 <= _response.status_code < 300:
200
+ _data = typing.cast(
201
+ typing.Any,
202
+ parse_obj_as(
203
+ type_=typing.Any, # type: ignore
204
+ object_=_response.json(),
205
+ ),
206
+ )
207
+ return HttpResponse(response=_response, data=_data)
208
+ if _response.status_code == 422:
209
+ raise UnprocessableEntityError(
210
+ headers=dict(_response.headers),
211
+ body=typing.cast(
212
+ HttpValidationError,
213
+ parse_obj_as(
214
+ type_=HttpValidationError, # type: ignore
215
+ object_=_response.json(),
216
+ ),
217
+ ),
218
+ )
219
+ _response_json = _response.json()
220
+ except JSONDecodeError:
221
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
222
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
223
+
224
+ def get_translation_task_status(
225
+ self,
226
+ task_id: str,
227
+ *,
228
+ run_id: typing.Optional[int] = None,
229
+ request_options: typing.Optional[RequestOptions] = None,
230
+ ) -> HttpResponse[OrchestratorPipelineResult]:
231
+ """
232
+ Parameters
233
+ ----------
234
+ task_id : str
235
+
236
+ run_id : typing.Optional[int]
237
+
238
+ request_options : typing.Optional[RequestOptions]
239
+ Request-specific configuration.
240
+
241
+ Returns
242
+ -------
243
+ HttpResponse[OrchestratorPipelineResult]
244
+ Successful Response
245
+ """
246
+ _response = self._client_wrapper.httpx_client.request(
247
+ f"translate/{jsonable_encoder(task_id)}",
248
+ method="GET",
249
+ params={
250
+ "run_id": run_id,
251
+ },
252
+ request_options=request_options,
253
+ )
254
+ try:
255
+ if 200 <= _response.status_code < 300:
256
+ _data = typing.cast(
257
+ OrchestratorPipelineResult,
258
+ parse_obj_as(
259
+ type_=OrchestratorPipelineResult, # type: ignore
260
+ object_=_response.json(),
261
+ ),
262
+ )
263
+ return HttpResponse(response=_response, data=_data)
264
+ if _response.status_code == 422:
265
+ raise UnprocessableEntityError(
266
+ headers=dict(_response.headers),
267
+ body=typing.cast(
268
+ HttpValidationError,
269
+ parse_obj_as(
270
+ type_=HttpValidationError, # type: ignore
271
+ object_=_response.json(),
272
+ ),
273
+ ),
274
+ )
275
+ _response_json = _response.json()
276
+ except JSONDecodeError:
277
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
278
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
279
+
280
+ def get_translation_result(
281
+ self,
282
+ run_id: typing.Optional[int],
283
+ *,
284
+ traceparent: typing.Optional[str] = None,
285
+ request_options: typing.Optional[RequestOptions] = None,
286
+ ) -> HttpResponse[TranslationResult]:
287
+ """
288
+ NOTE: This endpoint should be called only by the users to get values for their runs via API.
289
+ Further we need to validate if the user has access to the run_id, otherwise we should not return the output urls.
290
+
291
+ Parameters
292
+ ----------
293
+ run_id : typing.Optional[int]
294
+
295
+ traceparent : typing.Optional[str]
296
+
297
+ request_options : typing.Optional[RequestOptions]
298
+ Request-specific configuration.
299
+
300
+ Returns
301
+ -------
302
+ HttpResponse[TranslationResult]
303
+ Successful Response
304
+ """
305
+ _response = self._client_wrapper.httpx_client.request(
306
+ f"translation-result/{jsonable_encoder(run_id)}",
307
+ method="GET",
308
+ headers={
309
+ "traceparent": str(traceparent) if traceparent is not None else None,
310
+ },
311
+ request_options=request_options,
312
+ )
313
+ try:
314
+ if 200 <= _response.status_code < 300:
315
+ _data = typing.cast(
316
+ TranslationResult,
317
+ parse_obj_as(
318
+ type_=TranslationResult, # type: ignore
319
+ object_=_response.json(),
320
+ ),
321
+ )
322
+ return HttpResponse(response=_response, data=_data)
323
+ if _response.status_code == 422:
324
+ raise UnprocessableEntityError(
325
+ headers=dict(_response.headers),
326
+ body=typing.cast(
327
+ HttpValidationError,
328
+ parse_obj_as(
329
+ type_=HttpValidationError, # type: ignore
330
+ object_=_response.json(),
331
+ ),
332
+ ),
333
+ )
334
+ _response_json = _response.json()
335
+ except JSONDecodeError:
336
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
337
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
338
+
339
+ def get_translation_results(
340
+ self,
341
+ *,
342
+ run_ids: typing.Sequence[int],
343
+ run_id: typing.Optional[int] = None,
344
+ traceparent: typing.Optional[str] = None,
345
+ request_options: typing.Optional[RequestOptions] = None,
346
+ ) -> HttpResponse[typing.Dict[str, TranslationResult]]:
347
+ """
348
+ Parameters
349
+ ----------
350
+ run_ids : typing.Sequence[int]
351
+
352
+ run_id : typing.Optional[int]
353
+
354
+ traceparent : typing.Optional[str]
355
+
356
+ request_options : typing.Optional[RequestOptions]
357
+ Request-specific configuration.
358
+
359
+ Returns
360
+ -------
361
+ HttpResponse[typing.Dict[str, TranslationResult]]
362
+ Successful Response
363
+ """
364
+ _response = self._client_wrapper.httpx_client.request(
365
+ "translation-results",
366
+ method="POST",
367
+ params={
368
+ "run_id": run_id,
369
+ },
370
+ json={
371
+ "run_ids": run_ids,
372
+ },
373
+ headers={
374
+ "content-type": "application/json",
375
+ "traceparent": str(traceparent) if traceparent is not None else None,
376
+ },
377
+ request_options=request_options,
378
+ omit=OMIT,
379
+ )
380
+ try:
381
+ if 200 <= _response.status_code < 300:
382
+ _data = typing.cast(
383
+ typing.Dict[str, TranslationResult],
384
+ parse_obj_as(
385
+ type_=typing.Dict[str, TranslationResult], # type: ignore
386
+ object_=_response.json(),
387
+ ),
388
+ )
389
+ return HttpResponse(response=_response, data=_data)
390
+ if _response.status_code == 422:
391
+ raise UnprocessableEntityError(
392
+ headers=dict(_response.headers),
393
+ body=typing.cast(
394
+ HttpValidationError,
395
+ parse_obj_as(
396
+ type_=HttpValidationError, # type: ignore
397
+ object_=_response.json(),
398
+ ),
399
+ ),
400
+ )
401
+ _response_json = _response.json()
402
+ except JSONDecodeError:
403
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
404
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
405
+
406
+
407
+ class AsyncRawTranslationClient:
408
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
409
+ self._client_wrapper = client_wrapper
410
+
411
+ async def translation_stream(
412
+ self,
413
+ *,
414
+ source_language: Languages,
415
+ target_language: Languages,
416
+ text: str,
417
+ traceparent: typing.Optional[str] = None,
418
+ formality: typing.Optional[Formalities] = OMIT,
419
+ gender: typing.Optional[Gender] = OMIT,
420
+ team_id: typing.Optional[int] = OMIT,
421
+ project_name: typing.Optional[str] = OMIT,
422
+ project_description: typing.Optional[str] = OMIT,
423
+ folder_id: typing.Optional[int] = OMIT,
424
+ request_options: typing.Optional[RequestOptions] = None,
425
+ ) -> AsyncHttpResponse[typing.Any]:
426
+ """
427
+ Parameters
428
+ ----------
429
+ source_language : Languages
430
+
431
+ target_language : Languages
432
+
433
+ text : str
434
+
435
+ traceparent : typing.Optional[str]
436
+
437
+ formality : typing.Optional[Formalities]
438
+
439
+ gender : typing.Optional[Gender]
440
+
441
+ team_id : typing.Optional[int]
442
+
443
+ project_name : typing.Optional[str]
444
+
445
+ project_description : typing.Optional[str]
446
+
447
+ folder_id : typing.Optional[int]
448
+
449
+ request_options : typing.Optional[RequestOptions]
450
+ Request-specific configuration.
451
+
452
+ Returns
453
+ -------
454
+ AsyncHttpResponse[typing.Any]
455
+ Text translation stream
456
+ """
457
+ _response = await self._client_wrapper.httpx_client.request(
458
+ "translation/stream",
459
+ method="POST",
460
+ json={
461
+ "source_language": source_language,
462
+ "target_language": target_language,
463
+ "text": text,
464
+ "formality": formality,
465
+ "gender": gender,
466
+ "team_id": team_id,
467
+ "project_name": project_name,
468
+ "project_description": project_description,
469
+ "folder_id": folder_id,
470
+ },
471
+ headers={
472
+ "content-type": "application/json",
473
+ "traceparent": str(traceparent) if traceparent is not None else None,
474
+ },
475
+ request_options=request_options,
476
+ omit=OMIT,
477
+ )
478
+ try:
479
+ if _response is None or not _response.text.strip():
480
+ return AsyncHttpResponse(response=_response, data=None)
481
+ if 200 <= _response.status_code < 300:
482
+ _data = typing.cast(
483
+ typing.Any,
484
+ parse_obj_as(
485
+ type_=typing.Any, # type: ignore
486
+ object_=_response.json(),
487
+ ),
488
+ )
489
+ return AsyncHttpResponse(response=_response, data=_data)
490
+ if _response.status_code == 422:
491
+ raise UnprocessableEntityError(
492
+ headers=dict(_response.headers),
493
+ body=typing.cast(
494
+ HttpValidationError,
495
+ parse_obj_as(
496
+ type_=HttpValidationError, # type: ignore
497
+ object_=_response.json(),
498
+ ),
499
+ ),
500
+ )
501
+ _response_json = _response.json()
502
+ except JSONDecodeError:
503
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
504
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
505
+
506
+ async def create_translation(
507
+ self,
508
+ *,
509
+ texts: typing.Sequence[str],
510
+ source_language: Languages,
511
+ target_language: Languages,
512
+ run_id: typing.Optional[int] = None,
513
+ project_name: typing.Optional[str] = OMIT,
514
+ project_description: typing.Optional[str] = OMIT,
515
+ folder_id: typing.Optional[int] = OMIT,
516
+ age: typing.Optional[int] = OMIT,
517
+ formality: typing.Optional[Formalities] = OMIT,
518
+ gender: typing.Optional[Gender] = OMIT,
519
+ chosen_dictionaries: typing.Optional[typing.Sequence[int]] = OMIT,
520
+ request_options: typing.Optional[RequestOptions] = None,
521
+ ) -> AsyncHttpResponse[typing.Any]:
522
+ """
523
+ Parameters
524
+ ----------
525
+ texts : typing.Sequence[str]
526
+
527
+ source_language : Languages
528
+
529
+ target_language : Languages
530
+
531
+ run_id : typing.Optional[int]
532
+
533
+ project_name : typing.Optional[str]
534
+
535
+ project_description : typing.Optional[str]
536
+
537
+ folder_id : typing.Optional[int]
538
+
539
+ age : typing.Optional[int]
540
+
541
+ formality : typing.Optional[Formalities]
542
+
543
+ gender : typing.Optional[Gender]
544
+
545
+ chosen_dictionaries : typing.Optional[typing.Sequence[int]]
546
+
547
+ request_options : typing.Optional[RequestOptions]
548
+ Request-specific configuration.
549
+
550
+ Returns
551
+ -------
552
+ AsyncHttpResponse[typing.Any]
553
+ Successful Response
554
+ """
555
+ _response = await self._client_wrapper.httpx_client.request(
556
+ "translate",
557
+ method="POST",
558
+ params={
559
+ "run_id": run_id,
560
+ },
561
+ json={
562
+ "project_name": project_name,
563
+ "project_description": project_description,
564
+ "folder_id": folder_id,
565
+ "texts": texts,
566
+ "age": age,
567
+ "formality": formality,
568
+ "gender": gender,
569
+ "source_language": source_language,
570
+ "target_language": target_language,
571
+ "chosen_dictionaries": chosen_dictionaries,
572
+ },
573
+ headers={
574
+ "content-type": "application/json",
575
+ },
576
+ request_options=request_options,
577
+ omit=OMIT,
578
+ )
579
+ try:
580
+ if _response is None or not _response.text.strip():
581
+ return AsyncHttpResponse(response=_response, data=None)
582
+ if 200 <= _response.status_code < 300:
583
+ _data = typing.cast(
584
+ typing.Any,
585
+ parse_obj_as(
586
+ type_=typing.Any, # type: ignore
587
+ object_=_response.json(),
588
+ ),
589
+ )
590
+ return AsyncHttpResponse(response=_response, data=_data)
591
+ if _response.status_code == 422:
592
+ raise UnprocessableEntityError(
593
+ headers=dict(_response.headers),
594
+ body=typing.cast(
595
+ HttpValidationError,
596
+ parse_obj_as(
597
+ type_=HttpValidationError, # type: ignore
598
+ object_=_response.json(),
599
+ ),
600
+ ),
601
+ )
602
+ _response_json = _response.json()
603
+ except JSONDecodeError:
604
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
605
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
606
+
607
+ async def get_translation_task_status(
608
+ self,
609
+ task_id: str,
610
+ *,
611
+ run_id: typing.Optional[int] = None,
612
+ request_options: typing.Optional[RequestOptions] = None,
613
+ ) -> AsyncHttpResponse[OrchestratorPipelineResult]:
614
+ """
615
+ Parameters
616
+ ----------
617
+ task_id : str
618
+
619
+ run_id : typing.Optional[int]
620
+
621
+ request_options : typing.Optional[RequestOptions]
622
+ Request-specific configuration.
623
+
624
+ Returns
625
+ -------
626
+ AsyncHttpResponse[OrchestratorPipelineResult]
627
+ Successful Response
628
+ """
629
+ _response = await self._client_wrapper.httpx_client.request(
630
+ f"translate/{jsonable_encoder(task_id)}",
631
+ method="GET",
632
+ params={
633
+ "run_id": run_id,
634
+ },
635
+ request_options=request_options,
636
+ )
637
+ try:
638
+ if 200 <= _response.status_code < 300:
639
+ _data = typing.cast(
640
+ OrchestratorPipelineResult,
641
+ parse_obj_as(
642
+ type_=OrchestratorPipelineResult, # type: ignore
643
+ object_=_response.json(),
644
+ ),
645
+ )
646
+ return AsyncHttpResponse(response=_response, data=_data)
647
+ if _response.status_code == 422:
648
+ raise UnprocessableEntityError(
649
+ headers=dict(_response.headers),
650
+ body=typing.cast(
651
+ HttpValidationError,
652
+ parse_obj_as(
653
+ type_=HttpValidationError, # type: ignore
654
+ object_=_response.json(),
655
+ ),
656
+ ),
657
+ )
658
+ _response_json = _response.json()
659
+ except JSONDecodeError:
660
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
661
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
662
+
663
+ async def get_translation_result(
664
+ self,
665
+ run_id: typing.Optional[int],
666
+ *,
667
+ traceparent: typing.Optional[str] = None,
668
+ request_options: typing.Optional[RequestOptions] = None,
669
+ ) -> AsyncHttpResponse[TranslationResult]:
670
+ """
671
+ NOTE: This endpoint should be called only by the users to get values for their runs via API.
672
+ Further we need to validate if the user has access to the run_id, otherwise we should not return the output urls.
673
+
674
+ Parameters
675
+ ----------
676
+ run_id : typing.Optional[int]
677
+
678
+ traceparent : typing.Optional[str]
679
+
680
+ request_options : typing.Optional[RequestOptions]
681
+ Request-specific configuration.
682
+
683
+ Returns
684
+ -------
685
+ AsyncHttpResponse[TranslationResult]
686
+ Successful Response
687
+ """
688
+ _response = await self._client_wrapper.httpx_client.request(
689
+ f"translation-result/{jsonable_encoder(run_id)}",
690
+ method="GET",
691
+ headers={
692
+ "traceparent": str(traceparent) if traceparent is not None else None,
693
+ },
694
+ request_options=request_options,
695
+ )
696
+ try:
697
+ if 200 <= _response.status_code < 300:
698
+ _data = typing.cast(
699
+ TranslationResult,
700
+ parse_obj_as(
701
+ type_=TranslationResult, # type: ignore
702
+ object_=_response.json(),
703
+ ),
704
+ )
705
+ return AsyncHttpResponse(response=_response, data=_data)
706
+ if _response.status_code == 422:
707
+ raise UnprocessableEntityError(
708
+ headers=dict(_response.headers),
709
+ body=typing.cast(
710
+ HttpValidationError,
711
+ parse_obj_as(
712
+ type_=HttpValidationError, # type: ignore
713
+ object_=_response.json(),
714
+ ),
715
+ ),
716
+ )
717
+ _response_json = _response.json()
718
+ except JSONDecodeError:
719
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
720
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
721
+
722
+ async def get_translation_results(
723
+ self,
724
+ *,
725
+ run_ids: typing.Sequence[int],
726
+ run_id: typing.Optional[int] = None,
727
+ traceparent: typing.Optional[str] = None,
728
+ request_options: typing.Optional[RequestOptions] = None,
729
+ ) -> AsyncHttpResponse[typing.Dict[str, TranslationResult]]:
730
+ """
731
+ Parameters
732
+ ----------
733
+ run_ids : typing.Sequence[int]
734
+
735
+ run_id : typing.Optional[int]
736
+
737
+ traceparent : typing.Optional[str]
738
+
739
+ request_options : typing.Optional[RequestOptions]
740
+ Request-specific configuration.
741
+
742
+ Returns
743
+ -------
744
+ AsyncHttpResponse[typing.Dict[str, TranslationResult]]
745
+ Successful Response
746
+ """
747
+ _response = await self._client_wrapper.httpx_client.request(
748
+ "translation-results",
749
+ method="POST",
750
+ params={
751
+ "run_id": run_id,
752
+ },
753
+ json={
754
+ "run_ids": run_ids,
755
+ },
756
+ headers={
757
+ "content-type": "application/json",
758
+ "traceparent": str(traceparent) if traceparent is not None else None,
759
+ },
760
+ request_options=request_options,
761
+ omit=OMIT,
762
+ )
763
+ try:
764
+ if 200 <= _response.status_code < 300:
765
+ _data = typing.cast(
766
+ typing.Dict[str, TranslationResult],
767
+ parse_obj_as(
768
+ type_=typing.Dict[str, TranslationResult], # type: ignore
769
+ object_=_response.json(),
770
+ ),
771
+ )
772
+ return AsyncHttpResponse(response=_response, data=_data)
773
+ if _response.status_code == 422:
774
+ raise UnprocessableEntityError(
775
+ headers=dict(_response.headers),
776
+ body=typing.cast(
777
+ HttpValidationError,
778
+ parse_obj_as(
779
+ type_=HttpValidationError, # type: ignore
780
+ object_=_response.json(),
781
+ ),
782
+ ),
783
+ )
784
+ _response_json = _response.json()
785
+ except JSONDecodeError:
786
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
787
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)