mistralai 1.9.10__py3-none-any.whl → 1.10.0__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 (86) hide show
  1. mistralai/_hooks/registration.py +5 -0
  2. mistralai/_hooks/tracing.py +50 -0
  3. mistralai/_version.py +3 -3
  4. mistralai/accesses.py +51 -116
  5. mistralai/agents.py +58 -85
  6. mistralai/audio.py +8 -3
  7. mistralai/basesdk.py +15 -5
  8. mistralai/batch.py +6 -3
  9. mistralai/beta.py +10 -5
  10. mistralai/chat.py +70 -97
  11. mistralai/classifiers.py +57 -144
  12. mistralai/conversations.py +435 -412
  13. mistralai/documents.py +156 -359
  14. mistralai/embeddings.py +21 -42
  15. mistralai/extra/observability/__init__.py +15 -0
  16. mistralai/extra/observability/otel.py +393 -0
  17. mistralai/extra/run/tools.py +28 -16
  18. mistralai/files.py +53 -176
  19. mistralai/fim.py +46 -73
  20. mistralai/fine_tuning.py +6 -3
  21. mistralai/jobs.py +49 -158
  22. mistralai/libraries.py +71 -178
  23. mistralai/mistral_agents.py +298 -179
  24. mistralai/mistral_jobs.py +51 -138
  25. mistralai/models/__init__.py +94 -5
  26. mistralai/models/agent.py +15 -2
  27. mistralai/models/agentconversation.py +11 -3
  28. mistralai/models/agentcreationrequest.py +6 -2
  29. mistralai/models/agents_api_v1_agents_deleteop.py +16 -0
  30. mistralai/models/agents_api_v1_agents_getop.py +40 -3
  31. mistralai/models/agents_api_v1_agents_listop.py +72 -2
  32. mistralai/models/agents_api_v1_conversations_deleteop.py +18 -0
  33. mistralai/models/agents_api_v1_conversations_listop.py +39 -2
  34. mistralai/models/agentscompletionrequest.py +21 -6
  35. mistralai/models/agentscompletionstreamrequest.py +21 -6
  36. mistralai/models/agentupdaterequest.py +18 -2
  37. mistralai/models/audiotranscriptionrequest.py +2 -0
  38. mistralai/models/batchjobin.py +10 -0
  39. mistralai/models/chatcompletionrequest.py +22 -5
  40. mistralai/models/chatcompletionstreamrequest.py +22 -5
  41. mistralai/models/conversationrequest.py +15 -4
  42. mistralai/models/conversationrestartrequest.py +50 -2
  43. mistralai/models/conversationrestartstreamrequest.py +50 -2
  44. mistralai/models/conversationstreamrequest.py +15 -4
  45. mistralai/models/documentout.py +26 -10
  46. mistralai/models/documentupdatein.py +24 -3
  47. mistralai/models/embeddingrequest.py +8 -8
  48. mistralai/models/files_api_routes_list_filesop.py +7 -0
  49. mistralai/models/fimcompletionrequest.py +8 -9
  50. mistralai/models/fimcompletionstreamrequest.py +8 -9
  51. mistralai/models/httpvalidationerror.py +11 -6
  52. mistralai/models/libraries_documents_list_v1op.py +15 -2
  53. mistralai/models/libraryout.py +10 -7
  54. mistralai/models/listfilesout.py +35 -4
  55. mistralai/models/mistralerror.py +26 -0
  56. mistralai/models/modelcapabilities.py +13 -4
  57. mistralai/models/modelconversation.py +8 -2
  58. mistralai/models/no_response_error.py +13 -0
  59. mistralai/models/ocrpageobject.py +26 -5
  60. mistralai/models/ocrrequest.py +17 -1
  61. mistralai/models/ocrtableobject.py +31 -0
  62. mistralai/models/prediction.py +4 -0
  63. mistralai/models/requestsource.py +7 -0
  64. mistralai/models/responseformat.py +4 -2
  65. mistralai/models/responseformats.py +0 -1
  66. mistralai/models/responsevalidationerror.py +25 -0
  67. mistralai/models/sdkerror.py +30 -14
  68. mistralai/models/sharingdelete.py +36 -5
  69. mistralai/models/sharingin.py +36 -5
  70. mistralai/models/sharingout.py +3 -3
  71. mistralai/models/toolexecutiondeltaevent.py +13 -4
  72. mistralai/models/toolexecutiondoneevent.py +13 -4
  73. mistralai/models/toolexecutionentry.py +9 -4
  74. mistralai/models/toolexecutionstartedevent.py +13 -4
  75. mistralai/models_.py +67 -212
  76. mistralai/ocr.py +33 -36
  77. mistralai/sdk.py +15 -2
  78. mistralai/transcriptions.py +21 -60
  79. mistralai/utils/__init__.py +18 -5
  80. mistralai/utils/eventstreaming.py +10 -0
  81. mistralai/utils/serializers.py +3 -2
  82. mistralai/utils/unmarshal_json_response.py +24 -0
  83. {mistralai-1.9.10.dist-info → mistralai-1.10.0.dist-info}/METADATA +89 -40
  84. {mistralai-1.9.10.dist-info → mistralai-1.10.0.dist-info}/RECORD +86 -75
  85. {mistralai-1.9.10.dist-info → mistralai-1.10.0.dist-info}/WHEEL +1 -1
  86. {mistralai-1.9.10.dist-info → mistralai-1.10.0.dist-info/licenses}/LICENSE +0 -0
mistralai/documents.py CHANGED
@@ -5,7 +5,8 @@ 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 typing import Any, Mapping, Optional, Union
8
+ from mistralai.utils.unmarshal_json_response import unmarshal_json_response
9
+ from typing import Any, Dict, Mapping, Optional, Union
9
10
 
10
11
 
11
12
  class Documents(BaseSDK):
@@ -18,6 +19,7 @@ class Documents(BaseSDK):
18
19
  search: OptionalNullable[str] = UNSET,
19
20
  page_size: Optional[int] = 100,
20
21
  page: Optional[int] = 0,
22
+ filters_attributes: OptionalNullable[str] = UNSET,
21
23
  sort_by: Optional[str] = "created_at",
22
24
  sort_order: Optional[str] = "desc",
23
25
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
@@ -25,7 +27,7 @@ class Documents(BaseSDK):
25
27
  timeout_ms: Optional[int] = None,
26
28
  http_headers: Optional[Mapping[str, str]] = None,
27
29
  ) -> models.ListDocumentOut:
28
- r"""List document in a given library.
30
+ r"""List documents in a given library.
29
31
 
30
32
  Given a library, lists the document that have been uploaded to that library.
31
33
 
@@ -33,6 +35,7 @@ class Documents(BaseSDK):
33
35
  :param search:
34
36
  :param page_size:
35
37
  :param page:
38
+ :param filters_attributes:
36
39
  :param sort_by:
37
40
  :param sort_order:
38
41
  :param retries: Override the default retry configuration for this method
@@ -55,6 +58,7 @@ class Documents(BaseSDK):
55
58
  search=search,
56
59
  page_size=page_size,
57
60
  page=page,
61
+ filters_attributes=filters_attributes,
58
62
  sort_by=sort_by,
59
63
  sort_order=sort_order,
60
64
  )
@@ -100,31 +104,20 @@ class Documents(BaseSDK):
100
104
 
101
105
  response_data: Any = None
102
106
  if utils.match_response(http_res, "200", "application/json"):
103
- return utils.unmarshal_json(http_res.text, models.ListDocumentOut)
107
+ return unmarshal_json_response(models.ListDocumentOut, http_res)
104
108
  if utils.match_response(http_res, "422", "application/json"):
105
- response_data = utils.unmarshal_json(
106
- http_res.text, models.HTTPValidationErrorData
109
+ response_data = unmarshal_json_response(
110
+ models.HTTPValidationErrorData, http_res
107
111
  )
108
- raise models.HTTPValidationError(data=response_data)
112
+ raise models.HTTPValidationError(response_data, http_res)
109
113
  if utils.match_response(http_res, "4XX", "*"):
110
114
  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
- )
115
+ raise models.SDKError("API error occurred", http_res, http_res_text)
114
116
  if utils.match_response(http_res, "5XX", "*"):
115
117
  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
- )
118
+ raise models.SDKError("API error occurred", http_res, http_res_text)
119
119
 
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
- )
120
+ raise models.SDKError("Unexpected response received", http_res)
128
121
 
129
122
  async def list_async(
130
123
  self,
@@ -133,6 +126,7 @@ class Documents(BaseSDK):
133
126
  search: OptionalNullable[str] = UNSET,
134
127
  page_size: Optional[int] = 100,
135
128
  page: Optional[int] = 0,
129
+ filters_attributes: OptionalNullable[str] = UNSET,
136
130
  sort_by: Optional[str] = "created_at",
137
131
  sort_order: Optional[str] = "desc",
138
132
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
@@ -140,7 +134,7 @@ class Documents(BaseSDK):
140
134
  timeout_ms: Optional[int] = None,
141
135
  http_headers: Optional[Mapping[str, str]] = None,
142
136
  ) -> models.ListDocumentOut:
143
- r"""List document in a given library.
137
+ r"""List documents in a given library.
144
138
 
145
139
  Given a library, lists the document that have been uploaded to that library.
146
140
 
@@ -148,6 +142,7 @@ class Documents(BaseSDK):
148
142
  :param search:
149
143
  :param page_size:
150
144
  :param page:
145
+ :param filters_attributes:
151
146
  :param sort_by:
152
147
  :param sort_order:
153
148
  :param retries: Override the default retry configuration for this method
@@ -170,6 +165,7 @@ class Documents(BaseSDK):
170
165
  search=search,
171
166
  page_size=page_size,
172
167
  page=page,
168
+ filters_attributes=filters_attributes,
173
169
  sort_by=sort_by,
174
170
  sort_order=sort_order,
175
171
  )
@@ -215,31 +211,20 @@ class Documents(BaseSDK):
215
211
 
216
212
  response_data: Any = None
217
213
  if utils.match_response(http_res, "200", "application/json"):
218
- return utils.unmarshal_json(http_res.text, models.ListDocumentOut)
214
+ return unmarshal_json_response(models.ListDocumentOut, http_res)
219
215
  if utils.match_response(http_res, "422", "application/json"):
220
- response_data = utils.unmarshal_json(
221
- http_res.text, models.HTTPValidationErrorData
216
+ response_data = unmarshal_json_response(
217
+ models.HTTPValidationErrorData, http_res
222
218
  )
223
- raise models.HTTPValidationError(data=response_data)
219
+ raise models.HTTPValidationError(response_data, http_res)
224
220
  if utils.match_response(http_res, "4XX", "*"):
225
221
  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
- )
222
+ raise models.SDKError("API error occurred", http_res, http_res_text)
229
223
  if utils.match_response(http_res, "5XX", "*"):
230
224
  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
- )
225
+ raise models.SDKError("API error occurred", http_res, http_res_text)
234
226
 
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
- )
227
+ raise models.SDKError("Unexpected response received", http_res)
243
228
 
244
229
  def upload(
245
230
  self,
@@ -327,31 +312,20 @@ class Documents(BaseSDK):
327
312
 
328
313
  response_data: Any = None
329
314
  if utils.match_response(http_res, ["200", "201"], "application/json"):
330
- return utils.unmarshal_json(http_res.text, models.DocumentOut)
315
+ return unmarshal_json_response(models.DocumentOut, http_res)
331
316
  if utils.match_response(http_res, "422", "application/json"):
332
- response_data = utils.unmarshal_json(
333
- http_res.text, models.HTTPValidationErrorData
317
+ response_data = unmarshal_json_response(
318
+ models.HTTPValidationErrorData, http_res
334
319
  )
335
- raise models.HTTPValidationError(data=response_data)
320
+ raise models.HTTPValidationError(response_data, http_res)
336
321
  if utils.match_response(http_res, "4XX", "*"):
337
322
  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
- )
323
+ raise models.SDKError("API error occurred", http_res, http_res_text)
341
324
  if utils.match_response(http_res, "5XX", "*"):
342
325
  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
- )
326
+ raise models.SDKError("API error occurred", http_res, http_res_text)
346
327
 
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
- )
328
+ raise models.SDKError("Unexpected response received", http_res)
355
329
 
356
330
  async def upload_async(
357
331
  self,
@@ -439,31 +413,20 @@ class Documents(BaseSDK):
439
413
 
440
414
  response_data: Any = None
441
415
  if utils.match_response(http_res, ["200", "201"], "application/json"):
442
- return utils.unmarshal_json(http_res.text, models.DocumentOut)
416
+ return unmarshal_json_response(models.DocumentOut, http_res)
443
417
  if utils.match_response(http_res, "422", "application/json"):
444
- response_data = utils.unmarshal_json(
445
- http_res.text, models.HTTPValidationErrorData
418
+ response_data = unmarshal_json_response(
419
+ models.HTTPValidationErrorData, http_res
446
420
  )
447
- raise models.HTTPValidationError(data=response_data)
421
+ raise models.HTTPValidationError(response_data, http_res)
448
422
  if utils.match_response(http_res, "4XX", "*"):
449
423
  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
- )
424
+ raise models.SDKError("API error occurred", http_res, http_res_text)
453
425
  if utils.match_response(http_res, "5XX", "*"):
454
426
  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
- )
427
+ raise models.SDKError("API error occurred", http_res, http_res_text)
458
428
 
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
- )
429
+ raise models.SDKError("Unexpected response received", http_res)
467
430
 
468
431
  def get(
469
432
  self,
@@ -542,31 +505,20 @@ class Documents(BaseSDK):
542
505
 
543
506
  response_data: Any = None
544
507
  if utils.match_response(http_res, "200", "application/json"):
545
- return utils.unmarshal_json(http_res.text, models.DocumentOut)
508
+ return unmarshal_json_response(models.DocumentOut, http_res)
546
509
  if utils.match_response(http_res, "422", "application/json"):
547
- response_data = utils.unmarshal_json(
548
- http_res.text, models.HTTPValidationErrorData
510
+ response_data = unmarshal_json_response(
511
+ models.HTTPValidationErrorData, http_res
549
512
  )
550
- raise models.HTTPValidationError(data=response_data)
513
+ raise models.HTTPValidationError(response_data, http_res)
551
514
  if utils.match_response(http_res, "4XX", "*"):
552
515
  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
- )
516
+ raise models.SDKError("API error occurred", http_res, http_res_text)
556
517
  if utils.match_response(http_res, "5XX", "*"):
557
518
  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
- )
519
+ raise models.SDKError("API error occurred", http_res, http_res_text)
561
520
 
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
- )
521
+ raise models.SDKError("Unexpected response received", http_res)
570
522
 
571
523
  async def get_async(
572
524
  self,
@@ -645,31 +597,20 @@ class Documents(BaseSDK):
645
597
 
646
598
  response_data: Any = None
647
599
  if utils.match_response(http_res, "200", "application/json"):
648
- return utils.unmarshal_json(http_res.text, models.DocumentOut)
600
+ return unmarshal_json_response(models.DocumentOut, http_res)
649
601
  if utils.match_response(http_res, "422", "application/json"):
650
- response_data = utils.unmarshal_json(
651
- http_res.text, models.HTTPValidationErrorData
602
+ response_data = unmarshal_json_response(
603
+ models.HTTPValidationErrorData, http_res
652
604
  )
653
- raise models.HTTPValidationError(data=response_data)
605
+ raise models.HTTPValidationError(response_data, http_res)
654
606
  if utils.match_response(http_res, "4XX", "*"):
655
607
  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
- )
608
+ raise models.SDKError("API error occurred", http_res, http_res_text)
659
609
  if utils.match_response(http_res, "5XX", "*"):
660
610
  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
- )
611
+ raise models.SDKError("API error occurred", http_res, http_res_text)
664
612
 
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
- )
613
+ raise models.SDKError("Unexpected response received", http_res)
673
614
 
674
615
  def update(
675
616
  self,
@@ -677,6 +618,9 @@ class Documents(BaseSDK):
677
618
  library_id: str,
678
619
  document_id: str,
679
620
  name: OptionalNullable[str] = UNSET,
621
+ attributes: OptionalNullable[
622
+ Union[Dict[str, models.Attributes], Dict[str, models.AttributesTypedDict]]
623
+ ] = UNSET,
680
624
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
681
625
  server_url: Optional[str] = None,
682
626
  timeout_ms: Optional[int] = None,
@@ -689,6 +633,7 @@ class Documents(BaseSDK):
689
633
  :param library_id:
690
634
  :param document_id:
691
635
  :param name:
636
+ :param attributes:
692
637
  :param retries: Override the default retry configuration for this method
693
638
  :param server_url: Override the default server URL for this method
694
639
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -709,6 +654,7 @@ class Documents(BaseSDK):
709
654
  document_id=document_id,
710
655
  document_update_in=models.DocumentUpdateIn(
711
656
  name=name,
657
+ attributes=attributes,
712
658
  ),
713
659
  )
714
660
 
@@ -760,31 +706,20 @@ class Documents(BaseSDK):
760
706
 
761
707
  response_data: Any = None
762
708
  if utils.match_response(http_res, "200", "application/json"):
763
- return utils.unmarshal_json(http_res.text, models.DocumentOut)
709
+ return unmarshal_json_response(models.DocumentOut, http_res)
764
710
  if utils.match_response(http_res, "422", "application/json"):
765
- response_data = utils.unmarshal_json(
766
- http_res.text, models.HTTPValidationErrorData
711
+ response_data = unmarshal_json_response(
712
+ models.HTTPValidationErrorData, http_res
767
713
  )
768
- raise models.HTTPValidationError(data=response_data)
714
+ raise models.HTTPValidationError(response_data, http_res)
769
715
  if utils.match_response(http_res, "4XX", "*"):
770
716
  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
- )
717
+ raise models.SDKError("API error occurred", http_res, http_res_text)
774
718
  if utils.match_response(http_res, "5XX", "*"):
775
719
  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
- )
720
+ raise models.SDKError("API error occurred", http_res, http_res_text)
779
721
 
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
- )
722
+ raise models.SDKError("Unexpected response received", http_res)
788
723
 
789
724
  async def update_async(
790
725
  self,
@@ -792,6 +727,9 @@ class Documents(BaseSDK):
792
727
  library_id: str,
793
728
  document_id: str,
794
729
  name: OptionalNullable[str] = UNSET,
730
+ attributes: OptionalNullable[
731
+ Union[Dict[str, models.Attributes], Dict[str, models.AttributesTypedDict]]
732
+ ] = UNSET,
795
733
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
796
734
  server_url: Optional[str] = None,
797
735
  timeout_ms: Optional[int] = None,
@@ -804,6 +742,7 @@ class Documents(BaseSDK):
804
742
  :param library_id:
805
743
  :param document_id:
806
744
  :param name:
745
+ :param attributes:
807
746
  :param retries: Override the default retry configuration for this method
808
747
  :param server_url: Override the default server URL for this method
809
748
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -824,6 +763,7 @@ class Documents(BaseSDK):
824
763
  document_id=document_id,
825
764
  document_update_in=models.DocumentUpdateIn(
826
765
  name=name,
766
+ attributes=attributes,
827
767
  ),
828
768
  )
829
769
 
@@ -875,31 +815,20 @@ class Documents(BaseSDK):
875
815
 
876
816
  response_data: Any = None
877
817
  if utils.match_response(http_res, "200", "application/json"):
878
- return utils.unmarshal_json(http_res.text, models.DocumentOut)
818
+ return unmarshal_json_response(models.DocumentOut, http_res)
879
819
  if utils.match_response(http_res, "422", "application/json"):
880
- response_data = utils.unmarshal_json(
881
- http_res.text, models.HTTPValidationErrorData
820
+ response_data = unmarshal_json_response(
821
+ models.HTTPValidationErrorData, http_res
882
822
  )
883
- raise models.HTTPValidationError(data=response_data)
823
+ raise models.HTTPValidationError(response_data, http_res)
884
824
  if utils.match_response(http_res, "4XX", "*"):
885
825
  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
- )
826
+ raise models.SDKError("API error occurred", http_res, http_res_text)
889
827
  if utils.match_response(http_res, "5XX", "*"):
890
828
  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
- )
829
+ raise models.SDKError("API error occurred", http_res, http_res_text)
894
830
 
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
- )
831
+ raise models.SDKError("Unexpected response received", http_res)
903
832
 
904
833
  def delete(
905
834
  self,
@@ -980,29 +909,18 @@ class Documents(BaseSDK):
980
909
  if utils.match_response(http_res, "204", "*"):
981
910
  return
982
911
  if utils.match_response(http_res, "422", "application/json"):
983
- response_data = utils.unmarshal_json(
984
- http_res.text, models.HTTPValidationErrorData
912
+ response_data = unmarshal_json_response(
913
+ models.HTTPValidationErrorData, http_res
985
914
  )
986
- raise models.HTTPValidationError(data=response_data)
915
+ raise models.HTTPValidationError(response_data, http_res)
987
916
  if utils.match_response(http_res, "4XX", "*"):
988
917
  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
- )
918
+ raise models.SDKError("API error occurred", http_res, http_res_text)
992
919
  if utils.match_response(http_res, "5XX", "*"):
993
920
  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
- )
921
+ raise models.SDKError("API error occurred", http_res, http_res_text)
997
922
 
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
- )
923
+ raise models.SDKError("Unexpected response received", http_res)
1006
924
 
1007
925
  async def delete_async(
1008
926
  self,
@@ -1083,29 +1001,18 @@ class Documents(BaseSDK):
1083
1001
  if utils.match_response(http_res, "204", "*"):
1084
1002
  return
1085
1003
  if utils.match_response(http_res, "422", "application/json"):
1086
- response_data = utils.unmarshal_json(
1087
- http_res.text, models.HTTPValidationErrorData
1004
+ response_data = unmarshal_json_response(
1005
+ models.HTTPValidationErrorData, http_res
1088
1006
  )
1089
- raise models.HTTPValidationError(data=response_data)
1007
+ raise models.HTTPValidationError(response_data, http_res)
1090
1008
  if utils.match_response(http_res, "4XX", "*"):
1091
1009
  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
- )
1010
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1095
1011
  if utils.match_response(http_res, "5XX", "*"):
1096
1012
  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
- )
1013
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1100
1014
 
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
- )
1015
+ raise models.SDKError("Unexpected response received", http_res)
1109
1016
 
1110
1017
  def text_content(
1111
1018
  self,
@@ -1184,31 +1091,20 @@ class Documents(BaseSDK):
1184
1091
 
1185
1092
  response_data: Any = None
1186
1093
  if utils.match_response(http_res, "200", "application/json"):
1187
- return utils.unmarshal_json(http_res.text, models.DocumentTextContent)
1094
+ return unmarshal_json_response(models.DocumentTextContent, http_res)
1188
1095
  if utils.match_response(http_res, "422", "application/json"):
1189
- response_data = utils.unmarshal_json(
1190
- http_res.text, models.HTTPValidationErrorData
1096
+ response_data = unmarshal_json_response(
1097
+ models.HTTPValidationErrorData, http_res
1191
1098
  )
1192
- raise models.HTTPValidationError(data=response_data)
1099
+ raise models.HTTPValidationError(response_data, http_res)
1193
1100
  if utils.match_response(http_res, "4XX", "*"):
1194
1101
  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
- )
1102
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1198
1103
  if utils.match_response(http_res, "5XX", "*"):
1199
1104
  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
- )
1105
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1203
1106
 
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
- )
1107
+ raise models.SDKError("Unexpected response received", http_res)
1212
1108
 
1213
1109
  async def text_content_async(
1214
1110
  self,
@@ -1287,31 +1183,20 @@ class Documents(BaseSDK):
1287
1183
 
1288
1184
  response_data: Any = None
1289
1185
  if utils.match_response(http_res, "200", "application/json"):
1290
- return utils.unmarshal_json(http_res.text, models.DocumentTextContent)
1186
+ return unmarshal_json_response(models.DocumentTextContent, http_res)
1291
1187
  if utils.match_response(http_res, "422", "application/json"):
1292
- response_data = utils.unmarshal_json(
1293
- http_res.text, models.HTTPValidationErrorData
1188
+ response_data = unmarshal_json_response(
1189
+ models.HTTPValidationErrorData, http_res
1294
1190
  )
1295
- raise models.HTTPValidationError(data=response_data)
1191
+ raise models.HTTPValidationError(response_data, http_res)
1296
1192
  if utils.match_response(http_res, "4XX", "*"):
1297
1193
  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
- )
1194
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1301
1195
  if utils.match_response(http_res, "5XX", "*"):
1302
1196
  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
- )
1197
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1306
1198
 
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
- )
1199
+ raise models.SDKError("Unexpected response received", http_res)
1315
1200
 
1316
1201
  def status(
1317
1202
  self,
@@ -1390,31 +1275,20 @@ class Documents(BaseSDK):
1390
1275
 
1391
1276
  response_data: Any = None
1392
1277
  if utils.match_response(http_res, "200", "application/json"):
1393
- return utils.unmarshal_json(http_res.text, models.ProcessingStatusOut)
1278
+ return unmarshal_json_response(models.ProcessingStatusOut, http_res)
1394
1279
  if utils.match_response(http_res, "422", "application/json"):
1395
- response_data = utils.unmarshal_json(
1396
- http_res.text, models.HTTPValidationErrorData
1280
+ response_data = unmarshal_json_response(
1281
+ models.HTTPValidationErrorData, http_res
1397
1282
  )
1398
- raise models.HTTPValidationError(data=response_data)
1283
+ raise models.HTTPValidationError(response_data, http_res)
1399
1284
  if utils.match_response(http_res, "4XX", "*"):
1400
1285
  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
- )
1286
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1404
1287
  if utils.match_response(http_res, "5XX", "*"):
1405
1288
  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
- )
1289
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1409
1290
 
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
- )
1291
+ raise models.SDKError("Unexpected response received", http_res)
1418
1292
 
1419
1293
  async def status_async(
1420
1294
  self,
@@ -1493,31 +1367,20 @@ class Documents(BaseSDK):
1493
1367
 
1494
1368
  response_data: Any = None
1495
1369
  if utils.match_response(http_res, "200", "application/json"):
1496
- return utils.unmarshal_json(http_res.text, models.ProcessingStatusOut)
1370
+ return unmarshal_json_response(models.ProcessingStatusOut, http_res)
1497
1371
  if utils.match_response(http_res, "422", "application/json"):
1498
- response_data = utils.unmarshal_json(
1499
- http_res.text, models.HTTPValidationErrorData
1372
+ response_data = unmarshal_json_response(
1373
+ models.HTTPValidationErrorData, http_res
1500
1374
  )
1501
- raise models.HTTPValidationError(data=response_data)
1375
+ raise models.HTTPValidationError(response_data, http_res)
1502
1376
  if utils.match_response(http_res, "4XX", "*"):
1503
1377
  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
- )
1378
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1507
1379
  if utils.match_response(http_res, "5XX", "*"):
1508
1380
  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
- )
1381
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1512
1382
 
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
- )
1383
+ raise models.SDKError("Unexpected response received", http_res)
1521
1384
 
1522
1385
  def get_signed_url(
1523
1386
  self,
@@ -1596,31 +1459,20 @@ class Documents(BaseSDK):
1596
1459
 
1597
1460
  response_data: Any = None
1598
1461
  if utils.match_response(http_res, "200", "application/json"):
1599
- return utils.unmarshal_json(http_res.text, str)
1462
+ return unmarshal_json_response(str, http_res)
1600
1463
  if utils.match_response(http_res, "422", "application/json"):
1601
- response_data = utils.unmarshal_json(
1602
- http_res.text, models.HTTPValidationErrorData
1464
+ response_data = unmarshal_json_response(
1465
+ models.HTTPValidationErrorData, http_res
1603
1466
  )
1604
- raise models.HTTPValidationError(data=response_data)
1467
+ raise models.HTTPValidationError(response_data, http_res)
1605
1468
  if utils.match_response(http_res, "4XX", "*"):
1606
1469
  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
- )
1470
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1610
1471
  if utils.match_response(http_res, "5XX", "*"):
1611
1472
  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
- )
1473
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1615
1474
 
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
- )
1475
+ raise models.SDKError("Unexpected response received", http_res)
1624
1476
 
1625
1477
  async def get_signed_url_async(
1626
1478
  self,
@@ -1699,31 +1551,20 @@ class Documents(BaseSDK):
1699
1551
 
1700
1552
  response_data: Any = None
1701
1553
  if utils.match_response(http_res, "200", "application/json"):
1702
- return utils.unmarshal_json(http_res.text, str)
1554
+ return unmarshal_json_response(str, http_res)
1703
1555
  if utils.match_response(http_res, "422", "application/json"):
1704
- response_data = utils.unmarshal_json(
1705
- http_res.text, models.HTTPValidationErrorData
1556
+ response_data = unmarshal_json_response(
1557
+ models.HTTPValidationErrorData, http_res
1706
1558
  )
1707
- raise models.HTTPValidationError(data=response_data)
1559
+ raise models.HTTPValidationError(response_data, http_res)
1708
1560
  if utils.match_response(http_res, "4XX", "*"):
1709
1561
  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
- )
1562
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1713
1563
  if utils.match_response(http_res, "5XX", "*"):
1714
1564
  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
- )
1565
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1718
1566
 
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
- )
1567
+ raise models.SDKError("Unexpected response received", http_res)
1727
1568
 
1728
1569
  def extracted_text_signed_url(
1729
1570
  self,
@@ -1802,31 +1643,20 @@ class Documents(BaseSDK):
1802
1643
 
1803
1644
  response_data: Any = None
1804
1645
  if utils.match_response(http_res, "200", "application/json"):
1805
- return utils.unmarshal_json(http_res.text, str)
1646
+ return unmarshal_json_response(str, http_res)
1806
1647
  if utils.match_response(http_res, "422", "application/json"):
1807
- response_data = utils.unmarshal_json(
1808
- http_res.text, models.HTTPValidationErrorData
1648
+ response_data = unmarshal_json_response(
1649
+ models.HTTPValidationErrorData, http_res
1809
1650
  )
1810
- raise models.HTTPValidationError(data=response_data)
1651
+ raise models.HTTPValidationError(response_data, http_res)
1811
1652
  if utils.match_response(http_res, "4XX", "*"):
1812
1653
  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
- )
1654
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1816
1655
  if utils.match_response(http_res, "5XX", "*"):
1817
1656
  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
- )
1657
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1821
1658
 
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
- )
1659
+ raise models.SDKError("Unexpected response received", http_res)
1830
1660
 
1831
1661
  async def extracted_text_signed_url_async(
1832
1662
  self,
@@ -1905,31 +1735,20 @@ class Documents(BaseSDK):
1905
1735
 
1906
1736
  response_data: Any = None
1907
1737
  if utils.match_response(http_res, "200", "application/json"):
1908
- return utils.unmarshal_json(http_res.text, str)
1738
+ return unmarshal_json_response(str, http_res)
1909
1739
  if utils.match_response(http_res, "422", "application/json"):
1910
- response_data = utils.unmarshal_json(
1911
- http_res.text, models.HTTPValidationErrorData
1740
+ response_data = unmarshal_json_response(
1741
+ models.HTTPValidationErrorData, http_res
1912
1742
  )
1913
- raise models.HTTPValidationError(data=response_data)
1743
+ raise models.HTTPValidationError(response_data, http_res)
1914
1744
  if utils.match_response(http_res, "4XX", "*"):
1915
1745
  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
- )
1746
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1919
1747
  if utils.match_response(http_res, "5XX", "*"):
1920
1748
  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
- )
1749
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1924
1750
 
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
- )
1751
+ raise models.SDKError("Unexpected response received", http_res)
1933
1752
 
1934
1753
  def reprocess(
1935
1754
  self,
@@ -2010,29 +1829,18 @@ class Documents(BaseSDK):
2010
1829
  if utils.match_response(http_res, "204", "*"):
2011
1830
  return
2012
1831
  if utils.match_response(http_res, "422", "application/json"):
2013
- response_data = utils.unmarshal_json(
2014
- http_res.text, models.HTTPValidationErrorData
1832
+ response_data = unmarshal_json_response(
1833
+ models.HTTPValidationErrorData, http_res
2015
1834
  )
2016
- raise models.HTTPValidationError(data=response_data)
1835
+ raise models.HTTPValidationError(response_data, http_res)
2017
1836
  if utils.match_response(http_res, "4XX", "*"):
2018
1837
  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
- )
1838
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2022
1839
  if utils.match_response(http_res, "5XX", "*"):
2023
1840
  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
- )
1841
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2027
1842
 
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
- )
1843
+ raise models.SDKError("Unexpected response received", http_res)
2036
1844
 
2037
1845
  async def reprocess_async(
2038
1846
  self,
@@ -2113,26 +1921,15 @@ class Documents(BaseSDK):
2113
1921
  if utils.match_response(http_res, "204", "*"):
2114
1922
  return
2115
1923
  if utils.match_response(http_res, "422", "application/json"):
2116
- response_data = utils.unmarshal_json(
2117
- http_res.text, models.HTTPValidationErrorData
1924
+ response_data = unmarshal_json_response(
1925
+ models.HTTPValidationErrorData, http_res
2118
1926
  )
2119
- raise models.HTTPValidationError(data=response_data)
1927
+ raise models.HTTPValidationError(response_data, http_res)
2120
1928
  if utils.match_response(http_res, "4XX", "*"):
2121
1929
  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
- )
1930
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2125
1931
  if utils.match_response(http_res, "5XX", "*"):
2126
1932
  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
- )
1933
+ raise models.SDKError("API error occurred", http_res, http_res_text)
2130
1934
 
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
- )
1935
+ raise models.SDKError("Unexpected response received", http_res)