sarvamai 0.1.5a6__py3-none-any.whl → 0.1.5a7__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 (93) hide show
  1. sarvamai/__init__.py +45 -1
  2. sarvamai/chat/__init__.py +2 -0
  3. sarvamai/chat/client.py +9 -10
  4. sarvamai/chat/raw_client.py +48 -37
  5. sarvamai/client.py +13 -31
  6. sarvamai/core/__init__.py +5 -0
  7. sarvamai/core/api_error.py +13 -5
  8. sarvamai/core/client_wrapper.py +17 -20
  9. sarvamai/core/events.py +30 -0
  10. sarvamai/core/force_multipart.py +16 -0
  11. sarvamai/core/http_client.py +70 -24
  12. sarvamai/core/http_response.py +19 -11
  13. sarvamai/core/pydantic_utilities.py +69 -108
  14. sarvamai/environment.py +10 -3
  15. sarvamai/errors/__init__.py +2 -0
  16. sarvamai/errors/bad_request_error.py +4 -3
  17. sarvamai/errors/forbidden_error.py +4 -3
  18. sarvamai/errors/internal_server_error.py +4 -3
  19. sarvamai/errors/service_unavailable_error.py +4 -2
  20. sarvamai/errors/too_many_requests_error.py +4 -3
  21. sarvamai/errors/unprocessable_entity_error.py +4 -3
  22. sarvamai/requests/__init__.py +18 -0
  23. sarvamai/requests/audio_data.py +21 -0
  24. sarvamai/requests/audio_message.py +8 -0
  25. sarvamai/requests/chat_completion_request_message.py +3 -1
  26. sarvamai/requests/create_chat_completion_response.py +2 -2
  27. sarvamai/requests/diarized_transcript.py +2 -1
  28. sarvamai/requests/error_data.py +15 -0
  29. sarvamai/requests/error_details.py +0 -1
  30. sarvamai/requests/events_data.py +17 -0
  31. sarvamai/requests/language_identification_response.py +0 -1
  32. sarvamai/requests/speech_to_text_response.py +1 -2
  33. sarvamai/requests/speech_to_text_streaming_response.py +10 -0
  34. sarvamai/requests/speech_to_text_streaming_response_data.py +9 -0
  35. sarvamai/requests/speech_to_text_translate_response.py +0 -1
  36. sarvamai/requests/text_to_speech_response.py +2 -2
  37. sarvamai/requests/timestamps_model.py +2 -1
  38. sarvamai/requests/transcription_data.py +35 -0
  39. sarvamai/requests/transcription_metrics.py +15 -0
  40. sarvamai/requests/translation_response.py +0 -1
  41. sarvamai/requests/transliteration_response.py +0 -1
  42. sarvamai/speech_to_text/__init__.py +2 -0
  43. sarvamai/speech_to_text/client.py +13 -14
  44. sarvamai/speech_to_text/raw_client.py +99 -68
  45. sarvamai/speech_to_text_streaming/__init__.py +7 -0
  46. sarvamai/speech_to_text_streaming/client.py +189 -0
  47. sarvamai/speech_to_text_streaming/raw_client.py +166 -0
  48. sarvamai/speech_to_text_streaming/socket_client.py +129 -0
  49. sarvamai/speech_to_text_streaming/types/__init__.py +8 -0
  50. sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_language_code.py +8 -0
  51. sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_model.py +5 -0
  52. sarvamai/text/__init__.py +2 -0
  53. sarvamai/text/client.py +24 -25
  54. sarvamai/text/raw_client.py +126 -91
  55. sarvamai/text_to_speech/__init__.py +2 -0
  56. sarvamai/text_to_speech/client.py +10 -11
  57. sarvamai/text_to_speech/raw_client.py +49 -38
  58. sarvamai/types/__init__.py +24 -0
  59. sarvamai/types/audio_data.py +33 -0
  60. sarvamai/types/audio_data_encoding.py +5 -0
  61. sarvamai/types/audio_message.py +20 -0
  62. sarvamai/types/chat_completion_request_assistant_message.py +3 -3
  63. sarvamai/types/chat_completion_request_message.py +3 -2
  64. sarvamai/types/chat_completion_request_system_message.py +3 -3
  65. sarvamai/types/chat_completion_request_user_message.py +3 -3
  66. sarvamai/types/chat_completion_response_message.py +3 -3
  67. sarvamai/types/choice.py +4 -4
  68. sarvamai/types/completion_usage.py +3 -3
  69. sarvamai/types/create_chat_completion_response.py +3 -3
  70. sarvamai/types/diarized_entry.py +3 -3
  71. sarvamai/types/diarized_transcript.py +3 -3
  72. sarvamai/types/error_data.py +27 -0
  73. sarvamai/types/error_details.py +3 -3
  74. sarvamai/types/error_message.py +4 -4
  75. sarvamai/types/events_data.py +28 -0
  76. sarvamai/types/format.py +5 -0
  77. sarvamai/types/language_identification_response.py +2 -2
  78. sarvamai/types/speech_to_text_response.py +3 -3
  79. sarvamai/types/speech_to_text_streaming_response.py +22 -0
  80. sarvamai/types/speech_to_text_streaming_response_data.py +9 -0
  81. sarvamai/types/speech_to_text_streaming_response_type.py +5 -0
  82. sarvamai/types/speech_to_text_translate_response.py +3 -3
  83. sarvamai/types/text_to_speech_response.py +2 -2
  84. sarvamai/types/timestamps_model.py +2 -2
  85. sarvamai/types/transcription_data.py +45 -0
  86. sarvamai/types/transcription_metrics.py +27 -0
  87. sarvamai/types/translation_response.py +2 -2
  88. sarvamai/types/transliteration_response.py +2 -2
  89. sarvamai-0.1.5a7.dist-info/METADATA +28 -0
  90. sarvamai-0.1.5a7.dist-info/RECORD +134 -0
  91. sarvamai-0.1.5a6.dist-info/METADATA +0 -174
  92. sarvamai-0.1.5a6.dist-info/RECORD +0 -106
  93. {sarvamai-0.1.5a6.dist-info → sarvamai-0.1.5a7.dist-info}/WHEEL +0 -0
@@ -1,9 +1,11 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
+ import typing
4
+
3
5
  from ..core.api_error import ApiError
4
6
  from ..types.error_message import ErrorMessage
5
7
 
6
8
 
7
9
  class ServiceUnavailableError(ApiError):
8
- def __init__(self, body: ErrorMessage):
9
- super().__init__(status_code=503, body=body)
10
+ def __init__(self, body: ErrorMessage, headers: typing.Optional[typing.Dict[str, str]] = None):
11
+ super().__init__(status_code=503, headers=headers, body=body)
@@ -1,9 +1,10 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- from ..core.api_error import ApiError
4
3
  import typing
5
4
 
5
+ from ..core.api_error import ApiError
6
+
6
7
 
7
8
  class TooManyRequestsError(ApiError):
8
- def __init__(self, body: typing.Optional[typing.Any]):
9
- super().__init__(status_code=429, body=body)
9
+ def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
10
+ super().__init__(status_code=429, headers=headers, body=body)
@@ -1,9 +1,10 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- from ..core.api_error import ApiError
4
3
  import typing
5
4
 
5
+ from ..core.api_error import ApiError
6
+
6
7
 
7
8
  class UnprocessableEntityError(ApiError):
8
- def __init__(self, body: typing.Optional[typing.Any]):
9
- super().__init__(status_code=422, body=body)
9
+ def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
10
+ super().__init__(status_code=422, headers=headers, body=body)
@@ -1,5 +1,9 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
+ # isort: skip_file
4
+
5
+ from .audio_data import AudioDataParams
6
+ from .audio_message import AudioMessageParams
3
7
  from .chat_completion_request_assistant_message import ChatCompletionRequestAssistantMessageParams
4
8
  from .chat_completion_request_message import (
5
9
  ChatCompletionRequestMessageParams,
@@ -15,18 +19,26 @@ from .completion_usage import CompletionUsageParams
15
19
  from .create_chat_completion_response import CreateChatCompletionResponseParams
16
20
  from .diarized_entry import DiarizedEntryParams
17
21
  from .diarized_transcript import DiarizedTranscriptParams
22
+ from .error_data import ErrorDataParams
18
23
  from .error_details import ErrorDetailsParams
19
24
  from .error_message import ErrorMessageParams
25
+ from .events_data import EventsDataParams
20
26
  from .language_identification_response import LanguageIdentificationResponseParams
21
27
  from .speech_to_text_response import SpeechToTextResponseParams
28
+ from .speech_to_text_streaming_response import SpeechToTextStreamingResponseParams
29
+ from .speech_to_text_streaming_response_data import SpeechToTextStreamingResponseDataParams
22
30
  from .speech_to_text_translate_response import SpeechToTextTranslateResponseParams
23
31
  from .stop_configuration import StopConfigurationParams
24
32
  from .text_to_speech_response import TextToSpeechResponseParams
25
33
  from .timestamps_model import TimestampsModelParams
34
+ from .transcription_data import TranscriptionDataParams
35
+ from .transcription_metrics import TranscriptionMetricsParams
26
36
  from .translation_response import TranslationResponseParams
27
37
  from .transliteration_response import TransliterationResponseParams
28
38
 
29
39
  __all__ = [
40
+ "AudioDataParams",
41
+ "AudioMessageParams",
30
42
  "ChatCompletionRequestAssistantMessageParams",
31
43
  "ChatCompletionRequestMessageParams",
32
44
  "ChatCompletionRequestMessage_AssistantParams",
@@ -40,14 +52,20 @@ __all__ = [
40
52
  "CreateChatCompletionResponseParams",
41
53
  "DiarizedEntryParams",
42
54
  "DiarizedTranscriptParams",
55
+ "ErrorDataParams",
43
56
  "ErrorDetailsParams",
44
57
  "ErrorMessageParams",
58
+ "EventsDataParams",
45
59
  "LanguageIdentificationResponseParams",
46
60
  "SpeechToTextResponseParams",
61
+ "SpeechToTextStreamingResponseDataParams",
62
+ "SpeechToTextStreamingResponseParams",
47
63
  "SpeechToTextTranslateResponseParams",
48
64
  "StopConfigurationParams",
49
65
  "TextToSpeechResponseParams",
50
66
  "TimestampsModelParams",
67
+ "TranscriptionDataParams",
68
+ "TranscriptionMetricsParams",
51
69
  "TranslationResponseParams",
52
70
  "TransliterationResponseParams",
53
71
  ]
@@ -0,0 +1,21 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing_extensions
4
+ from ..types.audio_data_encoding import AudioDataEncoding
5
+
6
+
7
+ class AudioDataParams(typing_extensions.TypedDict):
8
+ data: str
9
+ """
10
+ Base64 encoded audio data
11
+ """
12
+
13
+ sample_rate: int
14
+ """
15
+ Audio sample rate in Hz (16kHz preferred, 8kHz least preferred)
16
+ """
17
+
18
+ encoding: AudioDataEncoding
19
+ """
20
+ Audio encoding format
21
+ """
@@ -0,0 +1,8 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing_extensions
4
+ from .audio_data import AudioDataParams
5
+
6
+
7
+ class AudioMessageParams(typing_extensions.TypedDict):
8
+ audio: AudioDataParams
@@ -1,9 +1,11 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
3
  from __future__ import annotations
4
- import typing_extensions
4
+
5
5
  import typing
6
6
 
7
+ import typing_extensions
8
+
7
9
 
8
10
  class ChatCompletionRequestMessage_AssistantParams(typing_extensions.TypedDict):
9
11
  role: typing.Literal["assistant"]
@@ -1,9 +1,9 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import typing_extensions
4
3
  import typing
5
- from .choice import ChoiceParams
4
+
6
5
  import typing_extensions
6
+ from .choice import ChoiceParams
7
7
  from .completion_usage import CompletionUsageParams
8
8
 
9
9
 
@@ -1,7 +1,8 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import typing_extensions
4
3
  import typing
4
+
5
+ import typing_extensions
5
6
  from .diarized_entry import DiarizedEntryParams
6
7
 
7
8
 
@@ -0,0 +1,15 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing_extensions
4
+
5
+
6
+ class ErrorDataParams(typing_extensions.TypedDict):
7
+ error: str
8
+ """
9
+ Error message
10
+ """
11
+
12
+ code: str
13
+ """
14
+ Error code
15
+ """
@@ -2,7 +2,6 @@
2
2
 
3
3
  import typing_extensions
4
4
  from ..types.error_code import ErrorCode
5
- import typing_extensions
6
5
 
7
6
 
8
7
  class ErrorDetailsParams(typing_extensions.TypedDict):
@@ -0,0 +1,17 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+
5
+ import typing_extensions
6
+
7
+
8
+ class EventsDataParams(typing_extensions.TypedDict):
9
+ event_type: str
10
+ """
11
+ Type of event
12
+ """
13
+
14
+ timestamp: dt.datetime
15
+ """
16
+ Event timestamp
17
+ """
@@ -1,7 +1,6 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
3
  import typing_extensions
4
- import typing_extensions
5
4
 
6
5
 
7
6
  class LanguageIdentificationResponseParams(typing_extensions.TypedDict):
@@ -1,9 +1,8 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
3
  import typing_extensions
4
- import typing_extensions
5
- from .timestamps_model import TimestampsModelParams
6
4
  from .diarized_transcript import DiarizedTranscriptParams
5
+ from .timestamps_model import TimestampsModelParams
7
6
 
8
7
 
9
8
  class SpeechToTextResponseParams(typing_extensions.TypedDict):
@@ -0,0 +1,10 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing_extensions
4
+ from ..types.speech_to_text_streaming_response_type import SpeechToTextStreamingResponseType
5
+ from .speech_to_text_streaming_response_data import SpeechToTextStreamingResponseDataParams
6
+
7
+
8
+ class SpeechToTextStreamingResponseParams(typing_extensions.TypedDict):
9
+ type: SpeechToTextStreamingResponseType
10
+ data: SpeechToTextStreamingResponseDataParams
@@ -0,0 +1,9 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from .error_data import ErrorDataParams
6
+ from .events_data import EventsDataParams
7
+ from .transcription_data import TranscriptionDataParams
8
+
9
+ SpeechToTextStreamingResponseDataParams = typing.Union[TranscriptionDataParams, ErrorDataParams, EventsDataParams]
@@ -1,6 +1,5 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import typing_extensions
4
3
  import typing_extensions
5
4
  from ..types.speech_to_text_translate_language import SpeechToTextTranslateLanguage
6
5
  from .diarized_transcript import DiarizedTranscriptParams
@@ -1,9 +1,9 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import typing_extensions
4
- import typing_extensions
5
3
  import typing
6
4
 
5
+ import typing_extensions
6
+
7
7
 
8
8
  class TextToSpeechResponseParams(typing_extensions.TypedDict):
9
9
  request_id: typing_extensions.NotRequired[str]
@@ -1,8 +1,9 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import typing_extensions
4
3
  import typing
5
4
 
5
+ import typing_extensions
6
+
6
7
 
7
8
  class TimestampsModelParams(typing_extensions.TypedDict):
8
9
  words: typing.Sequence[str]
@@ -0,0 +1,35 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import typing_extensions
6
+ from .transcription_metrics import TranscriptionMetricsParams
7
+
8
+
9
+ class TranscriptionDataParams(typing_extensions.TypedDict):
10
+ request_id: str
11
+ """
12
+ Unique identifier for the request
13
+ """
14
+
15
+ transcript: str
16
+ """
17
+ Transcript of the provided speech
18
+ """
19
+
20
+ timestamps: typing_extensions.NotRequired[typing.Dict[str, typing.Optional[typing.Any]]]
21
+ """
22
+ Timestamp information (if available)
23
+ """
24
+
25
+ diarized_transcript: typing_extensions.NotRequired[typing.Dict[str, typing.Optional[typing.Any]]]
26
+ """
27
+ Diarized transcript of the provided speech
28
+ """
29
+
30
+ language_code: typing_extensions.NotRequired[str]
31
+ """
32
+ BCP-47 code of detected language
33
+ """
34
+
35
+ metrics: TranscriptionMetricsParams
@@ -0,0 +1,15 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing_extensions
4
+
5
+
6
+ class TranscriptionMetricsParams(typing_extensions.TypedDict):
7
+ audio_duration: float
8
+ """
9
+ Duration of processed audio in seconds
10
+ """
11
+
12
+ processing_latency: float
13
+ """
14
+ Processing latency in seconds
15
+ """
@@ -1,7 +1,6 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
3
  import typing_extensions
4
- import typing_extensions
5
4
 
6
5
 
7
6
  class TranslationResponseParams(typing_extensions.TypedDict):
@@ -1,7 +1,6 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
3
  import typing_extensions
4
- import typing_extensions
5
4
 
6
5
 
7
6
  class TransliterationResponseParams(typing_extensions.TypedDict):
@@ -1,2 +1,4 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
+ # isort: skip_file
4
+
@@ -1,17 +1,16 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
3
  import typing
4
- from ..core.client_wrapper import SyncClientWrapper
5
- from .raw_client import RawSpeechToTextClient
4
+
6
5
  from .. import core
7
- from ..types.speech_to_text_model import SpeechToTextModel
8
- from ..types.speech_to_text_language import SpeechToTextLanguage
6
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
7
  from ..core.request_options import RequestOptions
8
+ from ..types.speech_to_text_language import SpeechToTextLanguage
9
+ from ..types.speech_to_text_model import SpeechToTextModel
10
10
  from ..types.speech_to_text_response import SpeechToTextResponse
11
11
  from ..types.speech_to_text_translate_model import SpeechToTextTranslateModel
12
12
  from ..types.speech_to_text_translate_response import SpeechToTextTranslateResponse
13
- from ..core.client_wrapper import AsyncClientWrapper
14
- from .raw_client import AsyncRawSpeechToTextClient
13
+ from .raw_client import AsyncRawSpeechToTextClient, RawSpeechToTextClient
15
14
 
16
15
  # this is used as the default value for optional parameters
17
16
  OMIT = typing.cast(typing.Any, ...)
@@ -88,10 +87,10 @@ class SpeechToTextClient:
88
87
  )
89
88
  client.speech_to_text.transcribe()
90
89
  """
91
- response = self._raw_client.transcribe(
90
+ _response = self._raw_client.transcribe(
92
91
  file=file, model=model, language_code=language_code, request_options=request_options
93
92
  )
94
- return response.data
93
+ return _response.data
95
94
 
96
95
  def translate(
97
96
  self,
@@ -144,8 +143,8 @@ class SpeechToTextClient:
144
143
  )
145
144
  client.speech_to_text.translate()
146
145
  """
147
- response = self._raw_client.translate(file=file, prompt=prompt, model=model, request_options=request_options)
148
- return response.data
146
+ _response = self._raw_client.translate(file=file, prompt=prompt, model=model, request_options=request_options)
147
+ return _response.data
149
148
 
150
149
 
151
150
  class AsyncSpeechToTextClient:
@@ -227,10 +226,10 @@ class AsyncSpeechToTextClient:
227
226
 
228
227
  asyncio.run(main())
229
228
  """
230
- response = await self._raw_client.transcribe(
229
+ _response = await self._raw_client.transcribe(
231
230
  file=file, model=model, language_code=language_code, request_options=request_options
232
231
  )
233
- return response.data
232
+ return _response.data
234
233
 
235
234
  async def translate(
236
235
  self,
@@ -291,7 +290,7 @@ class AsyncSpeechToTextClient:
291
290
 
292
291
  asyncio.run(main())
293
292
  """
294
- response = await self._raw_client.translate(
293
+ _response = await self._raw_client.translate(
295
294
  file=file, prompt=prompt, model=model, request_options=request_options
296
295
  )
297
- return response.data
296
+ return _response.data