sarvamai 0.1.5a4__tar.gz → 0.1.5a5__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.
Files changed (143) hide show
  1. sarvamai-0.1.5a5/PKG-INFO +28 -0
  2. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/pyproject.toml +25 -4
  3. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/__init__.py +45 -1
  4. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/chat/__init__.py +2 -0
  5. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/chat/client.py +9 -12
  6. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/chat/raw_client.py +48 -39
  7. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/client.py +13 -31
  8. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/core/__init__.py +5 -0
  9. sarvamai-0.1.5a5/src/sarvamai/core/api_error.py +23 -0
  10. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/core/client_wrapper.py +17 -20
  11. sarvamai-0.1.5a5/src/sarvamai/core/events.py +30 -0
  12. sarvamai-0.1.5a5/src/sarvamai/core/force_multipart.py +16 -0
  13. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/core/http_client.py +70 -24
  14. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/core/http_response.py +19 -11
  15. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/core/pydantic_utilities.py +69 -108
  16. sarvamai-0.1.5a5/src/sarvamai/environment.py +14 -0
  17. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/errors/__init__.py +2 -0
  18. sarvamai-0.1.5a5/src/sarvamai/errors/bad_request_error.py +10 -0
  19. sarvamai-0.1.5a5/src/sarvamai/errors/forbidden_error.py +10 -0
  20. sarvamai-0.1.5a5/src/sarvamai/errors/internal_server_error.py +10 -0
  21. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/errors/service_unavailable_error.py +4 -2
  22. sarvamai-0.1.5a5/src/sarvamai/errors/too_many_requests_error.py +10 -0
  23. sarvamai-0.1.5a5/src/sarvamai/errors/unprocessable_entity_error.py +10 -0
  24. sarvamai-0.1.5a5/src/sarvamai/py.typed +0 -0
  25. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/__init__.py +18 -0
  26. sarvamai-0.1.5a5/src/sarvamai/requests/audio_data.py +21 -0
  27. sarvamai-0.1.5a5/src/sarvamai/requests/audio_message.py +8 -0
  28. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/chat_completion_request_message.py +3 -1
  29. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/create_chat_completion_response.py +2 -2
  30. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/diarized_transcript.py +2 -1
  31. sarvamai-0.1.5a5/src/sarvamai/requests/error_data.py +15 -0
  32. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/error_details.py +0 -1
  33. sarvamai-0.1.5a5/src/sarvamai/requests/events_data.py +17 -0
  34. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/language_identification_response.py +0 -1
  35. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/speech_to_text_response.py +1 -2
  36. sarvamai-0.1.5a5/src/sarvamai/requests/speech_to_text_streaming_response.py +10 -0
  37. sarvamai-0.1.5a5/src/sarvamai/requests/speech_to_text_streaming_response_data.py +9 -0
  38. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/speech_to_text_translate_response.py +0 -1
  39. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/text_to_speech_response.py +2 -2
  40. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/timestamps_model.py +2 -1
  41. sarvamai-0.1.5a5/src/sarvamai/requests/transcription_data.py +35 -0
  42. sarvamai-0.1.5a5/src/sarvamai/requests/transcription_metrics.py +15 -0
  43. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/translation_response.py +0 -1
  44. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/transliteration_response.py +0 -1
  45. {sarvamai-0.1.5a4/src/sarvamai/text_to_speech → sarvamai-0.1.5a5/src/sarvamai/speech_to_text}/__init__.py +2 -0
  46. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/speech_to_text/client.py +13 -14
  47. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/speech_to_text/raw_client.py +99 -68
  48. sarvamai-0.1.5a5/src/sarvamai/speech_to_text_streaming/__init__.py +7 -0
  49. sarvamai-0.1.5a5/src/sarvamai/speech_to_text_streaming/client.py +189 -0
  50. sarvamai-0.1.5a5/src/sarvamai/speech_to_text_streaming/raw_client.py +166 -0
  51. sarvamai-0.1.5a5/src/sarvamai/speech_to_text_streaming/socket_client.py +129 -0
  52. sarvamai-0.1.5a5/src/sarvamai/speech_to_text_streaming/types/__init__.py +8 -0
  53. sarvamai-0.1.5a5/src/sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_language_code.py +8 -0
  54. sarvamai-0.1.5a5/src/sarvamai/speech_to_text_streaming/types/speech_to_text_streaming_model.py +5 -0
  55. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/text/__init__.py +2 -0
  56. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/text/client.py +24 -25
  57. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/text/raw_client.py +126 -91
  58. {sarvamai-0.1.5a4/src/sarvamai/speech_to_text → sarvamai-0.1.5a5/src/sarvamai/text_to_speech}/__init__.py +2 -0
  59. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/text_to_speech/client.py +10 -11
  60. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/text_to_speech/raw_client.py +49 -38
  61. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/__init__.py +24 -0
  62. sarvamai-0.1.5a5/src/sarvamai/types/audio_data.py +33 -0
  63. sarvamai-0.1.5a5/src/sarvamai/types/audio_data_encoding.py +5 -0
  64. sarvamai-0.1.5a5/src/sarvamai/types/audio_message.py +20 -0
  65. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/chat_completion_request_assistant_message.py +3 -3
  66. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/chat_completion_request_message.py +3 -2
  67. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/chat_completion_request_system_message.py +3 -3
  68. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/chat_completion_request_user_message.py +3 -3
  69. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/chat_completion_response_message.py +3 -3
  70. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/choice.py +4 -4
  71. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/completion_usage.py +3 -3
  72. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/create_chat_completion_response.py +3 -3
  73. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/diarized_entry.py +3 -3
  74. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/diarized_transcript.py +3 -3
  75. sarvamai-0.1.5a5/src/sarvamai/types/error_data.py +27 -0
  76. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/error_details.py +3 -3
  77. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/error_message.py +4 -4
  78. sarvamai-0.1.5a5/src/sarvamai/types/events_data.py +28 -0
  79. sarvamai-0.1.5a5/src/sarvamai/types/format.py +5 -0
  80. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/language_identification_response.py +2 -2
  81. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/speech_to_text_response.py +3 -3
  82. sarvamai-0.1.5a5/src/sarvamai/types/speech_to_text_streaming_response.py +22 -0
  83. sarvamai-0.1.5a5/src/sarvamai/types/speech_to_text_streaming_response_data.py +9 -0
  84. sarvamai-0.1.5a5/src/sarvamai/types/speech_to_text_streaming_response_type.py +5 -0
  85. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/speech_to_text_translate_response.py +3 -3
  86. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/text_to_speech_response.py +2 -2
  87. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/timestamps_model.py +2 -2
  88. sarvamai-0.1.5a5/src/sarvamai/types/transcription_data.py +45 -0
  89. sarvamai-0.1.5a5/src/sarvamai/types/transcription_metrics.py +27 -0
  90. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/translation_response.py +2 -2
  91. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/transliteration_response.py +2 -2
  92. sarvamai-0.1.5a4/PKG-INFO +0 -174
  93. sarvamai-0.1.5a4/README.md +0 -147
  94. sarvamai-0.1.5a4/src/sarvamai/core/api_error.py +0 -15
  95. sarvamai-0.1.5a4/src/sarvamai/environment.py +0 -7
  96. sarvamai-0.1.5a4/src/sarvamai/errors/bad_request_error.py +0 -9
  97. sarvamai-0.1.5a4/src/sarvamai/errors/forbidden_error.py +0 -9
  98. sarvamai-0.1.5a4/src/sarvamai/errors/internal_server_error.py +0 -9
  99. sarvamai-0.1.5a4/src/sarvamai/errors/too_many_requests_error.py +0 -9
  100. sarvamai-0.1.5a4/src/sarvamai/errors/unprocessable_entity_error.py +0 -9
  101. /sarvamai-0.1.5a4/src/sarvamai/py.typed → /sarvamai-0.1.5a5/README.md +0 -0
  102. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/core/datetime_utils.py +0 -0
  103. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/core/file.py +0 -0
  104. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/core/jsonable_encoder.py +0 -0
  105. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/core/query_encoder.py +0 -0
  106. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/core/remove_none_from_dict.py +0 -0
  107. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/core/request_options.py +0 -0
  108. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/core/serialization.py +0 -0
  109. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/play.py +0 -0
  110. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/chat_completion_request_assistant_message.py +0 -0
  111. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/chat_completion_request_system_message.py +0 -0
  112. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/chat_completion_request_user_message.py +0 -0
  113. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/chat_completion_response_message.py +0 -0
  114. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/choice.py +0 -0
  115. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/completion_usage.py +0 -0
  116. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/diarized_entry.py +0 -0
  117. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/error_message.py +0 -0
  118. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/requests/stop_configuration.py +0 -0
  119. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/error_code.py +0 -0
  120. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/finish_reason.py +0 -0
  121. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/numerals_format.py +0 -0
  122. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/reasoning_effort.py +0 -0
  123. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/role.py +0 -0
  124. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/sarvam_model_ids.py +0 -0
  125. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/speech_sample_rate.py +0 -0
  126. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/speech_to_text_language.py +0 -0
  127. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/speech_to_text_model.py +0 -0
  128. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/speech_to_text_translate_language.py +0 -0
  129. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/speech_to_text_translate_model.py +0 -0
  130. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/spoken_form_numerals_format.py +0 -0
  131. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/stop_configuration.py +0 -0
  132. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/text_to_speech_language.py +0 -0
  133. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/text_to_speech_model.py +0 -0
  134. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/text_to_speech_speaker.py +0 -0
  135. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/translate_mode.py +0 -0
  136. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/translate_model.py +0 -0
  137. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/translate_source_language.py +0 -0
  138. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/translate_speaker_gender.py +0 -0
  139. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/translate_target_language.py +0 -0
  140. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/translatiterate_target_language.py +0 -0
  141. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/transliterate_mode.py +0 -0
  142. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/types/transliterate_source_language.py +0 -0
  143. {sarvamai-0.1.5a4 → sarvamai-0.1.5a5}/src/sarvamai/version.py +0 -0
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.1
2
+ Name: sarvamai
3
+ Version: 0.1.5a5
4
+ Summary:
5
+ Requires-Python: >=3.8,<4.0
6
+ Classifier: Intended Audience :: Developers
7
+ Classifier: Operating System :: MacOS
8
+ Classifier: Operating System :: Microsoft :: Windows
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Operating System :: POSIX
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Typing :: Typed
21
+ Requires-Dist: httpx (>=0.21.2)
22
+ Requires-Dist: pydantic (>=1.9.2)
23
+ Requires-Dist: pydantic-core (>=2.18.2,<3.0.0)
24
+ Requires-Dist: typing_extensions (>=4.0.0)
25
+ Requires-Dist: websockets (==12.0)
26
+ Description-Content-Type: text/markdown
27
+
28
+
@@ -3,7 +3,7 @@ name = "sarvamai"
3
3
 
4
4
  [tool.poetry]
5
5
  name = "sarvamai"
6
- version = "0.1.5a4"
6
+ version = "0.1.5a5"
7
7
  description = ""
8
8
  readme = "README.md"
9
9
  authors = []
@@ -39,14 +39,15 @@ httpx = ">=0.21.2"
39
39
  pydantic = ">= 1.9.2"
40
40
  pydantic-core = "^2.18.2"
41
41
  typing_extensions = ">= 4.0.0"
42
+ websockets = "12.0"
42
43
 
43
- [tool.poetry.dev-dependencies]
44
- mypy = "1.0.1"
44
+ [tool.poetry.group.dev.dependencies]
45
+ mypy = "==1.13.0"
45
46
  pytest = "^7.4.0"
46
47
  pytest-asyncio = "^0.23.5"
47
48
  python-dateutil = "^2.9.0"
48
49
  types-python-dateutil = "^2.9.0.20240316"
49
- ruff = "^0.5.6"
50
+ ruff = "==0.11.5"
50
51
 
51
52
  [tool.pytest.ini_options]
52
53
  testpaths = [ "tests" ]
@@ -58,6 +59,26 @@ plugins = ["pydantic.mypy"]
58
59
  [tool.ruff]
59
60
  line-length = 120
60
61
 
62
+ [tool.ruff.lint]
63
+ select = [
64
+ "E", # pycodestyle errors
65
+ "F", # pyflakes
66
+ "I", # isort
67
+ ]
68
+ ignore = [
69
+ "E402", # Module level import not at top of file
70
+ "E501", # Line too long
71
+ "E711", # Comparison to `None` should be `cond is not None`
72
+ "E712", # Avoid equality comparisons to `True`; use `if ...:` checks
73
+ "E721", # Use `is` and `is not` for type comparisons, or `isinstance()` for insinstance checks
74
+ "E722", # Do not use bare `except`
75
+ "E731", # Do not assign a `lambda` expression, use a `def`
76
+ "F821", # Undefined name
77
+ "F841" # Local variable ... is assigned to but never used
78
+ ]
79
+
80
+ [tool.ruff.lint.isort]
81
+ section-order = ["future", "standard-library", "third-party", "first-party"]
61
82
 
62
83
  [build-system]
63
84
  requires = ["poetry-core"]
@@ -1,6 +1,11 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
+ # isort: skip_file
4
+
3
5
  from .types import (
6
+ AudioData,
7
+ AudioDataEncoding,
8
+ AudioMessage,
4
9
  ChatCompletionRequestAssistantMessage,
5
10
  ChatCompletionRequestMessage,
6
11
  ChatCompletionRequestMessage_Assistant,
@@ -15,9 +20,12 @@ from .types import (
15
20
  DiarizedEntry,
16
21
  DiarizedTranscript,
17
22
  ErrorCode,
23
+ ErrorData,
18
24
  ErrorDetails,
19
25
  ErrorMessage,
26
+ EventsData,
20
27
  FinishReason,
28
+ Format,
21
29
  LanguageIdentificationResponse,
22
30
  NumeralsFormat,
23
31
  ReasoningEffort,
@@ -27,6 +35,9 @@ from .types import (
27
35
  SpeechToTextLanguage,
28
36
  SpeechToTextModel,
29
37
  SpeechToTextResponse,
38
+ SpeechToTextStreamingResponse,
39
+ SpeechToTextStreamingResponseData,
40
+ SpeechToTextStreamingResponseType,
30
41
  SpeechToTextTranslateLanguage,
31
42
  SpeechToTextTranslateModel,
32
43
  SpeechToTextTranslateResponse,
@@ -37,6 +48,8 @@ from .types import (
37
48
  TextToSpeechResponse,
38
49
  TextToSpeechSpeaker,
39
50
  TimestampsModel,
51
+ TranscriptionData,
52
+ TranscriptionMetrics,
40
53
  TranslateMode,
41
54
  TranslateModel,
42
55
  TranslateSourceLanguage,
@@ -56,10 +69,12 @@ from .errors import (
56
69
  TooManyRequestsError,
57
70
  UnprocessableEntityError,
58
71
  )
59
- from . import chat, speech_to_text, text, text_to_speech
72
+ from . import chat, speech_to_text, speech_to_text_streaming, text, text_to_speech
60
73
  from .client import AsyncSarvamAI, SarvamAI
61
74
  from .environment import SarvamAIEnvironment
62
75
  from .requests import (
76
+ AudioDataParams,
77
+ AudioMessageParams,
63
78
  ChatCompletionRequestAssistantMessageParams,
64
79
  ChatCompletionRequestMessageParams,
65
80
  ChatCompletionRequestMessage_AssistantParams,
@@ -73,21 +88,33 @@ from .requests import (
73
88
  CreateChatCompletionResponseParams,
74
89
  DiarizedEntryParams,
75
90
  DiarizedTranscriptParams,
91
+ ErrorDataParams,
76
92
  ErrorDetailsParams,
77
93
  ErrorMessageParams,
94
+ EventsDataParams,
78
95
  LanguageIdentificationResponseParams,
79
96
  SpeechToTextResponseParams,
97
+ SpeechToTextStreamingResponseDataParams,
98
+ SpeechToTextStreamingResponseParams,
80
99
  SpeechToTextTranslateResponseParams,
81
100
  StopConfigurationParams,
82
101
  TextToSpeechResponseParams,
83
102
  TimestampsModelParams,
103
+ TranscriptionDataParams,
104
+ TranscriptionMetricsParams,
84
105
  TranslationResponseParams,
85
106
  TransliterationResponseParams,
86
107
  )
108
+ from .speech_to_text_streaming import SpeechToTextStreamingLanguageCode, SpeechToTextStreamingModel
87
109
  from .version import __version__
88
110
 
89
111
  __all__ = [
90
112
  "AsyncSarvamAI",
113
+ "AudioData",
114
+ "AudioDataEncoding",
115
+ "AudioDataParams",
116
+ "AudioMessage",
117
+ "AudioMessageParams",
91
118
  "BadRequestError",
92
119
  "ChatCompletionRequestAssistantMessage",
93
120
  "ChatCompletionRequestAssistantMessageParams",
@@ -116,12 +143,17 @@ __all__ = [
116
143
  "DiarizedTranscript",
117
144
  "DiarizedTranscriptParams",
118
145
  "ErrorCode",
146
+ "ErrorData",
147
+ "ErrorDataParams",
119
148
  "ErrorDetails",
120
149
  "ErrorDetailsParams",
121
150
  "ErrorMessage",
122
151
  "ErrorMessageParams",
152
+ "EventsData",
153
+ "EventsDataParams",
123
154
  "FinishReason",
124
155
  "ForbiddenError",
156
+ "Format",
125
157
  "InternalServerError",
126
158
  "LanguageIdentificationResponse",
127
159
  "LanguageIdentificationResponseParams",
@@ -137,6 +169,13 @@ __all__ = [
137
169
  "SpeechToTextModel",
138
170
  "SpeechToTextResponse",
139
171
  "SpeechToTextResponseParams",
172
+ "SpeechToTextStreamingLanguageCode",
173
+ "SpeechToTextStreamingModel",
174
+ "SpeechToTextStreamingResponse",
175
+ "SpeechToTextStreamingResponseData",
176
+ "SpeechToTextStreamingResponseDataParams",
177
+ "SpeechToTextStreamingResponseParams",
178
+ "SpeechToTextStreamingResponseType",
140
179
  "SpeechToTextTranslateLanguage",
141
180
  "SpeechToTextTranslateModel",
142
181
  "SpeechToTextTranslateResponse",
@@ -152,6 +191,10 @@ __all__ = [
152
191
  "TimestampsModel",
153
192
  "TimestampsModelParams",
154
193
  "TooManyRequestsError",
194
+ "TranscriptionData",
195
+ "TranscriptionDataParams",
196
+ "TranscriptionMetrics",
197
+ "TranscriptionMetricsParams",
155
198
  "TranslateMode",
156
199
  "TranslateModel",
157
200
  "TranslateSourceLanguage",
@@ -168,6 +211,7 @@ __all__ = [
168
211
  "__version__",
169
212
  "chat",
170
213
  "speech_to_text",
214
+ "speech_to_text_streaming",
171
215
  "text",
172
216
  "text_to_speech",
173
217
  ]
@@ -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,15 +1,14 @@
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 RawChatClient
4
+
5
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
+ from ..core.request_options import RequestOptions
6
7
  from ..requests.chat_completion_request_message import ChatCompletionRequestMessageParams
7
- from ..types.reasoning_effort import ReasoningEffort
8
8
  from ..requests.stop_configuration import StopConfigurationParams
9
- from ..core.request_options import RequestOptions
10
9
  from ..types.create_chat_completion_response import CreateChatCompletionResponse
11
- from ..core.client_wrapper import AsyncClientWrapper
12
- from .raw_client import AsyncRawChatClient
10
+ from ..types.reasoning_effort import ReasoningEffort
11
+ from .raw_client import AsyncRawChatClient, RawChatClient
13
12
 
14
13
  # this is used as the default value for optional parameters
15
14
  OMIT = typing.cast(typing.Any, ...)
@@ -84,7 +83,6 @@ class ChatClient:
84
83
  seed : typing.Optional[int]
85
84
  This feature is in Beta.
86
85
  If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.
87
- Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.
88
86
 
89
87
  frequency_penalty : typing.Optional[float]
90
88
  Number between -2.0 and 2.0. Positive values penalize new tokens based on
@@ -118,7 +116,7 @@ class ChatClient:
118
116
  messages=[{"content": "content", "role": "assistant"}],
119
117
  )
120
118
  """
121
- response = self._raw_client.completions(
119
+ _response = self._raw_client.completions(
122
120
  messages=messages,
123
121
  temperature=temperature,
124
122
  top_p=top_p,
@@ -133,7 +131,7 @@ class ChatClient:
133
131
  wiki_grounding=wiki_grounding,
134
132
  request_options=request_options,
135
133
  )
136
- return response.data
134
+ return _response.data
137
135
 
138
136
 
139
137
  class AsyncChatClient:
@@ -205,7 +203,6 @@ class AsyncChatClient:
205
203
  seed : typing.Optional[int]
206
204
  This feature is in Beta.
207
205
  If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.
208
- Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.
209
206
 
210
207
  frequency_penalty : typing.Optional[float]
211
208
  Number between -2.0 and 2.0. Positive values penalize new tokens based on
@@ -247,7 +244,7 @@ class AsyncChatClient:
247
244
 
248
245
  asyncio.run(main())
249
246
  """
250
- response = await self._raw_client.completions(
247
+ _response = await self._raw_client.completions(
251
248
  messages=messages,
252
249
  temperature=temperature,
253
250
  top_p=top_p,
@@ -262,4 +259,4 @@ class AsyncChatClient:
262
259
  wiki_grounding=wiki_grounding,
263
260
  request_options=request_options,
264
261
  )
265
- return response.data
262
+ return _response.data
@@ -1,24 +1,23 @@
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 ..requests.chat_completion_request_message import ChatCompletionRequestMessageParams
6
- from ..types.reasoning_effort import ReasoningEffort
7
- from ..requests.stop_configuration import StopConfigurationParams
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.pydantic_utilities import parse_obj_as
8
10
  from ..core.request_options import RequestOptions
9
- from ..core.http_response import HttpResponse
10
- from ..types.create_chat_completion_response import CreateChatCompletionResponse
11
11
  from ..core.serialization import convert_and_respect_annotation_metadata
12
- from ..core.pydantic_utilities import parse_obj_as
13
12
  from ..errors.bad_request_error import BadRequestError
14
13
  from ..errors.forbidden_error import ForbiddenError
15
- from ..errors.unprocessable_entity_error import UnprocessableEntityError
16
- from ..errors.too_many_requests_error import TooManyRequestsError
17
14
  from ..errors.internal_server_error import InternalServerError
18
- from json.decoder import JSONDecodeError
19
- from ..core.api_error import ApiError
20
- from ..core.client_wrapper import AsyncClientWrapper
21
- from ..core.http_response import AsyncHttpResponse
15
+ from ..errors.too_many_requests_error import TooManyRequestsError
16
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
17
+ from ..requests.chat_completion_request_message import ChatCompletionRequestMessageParams
18
+ from ..requests.stop_configuration import StopConfigurationParams
19
+ from ..types.create_chat_completion_response import CreateChatCompletionResponse
20
+ from ..types.reasoning_effort import ReasoningEffort
22
21
 
23
22
  # this is used as the default value for optional parameters
24
23
  OMIT = typing.cast(typing.Any, ...)
@@ -82,7 +81,6 @@ class RawChatClient:
82
81
  seed : typing.Optional[int]
83
82
  This feature is in Beta.
84
83
  If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.
85
- Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.
86
84
 
87
85
  frequency_penalty : typing.Optional[float]
88
86
  Number between -2.0 and 2.0. Positive values penalize new tokens based on
@@ -107,6 +105,7 @@ class RawChatClient:
107
105
  """
108
106
  _response = self._client_wrapper.httpx_client.request(
109
107
  "v1/chat/completions",
108
+ base_url=self._client_wrapper.get_environment().base,
110
109
  method="POST",
111
110
  json={
112
111
  "messages": convert_and_respect_annotation_metadata(
@@ -145,58 +144,63 @@ class RawChatClient:
145
144
  return HttpResponse(response=_response, data=_data)
146
145
  if _response.status_code == 400:
147
146
  raise BadRequestError(
148
- typing.cast(
147
+ headers=dict(_response.headers),
148
+ body=typing.cast(
149
149
  typing.Optional[typing.Any],
150
150
  parse_obj_as(
151
151
  type_=typing.Optional[typing.Any], # type: ignore
152
152
  object_=_response.json(),
153
153
  ),
154
- )
154
+ ),
155
155
  )
156
156
  if _response.status_code == 403:
157
157
  raise ForbiddenError(
158
- typing.cast(
158
+ headers=dict(_response.headers),
159
+ body=typing.cast(
159
160
  typing.Optional[typing.Any],
160
161
  parse_obj_as(
161
162
  type_=typing.Optional[typing.Any], # type: ignore
162
163
  object_=_response.json(),
163
164
  ),
164
- )
165
+ ),
165
166
  )
166
167
  if _response.status_code == 422:
167
168
  raise UnprocessableEntityError(
168
- typing.cast(
169
+ headers=dict(_response.headers),
170
+ body=typing.cast(
169
171
  typing.Optional[typing.Any],
170
172
  parse_obj_as(
171
173
  type_=typing.Optional[typing.Any], # type: ignore
172
174
  object_=_response.json(),
173
175
  ),
174
- )
176
+ ),
175
177
  )
176
178
  if _response.status_code == 429:
177
179
  raise TooManyRequestsError(
178
- typing.cast(
180
+ headers=dict(_response.headers),
181
+ body=typing.cast(
179
182
  typing.Optional[typing.Any],
180
183
  parse_obj_as(
181
184
  type_=typing.Optional[typing.Any], # type: ignore
182
185
  object_=_response.json(),
183
186
  ),
184
- )
187
+ ),
185
188
  )
186
189
  if _response.status_code == 500:
187
190
  raise InternalServerError(
188
- typing.cast(
191
+ headers=dict(_response.headers),
192
+ body=typing.cast(
189
193
  typing.Optional[typing.Any],
190
194
  parse_obj_as(
191
195
  type_=typing.Optional[typing.Any], # type: ignore
192
196
  object_=_response.json(),
193
197
  ),
194
- )
198
+ ),
195
199
  )
196
200
  _response_json = _response.json()
197
201
  except JSONDecodeError:
198
- raise ApiError(status_code=_response.status_code, body=_response.text)
199
- raise ApiError(status_code=_response.status_code, body=_response_json)
202
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
203
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
200
204
 
201
205
 
202
206
  class AsyncRawChatClient:
@@ -257,7 +261,6 @@ class AsyncRawChatClient:
257
261
  seed : typing.Optional[int]
258
262
  This feature is in Beta.
259
263
  If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.
260
- Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.
261
264
 
262
265
  frequency_penalty : typing.Optional[float]
263
266
  Number between -2.0 and 2.0. Positive values penalize new tokens based on
@@ -282,6 +285,7 @@ class AsyncRawChatClient:
282
285
  """
283
286
  _response = await self._client_wrapper.httpx_client.request(
284
287
  "v1/chat/completions",
288
+ base_url=self._client_wrapper.get_environment().base,
285
289
  method="POST",
286
290
  json={
287
291
  "messages": convert_and_respect_annotation_metadata(
@@ -320,55 +324,60 @@ class AsyncRawChatClient:
320
324
  return AsyncHttpResponse(response=_response, data=_data)
321
325
  if _response.status_code == 400:
322
326
  raise BadRequestError(
323
- typing.cast(
327
+ headers=dict(_response.headers),
328
+ body=typing.cast(
324
329
  typing.Optional[typing.Any],
325
330
  parse_obj_as(
326
331
  type_=typing.Optional[typing.Any], # type: ignore
327
332
  object_=_response.json(),
328
333
  ),
329
- )
334
+ ),
330
335
  )
331
336
  if _response.status_code == 403:
332
337
  raise ForbiddenError(
333
- typing.cast(
338
+ headers=dict(_response.headers),
339
+ body=typing.cast(
334
340
  typing.Optional[typing.Any],
335
341
  parse_obj_as(
336
342
  type_=typing.Optional[typing.Any], # type: ignore
337
343
  object_=_response.json(),
338
344
  ),
339
- )
345
+ ),
340
346
  )
341
347
  if _response.status_code == 422:
342
348
  raise UnprocessableEntityError(
343
- typing.cast(
349
+ headers=dict(_response.headers),
350
+ body=typing.cast(
344
351
  typing.Optional[typing.Any],
345
352
  parse_obj_as(
346
353
  type_=typing.Optional[typing.Any], # type: ignore
347
354
  object_=_response.json(),
348
355
  ),
349
- )
356
+ ),
350
357
  )
351
358
  if _response.status_code == 429:
352
359
  raise TooManyRequestsError(
353
- typing.cast(
360
+ headers=dict(_response.headers),
361
+ body=typing.cast(
354
362
  typing.Optional[typing.Any],
355
363
  parse_obj_as(
356
364
  type_=typing.Optional[typing.Any], # type: ignore
357
365
  object_=_response.json(),
358
366
  ),
359
- )
367
+ ),
360
368
  )
361
369
  if _response.status_code == 500:
362
370
  raise InternalServerError(
363
- typing.cast(
371
+ headers=dict(_response.headers),
372
+ body=typing.cast(
364
373
  typing.Optional[typing.Any],
365
374
  parse_obj_as(
366
375
  type_=typing.Optional[typing.Any], # type: ignore
367
376
  object_=_response.json(),
368
377
  ),
369
- )
378
+ ),
370
379
  )
371
380
  _response_json = _response.json()
372
381
  except JSONDecodeError:
373
- raise ApiError(status_code=_response.status_code, body=_response.text)
374
- raise ApiError(status_code=_response.status_code, body=_response_json)
382
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
383
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
@@ -1,20 +1,17 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import typing
4
- from .environment import SarvamAIEnvironment
5
3
  import os
4
+ import typing
5
+
6
6
  import httpx
7
+ from .chat.client import AsyncChatClient, ChatClient
7
8
  from .core.api_error import ApiError
8
- from .core.client_wrapper import SyncClientWrapper
9
- from .text.client import TextClient
10
- from .speech_to_text.client import SpeechToTextClient
11
- from .text_to_speech.client import TextToSpeechClient
12
- from .chat.client import ChatClient
13
- from .core.client_wrapper import AsyncClientWrapper
14
- from .text.client import AsyncTextClient
15
- from .speech_to_text.client import AsyncSpeechToTextClient
16
- from .text_to_speech.client import AsyncTextToSpeechClient
17
- from .chat.client import AsyncChatClient
9
+ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
10
+ from .environment import SarvamAIEnvironment
11
+ from .speech_to_text.client import AsyncSpeechToTextClient, SpeechToTextClient
12
+ from .speech_to_text_streaming.client import AsyncSpeechToTextStreamingClient, SpeechToTextStreamingClient
13
+ from .text.client import AsyncTextClient, TextClient
14
+ from .text_to_speech.client import AsyncTextToSpeechClient, TextToSpeechClient
18
15
 
19
16
 
20
17
  class SarvamAI:
@@ -23,9 +20,6 @@ class SarvamAI:
23
20
 
24
21
  Parameters
25
22
  ----------
26
- base_url : typing.Optional[str]
27
- The base url to use for requests from the client.
28
-
29
23
  environment : SarvamAIEnvironment
30
24
  The environment to use for requests from the client. from .environment import SarvamAIEnvironment
31
25
 
@@ -57,7 +51,6 @@ class SarvamAI:
57
51
  def __init__(
58
52
  self,
59
53
  *,
60
- base_url: typing.Optional[str] = None,
61
54
  environment: SarvamAIEnvironment = SarvamAIEnvironment.PRODUCTION,
62
55
  api_subscription_key: typing.Optional[str] = os.getenv("SARVAM_API_KEY"),
63
56
  timeout: typing.Optional[float] = None,
@@ -72,7 +65,7 @@ class SarvamAI:
72
65
  body="The client must be instantiated be either passing in api_subscription_key or setting SARVAM_API_KEY"
73
66
  )
74
67
  self._client_wrapper = SyncClientWrapper(
75
- base_url=_get_base_url(base_url=base_url, environment=environment),
68
+ environment=environment,
76
69
  api_subscription_key=api_subscription_key,
77
70
  httpx_client=httpx_client
78
71
  if httpx_client is not None
@@ -85,6 +78,7 @@ class SarvamAI:
85
78
  self.speech_to_text = SpeechToTextClient(client_wrapper=self._client_wrapper)
86
79
  self.text_to_speech = TextToSpeechClient(client_wrapper=self._client_wrapper)
87
80
  self.chat = ChatClient(client_wrapper=self._client_wrapper)
81
+ self.speech_to_text_streaming = SpeechToTextStreamingClient(client_wrapper=self._client_wrapper)
88
82
 
89
83
 
90
84
  class AsyncSarvamAI:
@@ -93,9 +87,6 @@ class AsyncSarvamAI:
93
87
 
94
88
  Parameters
95
89
  ----------
96
- base_url : typing.Optional[str]
97
- The base url to use for requests from the client.
98
-
99
90
  environment : SarvamAIEnvironment
100
91
  The environment to use for requests from the client. from .environment import SarvamAIEnvironment
101
92
 
@@ -127,7 +118,6 @@ class AsyncSarvamAI:
127
118
  def __init__(
128
119
  self,
129
120
  *,
130
- base_url: typing.Optional[str] = None,
131
121
  environment: SarvamAIEnvironment = SarvamAIEnvironment.PRODUCTION,
132
122
  api_subscription_key: typing.Optional[str] = os.getenv("SARVAM_API_KEY"),
133
123
  timeout: typing.Optional[float] = None,
@@ -142,7 +132,7 @@ class AsyncSarvamAI:
142
132
  body="The client must be instantiated be either passing in api_subscription_key or setting SARVAM_API_KEY"
143
133
  )
144
134
  self._client_wrapper = AsyncClientWrapper(
145
- base_url=_get_base_url(base_url=base_url, environment=environment),
135
+ environment=environment,
146
136
  api_subscription_key=api_subscription_key,
147
137
  httpx_client=httpx_client
148
138
  if httpx_client is not None
@@ -155,12 +145,4 @@ class AsyncSarvamAI:
155
145
  self.speech_to_text = AsyncSpeechToTextClient(client_wrapper=self._client_wrapper)
156
146
  self.text_to_speech = AsyncTextToSpeechClient(client_wrapper=self._client_wrapper)
157
147
  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")
148
+ self.speech_to_text_streaming = AsyncSpeechToTextStreamingClient(client_wrapper=self._client_wrapper)
@@ -1,8 +1,11 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
+ # isort: skip_file
4
+
3
5
  from .api_error import ApiError
4
6
  from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
5
7
  from .datetime_utils import serialize_datetime
8
+ from .events import EventEmitterMixin, EventType
6
9
  from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
7
10
  from .http_client import AsyncHttpClient, HttpClient
8
11
  from .http_response import AsyncHttpResponse, HttpResponse
@@ -27,6 +30,8 @@ __all__ = [
27
30
  "AsyncHttpClient",
28
31
  "AsyncHttpResponse",
29
32
  "BaseClientWrapper",
33
+ "EventEmitterMixin",
34
+ "EventType",
30
35
  "FieldMetadata",
31
36
  "File",
32
37
  "HttpClient",
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import Any, Dict, Optional
4
+
5
+
6
+ class ApiError(Exception):
7
+ headers: Optional[Dict[str, str]]
8
+ status_code: Optional[int]
9
+ body: Any
10
+
11
+ def __init__(
12
+ self,
13
+ *,
14
+ headers: Optional[Dict[str, str]] = None,
15
+ status_code: Optional[int] = None,
16
+ body: Any = None,
17
+ ) -> None:
18
+ self.headers = headers
19
+ self.status_code = status_code
20
+ self.body = body
21
+
22
+ def __str__(self) -> str:
23
+ return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}"