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.
Files changed (42) hide show
  1. mistralai/_version.py +3 -3
  2. mistralai/accesses.py +43 -108
  3. mistralai/agents.py +29 -68
  4. mistralai/audio.py +8 -3
  5. mistralai/basesdk.py +15 -5
  6. mistralai/batch.py +6 -3
  7. mistralai/beta.py +10 -5
  8. mistralai/chat.py +29 -68
  9. mistralai/classifiers.py +57 -144
  10. mistralai/conversations.py +143 -352
  11. mistralai/documents.py +137 -356
  12. mistralai/embeddings.py +21 -36
  13. mistralai/files.py +47 -176
  14. mistralai/fim.py +29 -68
  15. mistralai/fine_tuning.py +6 -3
  16. mistralai/jobs.py +49 -158
  17. mistralai/libraries.py +71 -178
  18. mistralai/mistral_agents.py +71 -180
  19. mistralai/mistral_jobs.py +41 -128
  20. mistralai/models/__init__.py +36 -3
  21. mistralai/models/apiendpoint.py +5 -0
  22. mistralai/models/embeddingrequest.py +5 -1
  23. mistralai/models/encodingformat.py +7 -0
  24. mistralai/models/httpvalidationerror.py +11 -6
  25. mistralai/models/mistralerror.py +26 -0
  26. mistralai/models/no_response_error.py +13 -0
  27. mistralai/models/responsevalidationerror.py +25 -0
  28. mistralai/models/sdkerror.py +30 -14
  29. mistralai/models/systemmessage.py +7 -3
  30. mistralai/models/systemmessagecontentchunks.py +21 -0
  31. mistralai/models_.py +71 -204
  32. mistralai/ocr.py +15 -36
  33. mistralai/sdk.py +15 -2
  34. mistralai/transcriptions.py +17 -56
  35. mistralai/utils/__init__.py +18 -5
  36. mistralai/utils/eventstreaming.py +10 -0
  37. mistralai/utils/serializers.py +3 -2
  38. mistralai/utils/unmarshal_json_response.py +24 -0
  39. {mistralai-1.9.9.dist-info → mistralai-1.9.11.dist-info}/METADATA +61 -30
  40. {mistralai-1.9.9.dist-info → mistralai-1.9.11.dist-info}/RECORD +42 -36
  41. {mistralai-1.9.9.dist-info → mistralai-1.9.11.dist-info}/WHEEL +1 -1
  42. {mistralai-1.9.9.dist-info → mistralai-1.9.11.dist-info/licenses}/LICENSE +0 -0
mistralai/documents.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
 
@@ -100,31 +101,20 @@ class Documents(BaseSDK):
100
101
 
101
102
  response_data: Any = None
102
103
  if utils.match_response(http_res, "200", "application/json"):
103
- return utils.unmarshal_json(http_res.text, models.ListDocumentOut)
104
+ return unmarshal_json_response(models.ListDocumentOut, http_res)
104
105
  if utils.match_response(http_res, "422", "application/json"):
105
- response_data = utils.unmarshal_json(
106
- http_res.text, models.HTTPValidationErrorData
106
+ response_data = unmarshal_json_response(
107
+ models.HTTPValidationErrorData, http_res
107
108
  )
108
- raise models.HTTPValidationError(data=response_data)
109
+ raise models.HTTPValidationError(response_data, http_res)
109
110
  if utils.match_response(http_res, "4XX", "*"):
110
111
  http_res_text = utils.stream_to_text(http_res)
111
- raise models.SDKError(
112
- "API error occurred", http_res.status_code, http_res_text, http_res
113
- )
112
+ raise models.SDKError("API error occurred", http_res, http_res_text)
114
113
  if utils.match_response(http_res, "5XX", "*"):
115
114
  http_res_text = utils.stream_to_text(http_res)
116
- raise models.SDKError(
117
- "API error occurred", http_res.status_code, http_res_text, http_res
118
- )
115
+ raise models.SDKError("API error occurred", http_res, http_res_text)
119
116
 
120
- content_type = http_res.headers.get("Content-Type")
121
- http_res_text = utils.stream_to_text(http_res)
122
- raise models.SDKError(
123
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
124
- http_res.status_code,
125
- http_res_text,
126
- http_res,
127
- )
117
+ raise models.SDKError("Unexpected response received", http_res)
128
118
 
129
119
  async def list_async(
130
120
  self,
@@ -215,31 +205,20 @@ class Documents(BaseSDK):
215
205
 
216
206
  response_data: Any = None
217
207
  if utils.match_response(http_res, "200", "application/json"):
218
- return utils.unmarshal_json(http_res.text, models.ListDocumentOut)
208
+ return unmarshal_json_response(models.ListDocumentOut, http_res)
219
209
  if utils.match_response(http_res, "422", "application/json"):
220
- response_data = utils.unmarshal_json(
221
- http_res.text, models.HTTPValidationErrorData
210
+ response_data = unmarshal_json_response(
211
+ models.HTTPValidationErrorData, http_res
222
212
  )
223
- raise models.HTTPValidationError(data=response_data)
213
+ raise models.HTTPValidationError(response_data, http_res)
224
214
  if utils.match_response(http_res, "4XX", "*"):
225
215
  http_res_text = await utils.stream_to_text_async(http_res)
226
- raise models.SDKError(
227
- "API error occurred", http_res.status_code, http_res_text, http_res
228
- )
216
+ raise models.SDKError("API error occurred", http_res, http_res_text)
229
217
  if utils.match_response(http_res, "5XX", "*"):
230
218
  http_res_text = await utils.stream_to_text_async(http_res)
231
- raise models.SDKError(
232
- "API error occurred", http_res.status_code, http_res_text, http_res
233
- )
219
+ raise models.SDKError("API error occurred", http_res, http_res_text)
234
220
 
235
- content_type = http_res.headers.get("Content-Type")
236
- http_res_text = await utils.stream_to_text_async(http_res)
237
- raise models.SDKError(
238
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
239
- http_res.status_code,
240
- http_res_text,
241
- http_res,
242
- )
221
+ raise models.SDKError("Unexpected response received", http_res)
243
222
 
244
223
  def upload(
245
224
  self,
@@ -327,31 +306,20 @@ class Documents(BaseSDK):
327
306
 
328
307
  response_data: Any = None
329
308
  if utils.match_response(http_res, ["200", "201"], "application/json"):
330
- return utils.unmarshal_json(http_res.text, models.DocumentOut)
309
+ return unmarshal_json_response(models.DocumentOut, http_res)
331
310
  if utils.match_response(http_res, "422", "application/json"):
332
- response_data = utils.unmarshal_json(
333
- http_res.text, models.HTTPValidationErrorData
311
+ response_data = unmarshal_json_response(
312
+ models.HTTPValidationErrorData, http_res
334
313
  )
335
- raise models.HTTPValidationError(data=response_data)
314
+ raise models.HTTPValidationError(response_data, http_res)
336
315
  if utils.match_response(http_res, "4XX", "*"):
337
316
  http_res_text = utils.stream_to_text(http_res)
338
- raise models.SDKError(
339
- "API error occurred", http_res.status_code, http_res_text, http_res
340
- )
317
+ raise models.SDKError("API error occurred", http_res, http_res_text)
341
318
  if utils.match_response(http_res, "5XX", "*"):
342
319
  http_res_text = utils.stream_to_text(http_res)
343
- raise models.SDKError(
344
- "API error occurred", http_res.status_code, http_res_text, http_res
345
- )
320
+ raise models.SDKError("API error occurred", http_res, http_res_text)
346
321
 
347
- content_type = http_res.headers.get("Content-Type")
348
- http_res_text = utils.stream_to_text(http_res)
349
- raise models.SDKError(
350
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
351
- http_res.status_code,
352
- http_res_text,
353
- http_res,
354
- )
322
+ raise models.SDKError("Unexpected response received", http_res)
355
323
 
356
324
  async def upload_async(
357
325
  self,
@@ -439,31 +407,20 @@ class Documents(BaseSDK):
439
407
 
440
408
  response_data: Any = None
441
409
  if utils.match_response(http_res, ["200", "201"], "application/json"):
442
- return utils.unmarshal_json(http_res.text, models.DocumentOut)
410
+ return unmarshal_json_response(models.DocumentOut, http_res)
443
411
  if utils.match_response(http_res, "422", "application/json"):
444
- response_data = utils.unmarshal_json(
445
- http_res.text, models.HTTPValidationErrorData
412
+ response_data = unmarshal_json_response(
413
+ models.HTTPValidationErrorData, http_res
446
414
  )
447
- raise models.HTTPValidationError(data=response_data)
415
+ raise models.HTTPValidationError(response_data, http_res)
448
416
  if utils.match_response(http_res, "4XX", "*"):
449
417
  http_res_text = await utils.stream_to_text_async(http_res)
450
- raise models.SDKError(
451
- "API error occurred", http_res.status_code, http_res_text, http_res
452
- )
418
+ raise models.SDKError("API error occurred", http_res, http_res_text)
453
419
  if utils.match_response(http_res, "5XX", "*"):
454
420
  http_res_text = await utils.stream_to_text_async(http_res)
455
- raise models.SDKError(
456
- "API error occurred", http_res.status_code, http_res_text, http_res
457
- )
421
+ raise models.SDKError("API error occurred", http_res, http_res_text)
458
422
 
459
- content_type = http_res.headers.get("Content-Type")
460
- http_res_text = await utils.stream_to_text_async(http_res)
461
- raise models.SDKError(
462
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
463
- http_res.status_code,
464
- http_res_text,
465
- http_res,
466
- )
423
+ raise models.SDKError("Unexpected response received", http_res)
467
424
 
468
425
  def get(
469
426
  self,
@@ -542,31 +499,20 @@ class Documents(BaseSDK):
542
499
 
543
500
  response_data: Any = None
544
501
  if utils.match_response(http_res, "200", "application/json"):
545
- return utils.unmarshal_json(http_res.text, models.DocumentOut)
502
+ return unmarshal_json_response(models.DocumentOut, http_res)
546
503
  if utils.match_response(http_res, "422", "application/json"):
547
- response_data = utils.unmarshal_json(
548
- http_res.text, models.HTTPValidationErrorData
504
+ response_data = unmarshal_json_response(
505
+ models.HTTPValidationErrorData, http_res
549
506
  )
550
- raise models.HTTPValidationError(data=response_data)
507
+ raise models.HTTPValidationError(response_data, http_res)
551
508
  if utils.match_response(http_res, "4XX", "*"):
552
509
  http_res_text = utils.stream_to_text(http_res)
553
- raise models.SDKError(
554
- "API error occurred", http_res.status_code, http_res_text, http_res
555
- )
510
+ raise models.SDKError("API error occurred", http_res, http_res_text)
556
511
  if utils.match_response(http_res, "5XX", "*"):
557
512
  http_res_text = utils.stream_to_text(http_res)
558
- raise models.SDKError(
559
- "API error occurred", http_res.status_code, http_res_text, http_res
560
- )
513
+ raise models.SDKError("API error occurred", http_res, http_res_text)
561
514
 
562
- content_type = http_res.headers.get("Content-Type")
563
- http_res_text = utils.stream_to_text(http_res)
564
- raise models.SDKError(
565
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
566
- http_res.status_code,
567
- http_res_text,
568
- http_res,
569
- )
515
+ raise models.SDKError("Unexpected response received", http_res)
570
516
 
571
517
  async def get_async(
572
518
  self,
@@ -645,31 +591,20 @@ class Documents(BaseSDK):
645
591
 
646
592
  response_data: Any = None
647
593
  if utils.match_response(http_res, "200", "application/json"):
648
- return utils.unmarshal_json(http_res.text, models.DocumentOut)
594
+ return unmarshal_json_response(models.DocumentOut, http_res)
649
595
  if utils.match_response(http_res, "422", "application/json"):
650
- response_data = utils.unmarshal_json(
651
- http_res.text, models.HTTPValidationErrorData
596
+ response_data = unmarshal_json_response(
597
+ models.HTTPValidationErrorData, http_res
652
598
  )
653
- raise models.HTTPValidationError(data=response_data)
599
+ raise models.HTTPValidationError(response_data, http_res)
654
600
  if utils.match_response(http_res, "4XX", "*"):
655
601
  http_res_text = await utils.stream_to_text_async(http_res)
656
- raise models.SDKError(
657
- "API error occurred", http_res.status_code, http_res_text, http_res
658
- )
602
+ raise models.SDKError("API error occurred", http_res, http_res_text)
659
603
  if utils.match_response(http_res, "5XX", "*"):
660
604
  http_res_text = await utils.stream_to_text_async(http_res)
661
- raise models.SDKError(
662
- "API error occurred", http_res.status_code, http_res_text, http_res
663
- )
605
+ raise models.SDKError("API error occurred", http_res, http_res_text)
664
606
 
665
- content_type = http_res.headers.get("Content-Type")
666
- http_res_text = await utils.stream_to_text_async(http_res)
667
- raise models.SDKError(
668
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
669
- http_res.status_code,
670
- http_res_text,
671
- http_res,
672
- )
607
+ raise models.SDKError("Unexpected response received", http_res)
673
608
 
674
609
  def update(
675
610
  self,
@@ -760,31 +695,20 @@ class Documents(BaseSDK):
760
695
 
761
696
  response_data: Any = None
762
697
  if utils.match_response(http_res, "200", "application/json"):
763
- return utils.unmarshal_json(http_res.text, models.DocumentOut)
698
+ return unmarshal_json_response(models.DocumentOut, http_res)
764
699
  if utils.match_response(http_res, "422", "application/json"):
765
- response_data = utils.unmarshal_json(
766
- http_res.text, models.HTTPValidationErrorData
700
+ response_data = unmarshal_json_response(
701
+ models.HTTPValidationErrorData, http_res
767
702
  )
768
- raise models.HTTPValidationError(data=response_data)
703
+ raise models.HTTPValidationError(response_data, http_res)
769
704
  if utils.match_response(http_res, "4XX", "*"):
770
705
  http_res_text = utils.stream_to_text(http_res)
771
- raise models.SDKError(
772
- "API error occurred", http_res.status_code, http_res_text, http_res
773
- )
706
+ raise models.SDKError("API error occurred", http_res, http_res_text)
774
707
  if utils.match_response(http_res, "5XX", "*"):
775
708
  http_res_text = utils.stream_to_text(http_res)
776
- raise models.SDKError(
777
- "API error occurred", http_res.status_code, http_res_text, http_res
778
- )
709
+ raise models.SDKError("API error occurred", http_res, http_res_text)
779
710
 
780
- content_type = http_res.headers.get("Content-Type")
781
- http_res_text = utils.stream_to_text(http_res)
782
- raise models.SDKError(
783
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
784
- http_res.status_code,
785
- http_res_text,
786
- http_res,
787
- )
711
+ raise models.SDKError("Unexpected response received", http_res)
788
712
 
789
713
  async def update_async(
790
714
  self,
@@ -875,31 +799,20 @@ class Documents(BaseSDK):
875
799
 
876
800
  response_data: Any = None
877
801
  if utils.match_response(http_res, "200", "application/json"):
878
- return utils.unmarshal_json(http_res.text, models.DocumentOut)
802
+ return unmarshal_json_response(models.DocumentOut, http_res)
879
803
  if utils.match_response(http_res, "422", "application/json"):
880
- response_data = utils.unmarshal_json(
881
- http_res.text, models.HTTPValidationErrorData
804
+ response_data = unmarshal_json_response(
805
+ models.HTTPValidationErrorData, http_res
882
806
  )
883
- raise models.HTTPValidationError(data=response_data)
807
+ raise models.HTTPValidationError(response_data, http_res)
884
808
  if utils.match_response(http_res, "4XX", "*"):
885
809
  http_res_text = await utils.stream_to_text_async(http_res)
886
- raise models.SDKError(
887
- "API error occurred", http_res.status_code, http_res_text, http_res
888
- )
810
+ raise models.SDKError("API error occurred", http_res, http_res_text)
889
811
  if utils.match_response(http_res, "5XX", "*"):
890
812
  http_res_text = await utils.stream_to_text_async(http_res)
891
- raise models.SDKError(
892
- "API error occurred", http_res.status_code, http_res_text, http_res
893
- )
813
+ raise models.SDKError("API error occurred", http_res, http_res_text)
894
814
 
895
- content_type = http_res.headers.get("Content-Type")
896
- http_res_text = await utils.stream_to_text_async(http_res)
897
- raise models.SDKError(
898
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
899
- http_res.status_code,
900
- http_res_text,
901
- http_res,
902
- )
815
+ raise models.SDKError("Unexpected response received", http_res)
903
816
 
904
817
  def delete(
905
818
  self,
@@ -980,29 +893,18 @@ class Documents(BaseSDK):
980
893
  if utils.match_response(http_res, "204", "*"):
981
894
  return
982
895
  if utils.match_response(http_res, "422", "application/json"):
983
- response_data = utils.unmarshal_json(
984
- http_res.text, models.HTTPValidationErrorData
896
+ response_data = unmarshal_json_response(
897
+ models.HTTPValidationErrorData, http_res
985
898
  )
986
- raise models.HTTPValidationError(data=response_data)
899
+ raise models.HTTPValidationError(response_data, http_res)
987
900
  if utils.match_response(http_res, "4XX", "*"):
988
901
  http_res_text = utils.stream_to_text(http_res)
989
- raise models.SDKError(
990
- "API error occurred", http_res.status_code, http_res_text, http_res
991
- )
902
+ raise models.SDKError("API error occurred", http_res, http_res_text)
992
903
  if utils.match_response(http_res, "5XX", "*"):
993
904
  http_res_text = utils.stream_to_text(http_res)
994
- raise models.SDKError(
995
- "API error occurred", http_res.status_code, http_res_text, http_res
996
- )
905
+ raise models.SDKError("API error occurred", http_res, http_res_text)
997
906
 
998
- content_type = http_res.headers.get("Content-Type")
999
- http_res_text = utils.stream_to_text(http_res)
1000
- raise models.SDKError(
1001
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1002
- http_res.status_code,
1003
- http_res_text,
1004
- http_res,
1005
- )
907
+ raise models.SDKError("Unexpected response received", http_res)
1006
908
 
1007
909
  async def delete_async(
1008
910
  self,
@@ -1083,29 +985,18 @@ class Documents(BaseSDK):
1083
985
  if utils.match_response(http_res, "204", "*"):
1084
986
  return
1085
987
  if utils.match_response(http_res, "422", "application/json"):
1086
- response_data = utils.unmarshal_json(
1087
- http_res.text, models.HTTPValidationErrorData
988
+ response_data = unmarshal_json_response(
989
+ models.HTTPValidationErrorData, http_res
1088
990
  )
1089
- raise models.HTTPValidationError(data=response_data)
991
+ raise models.HTTPValidationError(response_data, http_res)
1090
992
  if utils.match_response(http_res, "4XX", "*"):
1091
993
  http_res_text = await utils.stream_to_text_async(http_res)
1092
- raise models.SDKError(
1093
- "API error occurred", http_res.status_code, http_res_text, http_res
1094
- )
994
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1095
995
  if utils.match_response(http_res, "5XX", "*"):
1096
996
  http_res_text = await utils.stream_to_text_async(http_res)
1097
- raise models.SDKError(
1098
- "API error occurred", http_res.status_code, http_res_text, http_res
1099
- )
997
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1100
998
 
1101
- content_type = http_res.headers.get("Content-Type")
1102
- http_res_text = await utils.stream_to_text_async(http_res)
1103
- raise models.SDKError(
1104
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1105
- http_res.status_code,
1106
- http_res_text,
1107
- http_res,
1108
- )
999
+ raise models.SDKError("Unexpected response received", http_res)
1109
1000
 
1110
1001
  def text_content(
1111
1002
  self,
@@ -1184,31 +1075,20 @@ class Documents(BaseSDK):
1184
1075
 
1185
1076
  response_data: Any = None
1186
1077
  if utils.match_response(http_res, "200", "application/json"):
1187
- return utils.unmarshal_json(http_res.text, models.DocumentTextContent)
1078
+ return unmarshal_json_response(models.DocumentTextContent, http_res)
1188
1079
  if utils.match_response(http_res, "422", "application/json"):
1189
- response_data = utils.unmarshal_json(
1190
- http_res.text, models.HTTPValidationErrorData
1080
+ response_data = unmarshal_json_response(
1081
+ models.HTTPValidationErrorData, http_res
1191
1082
  )
1192
- raise models.HTTPValidationError(data=response_data)
1083
+ raise models.HTTPValidationError(response_data, http_res)
1193
1084
  if utils.match_response(http_res, "4XX", "*"):
1194
1085
  http_res_text = utils.stream_to_text(http_res)
1195
- raise models.SDKError(
1196
- "API error occurred", http_res.status_code, http_res_text, http_res
1197
- )
1086
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1198
1087
  if utils.match_response(http_res, "5XX", "*"):
1199
1088
  http_res_text = utils.stream_to_text(http_res)
1200
- raise models.SDKError(
1201
- "API error occurred", http_res.status_code, http_res_text, http_res
1202
- )
1089
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1203
1090
 
1204
- content_type = http_res.headers.get("Content-Type")
1205
- http_res_text = utils.stream_to_text(http_res)
1206
- raise models.SDKError(
1207
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1208
- http_res.status_code,
1209
- http_res_text,
1210
- http_res,
1211
- )
1091
+ raise models.SDKError("Unexpected response received", http_res)
1212
1092
 
1213
1093
  async def text_content_async(
1214
1094
  self,
@@ -1287,31 +1167,20 @@ class Documents(BaseSDK):
1287
1167
 
1288
1168
  response_data: Any = None
1289
1169
  if utils.match_response(http_res, "200", "application/json"):
1290
- return utils.unmarshal_json(http_res.text, models.DocumentTextContent)
1170
+ return unmarshal_json_response(models.DocumentTextContent, http_res)
1291
1171
  if utils.match_response(http_res, "422", "application/json"):
1292
- response_data = utils.unmarshal_json(
1293
- http_res.text, models.HTTPValidationErrorData
1172
+ response_data = unmarshal_json_response(
1173
+ models.HTTPValidationErrorData, http_res
1294
1174
  )
1295
- raise models.HTTPValidationError(data=response_data)
1175
+ raise models.HTTPValidationError(response_data, http_res)
1296
1176
  if utils.match_response(http_res, "4XX", "*"):
1297
1177
  http_res_text = await utils.stream_to_text_async(http_res)
1298
- raise models.SDKError(
1299
- "API error occurred", http_res.status_code, http_res_text, http_res
1300
- )
1178
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1301
1179
  if utils.match_response(http_res, "5XX", "*"):
1302
1180
  http_res_text = await utils.stream_to_text_async(http_res)
1303
- raise models.SDKError(
1304
- "API error occurred", http_res.status_code, http_res_text, http_res
1305
- )
1181
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1306
1182
 
1307
- content_type = http_res.headers.get("Content-Type")
1308
- http_res_text = await utils.stream_to_text_async(http_res)
1309
- raise models.SDKError(
1310
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1311
- http_res.status_code,
1312
- http_res_text,
1313
- http_res,
1314
- )
1183
+ raise models.SDKError("Unexpected response received", http_res)
1315
1184
 
1316
1185
  def status(
1317
1186
  self,
@@ -1390,31 +1259,20 @@ class Documents(BaseSDK):
1390
1259
 
1391
1260
  response_data: Any = None
1392
1261
  if utils.match_response(http_res, "200", "application/json"):
1393
- return utils.unmarshal_json(http_res.text, models.ProcessingStatusOut)
1262
+ return unmarshal_json_response(models.ProcessingStatusOut, http_res)
1394
1263
  if utils.match_response(http_res, "422", "application/json"):
1395
- response_data = utils.unmarshal_json(
1396
- http_res.text, models.HTTPValidationErrorData
1264
+ response_data = unmarshal_json_response(
1265
+ models.HTTPValidationErrorData, http_res
1397
1266
  )
1398
- raise models.HTTPValidationError(data=response_data)
1267
+ raise models.HTTPValidationError(response_data, http_res)
1399
1268
  if utils.match_response(http_res, "4XX", "*"):
1400
1269
  http_res_text = utils.stream_to_text(http_res)
1401
- raise models.SDKError(
1402
- "API error occurred", http_res.status_code, http_res_text, http_res
1403
- )
1270
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1404
1271
  if utils.match_response(http_res, "5XX", "*"):
1405
1272
  http_res_text = utils.stream_to_text(http_res)
1406
- raise models.SDKError(
1407
- "API error occurred", http_res.status_code, http_res_text, http_res
1408
- )
1273
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1409
1274
 
1410
- content_type = http_res.headers.get("Content-Type")
1411
- http_res_text = utils.stream_to_text(http_res)
1412
- raise models.SDKError(
1413
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1414
- http_res.status_code,
1415
- http_res_text,
1416
- http_res,
1417
- )
1275
+ raise models.SDKError("Unexpected response received", http_res)
1418
1276
 
1419
1277
  async def status_async(
1420
1278
  self,
@@ -1493,31 +1351,20 @@ class Documents(BaseSDK):
1493
1351
 
1494
1352
  response_data: Any = None
1495
1353
  if utils.match_response(http_res, "200", "application/json"):
1496
- return utils.unmarshal_json(http_res.text, models.ProcessingStatusOut)
1354
+ return unmarshal_json_response(models.ProcessingStatusOut, http_res)
1497
1355
  if utils.match_response(http_res, "422", "application/json"):
1498
- response_data = utils.unmarshal_json(
1499
- http_res.text, models.HTTPValidationErrorData
1356
+ response_data = unmarshal_json_response(
1357
+ models.HTTPValidationErrorData, http_res
1500
1358
  )
1501
- raise models.HTTPValidationError(data=response_data)
1359
+ raise models.HTTPValidationError(response_data, http_res)
1502
1360
  if utils.match_response(http_res, "4XX", "*"):
1503
1361
  http_res_text = await utils.stream_to_text_async(http_res)
1504
- raise models.SDKError(
1505
- "API error occurred", http_res.status_code, http_res_text, http_res
1506
- )
1362
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1507
1363
  if utils.match_response(http_res, "5XX", "*"):
1508
1364
  http_res_text = await utils.stream_to_text_async(http_res)
1509
- raise models.SDKError(
1510
- "API error occurred", http_res.status_code, http_res_text, http_res
1511
- )
1365
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1512
1366
 
1513
- content_type = http_res.headers.get("Content-Type")
1514
- http_res_text = await utils.stream_to_text_async(http_res)
1515
- raise models.SDKError(
1516
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1517
- http_res.status_code,
1518
- http_res_text,
1519
- http_res,
1520
- )
1367
+ raise models.SDKError("Unexpected response received", http_res)
1521
1368
 
1522
1369
  def get_signed_url(
1523
1370
  self,
@@ -1596,31 +1443,20 @@ class Documents(BaseSDK):
1596
1443
 
1597
1444
  response_data: Any = None
1598
1445
  if utils.match_response(http_res, "200", "application/json"):
1599
- return utils.unmarshal_json(http_res.text, str)
1446
+ return unmarshal_json_response(str, http_res)
1600
1447
  if utils.match_response(http_res, "422", "application/json"):
1601
- response_data = utils.unmarshal_json(
1602
- http_res.text, models.HTTPValidationErrorData
1448
+ response_data = unmarshal_json_response(
1449
+ models.HTTPValidationErrorData, http_res
1603
1450
  )
1604
- raise models.HTTPValidationError(data=response_data)
1451
+ raise models.HTTPValidationError(response_data, http_res)
1605
1452
  if utils.match_response(http_res, "4XX", "*"):
1606
1453
  http_res_text = utils.stream_to_text(http_res)
1607
- raise models.SDKError(
1608
- "API error occurred", http_res.status_code, http_res_text, http_res
1609
- )
1454
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1610
1455
  if utils.match_response(http_res, "5XX", "*"):
1611
1456
  http_res_text = utils.stream_to_text(http_res)
1612
- raise models.SDKError(
1613
- "API error occurred", http_res.status_code, http_res_text, http_res
1614
- )
1457
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1615
1458
 
1616
- content_type = http_res.headers.get("Content-Type")
1617
- http_res_text = utils.stream_to_text(http_res)
1618
- raise models.SDKError(
1619
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1620
- http_res.status_code,
1621
- http_res_text,
1622
- http_res,
1623
- )
1459
+ raise models.SDKError("Unexpected response received", http_res)
1624
1460
 
1625
1461
  async def get_signed_url_async(
1626
1462
  self,
@@ -1699,31 +1535,20 @@ class Documents(BaseSDK):
1699
1535
 
1700
1536
  response_data: Any = None
1701
1537
  if utils.match_response(http_res, "200", "application/json"):
1702
- return utils.unmarshal_json(http_res.text, str)
1538
+ return unmarshal_json_response(str, http_res)
1703
1539
  if utils.match_response(http_res, "422", "application/json"):
1704
- response_data = utils.unmarshal_json(
1705
- http_res.text, models.HTTPValidationErrorData
1540
+ response_data = unmarshal_json_response(
1541
+ models.HTTPValidationErrorData, http_res
1706
1542
  )
1707
- raise models.HTTPValidationError(data=response_data)
1543
+ raise models.HTTPValidationError(response_data, http_res)
1708
1544
  if utils.match_response(http_res, "4XX", "*"):
1709
1545
  http_res_text = await utils.stream_to_text_async(http_res)
1710
- raise models.SDKError(
1711
- "API error occurred", http_res.status_code, http_res_text, http_res
1712
- )
1546
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1713
1547
  if utils.match_response(http_res, "5XX", "*"):
1714
1548
  http_res_text = await utils.stream_to_text_async(http_res)
1715
- raise models.SDKError(
1716
- "API error occurred", http_res.status_code, http_res_text, http_res
1717
- )
1549
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1718
1550
 
1719
- content_type = http_res.headers.get("Content-Type")
1720
- http_res_text = await utils.stream_to_text_async(http_res)
1721
- raise models.SDKError(
1722
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1723
- http_res.status_code,
1724
- http_res_text,
1725
- http_res,
1726
- )
1551
+ raise models.SDKError("Unexpected response received", http_res)
1727
1552
 
1728
1553
  def extracted_text_signed_url(
1729
1554
  self,
@@ -1802,31 +1627,20 @@ class Documents(BaseSDK):
1802
1627
 
1803
1628
  response_data: Any = None
1804
1629
  if utils.match_response(http_res, "200", "application/json"):
1805
- return utils.unmarshal_json(http_res.text, str)
1630
+ return unmarshal_json_response(str, http_res)
1806
1631
  if utils.match_response(http_res, "422", "application/json"):
1807
- response_data = utils.unmarshal_json(
1808
- http_res.text, models.HTTPValidationErrorData
1632
+ response_data = unmarshal_json_response(
1633
+ models.HTTPValidationErrorData, http_res
1809
1634
  )
1810
- raise models.HTTPValidationError(data=response_data)
1635
+ raise models.HTTPValidationError(response_data, http_res)
1811
1636
  if utils.match_response(http_res, "4XX", "*"):
1812
1637
  http_res_text = utils.stream_to_text(http_res)
1813
- raise models.SDKError(
1814
- "API error occurred", http_res.status_code, http_res_text, http_res
1815
- )
1638
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1816
1639
  if utils.match_response(http_res, "5XX", "*"):
1817
1640
  http_res_text = utils.stream_to_text(http_res)
1818
- raise models.SDKError(
1819
- "API error occurred", http_res.status_code, http_res_text, http_res
1820
- )
1641
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1821
1642
 
1822
- content_type = http_res.headers.get("Content-Type")
1823
- http_res_text = utils.stream_to_text(http_res)
1824
- raise models.SDKError(
1825
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1826
- http_res.status_code,
1827
- http_res_text,
1828
- http_res,
1829
- )
1643
+ raise models.SDKError("Unexpected response received", http_res)
1830
1644
 
1831
1645
  async def extracted_text_signed_url_async(
1832
1646
  self,
@@ -1905,31 +1719,20 @@ class Documents(BaseSDK):
1905
1719
 
1906
1720
  response_data: Any = None
1907
1721
  if utils.match_response(http_res, "200", "application/json"):
1908
- return utils.unmarshal_json(http_res.text, str)
1722
+ return unmarshal_json_response(str, http_res)
1909
1723
  if utils.match_response(http_res, "422", "application/json"):
1910
- response_data = utils.unmarshal_json(
1911
- http_res.text, models.HTTPValidationErrorData
1724
+ response_data = unmarshal_json_response(
1725
+ models.HTTPValidationErrorData, http_res
1912
1726
  )
1913
- raise models.HTTPValidationError(data=response_data)
1727
+ raise models.HTTPValidationError(response_data, http_res)
1914
1728
  if utils.match_response(http_res, "4XX", "*"):
1915
1729
  http_res_text = await utils.stream_to_text_async(http_res)
1916
- raise models.SDKError(
1917
- "API error occurred", http_res.status_code, http_res_text, http_res
1918
- )
1730
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1919
1731
  if utils.match_response(http_res, "5XX", "*"):
1920
1732
  http_res_text = await utils.stream_to_text_async(http_res)
1921
- raise models.SDKError(
1922
- "API error occurred", http_res.status_code, http_res_text, http_res
1923
- )
1733
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1924
1734
 
1925
- content_type = http_res.headers.get("Content-Type")
1926
- http_res_text = await utils.stream_to_text_async(http_res)
1927
- raise models.SDKError(
1928
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1929
- http_res.status_code,
1930
- http_res_text,
1931
- http_res,
1932
- )
1735
+ raise models.SDKError("Unexpected response received", http_res)
1933
1736
 
1934
1737
  def reprocess(
1935
1738
  self,
@@ -2010,29 +1813,18 @@ class Documents(BaseSDK):
2010
1813
  if utils.match_response(http_res, "204", "*"):
2011
1814
  return
2012
1815
  if utils.match_response(http_res, "422", "application/json"):
2013
- response_data = utils.unmarshal_json(
2014
- http_res.text, models.HTTPValidationErrorData
1816
+ response_data = unmarshal_json_response(
1817
+ models.HTTPValidationErrorData, http_res
2015
1818
  )
2016
- raise models.HTTPValidationError(data=response_data)
1819
+ raise models.HTTPValidationError(response_data, http_res)
2017
1820
  if utils.match_response(http_res, "4XX", "*"):
2018
1821
  http_res_text = utils.stream_to_text(http_res)
2019
- raise models.SDKError(
2020
- "API error occurred", http_res.status_code, http_res_text, http_res
2021
- )
1822
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2022
1823
  if utils.match_response(http_res, "5XX", "*"):
2023
1824
  http_res_text = utils.stream_to_text(http_res)
2024
- raise models.SDKError(
2025
- "API error occurred", http_res.status_code, http_res_text, http_res
2026
- )
1825
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2027
1826
 
2028
- content_type = http_res.headers.get("Content-Type")
2029
- http_res_text = utils.stream_to_text(http_res)
2030
- raise models.SDKError(
2031
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2032
- http_res.status_code,
2033
- http_res_text,
2034
- http_res,
2035
- )
1827
+ raise models.SDKError("Unexpected response received", http_res)
2036
1828
 
2037
1829
  async def reprocess_async(
2038
1830
  self,
@@ -2113,26 +1905,15 @@ class Documents(BaseSDK):
2113
1905
  if utils.match_response(http_res, "204", "*"):
2114
1906
  return
2115
1907
  if utils.match_response(http_res, "422", "application/json"):
2116
- response_data = utils.unmarshal_json(
2117
- http_res.text, models.HTTPValidationErrorData
1908
+ response_data = unmarshal_json_response(
1909
+ models.HTTPValidationErrorData, http_res
2118
1910
  )
2119
- raise models.HTTPValidationError(data=response_data)
1911
+ raise models.HTTPValidationError(response_data, http_res)
2120
1912
  if utils.match_response(http_res, "4XX", "*"):
2121
1913
  http_res_text = await utils.stream_to_text_async(http_res)
2122
- raise models.SDKError(
2123
- "API error occurred", http_res.status_code, http_res_text, http_res
2124
- )
1914
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2125
1915
  if utils.match_response(http_res, "5XX", "*"):
2126
1916
  http_res_text = await utils.stream_to_text_async(http_res)
2127
- raise models.SDKError(
2128
- "API error occurred", http_res.status_code, http_res_text, http_res
2129
- )
1917
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2130
1918
 
2131
- content_type = http_res.headers.get("Content-Type")
2132
- http_res_text = await utils.stream_to_text_async(http_res)
2133
- raise models.SDKError(
2134
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2135
- http_res.status_code,
2136
- http_res_text,
2137
- http_res,
2138
- )
1919
+ raise models.SDKError("Unexpected response received", http_res)