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/mistral_jobs.py CHANGED
@@ -6,6 +6,7 @@ from mistralai import models, utils
6
6
  from mistralai._hooks import HookContext
7
7
  from mistralai.types import OptionalNullable, UNSET
8
8
  from mistralai.utils import get_security_from_env
9
+ from mistralai.utils.unmarshal_json_response import unmarshal_json_response
9
10
  from typing import Any, Dict, List, Mapping, Optional
10
11
 
11
12
 
@@ -104,26 +105,15 @@ class MistralJobs(BaseSDK):
104
105
  )
105
106
 
106
107
  if utils.match_response(http_res, "200", "application/json"):
107
- return utils.unmarshal_json(http_res.text, models.BatchJobsOut)
108
+ return unmarshal_json_response(models.BatchJobsOut, http_res)
108
109
  if utils.match_response(http_res, "4XX", "*"):
109
110
  http_res_text = utils.stream_to_text(http_res)
110
- raise models.SDKError(
111
- "API error occurred", http_res.status_code, http_res_text, http_res
112
- )
111
+ raise models.SDKError("API error occurred", http_res, http_res_text)
113
112
  if utils.match_response(http_res, "5XX", "*"):
114
113
  http_res_text = utils.stream_to_text(http_res)
115
- raise models.SDKError(
116
- "API error occurred", http_res.status_code, http_res_text, http_res
117
- )
118
-
119
- content_type = http_res.headers.get("Content-Type")
120
- http_res_text = utils.stream_to_text(http_res)
121
- raise models.SDKError(
122
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
123
- http_res.status_code,
124
- http_res_text,
125
- http_res,
126
- )
114
+ raise models.SDKError("API error occurred", http_res, http_res_text)
115
+
116
+ raise models.SDKError("Unexpected response received", http_res)
127
117
 
128
118
  async def list_async(
129
119
  self,
@@ -219,26 +209,15 @@ class MistralJobs(BaseSDK):
219
209
  )
220
210
 
221
211
  if utils.match_response(http_res, "200", "application/json"):
222
- return utils.unmarshal_json(http_res.text, models.BatchJobsOut)
212
+ return unmarshal_json_response(models.BatchJobsOut, http_res)
223
213
  if utils.match_response(http_res, "4XX", "*"):
224
214
  http_res_text = await utils.stream_to_text_async(http_res)
225
- raise models.SDKError(
226
- "API error occurred", http_res.status_code, http_res_text, http_res
227
- )
215
+ raise models.SDKError("API error occurred", http_res, http_res_text)
228
216
  if utils.match_response(http_res, "5XX", "*"):
229
217
  http_res_text = await utils.stream_to_text_async(http_res)
230
- raise models.SDKError(
231
- "API error occurred", http_res.status_code, http_res_text, http_res
232
- )
233
-
234
- content_type = http_res.headers.get("Content-Type")
235
- http_res_text = await utils.stream_to_text_async(http_res)
236
- raise models.SDKError(
237
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
238
- http_res.status_code,
239
- http_res_text,
240
- http_res,
241
- )
218
+ raise models.SDKError("API error occurred", http_res, http_res_text)
219
+
220
+ raise models.SDKError("Unexpected response received", http_res)
242
221
 
243
222
  def create(
244
223
  self,
@@ -258,12 +237,12 @@ class MistralJobs(BaseSDK):
258
237
 
259
238
  Create a new batch job, it will be queued for processing.
260
239
 
261
- :param input_files:
240
+ :param input_files: The list of input files to be used for batch inference, these files should be `jsonl` files, containing the input data corresponding to the bory request for the batch inference in a \"body\" field. An example of such file is the following: ```json {\"custom_id\": \"0\", \"body\": {\"max_tokens\": 100, \"messages\": [{\"role\": \"user\", \"content\": \"What is the best French cheese?\"}]}} {\"custom_id\": \"1\", \"body\": {\"max_tokens\": 100, \"messages\": [{\"role\": \"user\", \"content\": \"What is the best French wine?\"}]}} ```
262
241
  :param endpoint:
263
- :param model:
264
- :param agent_id:
265
- :param metadata:
266
- :param timeout_hours:
242
+ :param model: The model to be used for batch inference.
243
+ :param agent_id: In case you want to use a specific agent from the **deprecated** agents api for batch inference, you can specify the agent ID here.
244
+ :param metadata: The metadata of your choice to be associated with the batch inference job.
245
+ :param timeout_hours: The timeout in hours for the batch inference job.
267
246
  :param retries: Override the default retry configuration for this method
268
247
  :param server_url: Override the default server URL for this method
269
248
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -331,26 +310,15 @@ class MistralJobs(BaseSDK):
331
310
  )
332
311
 
333
312
  if utils.match_response(http_res, "200", "application/json"):
334
- return utils.unmarshal_json(http_res.text, models.BatchJobOut)
313
+ return unmarshal_json_response(models.BatchJobOut, http_res)
335
314
  if utils.match_response(http_res, "4XX", "*"):
336
315
  http_res_text = utils.stream_to_text(http_res)
337
- raise models.SDKError(
338
- "API error occurred", http_res.status_code, http_res_text, http_res
339
- )
316
+ raise models.SDKError("API error occurred", http_res, http_res_text)
340
317
  if utils.match_response(http_res, "5XX", "*"):
341
318
  http_res_text = utils.stream_to_text(http_res)
342
- raise models.SDKError(
343
- "API error occurred", http_res.status_code, http_res_text, http_res
344
- )
345
-
346
- content_type = http_res.headers.get("Content-Type")
347
- http_res_text = utils.stream_to_text(http_res)
348
- raise models.SDKError(
349
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
350
- http_res.status_code,
351
- http_res_text,
352
- http_res,
353
- )
319
+ raise models.SDKError("API error occurred", http_res, http_res_text)
320
+
321
+ raise models.SDKError("Unexpected response received", http_res)
354
322
 
355
323
  async def create_async(
356
324
  self,
@@ -370,12 +338,12 @@ class MistralJobs(BaseSDK):
370
338
 
371
339
  Create a new batch job, it will be queued for processing.
372
340
 
373
- :param input_files:
341
+ :param input_files: The list of input files to be used for batch inference, these files should be `jsonl` files, containing the input data corresponding to the bory request for the batch inference in a \"body\" field. An example of such file is the following: ```json {\"custom_id\": \"0\", \"body\": {\"max_tokens\": 100, \"messages\": [{\"role\": \"user\", \"content\": \"What is the best French cheese?\"}]}} {\"custom_id\": \"1\", \"body\": {\"max_tokens\": 100, \"messages\": [{\"role\": \"user\", \"content\": \"What is the best French wine?\"}]}} ```
374
342
  :param endpoint:
375
- :param model:
376
- :param agent_id:
377
- :param metadata:
378
- :param timeout_hours:
343
+ :param model: The model to be used for batch inference.
344
+ :param agent_id: In case you want to use a specific agent from the **deprecated** agents api for batch inference, you can specify the agent ID here.
345
+ :param metadata: The metadata of your choice to be associated with the batch inference job.
346
+ :param timeout_hours: The timeout in hours for the batch inference job.
379
347
  :param retries: Override the default retry configuration for this method
380
348
  :param server_url: Override the default server URL for this method
381
349
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -443,26 +411,15 @@ class MistralJobs(BaseSDK):
443
411
  )
444
412
 
445
413
  if utils.match_response(http_res, "200", "application/json"):
446
- return utils.unmarshal_json(http_res.text, models.BatchJobOut)
414
+ return unmarshal_json_response(models.BatchJobOut, http_res)
447
415
  if utils.match_response(http_res, "4XX", "*"):
448
416
  http_res_text = await utils.stream_to_text_async(http_res)
449
- raise models.SDKError(
450
- "API error occurred", http_res.status_code, http_res_text, http_res
451
- )
417
+ raise models.SDKError("API error occurred", http_res, http_res_text)
452
418
  if utils.match_response(http_res, "5XX", "*"):
453
419
  http_res_text = await utils.stream_to_text_async(http_res)
454
- raise models.SDKError(
455
- "API error occurred", http_res.status_code, http_res_text, http_res
456
- )
457
-
458
- content_type = http_res.headers.get("Content-Type")
459
- http_res_text = await utils.stream_to_text_async(http_res)
460
- raise models.SDKError(
461
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
462
- http_res.status_code,
463
- http_res_text,
464
- http_res,
465
- )
420
+ raise models.SDKError("API error occurred", http_res, http_res_text)
421
+
422
+ raise models.SDKError("Unexpected response received", http_res)
466
423
 
467
424
  def get(
468
425
  self,
@@ -537,26 +494,15 @@ class MistralJobs(BaseSDK):
537
494
  )
538
495
 
539
496
  if utils.match_response(http_res, "200", "application/json"):
540
- return utils.unmarshal_json(http_res.text, models.BatchJobOut)
497
+ return unmarshal_json_response(models.BatchJobOut, http_res)
541
498
  if utils.match_response(http_res, "4XX", "*"):
542
499
  http_res_text = utils.stream_to_text(http_res)
543
- raise models.SDKError(
544
- "API error occurred", http_res.status_code, http_res_text, http_res
545
- )
500
+ raise models.SDKError("API error occurred", http_res, http_res_text)
546
501
  if utils.match_response(http_res, "5XX", "*"):
547
502
  http_res_text = utils.stream_to_text(http_res)
548
- raise models.SDKError(
549
- "API error occurred", http_res.status_code, http_res_text, http_res
550
- )
551
-
552
- content_type = http_res.headers.get("Content-Type")
553
- http_res_text = utils.stream_to_text(http_res)
554
- raise models.SDKError(
555
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
556
- http_res.status_code,
557
- http_res_text,
558
- http_res,
559
- )
503
+ raise models.SDKError("API error occurred", http_res, http_res_text)
504
+
505
+ raise models.SDKError("Unexpected response received", http_res)
560
506
 
561
507
  async def get_async(
562
508
  self,
@@ -631,26 +577,15 @@ class MistralJobs(BaseSDK):
631
577
  )
632
578
 
633
579
  if utils.match_response(http_res, "200", "application/json"):
634
- return utils.unmarshal_json(http_res.text, models.BatchJobOut)
580
+ return unmarshal_json_response(models.BatchJobOut, http_res)
635
581
  if utils.match_response(http_res, "4XX", "*"):
636
582
  http_res_text = await utils.stream_to_text_async(http_res)
637
- raise models.SDKError(
638
- "API error occurred", http_res.status_code, http_res_text, http_res
639
- )
583
+ raise models.SDKError("API error occurred", http_res, http_res_text)
640
584
  if utils.match_response(http_res, "5XX", "*"):
641
585
  http_res_text = await utils.stream_to_text_async(http_res)
642
- raise models.SDKError(
643
- "API error occurred", http_res.status_code, http_res_text, http_res
644
- )
645
-
646
- content_type = http_res.headers.get("Content-Type")
647
- http_res_text = await utils.stream_to_text_async(http_res)
648
- raise models.SDKError(
649
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
650
- http_res.status_code,
651
- http_res_text,
652
- http_res,
653
- )
586
+ raise models.SDKError("API error occurred", http_res, http_res_text)
587
+
588
+ raise models.SDKError("Unexpected response received", http_res)
654
589
 
655
590
  def cancel(
656
591
  self,
@@ -725,26 +660,15 @@ class MistralJobs(BaseSDK):
725
660
  )
726
661
 
727
662
  if utils.match_response(http_res, "200", "application/json"):
728
- return utils.unmarshal_json(http_res.text, models.BatchJobOut)
663
+ return unmarshal_json_response(models.BatchJobOut, http_res)
729
664
  if utils.match_response(http_res, "4XX", "*"):
730
665
  http_res_text = utils.stream_to_text(http_res)
731
- raise models.SDKError(
732
- "API error occurred", http_res.status_code, http_res_text, http_res
733
- )
666
+ raise models.SDKError("API error occurred", http_res, http_res_text)
734
667
  if utils.match_response(http_res, "5XX", "*"):
735
668
  http_res_text = utils.stream_to_text(http_res)
736
- raise models.SDKError(
737
- "API error occurred", http_res.status_code, http_res_text, http_res
738
- )
739
-
740
- content_type = http_res.headers.get("Content-Type")
741
- http_res_text = utils.stream_to_text(http_res)
742
- raise models.SDKError(
743
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
744
- http_res.status_code,
745
- http_res_text,
746
- http_res,
747
- )
669
+ raise models.SDKError("API error occurred", http_res, http_res_text)
670
+
671
+ raise models.SDKError("Unexpected response received", http_res)
748
672
 
749
673
  async def cancel_async(
750
674
  self,
@@ -819,23 +743,12 @@ class MistralJobs(BaseSDK):
819
743
  )
820
744
 
821
745
  if utils.match_response(http_res, "200", "application/json"):
822
- return utils.unmarshal_json(http_res.text, models.BatchJobOut)
746
+ return unmarshal_json_response(models.BatchJobOut, http_res)
823
747
  if utils.match_response(http_res, "4XX", "*"):
824
748
  http_res_text = await utils.stream_to_text_async(http_res)
825
- raise models.SDKError(
826
- "API error occurred", http_res.status_code, http_res_text, http_res
827
- )
749
+ raise models.SDKError("API error occurred", http_res, http_res_text)
828
750
  if utils.match_response(http_res, "5XX", "*"):
829
751
  http_res_text = await utils.stream_to_text_async(http_res)
830
- raise models.SDKError(
831
- "API error occurred", http_res.status_code, http_res_text, http_res
832
- )
833
-
834
- content_type = http_res.headers.get("Content-Type")
835
- http_res_text = await utils.stream_to_text_async(http_res)
836
- raise models.SDKError(
837
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
838
- http_res.status_code,
839
- http_res_text,
840
- http_res,
841
- )
752
+ raise models.SDKError("API error occurred", http_res, http_res_text)
753
+
754
+ raise models.SDKError("Unexpected response received", http_res)
@@ -1,7 +1,10 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
+ from .mistralerror import MistralError
3
4
  from typing import TYPE_CHECKING
4
5
  from importlib import import_module
6
+ import builtins
7
+ import sys
5
8
 
6
9
  if TYPE_CHECKING:
7
10
  from .agent import (
@@ -38,6 +41,10 @@ if TYPE_CHECKING:
38
41
  AgentHandoffStartedEventType,
39
42
  AgentHandoffStartedEventTypedDict,
40
43
  )
44
+ from .agents_api_v1_agents_deleteop import (
45
+ AgentsAPIV1AgentsDeleteRequest,
46
+ AgentsAPIV1AgentsDeleteRequestTypedDict,
47
+ )
41
48
  from .agents_api_v1_agents_getop import (
42
49
  AgentsAPIV1AgentsGetRequest,
43
50
  AgentsAPIV1AgentsGetRequestTypedDict,
@@ -62,6 +69,10 @@ if TYPE_CHECKING:
62
69
  AgentsAPIV1ConversationsAppendRequest,
63
70
  AgentsAPIV1ConversationsAppendRequestTypedDict,
64
71
  )
72
+ from .agents_api_v1_conversations_deleteop import (
73
+ AgentsAPIV1ConversationsDeleteRequest,
74
+ AgentsAPIV1ConversationsDeleteRequestTypedDict,
75
+ )
65
76
  from .agents_api_v1_conversations_getop import (
66
77
  AgentsAPIV1ConversationsGetRequest,
67
78
  AgentsAPIV1ConversationsGetRequestTypedDict,
@@ -371,7 +382,12 @@ if TYPE_CHECKING:
371
382
  )
372
383
  from .documentout import DocumentOut, DocumentOutTypedDict
373
384
  from .documenttextcontent import DocumentTextContent, DocumentTextContentTypedDict
374
- from .documentupdatein import DocumentUpdateIn, DocumentUpdateInTypedDict
385
+ from .documentupdatein import (
386
+ Attributes,
387
+ AttributesTypedDict,
388
+ DocumentUpdateIn,
389
+ DocumentUpdateInTypedDict,
390
+ )
375
391
  from .documenturlchunk import (
376
392
  DocumentURLChunk,
377
393
  DocumentURLChunkType,
@@ -713,11 +729,19 @@ if TYPE_CHECKING:
713
729
  from .modellist import Data, DataTypedDict, ModelList, ModelListTypedDict
714
730
  from .moderationobject import ModerationObject, ModerationObjectTypedDict
715
731
  from .moderationresponse import ModerationResponse, ModerationResponseTypedDict
732
+ from .no_response_error import NoResponseError
716
733
  from .ocrimageobject import OCRImageObject, OCRImageObjectTypedDict
717
734
  from .ocrpagedimensions import OCRPageDimensions, OCRPageDimensionsTypedDict
718
735
  from .ocrpageobject import OCRPageObject, OCRPageObjectTypedDict
719
- from .ocrrequest import Document, DocumentTypedDict, OCRRequest, OCRRequestTypedDict
736
+ from .ocrrequest import (
737
+ Document,
738
+ DocumentTypedDict,
739
+ OCRRequest,
740
+ OCRRequestTypedDict,
741
+ TableFormat,
742
+ )
720
743
  from .ocrresponse import OCRResponse, OCRResponseTypedDict
744
+ from .ocrtableobject import Format, OCRTableObject, OCRTableObjectTypedDict
721
745
  from .ocrusageinfo import OCRUsageInfo, OCRUsageInfoTypedDict
722
746
  from .outputcontentchunks import OutputContentChunks, OutputContentChunksTypedDict
723
747
  from .paginationinfo import PaginationInfo, PaginationInfoTypedDict
@@ -728,6 +752,7 @@ if TYPE_CHECKING:
728
752
  ReferenceChunkType,
729
753
  ReferenceChunkTypedDict,
730
754
  )
755
+ from .requestsource import RequestSource
731
756
  from .responsedoneevent import (
732
757
  ResponseDoneEvent,
733
758
  ResponseDoneEventType,
@@ -745,6 +770,7 @@ if TYPE_CHECKING:
745
770
  ResponseStartedEventType,
746
771
  ResponseStartedEventTypedDict,
747
772
  )
773
+ from .responsevalidationerror import ResponseValidationError
748
774
  from .retrieve_model_v1_models_model_id_getop import (
749
775
  RetrieveModelV1ModelsModelIDGetRequest,
750
776
  RetrieveModelV1ModelsModelIDGetRequestTypedDict,
@@ -787,15 +813,21 @@ if TYPE_CHECKING:
787
813
  from .toolchoiceenum import ToolChoiceEnum
788
814
  from .toolexecutiondeltaevent import (
789
815
  ToolExecutionDeltaEvent,
816
+ ToolExecutionDeltaEventName,
817
+ ToolExecutionDeltaEventNameTypedDict,
790
818
  ToolExecutionDeltaEventType,
791
819
  ToolExecutionDeltaEventTypedDict,
792
820
  )
793
821
  from .toolexecutiondoneevent import (
794
822
  ToolExecutionDoneEvent,
823
+ ToolExecutionDoneEventName,
824
+ ToolExecutionDoneEventNameTypedDict,
795
825
  ToolExecutionDoneEventType,
796
826
  ToolExecutionDoneEventTypedDict,
797
827
  )
798
828
  from .toolexecutionentry import (
829
+ Name,
830
+ NameTypedDict,
799
831
  ToolExecutionEntry,
800
832
  ToolExecutionEntryObject,
801
833
  ToolExecutionEntryType,
@@ -803,6 +835,8 @@ if TYPE_CHECKING:
803
835
  )
804
836
  from .toolexecutionstartedevent import (
805
837
  ToolExecutionStartedEvent,
838
+ ToolExecutionStartedEventName,
839
+ ToolExecutionStartedEventNameTypedDict,
806
840
  ToolExecutionStartedEventType,
807
841
  ToolExecutionStartedEventTypedDict,
808
842
  )
@@ -923,6 +957,8 @@ __all__ = [
923
957
  "AgentUpdateRequestTools",
924
958
  "AgentUpdateRequestToolsTypedDict",
925
959
  "AgentUpdateRequestTypedDict",
960
+ "AgentsAPIV1AgentsDeleteRequest",
961
+ "AgentsAPIV1AgentsDeleteRequestTypedDict",
926
962
  "AgentsAPIV1AgentsGetRequest",
927
963
  "AgentsAPIV1AgentsGetRequestTypedDict",
928
964
  "AgentsAPIV1AgentsListRequest",
@@ -935,6 +971,8 @@ __all__ = [
935
971
  "AgentsAPIV1ConversationsAppendRequestTypedDict",
936
972
  "AgentsAPIV1ConversationsAppendStreamRequest",
937
973
  "AgentsAPIV1ConversationsAppendStreamRequestTypedDict",
974
+ "AgentsAPIV1ConversationsDeleteRequest",
975
+ "AgentsAPIV1ConversationsDeleteRequestTypedDict",
938
976
  "AgentsAPIV1ConversationsGetRequest",
939
977
  "AgentsAPIV1ConversationsGetRequestTypedDict",
940
978
  "AgentsAPIV1ConversationsGetResponseV1ConversationsGet",
@@ -975,6 +1013,8 @@ __all__ = [
975
1013
  "AssistantMessageContentTypedDict",
976
1014
  "AssistantMessageRole",
977
1015
  "AssistantMessageTypedDict",
1016
+ "Attributes",
1017
+ "AttributesTypedDict",
978
1018
  "AudioChunk",
979
1019
  "AudioChunkType",
980
1020
  "AudioChunkTypedDict",
@@ -1206,6 +1246,7 @@ __all__ = [
1206
1246
  "FilesAPIRoutesUploadFileMultiPartBodyParamsTypedDict",
1207
1247
  "FineTuneableModelType",
1208
1248
  "FinishReason",
1249
+ "Format",
1209
1250
  "Function",
1210
1251
  "FunctionCall",
1211
1252
  "FunctionCallEntry",
@@ -1391,6 +1432,7 @@ __all__ = [
1391
1432
  "MessagesTypedDict",
1392
1433
  "MetricOut",
1393
1434
  "MetricOutTypedDict",
1435
+ "MistralError",
1394
1436
  "MistralPromptMode",
1395
1437
  "ModelCapabilities",
1396
1438
  "ModelCapabilitiesTypedDict",
@@ -1406,6 +1448,9 @@ __all__ = [
1406
1448
  "ModerationObjectTypedDict",
1407
1449
  "ModerationResponse",
1408
1450
  "ModerationResponseTypedDict",
1451
+ "Name",
1452
+ "NameTypedDict",
1453
+ "NoResponseError",
1409
1454
  "OCRImageObject",
1410
1455
  "OCRImageObjectTypedDict",
1411
1456
  "OCRPageDimensions",
@@ -1416,6 +1461,8 @@ __all__ = [
1416
1461
  "OCRRequestTypedDict",
1417
1462
  "OCRResponse",
1418
1463
  "OCRResponseTypedDict",
1464
+ "OCRTableObject",
1465
+ "OCRTableObjectTypedDict",
1419
1466
  "OCRUsageInfo",
1420
1467
  "OCRUsageInfoTypedDict",
1421
1468
  "Object",
@@ -1437,6 +1484,7 @@ __all__ = [
1437
1484
  "ReferenceChunkTypedDict",
1438
1485
  "Repositories",
1439
1486
  "RepositoriesTypedDict",
1487
+ "RequestSource",
1440
1488
  "Response1",
1441
1489
  "Response1TypedDict",
1442
1490
  "ResponseBody",
@@ -1453,6 +1501,7 @@ __all__ = [
1453
1501
  "ResponseStartedEvent",
1454
1502
  "ResponseStartedEventType",
1455
1503
  "ResponseStartedEventTypedDict",
1504
+ "ResponseValidationError",
1456
1505
  "RetrieveFileOut",
1457
1506
  "RetrieveFileOutTypedDict",
1458
1507
  "RetrieveModelV1ModelsModelIDGetRequest",
@@ -1482,6 +1531,7 @@ __all__ = [
1482
1531
  "SystemMessageContentChunksTypedDict",
1483
1532
  "SystemMessageContentTypedDict",
1484
1533
  "SystemMessageTypedDict",
1534
+ "TableFormat",
1485
1535
  "TextChunk",
1486
1536
  "TextChunkType",
1487
1537
  "TextChunkTypedDict",
@@ -1498,9 +1548,13 @@ __all__ = [
1498
1548
  "ToolChoiceEnum",
1499
1549
  "ToolChoiceTypedDict",
1500
1550
  "ToolExecutionDeltaEvent",
1551
+ "ToolExecutionDeltaEventName",
1552
+ "ToolExecutionDeltaEventNameTypedDict",
1501
1553
  "ToolExecutionDeltaEventType",
1502
1554
  "ToolExecutionDeltaEventTypedDict",
1503
1555
  "ToolExecutionDoneEvent",
1556
+ "ToolExecutionDoneEventName",
1557
+ "ToolExecutionDoneEventNameTypedDict",
1504
1558
  "ToolExecutionDoneEventType",
1505
1559
  "ToolExecutionDoneEventTypedDict",
1506
1560
  "ToolExecutionEntry",
@@ -1508,6 +1562,8 @@ __all__ = [
1508
1562
  "ToolExecutionEntryType",
1509
1563
  "ToolExecutionEntryTypedDict",
1510
1564
  "ToolExecutionStartedEvent",
1565
+ "ToolExecutionStartedEventName",
1566
+ "ToolExecutionStartedEventNameTypedDict",
1511
1567
  "ToolExecutionStartedEventType",
1512
1568
  "ToolExecutionStartedEventTypedDict",
1513
1569
  "ToolFileChunk",
@@ -1604,6 +1660,8 @@ _dynamic_imports: dict[str, str] = {
1604
1660
  "AgentHandoffStartedEvent": ".agenthandoffstartedevent",
1605
1661
  "AgentHandoffStartedEventType": ".agenthandoffstartedevent",
1606
1662
  "AgentHandoffStartedEventTypedDict": ".agenthandoffstartedevent",
1663
+ "AgentsAPIV1AgentsDeleteRequest": ".agents_api_v1_agents_deleteop",
1664
+ "AgentsAPIV1AgentsDeleteRequestTypedDict": ".agents_api_v1_agents_deleteop",
1607
1665
  "AgentsAPIV1AgentsGetRequest": ".agents_api_v1_agents_getop",
1608
1666
  "AgentsAPIV1AgentsGetRequestTypedDict": ".agents_api_v1_agents_getop",
1609
1667
  "AgentsAPIV1AgentsListRequest": ".agents_api_v1_agents_listop",
@@ -1616,6 +1674,8 @@ _dynamic_imports: dict[str, str] = {
1616
1674
  "AgentsAPIV1ConversationsAppendStreamRequestTypedDict": ".agents_api_v1_conversations_append_streamop",
1617
1675
  "AgentsAPIV1ConversationsAppendRequest": ".agents_api_v1_conversations_appendop",
1618
1676
  "AgentsAPIV1ConversationsAppendRequestTypedDict": ".agents_api_v1_conversations_appendop",
1677
+ "AgentsAPIV1ConversationsDeleteRequest": ".agents_api_v1_conversations_deleteop",
1678
+ "AgentsAPIV1ConversationsDeleteRequestTypedDict": ".agents_api_v1_conversations_deleteop",
1619
1679
  "AgentsAPIV1ConversationsGetRequest": ".agents_api_v1_conversations_getop",
1620
1680
  "AgentsAPIV1ConversationsGetRequestTypedDict": ".agents_api_v1_conversations_getop",
1621
1681
  "AgentsAPIV1ConversationsGetResponseV1ConversationsGet": ".agents_api_v1_conversations_getop",
@@ -1852,6 +1912,8 @@ _dynamic_imports: dict[str, str] = {
1852
1912
  "DocumentOutTypedDict": ".documentout",
1853
1913
  "DocumentTextContent": ".documenttextcontent",
1854
1914
  "DocumentTextContentTypedDict": ".documenttextcontent",
1915
+ "Attributes": ".documentupdatein",
1916
+ "AttributesTypedDict": ".documentupdatein",
1855
1917
  "DocumentUpdateIn": ".documentupdatein",
1856
1918
  "DocumentUpdateInTypedDict": ".documentupdatein",
1857
1919
  "DocumentURLChunk": ".documenturlchunk",
@@ -2107,6 +2169,7 @@ _dynamic_imports: dict[str, str] = {
2107
2169
  "ModerationObjectTypedDict": ".moderationobject",
2108
2170
  "ModerationResponse": ".moderationresponse",
2109
2171
  "ModerationResponseTypedDict": ".moderationresponse",
2172
+ "NoResponseError": ".no_response_error",
2110
2173
  "OCRImageObject": ".ocrimageobject",
2111
2174
  "OCRImageObjectTypedDict": ".ocrimageobject",
2112
2175
  "OCRPageDimensions": ".ocrpagedimensions",
@@ -2117,8 +2180,12 @@ _dynamic_imports: dict[str, str] = {
2117
2180
  "DocumentTypedDict": ".ocrrequest",
2118
2181
  "OCRRequest": ".ocrrequest",
2119
2182
  "OCRRequestTypedDict": ".ocrrequest",
2183
+ "TableFormat": ".ocrrequest",
2120
2184
  "OCRResponse": ".ocrresponse",
2121
2185
  "OCRResponseTypedDict": ".ocrresponse",
2186
+ "Format": ".ocrtableobject",
2187
+ "OCRTableObject": ".ocrtableobject",
2188
+ "OCRTableObjectTypedDict": ".ocrtableobject",
2122
2189
  "OCRUsageInfo": ".ocrusageinfo",
2123
2190
  "OCRUsageInfoTypedDict": ".ocrusageinfo",
2124
2191
  "OutputContentChunks": ".outputcontentchunks",
@@ -2132,6 +2199,7 @@ _dynamic_imports: dict[str, str] = {
2132
2199
  "ReferenceChunk": ".referencechunk",
2133
2200
  "ReferenceChunkType": ".referencechunk",
2134
2201
  "ReferenceChunkTypedDict": ".referencechunk",
2202
+ "RequestSource": ".requestsource",
2135
2203
  "ResponseDoneEvent": ".responsedoneevent",
2136
2204
  "ResponseDoneEventType": ".responsedoneevent",
2137
2205
  "ResponseDoneEventTypedDict": ".responsedoneevent",
@@ -2144,6 +2212,7 @@ _dynamic_imports: dict[str, str] = {
2144
2212
  "ResponseStartedEvent": ".responsestartedevent",
2145
2213
  "ResponseStartedEventType": ".responsestartedevent",
2146
2214
  "ResponseStartedEventTypedDict": ".responsestartedevent",
2215
+ "ResponseValidationError": ".responsevalidationerror",
2147
2216
  "RetrieveModelV1ModelsModelIDGetRequest": ".retrieve_model_v1_models_model_id_getop",
2148
2217
  "RetrieveModelV1ModelsModelIDGetRequestTypedDict": ".retrieve_model_v1_models_model_id_getop",
2149
2218
  "RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet": ".retrieve_model_v1_models_model_id_getop",
@@ -2187,16 +2256,24 @@ _dynamic_imports: dict[str, str] = {
2187
2256
  "ToolChoiceTypedDict": ".toolchoice",
2188
2257
  "ToolChoiceEnum": ".toolchoiceenum",
2189
2258
  "ToolExecutionDeltaEvent": ".toolexecutiondeltaevent",
2259
+ "ToolExecutionDeltaEventName": ".toolexecutiondeltaevent",
2260
+ "ToolExecutionDeltaEventNameTypedDict": ".toolexecutiondeltaevent",
2190
2261
  "ToolExecutionDeltaEventType": ".toolexecutiondeltaevent",
2191
2262
  "ToolExecutionDeltaEventTypedDict": ".toolexecutiondeltaevent",
2192
2263
  "ToolExecutionDoneEvent": ".toolexecutiondoneevent",
2264
+ "ToolExecutionDoneEventName": ".toolexecutiondoneevent",
2265
+ "ToolExecutionDoneEventNameTypedDict": ".toolexecutiondoneevent",
2193
2266
  "ToolExecutionDoneEventType": ".toolexecutiondoneevent",
2194
2267
  "ToolExecutionDoneEventTypedDict": ".toolexecutiondoneevent",
2268
+ "Name": ".toolexecutionentry",
2269
+ "NameTypedDict": ".toolexecutionentry",
2195
2270
  "ToolExecutionEntry": ".toolexecutionentry",
2196
2271
  "ToolExecutionEntryObject": ".toolexecutionentry",
2197
2272
  "ToolExecutionEntryType": ".toolexecutionentry",
2198
2273
  "ToolExecutionEntryTypedDict": ".toolexecutionentry",
2199
2274
  "ToolExecutionStartedEvent": ".toolexecutionstartedevent",
2275
+ "ToolExecutionStartedEventName": ".toolexecutionstartedevent",
2276
+ "ToolExecutionStartedEventNameTypedDict": ".toolexecutionstartedevent",
2200
2277
  "ToolExecutionStartedEventType": ".toolexecutionstartedevent",
2201
2278
  "ToolExecutionStartedEventTypedDict": ".toolexecutionstartedevent",
2202
2279
  "ToolFileChunk": ".toolfilechunk",
@@ -2268,6 +2345,18 @@ _dynamic_imports: dict[str, str] = {
2268
2345
  }
2269
2346
 
2270
2347
 
2348
+ def dynamic_import(modname, retries=3):
2349
+ for attempt in range(retries):
2350
+ try:
2351
+ return import_module(modname, __package__)
2352
+ except KeyError:
2353
+ # Clear any half-initialized module and retry
2354
+ sys.modules.pop(modname, None)
2355
+ if attempt == retries - 1:
2356
+ break
2357
+ raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
2358
+
2359
+
2271
2360
  def __getattr__(attr_name: str) -> object:
2272
2361
  module_name = _dynamic_imports.get(attr_name)
2273
2362
  if module_name is None:
@@ -2276,7 +2365,7 @@ def __getattr__(attr_name: str) -> object:
2276
2365
  )
2277
2366
 
2278
2367
  try:
2279
- module = import_module(module_name, __package__)
2368
+ module = dynamic_import(module_name)
2280
2369
  result = getattr(module, attr_name)
2281
2370
  return result
2282
2371
  except ImportError as e:
@@ -2290,5 +2379,5 @@ def __getattr__(attr_name: str) -> object:
2290
2379
 
2291
2380
 
2292
2381
  def __dir__():
2293
- lazy_attrs = list(_dynamic_imports.keys())
2294
- return sorted(lazy_attrs)
2382
+ lazy_attrs = builtins.list(_dynamic_imports.keys())
2383
+ return builtins.sorted(lazy_attrs)