mistralai 1.1.0__py3-none-any.whl → 1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. mistralai/__init__.py +4 -0
  2. mistralai/_version.py +12 -0
  3. mistralai/agents.py +56 -22
  4. mistralai/batch.py +17 -0
  5. mistralai/chat.py +64 -30
  6. mistralai/classifiers.py +396 -0
  7. mistralai/embeddings.py +10 -6
  8. mistralai/files.py +252 -19
  9. mistralai/fim.py +40 -30
  10. mistralai/jobs.py +40 -20
  11. mistralai/mistral_jobs.py +733 -0
  12. mistralai/models/__init__.py +108 -18
  13. mistralai/models/agentscompletionrequest.py +27 -10
  14. mistralai/models/agentscompletionstreamrequest.py +27 -10
  15. mistralai/models/apiendpoint.py +9 -0
  16. mistralai/models/archiveftmodelout.py +11 -5
  17. mistralai/models/assistantmessage.py +11 -6
  18. mistralai/models/basemodelcard.py +22 -6
  19. mistralai/models/batcherror.py +17 -0
  20. mistralai/models/batchjobin.py +58 -0
  21. mistralai/models/batchjobout.py +117 -0
  22. mistralai/models/batchjobsout.py +30 -0
  23. mistralai/models/batchjobstatus.py +15 -0
  24. mistralai/models/chatclassificationrequest.py +104 -0
  25. mistralai/models/chatcompletionchoice.py +9 -4
  26. mistralai/models/chatcompletionrequest.py +32 -13
  27. mistralai/models/chatcompletionresponse.py +2 -2
  28. mistralai/models/chatcompletionstreamrequest.py +32 -13
  29. mistralai/models/checkpointout.py +1 -1
  30. mistralai/models/classificationobject.py +21 -0
  31. mistralai/models/classificationrequest.py +59 -0
  32. mistralai/models/classificationresponse.py +21 -0
  33. mistralai/models/completionchunk.py +2 -2
  34. mistralai/models/completionevent.py +1 -1
  35. mistralai/models/completionresponsestreamchoice.py +11 -5
  36. mistralai/models/delete_model_v1_models_model_id_deleteop.py +1 -2
  37. mistralai/models/deletefileout.py +1 -1
  38. mistralai/models/deletemodelout.py +2 -2
  39. mistralai/models/deltamessage.py +14 -7
  40. mistralai/models/detailedjobout.py +11 -5
  41. mistralai/models/embeddingrequest.py +5 -5
  42. mistralai/models/embeddingresponse.py +2 -1
  43. mistralai/models/embeddingresponsedata.py +2 -2
  44. mistralai/models/eventout.py +2 -2
  45. mistralai/models/filepurpose.py +8 -0
  46. mistralai/models/files_api_routes_delete_fileop.py +1 -2
  47. mistralai/models/files_api_routes_download_fileop.py +16 -0
  48. mistralai/models/files_api_routes_list_filesop.py +96 -0
  49. mistralai/models/files_api_routes_retrieve_fileop.py +1 -2
  50. mistralai/models/files_api_routes_upload_fileop.py +9 -9
  51. mistralai/models/fileschema.py +7 -21
  52. mistralai/models/fimcompletionrequest.py +20 -13
  53. mistralai/models/fimcompletionresponse.py +2 -2
  54. mistralai/models/fimcompletionstreamrequest.py +20 -13
  55. mistralai/models/ftmodelcapabilitiesout.py +2 -2
  56. mistralai/models/ftmodelcard.py +24 -6
  57. mistralai/models/ftmodelout.py +9 -5
  58. mistralai/models/function.py +2 -2
  59. mistralai/models/functioncall.py +2 -1
  60. mistralai/models/functionname.py +1 -1
  61. mistralai/models/githubrepositoryin.py +11 -5
  62. mistralai/models/githubrepositoryout.py +11 -5
  63. mistralai/models/httpvalidationerror.py +0 -2
  64. mistralai/models/imageurl.py +1 -2
  65. mistralai/models/imageurlchunk.py +11 -5
  66. mistralai/models/jobin.py +2 -2
  67. mistralai/models/jobmetadataout.py +1 -2
  68. mistralai/models/jobout.py +10 -5
  69. mistralai/models/jobs_api_routes_batch_cancel_batch_jobop.py +16 -0
  70. mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +16 -0
  71. mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +95 -0
  72. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +1 -2
  73. mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +1 -2
  74. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +1 -2
  75. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +2 -2
  76. mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +1 -2
  77. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +1 -2
  78. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +1 -2
  79. mistralai/models/jobsout.py +9 -5
  80. mistralai/models/legacyjobmetadataout.py +12 -5
  81. mistralai/models/listfilesout.py +5 -1
  82. mistralai/models/metricout.py +1 -2
  83. mistralai/models/modelcapabilities.py +2 -2
  84. mistralai/models/modellist.py +2 -2
  85. mistralai/models/responseformat.py +2 -2
  86. mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -2
  87. mistralai/models/retrievefileout.py +10 -21
  88. mistralai/models/sampletype.py +6 -2
  89. mistralai/models/security.py +2 -2
  90. mistralai/models/source.py +3 -2
  91. mistralai/models/systemmessage.py +6 -6
  92. mistralai/models/textchunk.py +9 -5
  93. mistralai/models/tool.py +2 -2
  94. mistralai/models/toolcall.py +2 -2
  95. mistralai/models/toolchoice.py +2 -2
  96. mistralai/models/toolmessage.py +2 -2
  97. mistralai/models/trainingfile.py +2 -2
  98. mistralai/models/trainingparameters.py +7 -2
  99. mistralai/models/trainingparametersin.py +7 -2
  100. mistralai/models/unarchiveftmodelout.py +11 -5
  101. mistralai/models/updateftmodelin.py +1 -2
  102. mistralai/models/uploadfileout.py +7 -21
  103. mistralai/models/usageinfo.py +1 -1
  104. mistralai/models/usermessage.py +36 -5
  105. mistralai/models/validationerror.py +2 -1
  106. mistralai/models/wandbintegration.py +11 -5
  107. mistralai/models/wandbintegrationout.py +12 -6
  108. mistralai/models_.py +48 -24
  109. mistralai/sdk.py +7 -0
  110. mistralai/sdkconfiguration.py +7 -7
  111. mistralai/utils/__init__.py +8 -0
  112. mistralai/utils/annotations.py +13 -2
  113. mistralai/utils/serializers.py +25 -0
  114. {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/METADATA +90 -14
  115. mistralai-1.2.1.dist-info/RECORD +276 -0
  116. {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/WHEEL +1 -1
  117. mistralai_azure/__init__.py +4 -0
  118. mistralai_azure/_version.py +12 -0
  119. mistralai_azure/chat.py +64 -30
  120. mistralai_azure/models/__init__.py +9 -3
  121. mistralai_azure/models/assistantmessage.py +11 -6
  122. mistralai_azure/models/chatcompletionchoice.py +10 -5
  123. mistralai_azure/models/chatcompletionrequest.py +32 -13
  124. mistralai_azure/models/chatcompletionresponse.py +2 -2
  125. mistralai_azure/models/chatcompletionstreamrequest.py +32 -13
  126. mistralai_azure/models/completionchunk.py +2 -2
  127. mistralai_azure/models/completionevent.py +1 -1
  128. mistralai_azure/models/completionresponsestreamchoice.py +9 -4
  129. mistralai_azure/models/deltamessage.py +14 -7
  130. mistralai_azure/models/function.py +2 -2
  131. mistralai_azure/models/functioncall.py +2 -1
  132. mistralai_azure/models/functionname.py +1 -1
  133. mistralai_azure/models/httpvalidationerror.py +0 -2
  134. mistralai_azure/models/responseformat.py +2 -2
  135. mistralai_azure/models/security.py +1 -2
  136. mistralai_azure/models/systemmessage.py +6 -6
  137. mistralai_azure/models/textchunk.py +9 -5
  138. mistralai_azure/models/tool.py +2 -2
  139. mistralai_azure/models/toolcall.py +2 -2
  140. mistralai_azure/models/toolchoice.py +2 -2
  141. mistralai_azure/models/toolmessage.py +2 -2
  142. mistralai_azure/models/usageinfo.py +1 -1
  143. mistralai_azure/models/usermessage.py +36 -5
  144. mistralai_azure/models/validationerror.py +2 -1
  145. mistralai_azure/sdkconfiguration.py +7 -7
  146. mistralai_azure/utils/__init__.py +8 -0
  147. mistralai_azure/utils/annotations.py +13 -2
  148. mistralai_azure/utils/serializers.py +25 -0
  149. mistralai_gcp/__init__.py +4 -0
  150. mistralai_gcp/_version.py +12 -0
  151. mistralai_gcp/chat.py +64 -30
  152. mistralai_gcp/fim.py +40 -30
  153. mistralai_gcp/models/__init__.py +9 -3
  154. mistralai_gcp/models/assistantmessage.py +11 -6
  155. mistralai_gcp/models/chatcompletionchoice.py +10 -5
  156. mistralai_gcp/models/chatcompletionrequest.py +32 -13
  157. mistralai_gcp/models/chatcompletionresponse.py +2 -2
  158. mistralai_gcp/models/chatcompletionstreamrequest.py +32 -13
  159. mistralai_gcp/models/completionchunk.py +2 -2
  160. mistralai_gcp/models/completionevent.py +1 -1
  161. mistralai_gcp/models/completionresponsestreamchoice.py +9 -4
  162. mistralai_gcp/models/deltamessage.py +14 -7
  163. mistralai_gcp/models/fimcompletionrequest.py +20 -13
  164. mistralai_gcp/models/fimcompletionresponse.py +2 -2
  165. mistralai_gcp/models/fimcompletionstreamrequest.py +20 -13
  166. mistralai_gcp/models/function.py +2 -2
  167. mistralai_gcp/models/functioncall.py +2 -1
  168. mistralai_gcp/models/functionname.py +1 -1
  169. mistralai_gcp/models/httpvalidationerror.py +0 -2
  170. mistralai_gcp/models/responseformat.py +2 -2
  171. mistralai_gcp/models/security.py +1 -2
  172. mistralai_gcp/models/systemmessage.py +6 -6
  173. mistralai_gcp/models/textchunk.py +9 -5
  174. mistralai_gcp/models/tool.py +2 -2
  175. mistralai_gcp/models/toolcall.py +2 -2
  176. mistralai_gcp/models/toolchoice.py +2 -2
  177. mistralai_gcp/models/toolmessage.py +2 -2
  178. mistralai_gcp/models/usageinfo.py +1 -1
  179. mistralai_gcp/models/usermessage.py +36 -5
  180. mistralai_gcp/models/validationerror.py +2 -1
  181. mistralai_gcp/sdk.py +20 -11
  182. mistralai_gcp/sdkconfiguration.py +7 -7
  183. mistralai_gcp/utils/__init__.py +8 -0
  184. mistralai_gcp/utils/annotations.py +13 -2
  185. mistralai_gcp/utils/serializers.py +25 -0
  186. mistralai-1.1.0.dist-info/RECORD +0 -254
  187. {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/LICENSE +0 -0
@@ -0,0 +1,396 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basesdk import BaseSDK
4
+ from mistralai import models, utils
5
+ from mistralai._hooks import HookContext
6
+ from mistralai.types import Nullable, OptionalNullable, UNSET
7
+ from mistralai.utils import get_security_from_env
8
+ from typing import Any, Optional, Union
9
+
10
+
11
+ class Classifiers(BaseSDK):
12
+ r"""Classifiers API."""
13
+
14
+ def moderate(
15
+ self,
16
+ *,
17
+ inputs: Union[
18
+ models.ClassificationRequestInputs,
19
+ models.ClassificationRequestInputsTypedDict,
20
+ ],
21
+ model: OptionalNullable[str] = UNSET,
22
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
23
+ server_url: Optional[str] = None,
24
+ timeout_ms: Optional[int] = None,
25
+ ) -> Optional[models.ClassificationResponse]:
26
+ r"""Moderations
27
+
28
+ :param inputs: Text to classify.
29
+ :param model:
30
+ :param retries: Override the default retry configuration for this method
31
+ :param server_url: Override the default server URL for this method
32
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
33
+ """
34
+ base_url = None
35
+ url_variables = None
36
+ if timeout_ms is None:
37
+ timeout_ms = self.sdk_configuration.timeout_ms
38
+
39
+ if server_url is not None:
40
+ base_url = server_url
41
+
42
+ request = models.ClassificationRequest(
43
+ inputs=inputs,
44
+ model=model,
45
+ )
46
+
47
+ req = self.build_request(
48
+ method="POST",
49
+ path="/v1/moderations",
50
+ base_url=base_url,
51
+ url_variables=url_variables,
52
+ request=request,
53
+ request_body_required=True,
54
+ request_has_path_params=False,
55
+ request_has_query_params=True,
56
+ user_agent_header="user-agent",
57
+ accept_header_value="application/json",
58
+ security=self.sdk_configuration.security,
59
+ get_serialized_body=lambda: utils.serialize_request_body(
60
+ request, False, False, "json", models.ClassificationRequest
61
+ ),
62
+ timeout_ms=timeout_ms,
63
+ )
64
+
65
+ if retries == UNSET:
66
+ if self.sdk_configuration.retry_config is not UNSET:
67
+ retries = self.sdk_configuration.retry_config
68
+
69
+ retry_config = None
70
+ if isinstance(retries, utils.RetryConfig):
71
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
72
+
73
+ http_res = self.do_request(
74
+ hook_ctx=HookContext(
75
+ operation_id="moderations_v1_moderations_post",
76
+ oauth2_scopes=[],
77
+ security_source=get_security_from_env(
78
+ self.sdk_configuration.security, models.Security
79
+ ),
80
+ ),
81
+ request=req,
82
+ error_status_codes=["422", "4XX", "5XX"],
83
+ retry_config=retry_config,
84
+ )
85
+
86
+ data: Any = None
87
+ if utils.match_response(http_res, "200", "application/json"):
88
+ return utils.unmarshal_json(
89
+ http_res.text, Optional[models.ClassificationResponse]
90
+ )
91
+ if utils.match_response(http_res, "422", "application/json"):
92
+ data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
93
+ raise models.HTTPValidationError(data=data)
94
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
95
+ http_res_text = utils.stream_to_text(http_res)
96
+ raise models.SDKError(
97
+ "API error occurred", http_res.status_code, http_res_text, http_res
98
+ )
99
+
100
+ content_type = http_res.headers.get("Content-Type")
101
+ http_res_text = utils.stream_to_text(http_res)
102
+ raise models.SDKError(
103
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
104
+ http_res.status_code,
105
+ http_res_text,
106
+ http_res,
107
+ )
108
+
109
+ async def moderate_async(
110
+ self,
111
+ *,
112
+ inputs: Union[
113
+ models.ClassificationRequestInputs,
114
+ models.ClassificationRequestInputsTypedDict,
115
+ ],
116
+ model: OptionalNullable[str] = UNSET,
117
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
118
+ server_url: Optional[str] = None,
119
+ timeout_ms: Optional[int] = None,
120
+ ) -> Optional[models.ClassificationResponse]:
121
+ r"""Moderations
122
+
123
+ :param inputs: Text to classify.
124
+ :param model:
125
+ :param retries: Override the default retry configuration for this method
126
+ :param server_url: Override the default server URL for this method
127
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
128
+ """
129
+ base_url = None
130
+ url_variables = None
131
+ if timeout_ms is None:
132
+ timeout_ms = self.sdk_configuration.timeout_ms
133
+
134
+ if server_url is not None:
135
+ base_url = server_url
136
+
137
+ request = models.ClassificationRequest(
138
+ inputs=inputs,
139
+ model=model,
140
+ )
141
+
142
+ req = self.build_request_async(
143
+ method="POST",
144
+ path="/v1/moderations",
145
+ base_url=base_url,
146
+ url_variables=url_variables,
147
+ request=request,
148
+ request_body_required=True,
149
+ request_has_path_params=False,
150
+ request_has_query_params=True,
151
+ user_agent_header="user-agent",
152
+ accept_header_value="application/json",
153
+ security=self.sdk_configuration.security,
154
+ get_serialized_body=lambda: utils.serialize_request_body(
155
+ request, False, False, "json", models.ClassificationRequest
156
+ ),
157
+ timeout_ms=timeout_ms,
158
+ )
159
+
160
+ if retries == UNSET:
161
+ if self.sdk_configuration.retry_config is not UNSET:
162
+ retries = self.sdk_configuration.retry_config
163
+
164
+ retry_config = None
165
+ if isinstance(retries, utils.RetryConfig):
166
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
167
+
168
+ http_res = await self.do_request_async(
169
+ hook_ctx=HookContext(
170
+ operation_id="moderations_v1_moderations_post",
171
+ oauth2_scopes=[],
172
+ security_source=get_security_from_env(
173
+ self.sdk_configuration.security, models.Security
174
+ ),
175
+ ),
176
+ request=req,
177
+ error_status_codes=["422", "4XX", "5XX"],
178
+ retry_config=retry_config,
179
+ )
180
+
181
+ data: Any = None
182
+ if utils.match_response(http_res, "200", "application/json"):
183
+ return utils.unmarshal_json(
184
+ http_res.text, Optional[models.ClassificationResponse]
185
+ )
186
+ if utils.match_response(http_res, "422", "application/json"):
187
+ data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
188
+ raise models.HTTPValidationError(data=data)
189
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
190
+ http_res_text = await utils.stream_to_text_async(http_res)
191
+ raise models.SDKError(
192
+ "API error occurred", http_res.status_code, http_res_text, http_res
193
+ )
194
+
195
+ content_type = http_res.headers.get("Content-Type")
196
+ http_res_text = await utils.stream_to_text_async(http_res)
197
+ raise models.SDKError(
198
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
199
+ http_res.status_code,
200
+ http_res_text,
201
+ http_res,
202
+ )
203
+
204
+ def moderate_chat(
205
+ self,
206
+ *,
207
+ inputs: Union[
208
+ models.ChatClassificationRequestInputs,
209
+ models.ChatClassificationRequestInputsTypedDict,
210
+ ],
211
+ model: Nullable[str],
212
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
213
+ server_url: Optional[str] = None,
214
+ timeout_ms: Optional[int] = None,
215
+ ) -> Optional[models.ClassificationResponse]:
216
+ r"""Moderations Chat
217
+
218
+ :param inputs: Chat to classify
219
+ :param model:
220
+ :param retries: Override the default retry configuration for this method
221
+ :param server_url: Override the default server URL for this method
222
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
223
+ """
224
+ base_url = None
225
+ url_variables = None
226
+ if timeout_ms is None:
227
+ timeout_ms = self.sdk_configuration.timeout_ms
228
+
229
+ if server_url is not None:
230
+ base_url = server_url
231
+
232
+ request = models.ChatClassificationRequest(
233
+ inputs=utils.get_pydantic_model(
234
+ inputs, models.ChatClassificationRequestInputs
235
+ ),
236
+ model=model,
237
+ )
238
+
239
+ req = self.build_request(
240
+ method="POST",
241
+ path="/v1/chat/moderations",
242
+ base_url=base_url,
243
+ url_variables=url_variables,
244
+ request=request,
245
+ request_body_required=True,
246
+ request_has_path_params=False,
247
+ request_has_query_params=True,
248
+ user_agent_header="user-agent",
249
+ accept_header_value="application/json",
250
+ security=self.sdk_configuration.security,
251
+ get_serialized_body=lambda: utils.serialize_request_body(
252
+ request, False, False, "json", models.ChatClassificationRequest
253
+ ),
254
+ timeout_ms=timeout_ms,
255
+ )
256
+
257
+ if retries == UNSET:
258
+ if self.sdk_configuration.retry_config is not UNSET:
259
+ retries = self.sdk_configuration.retry_config
260
+
261
+ retry_config = None
262
+ if isinstance(retries, utils.RetryConfig):
263
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
264
+
265
+ http_res = self.do_request(
266
+ hook_ctx=HookContext(
267
+ operation_id="moderations_chat_v1_chat_moderations_post",
268
+ oauth2_scopes=[],
269
+ security_source=get_security_from_env(
270
+ self.sdk_configuration.security, models.Security
271
+ ),
272
+ ),
273
+ request=req,
274
+ error_status_codes=["422", "4XX", "5XX"],
275
+ retry_config=retry_config,
276
+ )
277
+
278
+ data: Any = None
279
+ if utils.match_response(http_res, "200", "application/json"):
280
+ return utils.unmarshal_json(
281
+ http_res.text, Optional[models.ClassificationResponse]
282
+ )
283
+ if utils.match_response(http_res, "422", "application/json"):
284
+ data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
285
+ raise models.HTTPValidationError(data=data)
286
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
287
+ http_res_text = utils.stream_to_text(http_res)
288
+ raise models.SDKError(
289
+ "API error occurred", http_res.status_code, http_res_text, http_res
290
+ )
291
+
292
+ content_type = http_res.headers.get("Content-Type")
293
+ http_res_text = utils.stream_to_text(http_res)
294
+ raise models.SDKError(
295
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
296
+ http_res.status_code,
297
+ http_res_text,
298
+ http_res,
299
+ )
300
+
301
+ async def moderate_chat_async(
302
+ self,
303
+ *,
304
+ inputs: Union[
305
+ models.ChatClassificationRequestInputs,
306
+ models.ChatClassificationRequestInputsTypedDict,
307
+ ],
308
+ model: Nullable[str],
309
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
310
+ server_url: Optional[str] = None,
311
+ timeout_ms: Optional[int] = None,
312
+ ) -> Optional[models.ClassificationResponse]:
313
+ r"""Moderations Chat
314
+
315
+ :param inputs: Chat to classify
316
+ :param model:
317
+ :param retries: Override the default retry configuration for this method
318
+ :param server_url: Override the default server URL for this method
319
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
320
+ """
321
+ base_url = None
322
+ url_variables = None
323
+ if timeout_ms is None:
324
+ timeout_ms = self.sdk_configuration.timeout_ms
325
+
326
+ if server_url is not None:
327
+ base_url = server_url
328
+
329
+ request = models.ChatClassificationRequest(
330
+ inputs=utils.get_pydantic_model(
331
+ inputs, models.ChatClassificationRequestInputs
332
+ ),
333
+ model=model,
334
+ )
335
+
336
+ req = self.build_request_async(
337
+ method="POST",
338
+ path="/v1/chat/moderations",
339
+ base_url=base_url,
340
+ url_variables=url_variables,
341
+ request=request,
342
+ request_body_required=True,
343
+ request_has_path_params=False,
344
+ request_has_query_params=True,
345
+ user_agent_header="user-agent",
346
+ accept_header_value="application/json",
347
+ security=self.sdk_configuration.security,
348
+ get_serialized_body=lambda: utils.serialize_request_body(
349
+ request, False, False, "json", models.ChatClassificationRequest
350
+ ),
351
+ timeout_ms=timeout_ms,
352
+ )
353
+
354
+ if retries == UNSET:
355
+ if self.sdk_configuration.retry_config is not UNSET:
356
+ retries = self.sdk_configuration.retry_config
357
+
358
+ retry_config = None
359
+ if isinstance(retries, utils.RetryConfig):
360
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
361
+
362
+ http_res = await self.do_request_async(
363
+ hook_ctx=HookContext(
364
+ operation_id="moderations_chat_v1_chat_moderations_post",
365
+ oauth2_scopes=[],
366
+ security_source=get_security_from_env(
367
+ self.sdk_configuration.security, models.Security
368
+ ),
369
+ ),
370
+ request=req,
371
+ error_status_codes=["422", "4XX", "5XX"],
372
+ retry_config=retry_config,
373
+ )
374
+
375
+ data: Any = None
376
+ if utils.match_response(http_res, "200", "application/json"):
377
+ return utils.unmarshal_json(
378
+ http_res.text, Optional[models.ClassificationResponse]
379
+ )
380
+ if utils.match_response(http_res, "422", "application/json"):
381
+ data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
382
+ raise models.HTTPValidationError(data=data)
383
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
384
+ http_res_text = await utils.stream_to_text_async(http_res)
385
+ raise models.SDKError(
386
+ "API error occurred", http_res.status_code, http_res_text, http_res
387
+ )
388
+
389
+ content_type = http_res.headers.get("Content-Type")
390
+ http_res_text = await utils.stream_to_text_async(http_res)
391
+ raise models.SDKError(
392
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
393
+ http_res.status_code,
394
+ http_res_text,
395
+ http_res,
396
+ )
mistralai/embeddings.py CHANGED
@@ -15,7 +15,7 @@ class Embeddings(BaseSDK):
15
15
  self,
16
16
  *,
17
17
  inputs: Union[models.Inputs, models.InputsTypedDict],
18
- model: str,
18
+ model: Optional[str] = "mistral-embed",
19
19
  encoding_format: OptionalNullable[str] = UNSET,
20
20
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
21
21
  server_url: Optional[str] = None,
@@ -94,15 +94,17 @@ class Embeddings(BaseSDK):
94
94
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
95
95
  raise models.HTTPValidationError(data=data)
96
96
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
97
+ http_res_text = utils.stream_to_text(http_res)
97
98
  raise models.SDKError(
98
- "API error occurred", http_res.status_code, http_res.text, http_res
99
+ "API error occurred", http_res.status_code, http_res_text, http_res
99
100
  )
100
101
 
101
102
  content_type = http_res.headers.get("Content-Type")
103
+ http_res_text = utils.stream_to_text(http_res)
102
104
  raise models.SDKError(
103
105
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
104
106
  http_res.status_code,
105
- http_res.text,
107
+ http_res_text,
106
108
  http_res,
107
109
  )
108
110
 
@@ -110,7 +112,7 @@ class Embeddings(BaseSDK):
110
112
  self,
111
113
  *,
112
114
  inputs: Union[models.Inputs, models.InputsTypedDict],
113
- model: str,
115
+ model: Optional[str] = "mistral-embed",
114
116
  encoding_format: OptionalNullable[str] = UNSET,
115
117
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
116
118
  server_url: Optional[str] = None,
@@ -189,14 +191,16 @@ class Embeddings(BaseSDK):
189
191
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
190
192
  raise models.HTTPValidationError(data=data)
191
193
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
194
+ http_res_text = await utils.stream_to_text_async(http_res)
192
195
  raise models.SDKError(
193
- "API error occurred", http_res.status_code, http_res.text, http_res
196
+ "API error occurred", http_res.status_code, http_res_text, http_res
194
197
  )
195
198
 
196
199
  content_type = http_res.headers.get("Content-Type")
200
+ http_res_text = await utils.stream_to_text_async(http_res)
197
201
  raise models.SDKError(
198
202
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
199
203
  http_res.status_code,
200
- http_res.text,
204
+ http_res_text,
201
205
  http_res,
202
206
  )