sarvamai 0.1.5a1__tar.gz → 0.1.5a3__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 (116) hide show
  1. sarvamai-0.1.5a3/PKG-INFO +27 -0
  2. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/pyproject.toml +24 -4
  3. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/__init__.py +2 -0
  4. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/chat/__init__.py +2 -0
  5. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/chat/client.py +9 -22
  6. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/chat/raw_client.py +46 -47
  7. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/client.py +8 -12
  8. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/core/__init__.py +2 -0
  9. sarvamai-0.1.5a3/src/sarvamai/core/api_error.py +23 -0
  10. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/core/client_wrapper.py +5 -5
  11. sarvamai-0.1.5a3/src/sarvamai/core/force_multipart.py +16 -0
  12. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/core/http_client.py +70 -24
  13. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/core/http_response.py +19 -11
  14. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/core/pydantic_utilities.py +69 -108
  15. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/errors/__init__.py +2 -0
  16. sarvamai-0.1.5a3/src/sarvamai/errors/bad_request_error.py +10 -0
  17. sarvamai-0.1.5a3/src/sarvamai/errors/forbidden_error.py +10 -0
  18. sarvamai-0.1.5a3/src/sarvamai/errors/internal_server_error.py +10 -0
  19. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/errors/service_unavailable_error.py +4 -2
  20. sarvamai-0.1.5a3/src/sarvamai/errors/too_many_requests_error.py +10 -0
  21. sarvamai-0.1.5a3/src/sarvamai/errors/unprocessable_entity_error.py +10 -0
  22. sarvamai-0.1.5a3/src/sarvamai/py.typed +0 -0
  23. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/__init__.py +2 -0
  24. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/chat_completion_request_message.py +3 -1
  25. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/create_chat_completion_response.py +2 -2
  26. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/diarized_transcript.py +2 -1
  27. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/error_details.py +0 -1
  28. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/language_identification_response.py +0 -1
  29. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/speech_to_text_response.py +1 -2
  30. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/speech_to_text_translate_response.py +0 -1
  31. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/text_to_speech_response.py +2 -2
  32. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/timestamps_model.py +2 -1
  33. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/translation_response.py +0 -1
  34. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/transliteration_response.py +0 -1
  35. {sarvamai-0.1.5a1/src/sarvamai/text_to_speech → sarvamai-0.1.5a3/src/sarvamai/speech_to_text}/__init__.py +2 -0
  36. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/speech_to_text/client.py +13 -14
  37. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/speech_to_text/raw_client.py +95 -68
  38. {sarvamai-0.1.5a1/src/sarvamai/speech_to_text → sarvamai-0.1.5a3/src/sarvamai/text}/__init__.py +2 -0
  39. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/text/client.py +23 -24
  40. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/text/raw_client.py +120 -91
  41. {sarvamai-0.1.5a1/src/sarvamai/text → sarvamai-0.1.5a3/src/sarvamai/text_to_speech}/__init__.py +2 -0
  42. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/text_to_speech/client.py +10 -11
  43. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/text_to_speech/raw_client.py +47 -38
  44. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/__init__.py +2 -0
  45. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/chat_completion_request_assistant_message.py +3 -3
  46. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/chat_completion_request_message.py +3 -2
  47. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/chat_completion_request_system_message.py +3 -3
  48. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/chat_completion_request_user_message.py +3 -3
  49. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/chat_completion_response_message.py +3 -3
  50. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/choice.py +4 -4
  51. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/completion_usage.py +3 -3
  52. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/create_chat_completion_response.py +3 -3
  53. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/diarized_entry.py +3 -3
  54. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/diarized_transcript.py +3 -3
  55. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/error_details.py +3 -3
  56. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/error_message.py +4 -4
  57. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/language_identification_response.py +2 -2
  58. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/speech_to_text_response.py +3 -3
  59. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/speech_to_text_translate_response.py +3 -3
  60. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/text_to_speech_response.py +2 -2
  61. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/timestamps_model.py +2 -2
  62. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/translation_response.py +2 -2
  63. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/transliteration_response.py +2 -2
  64. sarvamai-0.1.5a1/PKG-INFO +0 -174
  65. sarvamai-0.1.5a1/README.md +0 -147
  66. sarvamai-0.1.5a1/src/sarvamai/core/api_error.py +0 -15
  67. sarvamai-0.1.5a1/src/sarvamai/errors/bad_request_error.py +0 -9
  68. sarvamai-0.1.5a1/src/sarvamai/errors/forbidden_error.py +0 -9
  69. sarvamai-0.1.5a1/src/sarvamai/errors/internal_server_error.py +0 -9
  70. sarvamai-0.1.5a1/src/sarvamai/errors/too_many_requests_error.py +0 -9
  71. sarvamai-0.1.5a1/src/sarvamai/errors/unprocessable_entity_error.py +0 -9
  72. /sarvamai-0.1.5a1/src/sarvamai/py.typed → /sarvamai-0.1.5a3/README.md +0 -0
  73. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/core/datetime_utils.py +0 -0
  74. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/core/events.py +0 -0
  75. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/core/file.py +0 -0
  76. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/core/jsonable_encoder.py +0 -0
  77. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/core/query_encoder.py +0 -0
  78. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/core/remove_none_from_dict.py +0 -0
  79. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/core/request_options.py +0 -0
  80. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/core/serialization.py +0 -0
  81. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/environment.py +0 -0
  82. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/play.py +0 -0
  83. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/chat_completion_request_assistant_message.py +0 -0
  84. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/chat_completion_request_system_message.py +0 -0
  85. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/chat_completion_request_user_message.py +0 -0
  86. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/chat_completion_response_message.py +0 -0
  87. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/choice.py +0 -0
  88. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/completion_usage.py +0 -0
  89. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/diarized_entry.py +0 -0
  90. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/error_message.py +0 -0
  91. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/requests/stop_configuration.py +0 -0
  92. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/error_code.py +0 -0
  93. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/finish_reason.py +0 -0
  94. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/numerals_format.py +0 -0
  95. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/reasoning_effort.py +0 -0
  96. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/role.py +0 -0
  97. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/sarvam_model_ids.py +0 -0
  98. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/speech_sample_rate.py +0 -0
  99. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/speech_to_text_language.py +0 -0
  100. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/speech_to_text_model.py +0 -0
  101. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/speech_to_text_translate_language.py +0 -0
  102. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/speech_to_text_translate_model.py +0 -0
  103. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/spoken_form_numerals_format.py +0 -0
  104. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/stop_configuration.py +0 -0
  105. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/text_to_speech_language.py +0 -0
  106. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/text_to_speech_model.py +0 -0
  107. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/text_to_speech_speaker.py +0 -0
  108. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/translate_mode.py +0 -0
  109. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/translate_model.py +0 -0
  110. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/translate_postprocessing.py +0 -0
  111. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/translate_source_language.py +0 -0
  112. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/translate_speaker_gender.py +0 -0
  113. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/translate_target_language.py +0 -0
  114. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/translatiterate_target_language.py +0 -0
  115. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/types/transliterate_source_language.py +0 -0
  116. {sarvamai-0.1.5a1 → sarvamai-0.1.5a3}/src/sarvamai/version.py +0 -0
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.1
2
+ Name: sarvamai
3
+ Version: 0.1.5a3
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
+ Description-Content-Type: text/markdown
26
+
27
+
@@ -3,7 +3,7 @@ name = "sarvamai"
3
3
 
4
4
  [tool.poetry]
5
5
  name = "sarvamai"
6
- version = "0.1.5a1"
6
+ version = "0.1.5a3"
7
7
  description = ""
8
8
  readme = "README.md"
9
9
  authors = []
@@ -40,13 +40,13 @@ pydantic = ">= 1.9.2"
40
40
  pydantic-core = "^2.18.2"
41
41
  typing_extensions = ">= 4.0.0"
42
42
 
43
- [tool.poetry.dev-dependencies]
44
- mypy = "1.0.1"
43
+ [tool.poetry.group.dev.dependencies]
44
+ mypy = "==1.13.0"
45
45
  pytest = "^7.4.0"
46
46
  pytest-asyncio = "^0.23.5"
47
47
  python-dateutil = "^2.9.0"
48
48
  types-python-dateutil = "^2.9.0.20240316"
49
- ruff = "^0.5.6"
49
+ ruff = "==0.11.5"
50
50
 
51
51
  [tool.pytest.ini_options]
52
52
  testpaths = [ "tests" ]
@@ -58,6 +58,26 @@ plugins = ["pydantic.mypy"]
58
58
  [tool.ruff]
59
59
  line-length = 120
60
60
 
61
+ [tool.ruff.lint]
62
+ select = [
63
+ "E", # pycodestyle errors
64
+ "F", # pyflakes
65
+ "I", # isort
66
+ ]
67
+ ignore = [
68
+ "E402", # Module level import not at top of file
69
+ "E501", # Line too long
70
+ "E711", # Comparison to `None` should be `cond is not None`
71
+ "E712", # Avoid equality comparisons to `True`; use `if ...:` checks
72
+ "E721", # Use `is` and `is not` for type comparisons, or `isinstance()` for insinstance checks
73
+ "E722", # Do not use bare `except`
74
+ "E731", # Do not assign a `lambda` expression, use a `def`
75
+ "F821", # Undefined name
76
+ "F841" # Local variable ... is assigned to but never used
77
+ ]
78
+
79
+ [tool.ruff.lint.isort]
80
+ section-order = ["future", "standard-library", "third-party", "first-party"]
61
81
 
62
82
  [build-system]
63
83
  requires = ["poetry-core"]
@@ -1,5 +1,7 @@
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 (
4
6
  ChatCompletionRequestAssistantMessage,
5
7
  ChatCompletionRequestMessage,
@@ -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, ...)
@@ -33,7 +32,6 @@ class ChatClient:
33
32
  def completions(
34
33
  self,
35
34
  *,
36
- authorization: str,
37
35
  messages: typing.Sequence[ChatCompletionRequestMessageParams],
38
36
  temperature: typing.Optional[float] = OMIT,
39
37
  top_p: typing.Optional[float] = OMIT,
@@ -53,9 +51,6 @@ class ChatClient:
53
51
 
54
52
  Parameters
55
53
  ----------
56
- authorization : str
57
- Bearer token for authentication. Format: "Bearer <token>"
58
-
59
54
  messages : typing.Sequence[ChatCompletionRequestMessageParams]
60
55
  A list of messages comprising the conversation so far.
61
56
 
@@ -119,12 +114,10 @@ class ChatClient:
119
114
  api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
120
115
  )
121
116
  client.chat.completions(
122
- authorization="Authorization",
123
117
  messages=[{"content": "content", "role": "assistant"}],
124
118
  )
125
119
  """
126
- response = self._raw_client.completions(
127
- authorization=authorization,
120
+ _response = self._raw_client.completions(
128
121
  messages=messages,
129
122
  temperature=temperature,
130
123
  top_p=top_p,
@@ -139,7 +132,7 @@ class ChatClient:
139
132
  wiki_grounding=wiki_grounding,
140
133
  request_options=request_options,
141
134
  )
142
- return response.data
135
+ return _response.data
143
136
 
144
137
 
145
138
  class AsyncChatClient:
@@ -160,7 +153,6 @@ class AsyncChatClient:
160
153
  async def completions(
161
154
  self,
162
155
  *,
163
- authorization: str,
164
156
  messages: typing.Sequence[ChatCompletionRequestMessageParams],
165
157
  temperature: typing.Optional[float] = OMIT,
166
158
  top_p: typing.Optional[float] = OMIT,
@@ -180,9 +172,6 @@ class AsyncChatClient:
180
172
 
181
173
  Parameters
182
174
  ----------
183
- authorization : str
184
- Bearer token for authentication. Format: "Bearer <token>"
185
-
186
175
  messages : typing.Sequence[ChatCompletionRequestMessageParams]
187
176
  A list of messages comprising the conversation so far.
188
177
 
@@ -251,15 +240,13 @@ class AsyncChatClient:
251
240
 
252
241
  async def main() -> None:
253
242
  await client.chat.completions(
254
- authorization="Authorization",
255
243
  messages=[{"content": "content", "role": "assistant"}],
256
244
  )
257
245
 
258
246
 
259
247
  asyncio.run(main())
260
248
  """
261
- response = await self._raw_client.completions(
262
- authorization=authorization,
249
+ _response = await self._raw_client.completions(
263
250
  messages=messages,
264
251
  temperature=temperature,
265
252
  top_p=top_p,
@@ -274,4 +261,4 @@ class AsyncChatClient:
274
261
  wiki_grounding=wiki_grounding,
275
262
  request_options=request_options,
276
263
  )
277
- return response.data
264
+ 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, ...)
@@ -31,7 +30,6 @@ class RawChatClient:
31
30
  def completions(
32
31
  self,
33
32
  *,
34
- authorization: str,
35
33
  messages: typing.Sequence[ChatCompletionRequestMessageParams],
36
34
  temperature: typing.Optional[float] = OMIT,
37
35
  top_p: typing.Optional[float] = OMIT,
@@ -51,9 +49,6 @@ class RawChatClient:
51
49
 
52
50
  Parameters
53
51
  ----------
54
- authorization : str
55
- Bearer token for authentication. Format: "Bearer <token>"
56
-
57
52
  messages : typing.Sequence[ChatCompletionRequestMessageParams]
58
53
  A list of messages comprising the conversation so far.
59
54
 
@@ -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,
@@ -151,58 +145,63 @@ class RawChatClient:
151
145
  return HttpResponse(response=_response, data=_data)
152
146
  if _response.status_code == 400:
153
147
  raise BadRequestError(
154
- typing.cast(
148
+ headers=dict(_response.headers),
149
+ body=typing.cast(
155
150
  typing.Optional[typing.Any],
156
151
  parse_obj_as(
157
152
  type_=typing.Optional[typing.Any], # type: ignore
158
153
  object_=_response.json(),
159
154
  ),
160
- )
155
+ ),
161
156
  )
162
157
  if _response.status_code == 403:
163
158
  raise ForbiddenError(
164
- typing.cast(
159
+ headers=dict(_response.headers),
160
+ body=typing.cast(
165
161
  typing.Optional[typing.Any],
166
162
  parse_obj_as(
167
163
  type_=typing.Optional[typing.Any], # type: ignore
168
164
  object_=_response.json(),
169
165
  ),
170
- )
166
+ ),
171
167
  )
172
168
  if _response.status_code == 422:
173
169
  raise UnprocessableEntityError(
174
- typing.cast(
170
+ headers=dict(_response.headers),
171
+ body=typing.cast(
175
172
  typing.Optional[typing.Any],
176
173
  parse_obj_as(
177
174
  type_=typing.Optional[typing.Any], # type: ignore
178
175
  object_=_response.json(),
179
176
  ),
180
- )
177
+ ),
181
178
  )
182
179
  if _response.status_code == 429:
183
180
  raise TooManyRequestsError(
184
- typing.cast(
181
+ headers=dict(_response.headers),
182
+ body=typing.cast(
185
183
  typing.Optional[typing.Any],
186
184
  parse_obj_as(
187
185
  type_=typing.Optional[typing.Any], # type: ignore
188
186
  object_=_response.json(),
189
187
  ),
190
- )
188
+ ),
191
189
  )
192
190
  if _response.status_code == 500:
193
191
  raise InternalServerError(
194
- typing.cast(
192
+ headers=dict(_response.headers),
193
+ body=typing.cast(
195
194
  typing.Optional[typing.Any],
196
195
  parse_obj_as(
197
196
  type_=typing.Optional[typing.Any], # type: ignore
198
197
  object_=_response.json(),
199
198
  ),
200
- )
199
+ ),
201
200
  )
202
201
  _response_json = _response.json()
203
202
  except JSONDecodeError:
204
- raise ApiError(status_code=_response.status_code, body=_response.text)
205
- raise ApiError(status_code=_response.status_code, body=_response_json)
203
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
204
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
206
205
 
207
206
 
208
207
  class AsyncRawChatClient:
@@ -212,7 +211,6 @@ class AsyncRawChatClient:
212
211
  async def completions(
213
212
  self,
214
213
  *,
215
- authorization: str,
216
214
  messages: typing.Sequence[ChatCompletionRequestMessageParams],
217
215
  temperature: typing.Optional[float] = OMIT,
218
216
  top_p: typing.Optional[float] = OMIT,
@@ -232,9 +230,6 @@ class AsyncRawChatClient:
232
230
 
233
231
  Parameters
234
232
  ----------
235
- authorization : str
236
- Bearer token for authentication. Format: "Bearer <token>"
237
-
238
233
  messages : typing.Sequence[ChatCompletionRequestMessageParams]
239
234
  A list of messages comprising the conversation so far.
240
235
 
@@ -315,7 +310,6 @@ class AsyncRawChatClient:
315
310
  },
316
311
  headers={
317
312
  "content-type": "application/json",
318
- "Authorization": str(authorization) if authorization is not None else None,
319
313
  },
320
314
  request_options=request_options,
321
315
  omit=OMIT,
@@ -332,55 +326,60 @@ class AsyncRawChatClient:
332
326
  return AsyncHttpResponse(response=_response, data=_data)
333
327
  if _response.status_code == 400:
334
328
  raise BadRequestError(
335
- typing.cast(
329
+ headers=dict(_response.headers),
330
+ body=typing.cast(
336
331
  typing.Optional[typing.Any],
337
332
  parse_obj_as(
338
333
  type_=typing.Optional[typing.Any], # type: ignore
339
334
  object_=_response.json(),
340
335
  ),
341
- )
336
+ ),
342
337
  )
343
338
  if _response.status_code == 403:
344
339
  raise ForbiddenError(
345
- typing.cast(
340
+ headers=dict(_response.headers),
341
+ body=typing.cast(
346
342
  typing.Optional[typing.Any],
347
343
  parse_obj_as(
348
344
  type_=typing.Optional[typing.Any], # type: ignore
349
345
  object_=_response.json(),
350
346
  ),
351
- )
347
+ ),
352
348
  )
353
349
  if _response.status_code == 422:
354
350
  raise UnprocessableEntityError(
355
- typing.cast(
351
+ headers=dict(_response.headers),
352
+ body=typing.cast(
356
353
  typing.Optional[typing.Any],
357
354
  parse_obj_as(
358
355
  type_=typing.Optional[typing.Any], # type: ignore
359
356
  object_=_response.json(),
360
357
  ),
361
- )
358
+ ),
362
359
  )
363
360
  if _response.status_code == 429:
364
361
  raise TooManyRequestsError(
365
- typing.cast(
362
+ headers=dict(_response.headers),
363
+ body=typing.cast(
366
364
  typing.Optional[typing.Any],
367
365
  parse_obj_as(
368
366
  type_=typing.Optional[typing.Any], # type: ignore
369
367
  object_=_response.json(),
370
368
  ),
371
- )
369
+ ),
372
370
  )
373
371
  if _response.status_code == 500:
374
372
  raise InternalServerError(
375
- typing.cast(
373
+ headers=dict(_response.headers),
374
+ body=typing.cast(
376
375
  typing.Optional[typing.Any],
377
376
  parse_obj_as(
378
377
  type_=typing.Optional[typing.Any], # type: ignore
379
378
  object_=_response.json(),
380
379
  ),
381
- )
380
+ ),
382
381
  )
383
382
  _response_json = _response.json()
384
383
  except JSONDecodeError:
385
- raise ApiError(status_code=_response.status_code, body=_response.text)
386
- raise ApiError(status_code=_response.status_code, body=_response_json)
384
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
385
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
@@ -1,20 +1,16 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- from .environment import SarvamAIEnvironment
4
- import typing
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 .text.client import AsyncTextClient, TextClient
13
+ from .text_to_speech.client import AsyncTextToSpeechClient, TextToSpeechClient
18
14
 
19
15
 
20
16
  class SarvamAI:
@@ -1,5 +1,7 @@
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
@@ -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}"
@@ -1,10 +1,10 @@
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
+
5
5
  import httpx
6
- from .http_client import HttpClient
7
- from .http_client import AsyncHttpClient
6
+ from ..environment import SarvamAIEnvironment
7
+ from .http_client import AsyncHttpClient, HttpClient
8
8
 
9
9
 
10
10
  class BaseClientWrapper:
@@ -17,10 +17,10 @@ class BaseClientWrapper:
17
17
 
18
18
  def get_headers(self) -> typing.Dict[str, str]:
19
19
  headers: typing.Dict[str, str] = {
20
- "User-Agent": "sarvamai/0.1.5a1",
20
+ "User-Agent": "sarvamai/0.1.5a3",
21
21
  "X-Fern-Language": "Python",
22
22
  "X-Fern-SDK-Name": "sarvamai",
23
- "X-Fern-SDK-Version": "0.1.5a1",
23
+ "X-Fern-SDK-Version": "0.1.5a3",
24
24
  }
25
25
  headers["api-subscription-key"] = self.api_subscription_key
26
26
  return headers
@@ -0,0 +1,16 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+
4
+ class ForceMultipartDict(dict):
5
+ """
6
+ A dictionary subclass that always evaluates to True in boolean contexts.
7
+
8
+ This is used to force multipart/form-data encoding in HTTP requests even when
9
+ the dictionary is empty, which would normally evaluate to False.
10
+ """
11
+
12
+ def __bool__(self):
13
+ return True
14
+
15
+
16
+ FORCE_MULTIPART = ForceMultipartDict()