sarvamai 0.1.5a1__tar.gz → 0.1.5a4__tar.gz
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-0.1.5a1 → sarvamai-0.1.5a4}/PKG-INFO +3 -3
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/README.md +2 -2
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/pyproject.toml +1 -1
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/__init__.py +2 -2
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/chat/client.py +0 -12
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/chat/raw_client.py +0 -12
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/client.py +20 -3
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/core/__init__.py +0 -3
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/core/client_wrapper.py +18 -15
- sarvamai-0.1.5a4/src/sarvamai/environment.py +7 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/speech_to_text/raw_client.py +0 -4
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/text/client.py +89 -47
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/text/raw_client.py +85 -49
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/text_to_speech/raw_client.py +0 -2
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/__init__.py +2 -2
- sarvamai-0.1.5a4/src/sarvamai/types/speech_to_text_model.py +7 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/speech_to_text_translate_model.py +1 -1
- sarvamai-0.1.5a4/src/sarvamai/types/translate_model.py +5 -0
- sarvamai-0.1.5a4/src/sarvamai/types/translate_source_language.py +33 -0
- sarvamai-0.1.5a4/src/sarvamai/types/translate_target_language.py +32 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/translatiterate_target_language.py +1 -1
- sarvamai-0.1.5a4/src/sarvamai/types/transliterate_mode.py +5 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/transliterate_source_language.py +1 -1
- sarvamai-0.1.5a1/src/sarvamai/core/events.py +0 -30
- sarvamai-0.1.5a1/src/sarvamai/environment.py +0 -14
- sarvamai-0.1.5a1/src/sarvamai/types/speech_to_text_model.py +0 -5
- sarvamai-0.1.5a1/src/sarvamai/types/translate_model.py +0 -5
- sarvamai-0.1.5a1/src/sarvamai/types/translate_postprocessing.py +0 -5
- sarvamai-0.1.5a1/src/sarvamai/types/translate_source_language.py +0 -10
- sarvamai-0.1.5a1/src/sarvamai/types/translate_target_language.py +0 -8
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/chat/__init__.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/core/api_error.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/core/datetime_utils.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/core/file.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/core/http_client.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/core/http_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/core/jsonable_encoder.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/core/pydantic_utilities.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/core/query_encoder.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/core/remove_none_from_dict.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/core/request_options.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/core/serialization.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/errors/__init__.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/errors/bad_request_error.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/errors/forbidden_error.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/errors/internal_server_error.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/errors/service_unavailable_error.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/errors/too_many_requests_error.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/errors/unprocessable_entity_error.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/play.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/py.typed +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/__init__.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/chat_completion_request_assistant_message.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/chat_completion_request_message.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/chat_completion_request_system_message.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/chat_completion_request_user_message.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/chat_completion_response_message.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/choice.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/completion_usage.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/create_chat_completion_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/diarized_entry.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/diarized_transcript.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/error_details.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/error_message.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/language_identification_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/speech_to_text_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/speech_to_text_translate_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/stop_configuration.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/text_to_speech_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/timestamps_model.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/translation_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/requests/transliteration_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/speech_to_text/__init__.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/speech_to_text/client.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/text/__init__.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/text_to_speech/__init__.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/text_to_speech/client.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/chat_completion_request_assistant_message.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/chat_completion_request_message.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/chat_completion_request_system_message.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/chat_completion_request_user_message.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/chat_completion_response_message.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/choice.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/completion_usage.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/create_chat_completion_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/diarized_entry.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/diarized_transcript.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/error_code.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/error_details.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/error_message.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/finish_reason.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/language_identification_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/numerals_format.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/reasoning_effort.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/role.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/sarvam_model_ids.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/speech_sample_rate.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/speech_to_text_language.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/speech_to_text_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/speech_to_text_translate_language.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/speech_to_text_translate_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/spoken_form_numerals_format.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/stop_configuration.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/text_to_speech_language.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/text_to_speech_model.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/text_to_speech_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/text_to_speech_speaker.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/timestamps_model.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/translate_mode.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/translate_speaker_gender.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/translation_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/types/transliteration_response.py +0 -0
- {sarvamai-0.1.5a1 → sarvamai-0.1.5a4}/src/sarvamai/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sarvamai
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5a4
|
|
4
4
|
Summary:
|
|
5
5
|
Requires-Python: >=3.8,<4.0
|
|
6
6
|
Classifier: Intended Audience :: Developers
|
|
@@ -58,7 +58,7 @@ client = SarvamAI(
|
|
|
58
58
|
client.text.translate(
|
|
59
59
|
input="input",
|
|
60
60
|
source_language_code="auto",
|
|
61
|
-
target_language_code="
|
|
61
|
+
target_language_code="bn-IN",
|
|
62
62
|
)
|
|
63
63
|
```
|
|
64
64
|
|
|
@@ -80,7 +80,7 @@ async def main() -> None:
|
|
|
80
80
|
await client.text.translate(
|
|
81
81
|
input="input",
|
|
82
82
|
source_language_code="auto",
|
|
83
|
-
target_language_code="
|
|
83
|
+
target_language_code="bn-IN",
|
|
84
84
|
)
|
|
85
85
|
|
|
86
86
|
|
|
@@ -32,7 +32,7 @@ client = SarvamAI(
|
|
|
32
32
|
client.text.translate(
|
|
33
33
|
input="input",
|
|
34
34
|
source_language_code="auto",
|
|
35
|
-
target_language_code="
|
|
35
|
+
target_language_code="bn-IN",
|
|
36
36
|
)
|
|
37
37
|
```
|
|
38
38
|
|
|
@@ -54,7 +54,7 @@ async def main() -> None:
|
|
|
54
54
|
await client.text.translate(
|
|
55
55
|
input="input",
|
|
56
56
|
source_language_code="auto",
|
|
57
|
-
target_language_code="
|
|
57
|
+
target_language_code="bn-IN",
|
|
58
58
|
)
|
|
59
59
|
|
|
60
60
|
|
|
@@ -39,12 +39,12 @@ from .types import (
|
|
|
39
39
|
TimestampsModel,
|
|
40
40
|
TranslateMode,
|
|
41
41
|
TranslateModel,
|
|
42
|
-
TranslatePostprocessing,
|
|
43
42
|
TranslateSourceLanguage,
|
|
44
43
|
TranslateSpeakerGender,
|
|
45
44
|
TranslateTargetLanguage,
|
|
46
45
|
TranslationResponse,
|
|
47
46
|
TranslatiterateTargetLanguage,
|
|
47
|
+
TransliterateMode,
|
|
48
48
|
TransliterateSourceLanguage,
|
|
49
49
|
TransliterationResponse,
|
|
50
50
|
)
|
|
@@ -154,13 +154,13 @@ __all__ = [
|
|
|
154
154
|
"TooManyRequestsError",
|
|
155
155
|
"TranslateMode",
|
|
156
156
|
"TranslateModel",
|
|
157
|
-
"TranslatePostprocessing",
|
|
158
157
|
"TranslateSourceLanguage",
|
|
159
158
|
"TranslateSpeakerGender",
|
|
160
159
|
"TranslateTargetLanguage",
|
|
161
160
|
"TranslationResponse",
|
|
162
161
|
"TranslationResponseParams",
|
|
163
162
|
"TranslatiterateTargetLanguage",
|
|
163
|
+
"TransliterateMode",
|
|
164
164
|
"TransliterateSourceLanguage",
|
|
165
165
|
"TransliterationResponse",
|
|
166
166
|
"TransliterationResponseParams",
|
|
@@ -33,7 +33,6 @@ class ChatClient:
|
|
|
33
33
|
def completions(
|
|
34
34
|
self,
|
|
35
35
|
*,
|
|
36
|
-
authorization: str,
|
|
37
36
|
messages: typing.Sequence[ChatCompletionRequestMessageParams],
|
|
38
37
|
temperature: typing.Optional[float] = OMIT,
|
|
39
38
|
top_p: typing.Optional[float] = OMIT,
|
|
@@ -53,9 +52,6 @@ class ChatClient:
|
|
|
53
52
|
|
|
54
53
|
Parameters
|
|
55
54
|
----------
|
|
56
|
-
authorization : str
|
|
57
|
-
Bearer token for authentication. Format: "Bearer <token>"
|
|
58
|
-
|
|
59
55
|
messages : typing.Sequence[ChatCompletionRequestMessageParams]
|
|
60
56
|
A list of messages comprising the conversation so far.
|
|
61
57
|
|
|
@@ -119,12 +115,10 @@ class ChatClient:
|
|
|
119
115
|
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
|
|
120
116
|
)
|
|
121
117
|
client.chat.completions(
|
|
122
|
-
authorization="Authorization",
|
|
123
118
|
messages=[{"content": "content", "role": "assistant"}],
|
|
124
119
|
)
|
|
125
120
|
"""
|
|
126
121
|
response = self._raw_client.completions(
|
|
127
|
-
authorization=authorization,
|
|
128
122
|
messages=messages,
|
|
129
123
|
temperature=temperature,
|
|
130
124
|
top_p=top_p,
|
|
@@ -160,7 +154,6 @@ class AsyncChatClient:
|
|
|
160
154
|
async def completions(
|
|
161
155
|
self,
|
|
162
156
|
*,
|
|
163
|
-
authorization: str,
|
|
164
157
|
messages: typing.Sequence[ChatCompletionRequestMessageParams],
|
|
165
158
|
temperature: typing.Optional[float] = OMIT,
|
|
166
159
|
top_p: typing.Optional[float] = OMIT,
|
|
@@ -180,9 +173,6 @@ class AsyncChatClient:
|
|
|
180
173
|
|
|
181
174
|
Parameters
|
|
182
175
|
----------
|
|
183
|
-
authorization : str
|
|
184
|
-
Bearer token for authentication. Format: "Bearer <token>"
|
|
185
|
-
|
|
186
176
|
messages : typing.Sequence[ChatCompletionRequestMessageParams]
|
|
187
177
|
A list of messages comprising the conversation so far.
|
|
188
178
|
|
|
@@ -251,7 +241,6 @@ class AsyncChatClient:
|
|
|
251
241
|
|
|
252
242
|
async def main() -> None:
|
|
253
243
|
await client.chat.completions(
|
|
254
|
-
authorization="Authorization",
|
|
255
244
|
messages=[{"content": "content", "role": "assistant"}],
|
|
256
245
|
)
|
|
257
246
|
|
|
@@ -259,7 +248,6 @@ class AsyncChatClient:
|
|
|
259
248
|
asyncio.run(main())
|
|
260
249
|
"""
|
|
261
250
|
response = await self._raw_client.completions(
|
|
262
|
-
authorization=authorization,
|
|
263
251
|
messages=messages,
|
|
264
252
|
temperature=temperature,
|
|
265
253
|
top_p=top_p,
|
|
@@ -31,7 +31,6 @@ class RawChatClient:
|
|
|
31
31
|
def completions(
|
|
32
32
|
self,
|
|
33
33
|
*,
|
|
34
|
-
authorization: str,
|
|
35
34
|
messages: typing.Sequence[ChatCompletionRequestMessageParams],
|
|
36
35
|
temperature: typing.Optional[float] = OMIT,
|
|
37
36
|
top_p: typing.Optional[float] = OMIT,
|
|
@@ -51,9 +50,6 @@ class RawChatClient:
|
|
|
51
50
|
|
|
52
51
|
Parameters
|
|
53
52
|
----------
|
|
54
|
-
authorization : str
|
|
55
|
-
Bearer token for authentication. Format: "Bearer <token>"
|
|
56
|
-
|
|
57
53
|
messages : typing.Sequence[ChatCompletionRequestMessageParams]
|
|
58
54
|
A list of messages comprising the conversation so far.
|
|
59
55
|
|
|
@@ -111,7 +107,6 @@ class RawChatClient:
|
|
|
111
107
|
"""
|
|
112
108
|
_response = self._client_wrapper.httpx_client.request(
|
|
113
109
|
"v1/chat/completions",
|
|
114
|
-
base_url=self._client_wrapper.get_environment().base,
|
|
115
110
|
method="POST",
|
|
116
111
|
json={
|
|
117
112
|
"messages": convert_and_respect_annotation_metadata(
|
|
@@ -134,7 +129,6 @@ class RawChatClient:
|
|
|
134
129
|
},
|
|
135
130
|
headers={
|
|
136
131
|
"content-type": "application/json",
|
|
137
|
-
"Authorization": str(authorization) if authorization is not None else None,
|
|
138
132
|
},
|
|
139
133
|
request_options=request_options,
|
|
140
134
|
omit=OMIT,
|
|
@@ -212,7 +206,6 @@ class AsyncRawChatClient:
|
|
|
212
206
|
async def completions(
|
|
213
207
|
self,
|
|
214
208
|
*,
|
|
215
|
-
authorization: str,
|
|
216
209
|
messages: typing.Sequence[ChatCompletionRequestMessageParams],
|
|
217
210
|
temperature: typing.Optional[float] = OMIT,
|
|
218
211
|
top_p: typing.Optional[float] = OMIT,
|
|
@@ -232,9 +225,6 @@ class AsyncRawChatClient:
|
|
|
232
225
|
|
|
233
226
|
Parameters
|
|
234
227
|
----------
|
|
235
|
-
authorization : str
|
|
236
|
-
Bearer token for authentication. Format: "Bearer <token>"
|
|
237
|
-
|
|
238
228
|
messages : typing.Sequence[ChatCompletionRequestMessageParams]
|
|
239
229
|
A list of messages comprising the conversation so far.
|
|
240
230
|
|
|
@@ -292,7 +282,6 @@ class AsyncRawChatClient:
|
|
|
292
282
|
"""
|
|
293
283
|
_response = await self._client_wrapper.httpx_client.request(
|
|
294
284
|
"v1/chat/completions",
|
|
295
|
-
base_url=self._client_wrapper.get_environment().base,
|
|
296
285
|
method="POST",
|
|
297
286
|
json={
|
|
298
287
|
"messages": convert_and_respect_annotation_metadata(
|
|
@@ -315,7 +304,6 @@ class AsyncRawChatClient:
|
|
|
315
304
|
},
|
|
316
305
|
headers={
|
|
317
306
|
"content-type": "application/json",
|
|
318
|
-
"Authorization": str(authorization) if authorization is not None else None,
|
|
319
307
|
},
|
|
320
308
|
request_options=request_options,
|
|
321
309
|
omit=OMIT,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
from .environment import SarvamAIEnvironment
|
|
4
3
|
import typing
|
|
4
|
+
from .environment import SarvamAIEnvironment
|
|
5
5
|
import os
|
|
6
6
|
import httpx
|
|
7
7
|
from .core.api_error import ApiError
|
|
@@ -23,6 +23,9 @@ class SarvamAI:
|
|
|
23
23
|
|
|
24
24
|
Parameters
|
|
25
25
|
----------
|
|
26
|
+
base_url : typing.Optional[str]
|
|
27
|
+
The base url to use for requests from the client.
|
|
28
|
+
|
|
26
29
|
environment : SarvamAIEnvironment
|
|
27
30
|
The environment to use for requests from the client. from .environment import SarvamAIEnvironment
|
|
28
31
|
|
|
@@ -54,6 +57,7 @@ class SarvamAI:
|
|
|
54
57
|
def __init__(
|
|
55
58
|
self,
|
|
56
59
|
*,
|
|
60
|
+
base_url: typing.Optional[str] = None,
|
|
57
61
|
environment: SarvamAIEnvironment = SarvamAIEnvironment.PRODUCTION,
|
|
58
62
|
api_subscription_key: typing.Optional[str] = os.getenv("SARVAM_API_KEY"),
|
|
59
63
|
timeout: typing.Optional[float] = None,
|
|
@@ -68,7 +72,7 @@ class SarvamAI:
|
|
|
68
72
|
body="The client must be instantiated be either passing in api_subscription_key or setting SARVAM_API_KEY"
|
|
69
73
|
)
|
|
70
74
|
self._client_wrapper = SyncClientWrapper(
|
|
71
|
-
environment=environment,
|
|
75
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
72
76
|
api_subscription_key=api_subscription_key,
|
|
73
77
|
httpx_client=httpx_client
|
|
74
78
|
if httpx_client is not None
|
|
@@ -89,6 +93,9 @@ class AsyncSarvamAI:
|
|
|
89
93
|
|
|
90
94
|
Parameters
|
|
91
95
|
----------
|
|
96
|
+
base_url : typing.Optional[str]
|
|
97
|
+
The base url to use for requests from the client.
|
|
98
|
+
|
|
92
99
|
environment : SarvamAIEnvironment
|
|
93
100
|
The environment to use for requests from the client. from .environment import SarvamAIEnvironment
|
|
94
101
|
|
|
@@ -120,6 +127,7 @@ class AsyncSarvamAI:
|
|
|
120
127
|
def __init__(
|
|
121
128
|
self,
|
|
122
129
|
*,
|
|
130
|
+
base_url: typing.Optional[str] = None,
|
|
123
131
|
environment: SarvamAIEnvironment = SarvamAIEnvironment.PRODUCTION,
|
|
124
132
|
api_subscription_key: typing.Optional[str] = os.getenv("SARVAM_API_KEY"),
|
|
125
133
|
timeout: typing.Optional[float] = None,
|
|
@@ -134,7 +142,7 @@ class AsyncSarvamAI:
|
|
|
134
142
|
body="The client must be instantiated be either passing in api_subscription_key or setting SARVAM_API_KEY"
|
|
135
143
|
)
|
|
136
144
|
self._client_wrapper = AsyncClientWrapper(
|
|
137
|
-
environment=environment,
|
|
145
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
138
146
|
api_subscription_key=api_subscription_key,
|
|
139
147
|
httpx_client=httpx_client
|
|
140
148
|
if httpx_client is not None
|
|
@@ -147,3 +155,12 @@ class AsyncSarvamAI:
|
|
|
147
155
|
self.speech_to_text = AsyncSpeechToTextClient(client_wrapper=self._client_wrapper)
|
|
148
156
|
self.text_to_speech = AsyncTextToSpeechClient(client_wrapper=self._client_wrapper)
|
|
149
157
|
self.chat = AsyncChatClient(client_wrapper=self._client_wrapper)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _get_base_url(*, base_url: typing.Optional[str] = None, environment: SarvamAIEnvironment) -> str:
|
|
161
|
+
if base_url is not None:
|
|
162
|
+
return base_url
|
|
163
|
+
elif environment is not None:
|
|
164
|
+
return environment.value
|
|
165
|
+
else:
|
|
166
|
+
raise Exception("Please pass in either base_url or environment to construct the client")
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
from .api_error import ApiError
|
|
4
4
|
from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
|
|
5
5
|
from .datetime_utils import serialize_datetime
|
|
6
|
-
from .events import EventEmitterMixin, EventType
|
|
7
6
|
from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
|
|
8
7
|
from .http_client import AsyncHttpClient, HttpClient
|
|
9
8
|
from .http_response import AsyncHttpResponse, HttpResponse
|
|
@@ -28,8 +27,6 @@ __all__ = [
|
|
|
28
27
|
"AsyncHttpClient",
|
|
29
28
|
"AsyncHttpResponse",
|
|
30
29
|
"BaseClientWrapper",
|
|
31
|
-
"EventEmitterMixin",
|
|
32
|
-
"EventType",
|
|
33
30
|
"FieldMetadata",
|
|
34
31
|
"File",
|
|
35
32
|
"HttpClient",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
from ..environment import SarvamAIEnvironment
|
|
4
3
|
import typing
|
|
5
4
|
import httpx
|
|
6
5
|
from .http_client import HttpClient
|
|
@@ -8,25 +7,23 @@ from .http_client import AsyncHttpClient
|
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
class BaseClientWrapper:
|
|
11
|
-
def __init__(
|
|
12
|
-
self, *, api_subscription_key: str, environment: SarvamAIEnvironment, timeout: typing.Optional[float] = None
|
|
13
|
-
):
|
|
10
|
+
def __init__(self, *, api_subscription_key: str, base_url: str, timeout: typing.Optional[float] = None):
|
|
14
11
|
self.api_subscription_key = api_subscription_key
|
|
15
|
-
self.
|
|
12
|
+
self._base_url = base_url
|
|
16
13
|
self._timeout = timeout
|
|
17
14
|
|
|
18
15
|
def get_headers(self) -> typing.Dict[str, str]:
|
|
19
16
|
headers: typing.Dict[str, str] = {
|
|
20
|
-
"User-Agent": "sarvamai/0.1.
|
|
17
|
+
"User-Agent": "sarvamai/0.1.5a4",
|
|
21
18
|
"X-Fern-Language": "Python",
|
|
22
19
|
"X-Fern-SDK-Name": "sarvamai",
|
|
23
|
-
"X-Fern-SDK-Version": "0.1.
|
|
20
|
+
"X-Fern-SDK-Version": "0.1.5a4",
|
|
24
21
|
}
|
|
25
22
|
headers["api-subscription-key"] = self.api_subscription_key
|
|
26
23
|
return headers
|
|
27
24
|
|
|
28
|
-
def
|
|
29
|
-
return self.
|
|
25
|
+
def get_base_url(self) -> str:
|
|
26
|
+
return self._base_url
|
|
30
27
|
|
|
31
28
|
def get_timeout(self) -> typing.Optional[float]:
|
|
32
29
|
return self._timeout
|
|
@@ -37,13 +34,16 @@ class SyncClientWrapper(BaseClientWrapper):
|
|
|
37
34
|
self,
|
|
38
35
|
*,
|
|
39
36
|
api_subscription_key: str,
|
|
40
|
-
|
|
37
|
+
base_url: str,
|
|
41
38
|
timeout: typing.Optional[float] = None,
|
|
42
39
|
httpx_client: httpx.Client,
|
|
43
40
|
):
|
|
44
|
-
super().__init__(api_subscription_key=api_subscription_key,
|
|
41
|
+
super().__init__(api_subscription_key=api_subscription_key, base_url=base_url, timeout=timeout)
|
|
45
42
|
self.httpx_client = HttpClient(
|
|
46
|
-
httpx_client=httpx_client,
|
|
43
|
+
httpx_client=httpx_client,
|
|
44
|
+
base_headers=self.get_headers,
|
|
45
|
+
base_timeout=self.get_timeout,
|
|
46
|
+
base_url=self.get_base_url,
|
|
47
47
|
)
|
|
48
48
|
|
|
49
49
|
|
|
@@ -52,11 +52,14 @@ class AsyncClientWrapper(BaseClientWrapper):
|
|
|
52
52
|
self,
|
|
53
53
|
*,
|
|
54
54
|
api_subscription_key: str,
|
|
55
|
-
|
|
55
|
+
base_url: str,
|
|
56
56
|
timeout: typing.Optional[float] = None,
|
|
57
57
|
httpx_client: httpx.AsyncClient,
|
|
58
58
|
):
|
|
59
|
-
super().__init__(api_subscription_key=api_subscription_key,
|
|
59
|
+
super().__init__(api_subscription_key=api_subscription_key, base_url=base_url, timeout=timeout)
|
|
60
60
|
self.httpx_client = AsyncHttpClient(
|
|
61
|
-
httpx_client=httpx_client,
|
|
61
|
+
httpx_client=httpx_client,
|
|
62
|
+
base_headers=self.get_headers,
|
|
63
|
+
base_timeout=self.get_timeout,
|
|
64
|
+
base_url=self.get_base_url,
|
|
62
65
|
)
|
|
@@ -80,7 +80,6 @@ class RawSpeechToTextClient:
|
|
|
80
80
|
"""
|
|
81
81
|
_response = self._client_wrapper.httpx_client.request(
|
|
82
82
|
"speech-to-text",
|
|
83
|
-
base_url=self._client_wrapper.get_environment().base,
|
|
84
83
|
method="POST",
|
|
85
84
|
data={
|
|
86
85
|
"model": model,
|
|
@@ -211,7 +210,6 @@ class RawSpeechToTextClient:
|
|
|
211
210
|
"""
|
|
212
211
|
_response = self._client_wrapper.httpx_client.request(
|
|
213
212
|
"speech-to-text-translate",
|
|
214
|
-
base_url=self._client_wrapper.get_environment().base,
|
|
215
213
|
method="POST",
|
|
216
214
|
data={
|
|
217
215
|
"prompt": prompt,
|
|
@@ -352,7 +350,6 @@ class AsyncRawSpeechToTextClient:
|
|
|
352
350
|
"""
|
|
353
351
|
_response = await self._client_wrapper.httpx_client.request(
|
|
354
352
|
"speech-to-text",
|
|
355
|
-
base_url=self._client_wrapper.get_environment().base,
|
|
356
353
|
method="POST",
|
|
357
354
|
data={
|
|
358
355
|
"model": model,
|
|
@@ -483,7 +480,6 @@ class AsyncRawSpeechToTextClient:
|
|
|
483
480
|
"""
|
|
484
481
|
_response = await self._client_wrapper.httpx_client.request(
|
|
485
482
|
"speech-to-text-translate",
|
|
486
|
-
base_url=self._client_wrapper.get_environment().base,
|
|
487
483
|
method="POST",
|
|
488
484
|
data={
|
|
489
485
|
"prompt": prompt,
|