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/mistral_agents.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, List, Mapping, Optional, Union
|
|
9
10
|
|
|
10
11
|
|
|
@@ -117,31 +118,20 @@ class MistralAgents(BaseSDK):
|
|
|
117
118
|
|
|
118
119
|
response_data: Any = None
|
|
119
120
|
if utils.match_response(http_res, "200", "application/json"):
|
|
120
|
-
return
|
|
121
|
+
return unmarshal_json_response(models.Agent, http_res)
|
|
121
122
|
if utils.match_response(http_res, "422", "application/json"):
|
|
122
|
-
response_data =
|
|
123
|
-
|
|
123
|
+
response_data = unmarshal_json_response(
|
|
124
|
+
models.HTTPValidationErrorData, http_res
|
|
124
125
|
)
|
|
125
|
-
raise models.HTTPValidationError(
|
|
126
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
126
127
|
if utils.match_response(http_res, "4XX", "*"):
|
|
127
128
|
http_res_text = utils.stream_to_text(http_res)
|
|
128
|
-
raise models.SDKError(
|
|
129
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
130
|
-
)
|
|
129
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
131
130
|
if utils.match_response(http_res, "5XX", "*"):
|
|
132
131
|
http_res_text = utils.stream_to_text(http_res)
|
|
133
|
-
raise models.SDKError(
|
|
134
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
135
|
-
)
|
|
132
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
136
133
|
|
|
137
|
-
|
|
138
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
139
|
-
raise models.SDKError(
|
|
140
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
141
|
-
http_res.status_code,
|
|
142
|
-
http_res_text,
|
|
143
|
-
http_res,
|
|
144
|
-
)
|
|
134
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
145
135
|
|
|
146
136
|
async def create_async(
|
|
147
137
|
self,
|
|
@@ -249,31 +239,20 @@ class MistralAgents(BaseSDK):
|
|
|
249
239
|
|
|
250
240
|
response_data: Any = None
|
|
251
241
|
if utils.match_response(http_res, "200", "application/json"):
|
|
252
|
-
return
|
|
242
|
+
return unmarshal_json_response(models.Agent, http_res)
|
|
253
243
|
if utils.match_response(http_res, "422", "application/json"):
|
|
254
|
-
response_data =
|
|
255
|
-
|
|
244
|
+
response_data = unmarshal_json_response(
|
|
245
|
+
models.HTTPValidationErrorData, http_res
|
|
256
246
|
)
|
|
257
|
-
raise models.HTTPValidationError(
|
|
247
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
258
248
|
if utils.match_response(http_res, "4XX", "*"):
|
|
259
249
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
260
|
-
raise models.SDKError(
|
|
261
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
262
|
-
)
|
|
250
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
263
251
|
if utils.match_response(http_res, "5XX", "*"):
|
|
264
252
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
265
|
-
raise models.SDKError(
|
|
266
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
267
|
-
)
|
|
253
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
268
254
|
|
|
269
|
-
|
|
270
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
271
|
-
raise models.SDKError(
|
|
272
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
273
|
-
http_res.status_code,
|
|
274
|
-
http_res_text,
|
|
275
|
-
http_res,
|
|
276
|
-
)
|
|
255
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
277
256
|
|
|
278
257
|
def list(
|
|
279
258
|
self,
|
|
@@ -352,31 +331,20 @@ class MistralAgents(BaseSDK):
|
|
|
352
331
|
|
|
353
332
|
response_data: Any = None
|
|
354
333
|
if utils.match_response(http_res, "200", "application/json"):
|
|
355
|
-
return
|
|
334
|
+
return unmarshal_json_response(List[models.Agent], http_res)
|
|
356
335
|
if utils.match_response(http_res, "422", "application/json"):
|
|
357
|
-
response_data =
|
|
358
|
-
|
|
336
|
+
response_data = unmarshal_json_response(
|
|
337
|
+
models.HTTPValidationErrorData, http_res
|
|
359
338
|
)
|
|
360
|
-
raise models.HTTPValidationError(
|
|
339
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
361
340
|
if utils.match_response(http_res, "4XX", "*"):
|
|
362
341
|
http_res_text = utils.stream_to_text(http_res)
|
|
363
|
-
raise models.SDKError(
|
|
364
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
365
|
-
)
|
|
342
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
366
343
|
if utils.match_response(http_res, "5XX", "*"):
|
|
367
344
|
http_res_text = utils.stream_to_text(http_res)
|
|
368
|
-
raise models.SDKError(
|
|
369
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
370
|
-
)
|
|
345
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
371
346
|
|
|
372
|
-
|
|
373
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
374
|
-
raise models.SDKError(
|
|
375
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
376
|
-
http_res.status_code,
|
|
377
|
-
http_res_text,
|
|
378
|
-
http_res,
|
|
379
|
-
)
|
|
347
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
380
348
|
|
|
381
349
|
async def list_async(
|
|
382
350
|
self,
|
|
@@ -455,31 +423,20 @@ class MistralAgents(BaseSDK):
|
|
|
455
423
|
|
|
456
424
|
response_data: Any = None
|
|
457
425
|
if utils.match_response(http_res, "200", "application/json"):
|
|
458
|
-
return
|
|
426
|
+
return unmarshal_json_response(List[models.Agent], http_res)
|
|
459
427
|
if utils.match_response(http_res, "422", "application/json"):
|
|
460
|
-
response_data =
|
|
461
|
-
|
|
428
|
+
response_data = unmarshal_json_response(
|
|
429
|
+
models.HTTPValidationErrorData, http_res
|
|
462
430
|
)
|
|
463
|
-
raise models.HTTPValidationError(
|
|
431
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
464
432
|
if utils.match_response(http_res, "4XX", "*"):
|
|
465
433
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
466
|
-
raise models.SDKError(
|
|
467
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
468
|
-
)
|
|
434
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
469
435
|
if utils.match_response(http_res, "5XX", "*"):
|
|
470
436
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
471
|
-
raise models.SDKError(
|
|
472
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
473
|
-
)
|
|
437
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
474
438
|
|
|
475
|
-
|
|
476
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
477
|
-
raise models.SDKError(
|
|
478
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
479
|
-
http_res.status_code,
|
|
480
|
-
http_res_text,
|
|
481
|
-
http_res,
|
|
482
|
-
)
|
|
439
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
483
440
|
|
|
484
441
|
def get(
|
|
485
442
|
self,
|
|
@@ -555,31 +512,20 @@ class MistralAgents(BaseSDK):
|
|
|
555
512
|
|
|
556
513
|
response_data: Any = None
|
|
557
514
|
if utils.match_response(http_res, "200", "application/json"):
|
|
558
|
-
return
|
|
515
|
+
return unmarshal_json_response(models.Agent, http_res)
|
|
559
516
|
if utils.match_response(http_res, "422", "application/json"):
|
|
560
|
-
response_data =
|
|
561
|
-
|
|
517
|
+
response_data = unmarshal_json_response(
|
|
518
|
+
models.HTTPValidationErrorData, http_res
|
|
562
519
|
)
|
|
563
|
-
raise models.HTTPValidationError(
|
|
520
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
564
521
|
if utils.match_response(http_res, "4XX", "*"):
|
|
565
522
|
http_res_text = utils.stream_to_text(http_res)
|
|
566
|
-
raise models.SDKError(
|
|
567
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
568
|
-
)
|
|
523
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
569
524
|
if utils.match_response(http_res, "5XX", "*"):
|
|
570
525
|
http_res_text = utils.stream_to_text(http_res)
|
|
571
|
-
raise models.SDKError(
|
|
572
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
573
|
-
)
|
|
526
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
574
527
|
|
|
575
|
-
|
|
576
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
577
|
-
raise models.SDKError(
|
|
578
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
579
|
-
http_res.status_code,
|
|
580
|
-
http_res_text,
|
|
581
|
-
http_res,
|
|
582
|
-
)
|
|
528
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
583
529
|
|
|
584
530
|
async def get_async(
|
|
585
531
|
self,
|
|
@@ -655,31 +601,20 @@ class MistralAgents(BaseSDK):
|
|
|
655
601
|
|
|
656
602
|
response_data: Any = None
|
|
657
603
|
if utils.match_response(http_res, "200", "application/json"):
|
|
658
|
-
return
|
|
604
|
+
return unmarshal_json_response(models.Agent, http_res)
|
|
659
605
|
if utils.match_response(http_res, "422", "application/json"):
|
|
660
|
-
response_data =
|
|
661
|
-
|
|
606
|
+
response_data = unmarshal_json_response(
|
|
607
|
+
models.HTTPValidationErrorData, http_res
|
|
662
608
|
)
|
|
663
|
-
raise models.HTTPValidationError(
|
|
609
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
664
610
|
if utils.match_response(http_res, "4XX", "*"):
|
|
665
611
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
666
|
-
raise models.SDKError(
|
|
667
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
668
|
-
)
|
|
612
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
669
613
|
if utils.match_response(http_res, "5XX", "*"):
|
|
670
614
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
671
|
-
raise models.SDKError(
|
|
672
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
673
|
-
)
|
|
615
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
674
616
|
|
|
675
|
-
|
|
676
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
677
|
-
raise models.SDKError(
|
|
678
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
679
|
-
http_res.status_code,
|
|
680
|
-
http_res_text,
|
|
681
|
-
http_res,
|
|
682
|
-
)
|
|
617
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
683
618
|
|
|
684
619
|
def update(
|
|
685
620
|
self,
|
|
@@ -796,31 +731,20 @@ class MistralAgents(BaseSDK):
|
|
|
796
731
|
|
|
797
732
|
response_data: Any = None
|
|
798
733
|
if utils.match_response(http_res, "200", "application/json"):
|
|
799
|
-
return
|
|
734
|
+
return unmarshal_json_response(models.Agent, http_res)
|
|
800
735
|
if utils.match_response(http_res, "422", "application/json"):
|
|
801
|
-
response_data =
|
|
802
|
-
|
|
736
|
+
response_data = unmarshal_json_response(
|
|
737
|
+
models.HTTPValidationErrorData, http_res
|
|
803
738
|
)
|
|
804
|
-
raise models.HTTPValidationError(
|
|
739
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
805
740
|
if utils.match_response(http_res, "4XX", "*"):
|
|
806
741
|
http_res_text = utils.stream_to_text(http_res)
|
|
807
|
-
raise models.SDKError(
|
|
808
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
809
|
-
)
|
|
742
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
810
743
|
if utils.match_response(http_res, "5XX", "*"):
|
|
811
744
|
http_res_text = utils.stream_to_text(http_res)
|
|
812
|
-
raise models.SDKError(
|
|
813
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
814
|
-
)
|
|
745
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
815
746
|
|
|
816
|
-
|
|
817
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
818
|
-
raise models.SDKError(
|
|
819
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
820
|
-
http_res.status_code,
|
|
821
|
-
http_res_text,
|
|
822
|
-
http_res,
|
|
823
|
-
)
|
|
747
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
824
748
|
|
|
825
749
|
async def update_async(
|
|
826
750
|
self,
|
|
@@ -937,31 +861,20 @@ class MistralAgents(BaseSDK):
|
|
|
937
861
|
|
|
938
862
|
response_data: Any = None
|
|
939
863
|
if utils.match_response(http_res, "200", "application/json"):
|
|
940
|
-
return
|
|
864
|
+
return unmarshal_json_response(models.Agent, http_res)
|
|
941
865
|
if utils.match_response(http_res, "422", "application/json"):
|
|
942
|
-
response_data =
|
|
943
|
-
|
|
866
|
+
response_data = unmarshal_json_response(
|
|
867
|
+
models.HTTPValidationErrorData, http_res
|
|
944
868
|
)
|
|
945
|
-
raise models.HTTPValidationError(
|
|
869
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
946
870
|
if utils.match_response(http_res, "4XX", "*"):
|
|
947
871
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
948
|
-
raise models.SDKError(
|
|
949
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
950
|
-
)
|
|
872
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
951
873
|
if utils.match_response(http_res, "5XX", "*"):
|
|
952
874
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
953
|
-
raise models.SDKError(
|
|
954
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
955
|
-
)
|
|
875
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
956
876
|
|
|
957
|
-
|
|
958
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
959
|
-
raise models.SDKError(
|
|
960
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
961
|
-
http_res.status_code,
|
|
962
|
-
http_res_text,
|
|
963
|
-
http_res,
|
|
964
|
-
)
|
|
877
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
965
878
|
|
|
966
879
|
def update_version(
|
|
967
880
|
self,
|
|
@@ -1040,31 +953,20 @@ class MistralAgents(BaseSDK):
|
|
|
1040
953
|
|
|
1041
954
|
response_data: Any = None
|
|
1042
955
|
if utils.match_response(http_res, "200", "application/json"):
|
|
1043
|
-
return
|
|
956
|
+
return unmarshal_json_response(models.Agent, http_res)
|
|
1044
957
|
if utils.match_response(http_res, "422", "application/json"):
|
|
1045
|
-
response_data =
|
|
1046
|
-
|
|
958
|
+
response_data = unmarshal_json_response(
|
|
959
|
+
models.HTTPValidationErrorData, http_res
|
|
1047
960
|
)
|
|
1048
|
-
raise models.HTTPValidationError(
|
|
961
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
1049
962
|
if utils.match_response(http_res, "4XX", "*"):
|
|
1050
963
|
http_res_text = utils.stream_to_text(http_res)
|
|
1051
|
-
raise models.SDKError(
|
|
1052
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1053
|
-
)
|
|
964
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
1054
965
|
if utils.match_response(http_res, "5XX", "*"):
|
|
1055
966
|
http_res_text = utils.stream_to_text(http_res)
|
|
1056
|
-
raise models.SDKError(
|
|
1057
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1058
|
-
)
|
|
967
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
1059
968
|
|
|
1060
|
-
|
|
1061
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
1062
|
-
raise models.SDKError(
|
|
1063
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1064
|
-
http_res.status_code,
|
|
1065
|
-
http_res_text,
|
|
1066
|
-
http_res,
|
|
1067
|
-
)
|
|
969
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
1068
970
|
|
|
1069
971
|
async def update_version_async(
|
|
1070
972
|
self,
|
|
@@ -1143,28 +1045,17 @@ class MistralAgents(BaseSDK):
|
|
|
1143
1045
|
|
|
1144
1046
|
response_data: Any = None
|
|
1145
1047
|
if utils.match_response(http_res, "200", "application/json"):
|
|
1146
|
-
return
|
|
1048
|
+
return unmarshal_json_response(models.Agent, http_res)
|
|
1147
1049
|
if utils.match_response(http_res, "422", "application/json"):
|
|
1148
|
-
response_data =
|
|
1149
|
-
|
|
1050
|
+
response_data = unmarshal_json_response(
|
|
1051
|
+
models.HTTPValidationErrorData, http_res
|
|
1150
1052
|
)
|
|
1151
|
-
raise models.HTTPValidationError(
|
|
1053
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
1152
1054
|
if utils.match_response(http_res, "4XX", "*"):
|
|
1153
1055
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1154
|
-
raise models.SDKError(
|
|
1155
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1156
|
-
)
|
|
1056
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
1157
1057
|
if utils.match_response(http_res, "5XX", "*"):
|
|
1158
1058
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1159
|
-
raise models.SDKError(
|
|
1160
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1161
|
-
)
|
|
1059
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
1162
1060
|
|
|
1163
|
-
|
|
1164
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1165
|
-
raise models.SDKError(
|
|
1166
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1167
|
-
http_res.status_code,
|
|
1168
|
-
http_res_text,
|
|
1169
|
-
http_res,
|
|
1170
|
-
)
|
|
1061
|
+
raise models.SDKError("Unexpected response received", http_res)
|
mistralai/mistral_jobs.py
CHANGED
|
@@ -6,6 +6,7 @@ from mistralai import models, utils
|
|
|
6
6
|
from mistralai._hooks import HookContext
|
|
7
7
|
from mistralai.types import OptionalNullable, UNSET
|
|
8
8
|
from mistralai.utils import get_security_from_env
|
|
9
|
+
from mistralai.utils.unmarshal_json_response import unmarshal_json_response
|
|
9
10
|
from typing import Any, Dict, List, Mapping, Optional
|
|
10
11
|
|
|
11
12
|
|
|
@@ -104,26 +105,15 @@ class MistralJobs(BaseSDK):
|
|
|
104
105
|
)
|
|
105
106
|
|
|
106
107
|
if utils.match_response(http_res, "200", "application/json"):
|
|
107
|
-
return
|
|
108
|
+
return unmarshal_json_response(models.BatchJobsOut, http_res)
|
|
108
109
|
if utils.match_response(http_res, "4XX", "*"):
|
|
109
110
|
http_res_text = utils.stream_to_text(http_res)
|
|
110
|
-
raise models.SDKError(
|
|
111
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
112
|
-
)
|
|
111
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
113
112
|
if utils.match_response(http_res, "5XX", "*"):
|
|
114
113
|
http_res_text = utils.stream_to_text(http_res)
|
|
115
|
-
raise models.SDKError(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
content_type = http_res.headers.get("Content-Type")
|
|
120
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
121
|
-
raise models.SDKError(
|
|
122
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
123
|
-
http_res.status_code,
|
|
124
|
-
http_res_text,
|
|
125
|
-
http_res,
|
|
126
|
-
)
|
|
114
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
115
|
+
|
|
116
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
127
117
|
|
|
128
118
|
async def list_async(
|
|
129
119
|
self,
|
|
@@ -219,26 +209,15 @@ class MistralJobs(BaseSDK):
|
|
|
219
209
|
)
|
|
220
210
|
|
|
221
211
|
if utils.match_response(http_res, "200", "application/json"):
|
|
222
|
-
return
|
|
212
|
+
return unmarshal_json_response(models.BatchJobsOut, http_res)
|
|
223
213
|
if utils.match_response(http_res, "4XX", "*"):
|
|
224
214
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
225
|
-
raise models.SDKError(
|
|
226
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
227
|
-
)
|
|
215
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
228
216
|
if utils.match_response(http_res, "5XX", "*"):
|
|
229
217
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
230
|
-
raise models.SDKError(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
content_type = http_res.headers.get("Content-Type")
|
|
235
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
236
|
-
raise models.SDKError(
|
|
237
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
238
|
-
http_res.status_code,
|
|
239
|
-
http_res_text,
|
|
240
|
-
http_res,
|
|
241
|
-
)
|
|
218
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
219
|
+
|
|
220
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
242
221
|
|
|
243
222
|
def create(
|
|
244
223
|
self,
|
|
@@ -331,26 +310,15 @@ class MistralJobs(BaseSDK):
|
|
|
331
310
|
)
|
|
332
311
|
|
|
333
312
|
if utils.match_response(http_res, "200", "application/json"):
|
|
334
|
-
return
|
|
313
|
+
return unmarshal_json_response(models.BatchJobOut, http_res)
|
|
335
314
|
if utils.match_response(http_res, "4XX", "*"):
|
|
336
315
|
http_res_text = utils.stream_to_text(http_res)
|
|
337
|
-
raise models.SDKError(
|
|
338
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
339
|
-
)
|
|
316
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
340
317
|
if utils.match_response(http_res, "5XX", "*"):
|
|
341
318
|
http_res_text = utils.stream_to_text(http_res)
|
|
342
|
-
raise models.SDKError(
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
content_type = http_res.headers.get("Content-Type")
|
|
347
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
348
|
-
raise models.SDKError(
|
|
349
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
350
|
-
http_res.status_code,
|
|
351
|
-
http_res_text,
|
|
352
|
-
http_res,
|
|
353
|
-
)
|
|
319
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
320
|
+
|
|
321
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
354
322
|
|
|
355
323
|
async def create_async(
|
|
356
324
|
self,
|
|
@@ -443,26 +411,15 @@ class MistralJobs(BaseSDK):
|
|
|
443
411
|
)
|
|
444
412
|
|
|
445
413
|
if utils.match_response(http_res, "200", "application/json"):
|
|
446
|
-
return
|
|
414
|
+
return unmarshal_json_response(models.BatchJobOut, http_res)
|
|
447
415
|
if utils.match_response(http_res, "4XX", "*"):
|
|
448
416
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
449
|
-
raise models.SDKError(
|
|
450
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
451
|
-
)
|
|
417
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
452
418
|
if utils.match_response(http_res, "5XX", "*"):
|
|
453
419
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
454
|
-
raise models.SDKError(
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
content_type = http_res.headers.get("Content-Type")
|
|
459
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
460
|
-
raise models.SDKError(
|
|
461
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
462
|
-
http_res.status_code,
|
|
463
|
-
http_res_text,
|
|
464
|
-
http_res,
|
|
465
|
-
)
|
|
420
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
421
|
+
|
|
422
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
466
423
|
|
|
467
424
|
def get(
|
|
468
425
|
self,
|
|
@@ -537,26 +494,15 @@ class MistralJobs(BaseSDK):
|
|
|
537
494
|
)
|
|
538
495
|
|
|
539
496
|
if utils.match_response(http_res, "200", "application/json"):
|
|
540
|
-
return
|
|
497
|
+
return unmarshal_json_response(models.BatchJobOut, http_res)
|
|
541
498
|
if utils.match_response(http_res, "4XX", "*"):
|
|
542
499
|
http_res_text = utils.stream_to_text(http_res)
|
|
543
|
-
raise models.SDKError(
|
|
544
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
545
|
-
)
|
|
500
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
546
501
|
if utils.match_response(http_res, "5XX", "*"):
|
|
547
502
|
http_res_text = utils.stream_to_text(http_res)
|
|
548
|
-
raise models.SDKError(
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
content_type = http_res.headers.get("Content-Type")
|
|
553
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
554
|
-
raise models.SDKError(
|
|
555
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
556
|
-
http_res.status_code,
|
|
557
|
-
http_res_text,
|
|
558
|
-
http_res,
|
|
559
|
-
)
|
|
503
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
504
|
+
|
|
505
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
560
506
|
|
|
561
507
|
async def get_async(
|
|
562
508
|
self,
|
|
@@ -631,26 +577,15 @@ class MistralJobs(BaseSDK):
|
|
|
631
577
|
)
|
|
632
578
|
|
|
633
579
|
if utils.match_response(http_res, "200", "application/json"):
|
|
634
|
-
return
|
|
580
|
+
return unmarshal_json_response(models.BatchJobOut, http_res)
|
|
635
581
|
if utils.match_response(http_res, "4XX", "*"):
|
|
636
582
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
637
|
-
raise models.SDKError(
|
|
638
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
639
|
-
)
|
|
583
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
640
584
|
if utils.match_response(http_res, "5XX", "*"):
|
|
641
585
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
642
|
-
raise models.SDKError(
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
content_type = http_res.headers.get("Content-Type")
|
|
647
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
648
|
-
raise models.SDKError(
|
|
649
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
650
|
-
http_res.status_code,
|
|
651
|
-
http_res_text,
|
|
652
|
-
http_res,
|
|
653
|
-
)
|
|
586
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
587
|
+
|
|
588
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
654
589
|
|
|
655
590
|
def cancel(
|
|
656
591
|
self,
|
|
@@ -725,26 +660,15 @@ class MistralJobs(BaseSDK):
|
|
|
725
660
|
)
|
|
726
661
|
|
|
727
662
|
if utils.match_response(http_res, "200", "application/json"):
|
|
728
|
-
return
|
|
663
|
+
return unmarshal_json_response(models.BatchJobOut, http_res)
|
|
729
664
|
if utils.match_response(http_res, "4XX", "*"):
|
|
730
665
|
http_res_text = utils.stream_to_text(http_res)
|
|
731
|
-
raise models.SDKError(
|
|
732
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
733
|
-
)
|
|
666
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
734
667
|
if utils.match_response(http_res, "5XX", "*"):
|
|
735
668
|
http_res_text = utils.stream_to_text(http_res)
|
|
736
|
-
raise models.SDKError(
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
content_type = http_res.headers.get("Content-Type")
|
|
741
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
742
|
-
raise models.SDKError(
|
|
743
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
744
|
-
http_res.status_code,
|
|
745
|
-
http_res_text,
|
|
746
|
-
http_res,
|
|
747
|
-
)
|
|
669
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
670
|
+
|
|
671
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
748
672
|
|
|
749
673
|
async def cancel_async(
|
|
750
674
|
self,
|
|
@@ -819,23 +743,12 @@ class MistralJobs(BaseSDK):
|
|
|
819
743
|
)
|
|
820
744
|
|
|
821
745
|
if utils.match_response(http_res, "200", "application/json"):
|
|
822
|
-
return
|
|
746
|
+
return unmarshal_json_response(models.BatchJobOut, http_res)
|
|
823
747
|
if utils.match_response(http_res, "4XX", "*"):
|
|
824
748
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
825
|
-
raise models.SDKError(
|
|
826
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
827
|
-
)
|
|
749
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
828
750
|
if utils.match_response(http_res, "5XX", "*"):
|
|
829
751
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
830
|
-
raise models.SDKError(
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
content_type = http_res.headers.get("Content-Type")
|
|
835
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
836
|
-
raise models.SDKError(
|
|
837
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
838
|
-
http_res.status_code,
|
|
839
|
-
http_res_text,
|
|
840
|
-
http_res,
|
|
841
|
-
)
|
|
752
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
753
|
+
|
|
754
|
+
raise models.SDKError("Unexpected response received", http_res)
|