mistralai 1.9.9__py3-none-any.whl → 1.9.11__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.
- mistralai/_version.py +3 -3
- mistralai/accesses.py +43 -108
- mistralai/agents.py +29 -68
- mistralai/audio.py +8 -3
- mistralai/basesdk.py +15 -5
- mistralai/batch.py +6 -3
- mistralai/beta.py +10 -5
- mistralai/chat.py +29 -68
- mistralai/classifiers.py +57 -144
- mistralai/conversations.py +143 -352
- mistralai/documents.py +137 -356
- mistralai/embeddings.py +21 -36
- mistralai/files.py +47 -176
- mistralai/fim.py +29 -68
- mistralai/fine_tuning.py +6 -3
- mistralai/jobs.py +49 -158
- mistralai/libraries.py +71 -178
- mistralai/mistral_agents.py +71 -180
- mistralai/mistral_jobs.py +41 -128
- mistralai/models/__init__.py +36 -3
- mistralai/models/apiendpoint.py +5 -0
- mistralai/models/embeddingrequest.py +5 -1
- mistralai/models/encodingformat.py +7 -0
- mistralai/models/httpvalidationerror.py +11 -6
- mistralai/models/mistralerror.py +26 -0
- mistralai/models/no_response_error.py +13 -0
- mistralai/models/responsevalidationerror.py +25 -0
- mistralai/models/sdkerror.py +30 -14
- mistralai/models/systemmessage.py +7 -3
- mistralai/models/systemmessagecontentchunks.py +21 -0
- mistralai/models_.py +71 -204
- mistralai/ocr.py +15 -36
- mistralai/sdk.py +15 -2
- mistralai/transcriptions.py +17 -56
- mistralai/utils/__init__.py +18 -5
- mistralai/utils/eventstreaming.py +10 -0
- mistralai/utils/serializers.py +3 -2
- mistralai/utils/unmarshal_json_response.py +24 -0
- {mistralai-1.9.9.dist-info → mistralai-1.9.11.dist-info}/METADATA +61 -30
- {mistralai-1.9.9.dist-info → mistralai-1.9.11.dist-info}/RECORD +42 -36
- {mistralai-1.9.9.dist-info → mistralai-1.9.11.dist-info}/WHEEL +1 -1
- {mistralai-1.9.9.dist-info → mistralai-1.9.11.dist-info/licenses}/LICENSE +0 -0
mistralai/chat.py
CHANGED
|
@@ -5,6 +5,7 @@ from mistralai import models, utils
|
|
|
5
5
|
from mistralai._hooks import HookContext
|
|
6
6
|
from mistralai.types import OptionalNullable, UNSET
|
|
7
7
|
from mistralai.utils import eventstreaming, get_security_from_env
|
|
8
|
+
from mistralai.utils.unmarshal_json_response import unmarshal_json_response
|
|
8
9
|
from typing import Any, List, Mapping, Optional, Union
|
|
9
10
|
|
|
10
11
|
# region imports
|
|
@@ -236,31 +237,20 @@ class Chat(BaseSDK):
|
|
|
236
237
|
|
|
237
238
|
response_data: Any = None
|
|
238
239
|
if utils.match_response(http_res, "200", "application/json"):
|
|
239
|
-
return
|
|
240
|
+
return unmarshal_json_response(models.ChatCompletionResponse, http_res)
|
|
240
241
|
if utils.match_response(http_res, "422", "application/json"):
|
|
241
|
-
response_data =
|
|
242
|
-
|
|
242
|
+
response_data = unmarshal_json_response(
|
|
243
|
+
models.HTTPValidationErrorData, http_res
|
|
243
244
|
)
|
|
244
|
-
raise models.HTTPValidationError(
|
|
245
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
245
246
|
if utils.match_response(http_res, "4XX", "*"):
|
|
246
247
|
http_res_text = utils.stream_to_text(http_res)
|
|
247
|
-
raise models.SDKError(
|
|
248
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
249
|
-
)
|
|
248
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
250
249
|
if utils.match_response(http_res, "5XX", "*"):
|
|
251
250
|
http_res_text = utils.stream_to_text(http_res)
|
|
252
|
-
raise models.SDKError(
|
|
253
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
254
|
-
)
|
|
251
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
255
252
|
|
|
256
|
-
|
|
257
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
258
|
-
raise models.SDKError(
|
|
259
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
260
|
-
http_res.status_code,
|
|
261
|
-
http_res_text,
|
|
262
|
-
http_res,
|
|
263
|
-
)
|
|
253
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
264
254
|
|
|
265
255
|
async def complete_async(
|
|
266
256
|
self,
|
|
@@ -405,31 +395,20 @@ class Chat(BaseSDK):
|
|
|
405
395
|
|
|
406
396
|
response_data: Any = None
|
|
407
397
|
if utils.match_response(http_res, "200", "application/json"):
|
|
408
|
-
return
|
|
398
|
+
return unmarshal_json_response(models.ChatCompletionResponse, http_res)
|
|
409
399
|
if utils.match_response(http_res, "422", "application/json"):
|
|
410
|
-
response_data =
|
|
411
|
-
|
|
400
|
+
response_data = unmarshal_json_response(
|
|
401
|
+
models.HTTPValidationErrorData, http_res
|
|
412
402
|
)
|
|
413
|
-
raise models.HTTPValidationError(
|
|
403
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
414
404
|
if utils.match_response(http_res, "4XX", "*"):
|
|
415
405
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
416
|
-
raise models.SDKError(
|
|
417
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
418
|
-
)
|
|
406
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
419
407
|
if utils.match_response(http_res, "5XX", "*"):
|
|
420
408
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
421
|
-
raise models.SDKError(
|
|
422
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
423
|
-
)
|
|
409
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
424
410
|
|
|
425
|
-
|
|
426
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
427
|
-
raise models.SDKError(
|
|
428
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
429
|
-
http_res.status_code,
|
|
430
|
-
http_res_text,
|
|
431
|
-
http_res,
|
|
432
|
-
)
|
|
411
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
433
412
|
|
|
434
413
|
def stream(
|
|
435
414
|
self,
|
|
@@ -591,32 +570,23 @@ class Chat(BaseSDK):
|
|
|
591
570
|
http_res,
|
|
592
571
|
lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
|
|
593
572
|
sentinel="[DONE]",
|
|
573
|
+
client_ref=self,
|
|
594
574
|
)
|
|
595
575
|
if utils.match_response(http_res, "422", "application/json"):
|
|
596
576
|
http_res_text = utils.stream_to_text(http_res)
|
|
597
|
-
response_data =
|
|
598
|
-
|
|
577
|
+
response_data = unmarshal_json_response(
|
|
578
|
+
models.HTTPValidationErrorData, http_res, http_res_text
|
|
599
579
|
)
|
|
600
|
-
raise models.HTTPValidationError(
|
|
580
|
+
raise models.HTTPValidationError(response_data, http_res, http_res_text)
|
|
601
581
|
if utils.match_response(http_res, "4XX", "*"):
|
|
602
582
|
http_res_text = utils.stream_to_text(http_res)
|
|
603
|
-
raise models.SDKError(
|
|
604
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
605
|
-
)
|
|
583
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
606
584
|
if utils.match_response(http_res, "5XX", "*"):
|
|
607
585
|
http_res_text = utils.stream_to_text(http_res)
|
|
608
|
-
raise models.SDKError(
|
|
609
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
610
|
-
)
|
|
586
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
611
587
|
|
|
612
|
-
content_type = http_res.headers.get("Content-Type")
|
|
613
588
|
http_res_text = utils.stream_to_text(http_res)
|
|
614
|
-
raise models.SDKError(
|
|
615
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
616
|
-
http_res.status_code,
|
|
617
|
-
http_res_text,
|
|
618
|
-
http_res,
|
|
619
|
-
)
|
|
589
|
+
raise models.SDKError("Unexpected response received", http_res, http_res_text)
|
|
620
590
|
|
|
621
591
|
async def stream_async(
|
|
622
592
|
self,
|
|
@@ -778,29 +748,20 @@ class Chat(BaseSDK):
|
|
|
778
748
|
http_res,
|
|
779
749
|
lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
|
|
780
750
|
sentinel="[DONE]",
|
|
751
|
+
client_ref=self,
|
|
781
752
|
)
|
|
782
753
|
if utils.match_response(http_res, "422", "application/json"):
|
|
783
754
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
784
|
-
response_data =
|
|
785
|
-
|
|
755
|
+
response_data = unmarshal_json_response(
|
|
756
|
+
models.HTTPValidationErrorData, http_res, http_res_text
|
|
786
757
|
)
|
|
787
|
-
raise models.HTTPValidationError(
|
|
758
|
+
raise models.HTTPValidationError(response_data, http_res, http_res_text)
|
|
788
759
|
if utils.match_response(http_res, "4XX", "*"):
|
|
789
760
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
790
|
-
raise models.SDKError(
|
|
791
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
792
|
-
)
|
|
761
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
793
762
|
if utils.match_response(http_res, "5XX", "*"):
|
|
794
763
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
795
|
-
raise models.SDKError(
|
|
796
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
797
|
-
)
|
|
764
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
798
765
|
|
|
799
|
-
content_type = http_res.headers.get("Content-Type")
|
|
800
766
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
801
|
-
raise models.SDKError(
|
|
802
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
803
|
-
http_res.status_code,
|
|
804
|
-
http_res_text,
|
|
805
|
-
http_res,
|
|
806
|
-
)
|
|
767
|
+
raise models.SDKError("Unexpected response received", http_res, http_res_text)
|
mistralai/classifiers.py
CHANGED
|
@@ -5,6 +5,7 @@ from mistralai import models, utils
|
|
|
5
5
|
from mistralai._hooks import HookContext
|
|
6
6
|
from mistralai.types import OptionalNullable, UNSET
|
|
7
7
|
from mistralai.utils import get_security_from_env
|
|
8
|
+
from mistralai.utils.unmarshal_json_response import unmarshal_json_response
|
|
8
9
|
from typing import Any, Mapping, Optional, Union
|
|
9
10
|
|
|
10
11
|
|
|
@@ -92,31 +93,20 @@ class Classifiers(BaseSDK):
|
|
|
92
93
|
|
|
93
94
|
response_data: Any = None
|
|
94
95
|
if utils.match_response(http_res, "200", "application/json"):
|
|
95
|
-
return
|
|
96
|
+
return unmarshal_json_response(models.ModerationResponse, http_res)
|
|
96
97
|
if utils.match_response(http_res, "422", "application/json"):
|
|
97
|
-
response_data =
|
|
98
|
-
|
|
98
|
+
response_data = unmarshal_json_response(
|
|
99
|
+
models.HTTPValidationErrorData, http_res
|
|
99
100
|
)
|
|
100
|
-
raise models.HTTPValidationError(
|
|
101
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
101
102
|
if utils.match_response(http_res, "4XX", "*"):
|
|
102
103
|
http_res_text = utils.stream_to_text(http_res)
|
|
103
|
-
raise models.SDKError(
|
|
104
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
105
|
-
)
|
|
104
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
106
105
|
if utils.match_response(http_res, "5XX", "*"):
|
|
107
106
|
http_res_text = utils.stream_to_text(http_res)
|
|
108
|
-
raise models.SDKError(
|
|
109
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
110
|
-
)
|
|
107
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
111
108
|
|
|
112
|
-
|
|
113
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
114
|
-
raise models.SDKError(
|
|
115
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
116
|
-
http_res.status_code,
|
|
117
|
-
http_res_text,
|
|
118
|
-
http_res,
|
|
119
|
-
)
|
|
109
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
120
110
|
|
|
121
111
|
async def moderate_async(
|
|
122
112
|
self,
|
|
@@ -199,31 +189,20 @@ class Classifiers(BaseSDK):
|
|
|
199
189
|
|
|
200
190
|
response_data: Any = None
|
|
201
191
|
if utils.match_response(http_res, "200", "application/json"):
|
|
202
|
-
return
|
|
192
|
+
return unmarshal_json_response(models.ModerationResponse, http_res)
|
|
203
193
|
if utils.match_response(http_res, "422", "application/json"):
|
|
204
|
-
response_data =
|
|
205
|
-
|
|
194
|
+
response_data = unmarshal_json_response(
|
|
195
|
+
models.HTTPValidationErrorData, http_res
|
|
206
196
|
)
|
|
207
|
-
raise models.HTTPValidationError(
|
|
197
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
208
198
|
if utils.match_response(http_res, "4XX", "*"):
|
|
209
199
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
210
|
-
raise models.SDKError(
|
|
211
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
212
|
-
)
|
|
200
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
213
201
|
if utils.match_response(http_res, "5XX", "*"):
|
|
214
202
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
215
|
-
raise models.SDKError(
|
|
216
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
217
|
-
)
|
|
203
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
218
204
|
|
|
219
|
-
|
|
220
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
221
|
-
raise models.SDKError(
|
|
222
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
223
|
-
http_res.status_code,
|
|
224
|
-
http_res_text,
|
|
225
|
-
http_res,
|
|
226
|
-
)
|
|
205
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
227
206
|
|
|
228
207
|
def moderate_chat(
|
|
229
208
|
self,
|
|
@@ -306,31 +285,20 @@ class Classifiers(BaseSDK):
|
|
|
306
285
|
|
|
307
286
|
response_data: Any = None
|
|
308
287
|
if utils.match_response(http_res, "200", "application/json"):
|
|
309
|
-
return
|
|
288
|
+
return unmarshal_json_response(models.ModerationResponse, http_res)
|
|
310
289
|
if utils.match_response(http_res, "422", "application/json"):
|
|
311
|
-
response_data =
|
|
312
|
-
|
|
290
|
+
response_data = unmarshal_json_response(
|
|
291
|
+
models.HTTPValidationErrorData, http_res
|
|
313
292
|
)
|
|
314
|
-
raise models.HTTPValidationError(
|
|
293
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
315
294
|
if utils.match_response(http_res, "4XX", "*"):
|
|
316
295
|
http_res_text = utils.stream_to_text(http_res)
|
|
317
|
-
raise models.SDKError(
|
|
318
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
319
|
-
)
|
|
296
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
320
297
|
if utils.match_response(http_res, "5XX", "*"):
|
|
321
298
|
http_res_text = utils.stream_to_text(http_res)
|
|
322
|
-
raise models.SDKError(
|
|
323
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
324
|
-
)
|
|
299
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
325
300
|
|
|
326
|
-
|
|
327
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
328
|
-
raise models.SDKError(
|
|
329
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
330
|
-
http_res.status_code,
|
|
331
|
-
http_res_text,
|
|
332
|
-
http_res,
|
|
333
|
-
)
|
|
301
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
334
302
|
|
|
335
303
|
async def moderate_chat_async(
|
|
336
304
|
self,
|
|
@@ -413,31 +381,20 @@ class Classifiers(BaseSDK):
|
|
|
413
381
|
|
|
414
382
|
response_data: Any = None
|
|
415
383
|
if utils.match_response(http_res, "200", "application/json"):
|
|
416
|
-
return
|
|
384
|
+
return unmarshal_json_response(models.ModerationResponse, http_res)
|
|
417
385
|
if utils.match_response(http_res, "422", "application/json"):
|
|
418
|
-
response_data =
|
|
419
|
-
|
|
386
|
+
response_data = unmarshal_json_response(
|
|
387
|
+
models.HTTPValidationErrorData, http_res
|
|
420
388
|
)
|
|
421
|
-
raise models.HTTPValidationError(
|
|
389
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
422
390
|
if utils.match_response(http_res, "4XX", "*"):
|
|
423
391
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
424
|
-
raise models.SDKError(
|
|
425
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
426
|
-
)
|
|
392
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
427
393
|
if utils.match_response(http_res, "5XX", "*"):
|
|
428
394
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
429
|
-
raise models.SDKError(
|
|
430
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
431
|
-
)
|
|
395
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
432
396
|
|
|
433
|
-
|
|
434
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
435
|
-
raise models.SDKError(
|
|
436
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
437
|
-
http_res.status_code,
|
|
438
|
-
http_res_text,
|
|
439
|
-
http_res,
|
|
440
|
-
)
|
|
397
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
441
398
|
|
|
442
399
|
def classify(
|
|
443
400
|
self,
|
|
@@ -520,31 +477,20 @@ class Classifiers(BaseSDK):
|
|
|
520
477
|
|
|
521
478
|
response_data: Any = None
|
|
522
479
|
if utils.match_response(http_res, "200", "application/json"):
|
|
523
|
-
return
|
|
480
|
+
return unmarshal_json_response(models.ClassificationResponse, http_res)
|
|
524
481
|
if utils.match_response(http_res, "422", "application/json"):
|
|
525
|
-
response_data =
|
|
526
|
-
|
|
482
|
+
response_data = unmarshal_json_response(
|
|
483
|
+
models.HTTPValidationErrorData, http_res
|
|
527
484
|
)
|
|
528
|
-
raise models.HTTPValidationError(
|
|
485
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
529
486
|
if utils.match_response(http_res, "4XX", "*"):
|
|
530
487
|
http_res_text = utils.stream_to_text(http_res)
|
|
531
|
-
raise models.SDKError(
|
|
532
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
533
|
-
)
|
|
488
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
534
489
|
if utils.match_response(http_res, "5XX", "*"):
|
|
535
490
|
http_res_text = utils.stream_to_text(http_res)
|
|
536
|
-
raise models.SDKError(
|
|
537
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
538
|
-
)
|
|
491
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
539
492
|
|
|
540
|
-
|
|
541
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
542
|
-
raise models.SDKError(
|
|
543
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
544
|
-
http_res.status_code,
|
|
545
|
-
http_res_text,
|
|
546
|
-
http_res,
|
|
547
|
-
)
|
|
493
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
548
494
|
|
|
549
495
|
async def classify_async(
|
|
550
496
|
self,
|
|
@@ -627,31 +573,20 @@ class Classifiers(BaseSDK):
|
|
|
627
573
|
|
|
628
574
|
response_data: Any = None
|
|
629
575
|
if utils.match_response(http_res, "200", "application/json"):
|
|
630
|
-
return
|
|
576
|
+
return unmarshal_json_response(models.ClassificationResponse, http_res)
|
|
631
577
|
if utils.match_response(http_res, "422", "application/json"):
|
|
632
|
-
response_data =
|
|
633
|
-
|
|
578
|
+
response_data = unmarshal_json_response(
|
|
579
|
+
models.HTTPValidationErrorData, http_res
|
|
634
580
|
)
|
|
635
|
-
raise models.HTTPValidationError(
|
|
581
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
636
582
|
if utils.match_response(http_res, "4XX", "*"):
|
|
637
583
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
638
|
-
raise models.SDKError(
|
|
639
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
640
|
-
)
|
|
584
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
641
585
|
if utils.match_response(http_res, "5XX", "*"):
|
|
642
586
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
643
|
-
raise models.SDKError(
|
|
644
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
645
|
-
)
|
|
587
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
646
588
|
|
|
647
|
-
|
|
648
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
649
|
-
raise models.SDKError(
|
|
650
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
651
|
-
http_res.status_code,
|
|
652
|
-
http_res_text,
|
|
653
|
-
http_res,
|
|
654
|
-
)
|
|
589
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
655
590
|
|
|
656
591
|
def classify_chat(
|
|
657
592
|
self,
|
|
@@ -731,31 +666,20 @@ class Classifiers(BaseSDK):
|
|
|
731
666
|
|
|
732
667
|
response_data: Any = None
|
|
733
668
|
if utils.match_response(http_res, "200", "application/json"):
|
|
734
|
-
return
|
|
669
|
+
return unmarshal_json_response(models.ClassificationResponse, http_res)
|
|
735
670
|
if utils.match_response(http_res, "422", "application/json"):
|
|
736
|
-
response_data =
|
|
737
|
-
|
|
671
|
+
response_data = unmarshal_json_response(
|
|
672
|
+
models.HTTPValidationErrorData, http_res
|
|
738
673
|
)
|
|
739
|
-
raise models.HTTPValidationError(
|
|
674
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
740
675
|
if utils.match_response(http_res, "4XX", "*"):
|
|
741
676
|
http_res_text = utils.stream_to_text(http_res)
|
|
742
|
-
raise models.SDKError(
|
|
743
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
744
|
-
)
|
|
677
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
745
678
|
if utils.match_response(http_res, "5XX", "*"):
|
|
746
679
|
http_res_text = utils.stream_to_text(http_res)
|
|
747
|
-
raise models.SDKError(
|
|
748
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
749
|
-
)
|
|
680
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
750
681
|
|
|
751
|
-
|
|
752
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
753
|
-
raise models.SDKError(
|
|
754
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
755
|
-
http_res.status_code,
|
|
756
|
-
http_res_text,
|
|
757
|
-
http_res,
|
|
758
|
-
)
|
|
682
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
759
683
|
|
|
760
684
|
async def classify_chat_async(
|
|
761
685
|
self,
|
|
@@ -835,28 +759,17 @@ class Classifiers(BaseSDK):
|
|
|
835
759
|
|
|
836
760
|
response_data: Any = None
|
|
837
761
|
if utils.match_response(http_res, "200", "application/json"):
|
|
838
|
-
return
|
|
762
|
+
return unmarshal_json_response(models.ClassificationResponse, http_res)
|
|
839
763
|
if utils.match_response(http_res, "422", "application/json"):
|
|
840
|
-
response_data =
|
|
841
|
-
|
|
764
|
+
response_data = unmarshal_json_response(
|
|
765
|
+
models.HTTPValidationErrorData, http_res
|
|
842
766
|
)
|
|
843
|
-
raise models.HTTPValidationError(
|
|
767
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
844
768
|
if utils.match_response(http_res, "4XX", "*"):
|
|
845
769
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
846
|
-
raise models.SDKError(
|
|
847
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
848
|
-
)
|
|
770
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
849
771
|
if utils.match_response(http_res, "5XX", "*"):
|
|
850
772
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
851
|
-
raise models.SDKError(
|
|
852
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
853
|
-
)
|
|
773
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
854
774
|
|
|
855
|
-
|
|
856
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
857
|
-
raise models.SDKError(
|
|
858
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
859
|
-
http_res.status_code,
|
|
860
|
-
http_res_text,
|
|
861
|
-
http_res,
|
|
862
|
-
)
|
|
775
|
+
raise models.SDKError("Unexpected response received", http_res)
|