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/files.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 List, Mapping, Optional, Union
10
11
 
11
12
 
@@ -99,26 +100,15 @@ class Files(BaseSDK):
99
100
  )
100
101
 
101
102
  if utils.match_response(http_res, "200", "application/json"):
102
- return utils.unmarshal_json(http_res.text, models.UploadFileOut)
103
+ return unmarshal_json_response(models.UploadFileOut, http_res)
103
104
  if utils.match_response(http_res, "4XX", "*"):
104
105
  http_res_text = utils.stream_to_text(http_res)
105
- raise models.SDKError(
106
- "API error occurred", http_res.status_code, http_res_text, http_res
107
- )
106
+ raise models.SDKError("API error occurred", http_res, http_res_text)
108
107
  if utils.match_response(http_res, "5XX", "*"):
109
108
  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
- )
109
+ raise models.SDKError("API error occurred", http_res, http_res_text)
113
110
 
114
- content_type = http_res.headers.get("Content-Type")
115
- http_res_text = utils.stream_to_text(http_res)
116
- raise models.SDKError(
117
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
118
- http_res.status_code,
119
- http_res_text,
120
- http_res,
121
- )
111
+ raise models.SDKError("Unexpected response received", http_res)
122
112
 
123
113
  async def upload_async(
124
114
  self,
@@ -207,32 +197,22 @@ class Files(BaseSDK):
207
197
  )
208
198
 
209
199
  if utils.match_response(http_res, "200", "application/json"):
210
- return utils.unmarshal_json(http_res.text, models.UploadFileOut)
200
+ return unmarshal_json_response(models.UploadFileOut, http_res)
211
201
  if utils.match_response(http_res, "4XX", "*"):
212
202
  http_res_text = await utils.stream_to_text_async(http_res)
213
- raise models.SDKError(
214
- "API error occurred", http_res.status_code, http_res_text, http_res
215
- )
203
+ raise models.SDKError("API error occurred", http_res, http_res_text)
216
204
  if utils.match_response(http_res, "5XX", "*"):
217
205
  http_res_text = await utils.stream_to_text_async(http_res)
218
- raise models.SDKError(
219
- "API error occurred", http_res.status_code, http_res_text, http_res
220
- )
206
+ raise models.SDKError("API error occurred", http_res, http_res_text)
221
207
 
222
- content_type = http_res.headers.get("Content-Type")
223
- http_res_text = await utils.stream_to_text_async(http_res)
224
- raise models.SDKError(
225
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
226
- http_res.status_code,
227
- http_res_text,
228
- http_res,
229
- )
208
+ raise models.SDKError("Unexpected response received", http_res)
230
209
 
231
210
  def list(
232
211
  self,
233
212
  *,
234
213
  page: Optional[int] = 0,
235
214
  page_size: Optional[int] = 100,
215
+ include_total: Optional[bool] = True,
236
216
  sample_type: OptionalNullable[List[models.SampleType]] = UNSET,
237
217
  source: OptionalNullable[List[models.Source]] = UNSET,
238
218
  search: OptionalNullable[str] = UNSET,
@@ -248,6 +228,7 @@ class Files(BaseSDK):
248
228
 
249
229
  :param page:
250
230
  :param page_size:
231
+ :param include_total:
251
232
  :param sample_type:
252
233
  :param source:
253
234
  :param search:
@@ -270,6 +251,7 @@ class Files(BaseSDK):
270
251
  request = models.FilesAPIRoutesListFilesRequest(
271
252
  page=page,
272
253
  page_size=page_size,
254
+ include_total=include_total,
273
255
  sample_type=sample_type,
274
256
  source=source,
275
257
  search=search,
@@ -316,32 +298,22 @@ class Files(BaseSDK):
316
298
  )
317
299
 
318
300
  if utils.match_response(http_res, "200", "application/json"):
319
- return utils.unmarshal_json(http_res.text, models.ListFilesOut)
301
+ return unmarshal_json_response(models.ListFilesOut, http_res)
320
302
  if utils.match_response(http_res, "4XX", "*"):
321
303
  http_res_text = utils.stream_to_text(http_res)
322
- raise models.SDKError(
323
- "API error occurred", http_res.status_code, http_res_text, http_res
324
- )
304
+ raise models.SDKError("API error occurred", http_res, http_res_text)
325
305
  if utils.match_response(http_res, "5XX", "*"):
326
306
  http_res_text = utils.stream_to_text(http_res)
327
- raise models.SDKError(
328
- "API error occurred", http_res.status_code, http_res_text, http_res
329
- )
307
+ raise models.SDKError("API error occurred", http_res, http_res_text)
330
308
 
331
- content_type = http_res.headers.get("Content-Type")
332
- http_res_text = utils.stream_to_text(http_res)
333
- raise models.SDKError(
334
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
335
- http_res.status_code,
336
- http_res_text,
337
- http_res,
338
- )
309
+ raise models.SDKError("Unexpected response received", http_res)
339
310
 
340
311
  async def list_async(
341
312
  self,
342
313
  *,
343
314
  page: Optional[int] = 0,
344
315
  page_size: Optional[int] = 100,
316
+ include_total: Optional[bool] = True,
345
317
  sample_type: OptionalNullable[List[models.SampleType]] = UNSET,
346
318
  source: OptionalNullable[List[models.Source]] = UNSET,
347
319
  search: OptionalNullable[str] = UNSET,
@@ -357,6 +329,7 @@ class Files(BaseSDK):
357
329
 
358
330
  :param page:
359
331
  :param page_size:
332
+ :param include_total:
360
333
  :param sample_type:
361
334
  :param source:
362
335
  :param search:
@@ -379,6 +352,7 @@ class Files(BaseSDK):
379
352
  request = models.FilesAPIRoutesListFilesRequest(
380
353
  page=page,
381
354
  page_size=page_size,
355
+ include_total=include_total,
382
356
  sample_type=sample_type,
383
357
  source=source,
384
358
  search=search,
@@ -425,26 +399,15 @@ class Files(BaseSDK):
425
399
  )
426
400
 
427
401
  if utils.match_response(http_res, "200", "application/json"):
428
- return utils.unmarshal_json(http_res.text, models.ListFilesOut)
402
+ return unmarshal_json_response(models.ListFilesOut, http_res)
429
403
  if utils.match_response(http_res, "4XX", "*"):
430
404
  http_res_text = await utils.stream_to_text_async(http_res)
431
- raise models.SDKError(
432
- "API error occurred", http_res.status_code, http_res_text, http_res
433
- )
405
+ raise models.SDKError("API error occurred", http_res, http_res_text)
434
406
  if utils.match_response(http_res, "5XX", "*"):
435
407
  http_res_text = await utils.stream_to_text_async(http_res)
436
- raise models.SDKError(
437
- "API error occurred", http_res.status_code, http_res_text, http_res
438
- )
408
+ raise models.SDKError("API error occurred", http_res, http_res_text)
439
409
 
440
- content_type = http_res.headers.get("Content-Type")
441
- http_res_text = await utils.stream_to_text_async(http_res)
442
- raise models.SDKError(
443
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
444
- http_res.status_code,
445
- http_res_text,
446
- http_res,
447
- )
410
+ raise models.SDKError("Unexpected response received", http_res)
448
411
 
449
412
  def retrieve(
450
413
  self,
@@ -519,26 +482,15 @@ class Files(BaseSDK):
519
482
  )
520
483
 
521
484
  if utils.match_response(http_res, "200", "application/json"):
522
- return utils.unmarshal_json(http_res.text, models.RetrieveFileOut)
485
+ return unmarshal_json_response(models.RetrieveFileOut, http_res)
523
486
  if utils.match_response(http_res, "4XX", "*"):
524
487
  http_res_text = utils.stream_to_text(http_res)
525
- raise models.SDKError(
526
- "API error occurred", http_res.status_code, http_res_text, http_res
527
- )
488
+ raise models.SDKError("API error occurred", http_res, http_res_text)
528
489
  if utils.match_response(http_res, "5XX", "*"):
529
490
  http_res_text = utils.stream_to_text(http_res)
530
- raise models.SDKError(
531
- "API error occurred", http_res.status_code, http_res_text, http_res
532
- )
491
+ raise models.SDKError("API error occurred", http_res, http_res_text)
533
492
 
534
- content_type = http_res.headers.get("Content-Type")
535
- http_res_text = utils.stream_to_text(http_res)
536
- raise models.SDKError(
537
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
538
- http_res.status_code,
539
- http_res_text,
540
- http_res,
541
- )
493
+ raise models.SDKError("Unexpected response received", http_res)
542
494
 
543
495
  async def retrieve_async(
544
496
  self,
@@ -613,26 +565,15 @@ class Files(BaseSDK):
613
565
  )
614
566
 
615
567
  if utils.match_response(http_res, "200", "application/json"):
616
- return utils.unmarshal_json(http_res.text, models.RetrieveFileOut)
568
+ return unmarshal_json_response(models.RetrieveFileOut, http_res)
617
569
  if utils.match_response(http_res, "4XX", "*"):
618
570
  http_res_text = await utils.stream_to_text_async(http_res)
619
- raise models.SDKError(
620
- "API error occurred", http_res.status_code, http_res_text, http_res
621
- )
571
+ raise models.SDKError("API error occurred", http_res, http_res_text)
622
572
  if utils.match_response(http_res, "5XX", "*"):
623
573
  http_res_text = await utils.stream_to_text_async(http_res)
624
- raise models.SDKError(
625
- "API error occurred", http_res.status_code, http_res_text, http_res
626
- )
574
+ raise models.SDKError("API error occurred", http_res, http_res_text)
627
575
 
628
- content_type = http_res.headers.get("Content-Type")
629
- http_res_text = await utils.stream_to_text_async(http_res)
630
- raise models.SDKError(
631
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
632
- http_res.status_code,
633
- http_res_text,
634
- http_res,
635
- )
576
+ raise models.SDKError("Unexpected response received", http_res)
636
577
 
637
578
  def delete(
638
579
  self,
@@ -707,26 +648,15 @@ class Files(BaseSDK):
707
648
  )
708
649
 
709
650
  if utils.match_response(http_res, "200", "application/json"):
710
- return utils.unmarshal_json(http_res.text, models.DeleteFileOut)
651
+ return unmarshal_json_response(models.DeleteFileOut, http_res)
711
652
  if utils.match_response(http_res, "4XX", "*"):
712
653
  http_res_text = utils.stream_to_text(http_res)
713
- raise models.SDKError(
714
- "API error occurred", http_res.status_code, http_res_text, http_res
715
- )
654
+ raise models.SDKError("API error occurred", http_res, http_res_text)
716
655
  if utils.match_response(http_res, "5XX", "*"):
717
656
  http_res_text = utils.stream_to_text(http_res)
718
- raise models.SDKError(
719
- "API error occurred", http_res.status_code, http_res_text, http_res
720
- )
657
+ raise models.SDKError("API error occurred", http_res, http_res_text)
721
658
 
722
- content_type = http_res.headers.get("Content-Type")
723
- http_res_text = utils.stream_to_text(http_res)
724
- raise models.SDKError(
725
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
726
- http_res.status_code,
727
- http_res_text,
728
- http_res,
729
- )
659
+ raise models.SDKError("Unexpected response received", http_res)
730
660
 
731
661
  async def delete_async(
732
662
  self,
@@ -801,26 +731,15 @@ class Files(BaseSDK):
801
731
  )
802
732
 
803
733
  if utils.match_response(http_res, "200", "application/json"):
804
- return utils.unmarshal_json(http_res.text, models.DeleteFileOut)
734
+ return unmarshal_json_response(models.DeleteFileOut, http_res)
805
735
  if utils.match_response(http_res, "4XX", "*"):
806
736
  http_res_text = await utils.stream_to_text_async(http_res)
807
- raise models.SDKError(
808
- "API error occurred", http_res.status_code, http_res_text, http_res
809
- )
737
+ raise models.SDKError("API error occurred", http_res, http_res_text)
810
738
  if utils.match_response(http_res, "5XX", "*"):
811
739
  http_res_text = await utils.stream_to_text_async(http_res)
812
- raise models.SDKError(
813
- "API error occurred", http_res.status_code, http_res_text, http_res
814
- )
740
+ raise models.SDKError("API error occurred", http_res, http_res_text)
815
741
 
816
- content_type = http_res.headers.get("Content-Type")
817
- http_res_text = await utils.stream_to_text_async(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
- )
742
+ raise models.SDKError("Unexpected response received", http_res)
824
743
 
825
744
  def download(
826
745
  self,
@@ -899,23 +818,13 @@ class Files(BaseSDK):
899
818
  return http_res
900
819
  if utils.match_response(http_res, "4XX", "*"):
901
820
  http_res_text = utils.stream_to_text(http_res)
902
- raise models.SDKError(
903
- "API error occurred", http_res.status_code, http_res_text, http_res
904
- )
821
+ raise models.SDKError("API error occurred", http_res, http_res_text)
905
822
  if utils.match_response(http_res, "5XX", "*"):
906
823
  http_res_text = utils.stream_to_text(http_res)
907
- raise models.SDKError(
908
- "API error occurred", http_res.status_code, http_res_text, http_res
909
- )
824
+ raise models.SDKError("API error occurred", http_res, http_res_text)
910
825
 
911
- content_type = http_res.headers.get("Content-Type")
912
826
  http_res_text = utils.stream_to_text(http_res)
913
- raise models.SDKError(
914
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
915
- http_res.status_code,
916
- http_res_text,
917
- http_res,
918
- )
827
+ raise models.SDKError("Unexpected response received", http_res, http_res_text)
919
828
 
920
829
  async def download_async(
921
830
  self,
@@ -994,23 +903,13 @@ class Files(BaseSDK):
994
903
  return http_res
995
904
  if utils.match_response(http_res, "4XX", "*"):
996
905
  http_res_text = await utils.stream_to_text_async(http_res)
997
- raise models.SDKError(
998
- "API error occurred", http_res.status_code, http_res_text, http_res
999
- )
906
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1000
907
  if utils.match_response(http_res, "5XX", "*"):
1001
908
  http_res_text = await utils.stream_to_text_async(http_res)
1002
- raise models.SDKError(
1003
- "API error occurred", http_res.status_code, http_res_text, http_res
1004
- )
909
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1005
910
 
1006
- content_type = http_res.headers.get("Content-Type")
1007
911
  http_res_text = await utils.stream_to_text_async(http_res)
1008
- raise models.SDKError(
1009
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1010
- http_res.status_code,
1011
- http_res_text,
1012
- http_res,
1013
- )
912
+ raise models.SDKError("Unexpected response received", http_res, http_res_text)
1014
913
 
1015
914
  def get_signed_url(
1016
915
  self,
@@ -1086,26 +985,15 @@ class Files(BaseSDK):
1086
985
  )
1087
986
 
1088
987
  if utils.match_response(http_res, "200", "application/json"):
1089
- return utils.unmarshal_json(http_res.text, models.FileSignedURL)
988
+ return unmarshal_json_response(models.FileSignedURL, http_res)
1090
989
  if utils.match_response(http_res, "4XX", "*"):
1091
990
  http_res_text = utils.stream_to_text(http_res)
1092
- raise models.SDKError(
1093
- "API error occurred", http_res.status_code, http_res_text, http_res
1094
- )
991
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1095
992
  if utils.match_response(http_res, "5XX", "*"):
1096
993
  http_res_text = utils.stream_to_text(http_res)
1097
- raise models.SDKError(
1098
- "API error occurred", http_res.status_code, http_res_text, http_res
1099
- )
994
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1100
995
 
1101
- content_type = http_res.headers.get("Content-Type")
1102
- http_res_text = utils.stream_to_text(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
- )
996
+ raise models.SDKError("Unexpected response received", http_res)
1109
997
 
1110
998
  async def get_signed_url_async(
1111
999
  self,
@@ -1181,23 +1069,12 @@ class Files(BaseSDK):
1181
1069
  )
1182
1070
 
1183
1071
  if utils.match_response(http_res, "200", "application/json"):
1184
- return utils.unmarshal_json(http_res.text, models.FileSignedURL)
1072
+ return unmarshal_json_response(models.FileSignedURL, http_res)
1185
1073
  if utils.match_response(http_res, "4XX", "*"):
1186
1074
  http_res_text = await utils.stream_to_text_async(http_res)
1187
- raise models.SDKError(
1188
- "API error occurred", http_res.status_code, http_res_text, http_res
1189
- )
1075
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1190
1076
  if utils.match_response(http_res, "5XX", "*"):
1191
1077
  http_res_text = await utils.stream_to_text_async(http_res)
1192
- raise models.SDKError(
1193
- "API error occurred", http_res.status_code, http_res_text, http_res
1194
- )
1078
+ raise models.SDKError("API error occurred", http_res, http_res_text)
1195
1079
 
1196
- content_type = http_res.headers.get("Content-Type")
1197
- http_res_text = await utils.stream_to_text_async(http_res)
1198
- raise models.SDKError(
1199
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1200
- http_res.status_code,
1201
- http_res_text,
1202
- http_res,
1203
- )
1080
+ raise models.SDKError("Unexpected response received", http_res)