sarvamai 0.1.5a5__py3-none-any.whl → 0.1.5a6__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.
- sarvamai/__init__.py +1 -45
- sarvamai/chat/__init__.py +0 -2
- sarvamai/chat/client.py +10 -9
- sarvamai/chat/raw_client.py +37 -48
- sarvamai/client.py +31 -13
- sarvamai/core/__init__.py +0 -5
- sarvamai/core/api_error.py +5 -13
- sarvamai/core/client_wrapper.py +20 -17
- sarvamai/core/http_client.py +24 -70
- sarvamai/core/http_response.py +11 -19
- sarvamai/core/pydantic_utilities.py +108 -69
- sarvamai/environment.py +3 -10
- sarvamai/errors/__init__.py +0 -2
- sarvamai/errors/bad_request_error.py +3 -4
- sarvamai/errors/forbidden_error.py +3 -4
- sarvamai/errors/internal_server_error.py +3 -4
- sarvamai/errors/service_unavailable_error.py +2 -4
- sarvamai/errors/too_many_requests_error.py +3 -4
- sarvamai/errors/unprocessable_entity_error.py +3 -4
- sarvamai/requests/__init__.py +0 -18
- sarvamai/requests/chat_completion_request_message.py +1 -3
- sarvamai/requests/create_chat_completion_response.py +2 -2
- sarvamai/requests/diarized_transcript.py +1 -2
- sarvamai/requests/error_details.py +1 -0
- sarvamai/requests/language_identification_response.py +1 -0
- sarvamai/requests/speech_to_text_response.py +2 -1
- sarvamai/requests/speech_to_text_translate_response.py +1 -0
- sarvamai/requests/text_to_speech_response.py +2 -2
- sarvamai/requests/timestamps_model.py +1 -2
- sarvamai/requests/translation_response.py +1 -0
- sarvamai/requests/transliteration_response.py +1 -0
- sarvamai/speech_to_text/__init__.py +0 -2
- sarvamai/speech_to_text/client.py +14 -13
- sarvamai/speech_to_text/raw_client.py +68 -99
- sarvamai/text/__init__.py +0 -2
- sarvamai/text/client.py +25 -24
- sarvamai/text/raw_client.py +91 -126
- sarvamai/text_to_speech/__init__.py +0 -2
- sarvamai/text_to_speech/client.py +11 -10
- sarvamai/text_to_speech/raw_client.py +38 -49
- sarvamai/types/__init__.py +0 -24
- sarvamai/types/chat_completion_request_assistant_message.py +3 -3
- sarvamai/types/chat_completion_request_message.py +2 -3
- sarvamai/types/chat_completion_request_system_message.py +3 -3
- sarvamai/types/chat_completion_request_user_message.py +3 -3
- sarvamai/types/chat_completion_response_message.py +3 -3
- sarvamai/types/choice.py +4 -4
- sarvamai/types/completion_usage.py +3 -3
- sarvamai/types/create_chat_completion_response.py +3 -3
- sarvamai/types/diarized_entry.py +3 -3
- sarvamai/types/diarized_transcript.py +3 -3
- sarvamai/types/error_details.py +3 -3
- sarvamai/types/error_message.py +4 -4
- sarvamai/types/language_identification_response.py +2 -2
- sarvamai/types/speech_to_text_response.py +3 -3
- sarvamai/types/speech_to_text_translate_response.py +3 -3
- sarvamai/types/text_to_speech_response.py +2 -2
- sarvamai/types/timestamps_model.py +2 -2
- sarvamai/types/translation_response.py +2 -2
- sarvamai/types/transliteration_response.py +2 -2
- sarvamai-0.1.5a6.dist-info/METADATA +174 -0
- sarvamai-0.1.5a6.dist-info/RECORD +106 -0
- sarvamai/core/events.py +0 -30
- sarvamai/core/force_multipart.py +0 -16
- sarvamai/requests/audio_data.py +0 -21
- sarvamai/requests/audio_message.py +0 -8
- sarvamai/requests/error_data.py +0 -15
- sarvamai/requests/events_data.py +0 -17
- sarvamai/requests/speech_to_text_streaming_response.py +0 -10
- sarvamai/requests/speech_to_text_streaming_response_data.py +0 -9
- sarvamai/requests/transcription_data.py +0 -35
- sarvamai/requests/transcription_metrics.py +0 -15
- sarvamai/speech_to_text_streaming/__init__.py +0 -7
- sarvamai/speech_to_text_streaming/client.py +0 -189
- sarvamai/speech_to_text_streaming/raw_client.py +0 -166
- sarvamai/speech_to_text_streaming/socket_client.py +0 -129
- sarvamai/speech_to_text_streaming/types/__init__.py +0 -8
- sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_language_code.py +0 -8
- sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_model.py +0 -5
- sarvamai/types/audio_data.py +0 -33
- sarvamai/types/audio_data_encoding.py +0 -5
- sarvamai/types/audio_message.py +0 -20
- sarvamai/types/error_data.py +0 -27
- sarvamai/types/events_data.py +0 -28
- sarvamai/types/format.py +0 -5
- sarvamai/types/speech_to_text_streaming_response.py +0 -22
- sarvamai/types/speech_to_text_streaming_response_data.py +0 -9
- sarvamai/types/speech_to_text_streaming_response_type.py +0 -5
- sarvamai/types/transcription_data.py +0 -45
- sarvamai/types/transcription_metrics.py +0 -27
- sarvamai-0.1.5a5.dist-info/METADATA +0 -28
- sarvamai-0.1.5a5.dist-info/RECORD +0 -134
- {sarvamai-0.1.5a5.dist-info → sarvamai-0.1.5a6.dist-info}/WHEEL +0 -0
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
|
-
from
|
|
5
|
-
|
|
4
|
+
from ..core.client_wrapper import SyncClientWrapper
|
|
6
5
|
from .. import core
|
|
7
|
-
from ..
|
|
8
|
-
from ..
|
|
9
|
-
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
10
|
-
from ..core.pydantic_utilities import parse_obj_as
|
|
6
|
+
from ..types.speech_to_text_model import SpeechToTextModel
|
|
7
|
+
from ..types.speech_to_text_language import SpeechToTextLanguage
|
|
11
8
|
from ..core.request_options import RequestOptions
|
|
9
|
+
from ..core.http_response import HttpResponse
|
|
10
|
+
from ..types.speech_to_text_response import SpeechToTextResponse
|
|
11
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
12
12
|
from ..errors.bad_request_error import BadRequestError
|
|
13
13
|
from ..errors.forbidden_error import ForbiddenError
|
|
14
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
15
|
+
from ..errors.too_many_requests_error import TooManyRequestsError
|
|
14
16
|
from ..errors.internal_server_error import InternalServerError
|
|
15
17
|
from ..errors.service_unavailable_error import ServiceUnavailableError
|
|
16
|
-
from ..errors.too_many_requests_error import TooManyRequestsError
|
|
17
|
-
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
18
18
|
from ..types.error_message import ErrorMessage
|
|
19
|
-
from
|
|
20
|
-
from ..
|
|
21
|
-
from ..types.speech_to_text_response import SpeechToTextResponse
|
|
19
|
+
from json.decoder import JSONDecodeError
|
|
20
|
+
from ..core.api_error import ApiError
|
|
22
21
|
from ..types.speech_to_text_translate_model import SpeechToTextTranslateModel
|
|
23
22
|
from ..types.speech_to_text_translate_response import SpeechToTextTranslateResponse
|
|
23
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
|
24
|
+
from ..core.http_response import AsyncHttpResponse
|
|
24
25
|
|
|
25
26
|
# this is used as the default value for optional parameters
|
|
26
27
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -79,7 +80,6 @@ class RawSpeechToTextClient:
|
|
|
79
80
|
"""
|
|
80
81
|
_response = self._client_wrapper.httpx_client.request(
|
|
81
82
|
"speech-to-text",
|
|
82
|
-
base_url=self._client_wrapper.get_environment().base,
|
|
83
83
|
method="POST",
|
|
84
84
|
data={
|
|
85
85
|
"model": model,
|
|
@@ -90,7 +90,6 @@ class RawSpeechToTextClient:
|
|
|
90
90
|
},
|
|
91
91
|
request_options=request_options,
|
|
92
92
|
omit=OMIT,
|
|
93
|
-
force_multipart=True,
|
|
94
93
|
)
|
|
95
94
|
try:
|
|
96
95
|
if 200 <= _response.status_code < 300:
|
|
@@ -104,74 +103,68 @@ class RawSpeechToTextClient:
|
|
|
104
103
|
return HttpResponse(response=_response, data=_data)
|
|
105
104
|
if _response.status_code == 400:
|
|
106
105
|
raise BadRequestError(
|
|
107
|
-
|
|
108
|
-
body=typing.cast(
|
|
106
|
+
typing.cast(
|
|
109
107
|
typing.Optional[typing.Any],
|
|
110
108
|
parse_obj_as(
|
|
111
109
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
112
110
|
object_=_response.json(),
|
|
113
111
|
),
|
|
114
|
-
)
|
|
112
|
+
)
|
|
115
113
|
)
|
|
116
114
|
if _response.status_code == 403:
|
|
117
115
|
raise ForbiddenError(
|
|
118
|
-
|
|
119
|
-
body=typing.cast(
|
|
116
|
+
typing.cast(
|
|
120
117
|
typing.Optional[typing.Any],
|
|
121
118
|
parse_obj_as(
|
|
122
119
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
123
120
|
object_=_response.json(),
|
|
124
121
|
),
|
|
125
|
-
)
|
|
122
|
+
)
|
|
126
123
|
)
|
|
127
124
|
if _response.status_code == 422:
|
|
128
125
|
raise UnprocessableEntityError(
|
|
129
|
-
|
|
130
|
-
body=typing.cast(
|
|
126
|
+
typing.cast(
|
|
131
127
|
typing.Optional[typing.Any],
|
|
132
128
|
parse_obj_as(
|
|
133
129
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
134
130
|
object_=_response.json(),
|
|
135
131
|
),
|
|
136
|
-
)
|
|
132
|
+
)
|
|
137
133
|
)
|
|
138
134
|
if _response.status_code == 429:
|
|
139
135
|
raise TooManyRequestsError(
|
|
140
|
-
|
|
141
|
-
body=typing.cast(
|
|
136
|
+
typing.cast(
|
|
142
137
|
typing.Optional[typing.Any],
|
|
143
138
|
parse_obj_as(
|
|
144
139
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
145
140
|
object_=_response.json(),
|
|
146
141
|
),
|
|
147
|
-
)
|
|
142
|
+
)
|
|
148
143
|
)
|
|
149
144
|
if _response.status_code == 500:
|
|
150
145
|
raise InternalServerError(
|
|
151
|
-
|
|
152
|
-
body=typing.cast(
|
|
146
|
+
typing.cast(
|
|
153
147
|
typing.Optional[typing.Any],
|
|
154
148
|
parse_obj_as(
|
|
155
149
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
156
150
|
object_=_response.json(),
|
|
157
151
|
),
|
|
158
|
-
)
|
|
152
|
+
)
|
|
159
153
|
)
|
|
160
154
|
if _response.status_code == 503:
|
|
161
155
|
raise ServiceUnavailableError(
|
|
162
|
-
|
|
163
|
-
body=typing.cast(
|
|
156
|
+
typing.cast(
|
|
164
157
|
ErrorMessage,
|
|
165
158
|
parse_obj_as(
|
|
166
159
|
type_=ErrorMessage, # type: ignore
|
|
167
160
|
object_=_response.json(),
|
|
168
161
|
),
|
|
169
|
-
)
|
|
162
|
+
)
|
|
170
163
|
)
|
|
171
164
|
_response_json = _response.json()
|
|
172
165
|
except JSONDecodeError:
|
|
173
|
-
raise ApiError(status_code=_response.status_code,
|
|
174
|
-
raise ApiError(status_code=_response.status_code,
|
|
166
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
167
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
175
168
|
|
|
176
169
|
def translate(
|
|
177
170
|
self,
|
|
@@ -217,7 +210,6 @@ class RawSpeechToTextClient:
|
|
|
217
210
|
"""
|
|
218
211
|
_response = self._client_wrapper.httpx_client.request(
|
|
219
212
|
"speech-to-text-translate",
|
|
220
|
-
base_url=self._client_wrapper.get_environment().base,
|
|
221
213
|
method="POST",
|
|
222
214
|
data={
|
|
223
215
|
"prompt": prompt,
|
|
@@ -228,7 +220,6 @@ class RawSpeechToTextClient:
|
|
|
228
220
|
},
|
|
229
221
|
request_options=request_options,
|
|
230
222
|
omit=OMIT,
|
|
231
|
-
force_multipart=True,
|
|
232
223
|
)
|
|
233
224
|
try:
|
|
234
225
|
if 200 <= _response.status_code < 300:
|
|
@@ -242,74 +233,68 @@ class RawSpeechToTextClient:
|
|
|
242
233
|
return HttpResponse(response=_response, data=_data)
|
|
243
234
|
if _response.status_code == 400:
|
|
244
235
|
raise BadRequestError(
|
|
245
|
-
|
|
246
|
-
body=typing.cast(
|
|
236
|
+
typing.cast(
|
|
247
237
|
typing.Optional[typing.Any],
|
|
248
238
|
parse_obj_as(
|
|
249
239
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
250
240
|
object_=_response.json(),
|
|
251
241
|
),
|
|
252
|
-
)
|
|
242
|
+
)
|
|
253
243
|
)
|
|
254
244
|
if _response.status_code == 403:
|
|
255
245
|
raise ForbiddenError(
|
|
256
|
-
|
|
257
|
-
body=typing.cast(
|
|
246
|
+
typing.cast(
|
|
258
247
|
typing.Optional[typing.Any],
|
|
259
248
|
parse_obj_as(
|
|
260
249
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
261
250
|
object_=_response.json(),
|
|
262
251
|
),
|
|
263
|
-
)
|
|
252
|
+
)
|
|
264
253
|
)
|
|
265
254
|
if _response.status_code == 422:
|
|
266
255
|
raise UnprocessableEntityError(
|
|
267
|
-
|
|
268
|
-
body=typing.cast(
|
|
256
|
+
typing.cast(
|
|
269
257
|
typing.Optional[typing.Any],
|
|
270
258
|
parse_obj_as(
|
|
271
259
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
272
260
|
object_=_response.json(),
|
|
273
261
|
),
|
|
274
|
-
)
|
|
262
|
+
)
|
|
275
263
|
)
|
|
276
264
|
if _response.status_code == 429:
|
|
277
265
|
raise TooManyRequestsError(
|
|
278
|
-
|
|
279
|
-
body=typing.cast(
|
|
266
|
+
typing.cast(
|
|
280
267
|
typing.Optional[typing.Any],
|
|
281
268
|
parse_obj_as(
|
|
282
269
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
283
270
|
object_=_response.json(),
|
|
284
271
|
),
|
|
285
|
-
)
|
|
272
|
+
)
|
|
286
273
|
)
|
|
287
274
|
if _response.status_code == 500:
|
|
288
275
|
raise InternalServerError(
|
|
289
|
-
|
|
290
|
-
body=typing.cast(
|
|
276
|
+
typing.cast(
|
|
291
277
|
typing.Optional[typing.Any],
|
|
292
278
|
parse_obj_as(
|
|
293
279
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
294
280
|
object_=_response.json(),
|
|
295
281
|
),
|
|
296
|
-
)
|
|
282
|
+
)
|
|
297
283
|
)
|
|
298
284
|
if _response.status_code == 503:
|
|
299
285
|
raise ServiceUnavailableError(
|
|
300
|
-
|
|
301
|
-
body=typing.cast(
|
|
286
|
+
typing.cast(
|
|
302
287
|
ErrorMessage,
|
|
303
288
|
parse_obj_as(
|
|
304
289
|
type_=ErrorMessage, # type: ignore
|
|
305
290
|
object_=_response.json(),
|
|
306
291
|
),
|
|
307
|
-
)
|
|
292
|
+
)
|
|
308
293
|
)
|
|
309
294
|
_response_json = _response.json()
|
|
310
295
|
except JSONDecodeError:
|
|
311
|
-
raise ApiError(status_code=_response.status_code,
|
|
312
|
-
raise ApiError(status_code=_response.status_code,
|
|
296
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
297
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
313
298
|
|
|
314
299
|
|
|
315
300
|
class AsyncRawSpeechToTextClient:
|
|
@@ -365,7 +350,6 @@ class AsyncRawSpeechToTextClient:
|
|
|
365
350
|
"""
|
|
366
351
|
_response = await self._client_wrapper.httpx_client.request(
|
|
367
352
|
"speech-to-text",
|
|
368
|
-
base_url=self._client_wrapper.get_environment().base,
|
|
369
353
|
method="POST",
|
|
370
354
|
data={
|
|
371
355
|
"model": model,
|
|
@@ -376,7 +360,6 @@ class AsyncRawSpeechToTextClient:
|
|
|
376
360
|
},
|
|
377
361
|
request_options=request_options,
|
|
378
362
|
omit=OMIT,
|
|
379
|
-
force_multipart=True,
|
|
380
363
|
)
|
|
381
364
|
try:
|
|
382
365
|
if 200 <= _response.status_code < 300:
|
|
@@ -390,74 +373,68 @@ class AsyncRawSpeechToTextClient:
|
|
|
390
373
|
return AsyncHttpResponse(response=_response, data=_data)
|
|
391
374
|
if _response.status_code == 400:
|
|
392
375
|
raise BadRequestError(
|
|
393
|
-
|
|
394
|
-
body=typing.cast(
|
|
376
|
+
typing.cast(
|
|
395
377
|
typing.Optional[typing.Any],
|
|
396
378
|
parse_obj_as(
|
|
397
379
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
398
380
|
object_=_response.json(),
|
|
399
381
|
),
|
|
400
|
-
)
|
|
382
|
+
)
|
|
401
383
|
)
|
|
402
384
|
if _response.status_code == 403:
|
|
403
385
|
raise ForbiddenError(
|
|
404
|
-
|
|
405
|
-
body=typing.cast(
|
|
386
|
+
typing.cast(
|
|
406
387
|
typing.Optional[typing.Any],
|
|
407
388
|
parse_obj_as(
|
|
408
389
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
409
390
|
object_=_response.json(),
|
|
410
391
|
),
|
|
411
|
-
)
|
|
392
|
+
)
|
|
412
393
|
)
|
|
413
394
|
if _response.status_code == 422:
|
|
414
395
|
raise UnprocessableEntityError(
|
|
415
|
-
|
|
416
|
-
body=typing.cast(
|
|
396
|
+
typing.cast(
|
|
417
397
|
typing.Optional[typing.Any],
|
|
418
398
|
parse_obj_as(
|
|
419
399
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
420
400
|
object_=_response.json(),
|
|
421
401
|
),
|
|
422
|
-
)
|
|
402
|
+
)
|
|
423
403
|
)
|
|
424
404
|
if _response.status_code == 429:
|
|
425
405
|
raise TooManyRequestsError(
|
|
426
|
-
|
|
427
|
-
body=typing.cast(
|
|
406
|
+
typing.cast(
|
|
428
407
|
typing.Optional[typing.Any],
|
|
429
408
|
parse_obj_as(
|
|
430
409
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
431
410
|
object_=_response.json(),
|
|
432
411
|
),
|
|
433
|
-
)
|
|
412
|
+
)
|
|
434
413
|
)
|
|
435
414
|
if _response.status_code == 500:
|
|
436
415
|
raise InternalServerError(
|
|
437
|
-
|
|
438
|
-
body=typing.cast(
|
|
416
|
+
typing.cast(
|
|
439
417
|
typing.Optional[typing.Any],
|
|
440
418
|
parse_obj_as(
|
|
441
419
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
442
420
|
object_=_response.json(),
|
|
443
421
|
),
|
|
444
|
-
)
|
|
422
|
+
)
|
|
445
423
|
)
|
|
446
424
|
if _response.status_code == 503:
|
|
447
425
|
raise ServiceUnavailableError(
|
|
448
|
-
|
|
449
|
-
body=typing.cast(
|
|
426
|
+
typing.cast(
|
|
450
427
|
ErrorMessage,
|
|
451
428
|
parse_obj_as(
|
|
452
429
|
type_=ErrorMessage, # type: ignore
|
|
453
430
|
object_=_response.json(),
|
|
454
431
|
),
|
|
455
|
-
)
|
|
432
|
+
)
|
|
456
433
|
)
|
|
457
434
|
_response_json = _response.json()
|
|
458
435
|
except JSONDecodeError:
|
|
459
|
-
raise ApiError(status_code=_response.status_code,
|
|
460
|
-
raise ApiError(status_code=_response.status_code,
|
|
436
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
437
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
461
438
|
|
|
462
439
|
async def translate(
|
|
463
440
|
self,
|
|
@@ -503,7 +480,6 @@ class AsyncRawSpeechToTextClient:
|
|
|
503
480
|
"""
|
|
504
481
|
_response = await self._client_wrapper.httpx_client.request(
|
|
505
482
|
"speech-to-text-translate",
|
|
506
|
-
base_url=self._client_wrapper.get_environment().base,
|
|
507
483
|
method="POST",
|
|
508
484
|
data={
|
|
509
485
|
"prompt": prompt,
|
|
@@ -514,7 +490,6 @@ class AsyncRawSpeechToTextClient:
|
|
|
514
490
|
},
|
|
515
491
|
request_options=request_options,
|
|
516
492
|
omit=OMIT,
|
|
517
|
-
force_multipart=True,
|
|
518
493
|
)
|
|
519
494
|
try:
|
|
520
495
|
if 200 <= _response.status_code < 300:
|
|
@@ -528,71 +503,65 @@ class AsyncRawSpeechToTextClient:
|
|
|
528
503
|
return AsyncHttpResponse(response=_response, data=_data)
|
|
529
504
|
if _response.status_code == 400:
|
|
530
505
|
raise BadRequestError(
|
|
531
|
-
|
|
532
|
-
body=typing.cast(
|
|
506
|
+
typing.cast(
|
|
533
507
|
typing.Optional[typing.Any],
|
|
534
508
|
parse_obj_as(
|
|
535
509
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
536
510
|
object_=_response.json(),
|
|
537
511
|
),
|
|
538
|
-
)
|
|
512
|
+
)
|
|
539
513
|
)
|
|
540
514
|
if _response.status_code == 403:
|
|
541
515
|
raise ForbiddenError(
|
|
542
|
-
|
|
543
|
-
body=typing.cast(
|
|
516
|
+
typing.cast(
|
|
544
517
|
typing.Optional[typing.Any],
|
|
545
518
|
parse_obj_as(
|
|
546
519
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
547
520
|
object_=_response.json(),
|
|
548
521
|
),
|
|
549
|
-
)
|
|
522
|
+
)
|
|
550
523
|
)
|
|
551
524
|
if _response.status_code == 422:
|
|
552
525
|
raise UnprocessableEntityError(
|
|
553
|
-
|
|
554
|
-
body=typing.cast(
|
|
526
|
+
typing.cast(
|
|
555
527
|
typing.Optional[typing.Any],
|
|
556
528
|
parse_obj_as(
|
|
557
529
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
558
530
|
object_=_response.json(),
|
|
559
531
|
),
|
|
560
|
-
)
|
|
532
|
+
)
|
|
561
533
|
)
|
|
562
534
|
if _response.status_code == 429:
|
|
563
535
|
raise TooManyRequestsError(
|
|
564
|
-
|
|
565
|
-
body=typing.cast(
|
|
536
|
+
typing.cast(
|
|
566
537
|
typing.Optional[typing.Any],
|
|
567
538
|
parse_obj_as(
|
|
568
539
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
569
540
|
object_=_response.json(),
|
|
570
541
|
),
|
|
571
|
-
)
|
|
542
|
+
)
|
|
572
543
|
)
|
|
573
544
|
if _response.status_code == 500:
|
|
574
545
|
raise InternalServerError(
|
|
575
|
-
|
|
576
|
-
body=typing.cast(
|
|
546
|
+
typing.cast(
|
|
577
547
|
typing.Optional[typing.Any],
|
|
578
548
|
parse_obj_as(
|
|
579
549
|
type_=typing.Optional[typing.Any], # type: ignore
|
|
580
550
|
object_=_response.json(),
|
|
581
551
|
),
|
|
582
|
-
)
|
|
552
|
+
)
|
|
583
553
|
)
|
|
584
554
|
if _response.status_code == 503:
|
|
585
555
|
raise ServiceUnavailableError(
|
|
586
|
-
|
|
587
|
-
body=typing.cast(
|
|
556
|
+
typing.cast(
|
|
588
557
|
ErrorMessage,
|
|
589
558
|
parse_obj_as(
|
|
590
559
|
type_=ErrorMessage, # type: ignore
|
|
591
560
|
object_=_response.json(),
|
|
592
561
|
),
|
|
593
|
-
)
|
|
562
|
+
)
|
|
594
563
|
)
|
|
595
564
|
_response_json = _response.json()
|
|
596
565
|
except JSONDecodeError:
|
|
597
|
-
raise ApiError(status_code=_response.status_code,
|
|
598
|
-
raise ApiError(status_code=_response.status_code,
|
|
566
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
567
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
sarvamai/text/__init__.py
CHANGED
sarvamai/text/client.py
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
|
-
|
|
5
|
-
from
|
|
6
|
-
from ..core.request_options import RequestOptions
|
|
7
|
-
from ..types.language_identification_response import LanguageIdentificationResponse
|
|
8
|
-
from ..types.numerals_format import NumeralsFormat
|
|
9
|
-
from ..types.spoken_form_numerals_format import SpokenFormNumeralsFormat
|
|
10
|
-
from ..types.translate_mode import TranslateMode
|
|
11
|
-
from ..types.translate_model import TranslateModel
|
|
4
|
+
from ..core.client_wrapper import SyncClientWrapper
|
|
5
|
+
from .raw_client import RawTextClient
|
|
12
6
|
from ..types.translate_source_language import TranslateSourceLanguage
|
|
13
|
-
from ..types.translate_speaker_gender import TranslateSpeakerGender
|
|
14
7
|
from ..types.translate_target_language import TranslateTargetLanguage
|
|
15
|
-
from ..types.
|
|
16
|
-
from ..types.
|
|
8
|
+
from ..types.translate_speaker_gender import TranslateSpeakerGender
|
|
9
|
+
from ..types.translate_mode import TranslateMode
|
|
10
|
+
from ..types.translate_model import TranslateModel
|
|
17
11
|
from ..types.transliterate_mode import TransliterateMode
|
|
12
|
+
from ..types.numerals_format import NumeralsFormat
|
|
13
|
+
from ..core.request_options import RequestOptions
|
|
14
|
+
from ..types.translation_response import TranslationResponse
|
|
15
|
+
from ..types.language_identification_response import LanguageIdentificationResponse
|
|
18
16
|
from ..types.transliterate_source_language import TransliterateSourceLanguage
|
|
17
|
+
from ..types.translatiterate_target_language import TranslatiterateTargetLanguage
|
|
18
|
+
from ..types.spoken_form_numerals_format import SpokenFormNumeralsFormat
|
|
19
19
|
from ..types.transliteration_response import TransliterationResponse
|
|
20
|
-
from .
|
|
20
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
|
21
|
+
from .raw_client import AsyncRawTextClient
|
|
21
22
|
|
|
22
23
|
# this is used as the default value for optional parameters
|
|
23
24
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -179,7 +180,7 @@ class TextClient:
|
|
|
179
180
|
target_language_code="bn-IN",
|
|
180
181
|
)
|
|
181
182
|
"""
|
|
182
|
-
|
|
183
|
+
response = self._raw_client.translate(
|
|
183
184
|
input=input,
|
|
184
185
|
source_language_code=source_language_code,
|
|
185
186
|
target_language_code=target_language_code,
|
|
@@ -191,7 +192,7 @@ class TextClient:
|
|
|
191
192
|
numerals_format=numerals_format,
|
|
192
193
|
request_options=request_options,
|
|
193
194
|
)
|
|
194
|
-
return
|
|
195
|
+
return response.data
|
|
195
196
|
|
|
196
197
|
def identify_language(
|
|
197
198
|
self, *, input: str, request_options: typing.Optional[RequestOptions] = None
|
|
@@ -223,8 +224,8 @@ class TextClient:
|
|
|
223
224
|
input="input",
|
|
224
225
|
)
|
|
225
226
|
"""
|
|
226
|
-
|
|
227
|
-
return
|
|
227
|
+
response = self._raw_client.identify_language(input=input, request_options=request_options)
|
|
228
|
+
return response.data
|
|
228
229
|
|
|
229
230
|
def transliterate(
|
|
230
231
|
self,
|
|
@@ -335,7 +336,7 @@ class TextClient:
|
|
|
335
336
|
target_language_code="bn-IN",
|
|
336
337
|
)
|
|
337
338
|
"""
|
|
338
|
-
|
|
339
|
+
response = self._raw_client.transliterate(
|
|
339
340
|
input=input,
|
|
340
341
|
source_language_code=source_language_code,
|
|
341
342
|
target_language_code=target_language_code,
|
|
@@ -344,7 +345,7 @@ class TextClient:
|
|
|
344
345
|
spoken_form=spoken_form,
|
|
345
346
|
request_options=request_options,
|
|
346
347
|
)
|
|
347
|
-
return
|
|
348
|
+
return response.data
|
|
348
349
|
|
|
349
350
|
|
|
350
351
|
class AsyncTextClient:
|
|
@@ -511,7 +512,7 @@ class AsyncTextClient:
|
|
|
511
512
|
|
|
512
513
|
asyncio.run(main())
|
|
513
514
|
"""
|
|
514
|
-
|
|
515
|
+
response = await self._raw_client.translate(
|
|
515
516
|
input=input,
|
|
516
517
|
source_language_code=source_language_code,
|
|
517
518
|
target_language_code=target_language_code,
|
|
@@ -523,7 +524,7 @@ class AsyncTextClient:
|
|
|
523
524
|
numerals_format=numerals_format,
|
|
524
525
|
request_options=request_options,
|
|
525
526
|
)
|
|
526
|
-
return
|
|
527
|
+
return response.data
|
|
527
528
|
|
|
528
529
|
async def identify_language(
|
|
529
530
|
self, *, input: str, request_options: typing.Optional[RequestOptions] = None
|
|
@@ -563,8 +564,8 @@ class AsyncTextClient:
|
|
|
563
564
|
|
|
564
565
|
asyncio.run(main())
|
|
565
566
|
"""
|
|
566
|
-
|
|
567
|
-
return
|
|
567
|
+
response = await self._raw_client.identify_language(input=input, request_options=request_options)
|
|
568
|
+
return response.data
|
|
568
569
|
|
|
569
570
|
async def transliterate(
|
|
570
571
|
self,
|
|
@@ -683,7 +684,7 @@ class AsyncTextClient:
|
|
|
683
684
|
|
|
684
685
|
asyncio.run(main())
|
|
685
686
|
"""
|
|
686
|
-
|
|
687
|
+
response = await self._raw_client.transliterate(
|
|
687
688
|
input=input,
|
|
688
689
|
source_language_code=source_language_code,
|
|
689
690
|
target_language_code=target_language_code,
|
|
@@ -692,4 +693,4 @@ class AsyncTextClient:
|
|
|
692
693
|
spoken_form=spoken_form,
|
|
693
694
|
request_options=request_options,
|
|
694
695
|
)
|
|
695
|
-
return
|
|
696
|
+
return response.data
|