mistralai 1.9.11__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 (68) hide show
  1. mistralai/_hooks/registration.py +5 -0
  2. mistralai/_hooks/tracing.py +50 -0
  3. mistralai/_version.py +2 -2
  4. mistralai/accesses.py +8 -8
  5. mistralai/agents.py +29 -17
  6. mistralai/chat.py +41 -29
  7. mistralai/conversations.py +294 -62
  8. mistralai/documents.py +19 -3
  9. mistralai/embeddings.py +6 -6
  10. mistralai/extra/observability/__init__.py +15 -0
  11. mistralai/extra/observability/otel.py +393 -0
  12. mistralai/extra/run/tools.py +28 -16
  13. mistralai/files.py +6 -0
  14. mistralai/fim.py +17 -5
  15. mistralai/mistral_agents.py +229 -1
  16. mistralai/mistral_jobs.py +10 -10
  17. mistralai/models/__init__.py +69 -2
  18. mistralai/models/agent.py +15 -2
  19. mistralai/models/agentconversation.py +11 -3
  20. mistralai/models/agentcreationrequest.py +6 -2
  21. mistralai/models/agents_api_v1_agents_deleteop.py +16 -0
  22. mistralai/models/agents_api_v1_agents_getop.py +40 -3
  23. mistralai/models/agents_api_v1_agents_listop.py +72 -2
  24. mistralai/models/agents_api_v1_conversations_deleteop.py +18 -0
  25. mistralai/models/agents_api_v1_conversations_listop.py +39 -2
  26. mistralai/models/agentscompletionrequest.py +21 -6
  27. mistralai/models/agentscompletionstreamrequest.py +21 -6
  28. mistralai/models/agentupdaterequest.py +18 -2
  29. mistralai/models/audiotranscriptionrequest.py +2 -0
  30. mistralai/models/batchjobin.py +10 -0
  31. mistralai/models/chatcompletionrequest.py +22 -5
  32. mistralai/models/chatcompletionstreamrequest.py +22 -5
  33. mistralai/models/conversationrequest.py +15 -4
  34. mistralai/models/conversationrestartrequest.py +50 -2
  35. mistralai/models/conversationrestartstreamrequest.py +50 -2
  36. mistralai/models/conversationstreamrequest.py +15 -4
  37. mistralai/models/documentout.py +26 -10
  38. mistralai/models/documentupdatein.py +24 -3
  39. mistralai/models/embeddingrequest.py +8 -8
  40. mistralai/models/files_api_routes_list_filesop.py +7 -0
  41. mistralai/models/fimcompletionrequest.py +8 -9
  42. mistralai/models/fimcompletionstreamrequest.py +8 -9
  43. mistralai/models/libraries_documents_list_v1op.py +15 -2
  44. mistralai/models/libraryout.py +10 -7
  45. mistralai/models/listfilesout.py +35 -4
  46. mistralai/models/modelcapabilities.py +13 -4
  47. mistralai/models/modelconversation.py +8 -2
  48. mistralai/models/ocrpageobject.py +26 -5
  49. mistralai/models/ocrrequest.py +17 -1
  50. mistralai/models/ocrtableobject.py +31 -0
  51. mistralai/models/prediction.py +4 -0
  52. mistralai/models/requestsource.py +7 -0
  53. mistralai/models/responseformat.py +4 -2
  54. mistralai/models/responseformats.py +0 -1
  55. mistralai/models/sharingdelete.py +36 -5
  56. mistralai/models/sharingin.py +36 -5
  57. mistralai/models/sharingout.py +3 -3
  58. mistralai/models/toolexecutiondeltaevent.py +13 -4
  59. mistralai/models/toolexecutiondoneevent.py +13 -4
  60. mistralai/models/toolexecutionentry.py +9 -4
  61. mistralai/models/toolexecutionstartedevent.py +13 -4
  62. mistralai/models_.py +2 -14
  63. mistralai/ocr.py +18 -0
  64. mistralai/transcriptions.py +4 -4
  65. {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/METADATA +30 -12
  66. {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/RECORD +68 -61
  67. {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/WHEEL +0 -0
  68. {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/licenses/LICENSE +0 -0
@@ -8,22 +8,31 @@ from typing_extensions import NotRequired, TypedDict
8
8
 
9
9
  class ModelCapabilitiesTypedDict(TypedDict):
10
10
  completion_chat: NotRequired[bool]
11
- completion_fim: NotRequired[bool]
12
11
  function_calling: NotRequired[bool]
12
+ completion_fim: NotRequired[bool]
13
13
  fine_tuning: NotRequired[bool]
14
14
  vision: NotRequired[bool]
15
+ ocr: NotRequired[bool]
15
16
  classification: NotRequired[bool]
17
+ moderation: NotRequired[bool]
18
+ audio: NotRequired[bool]
16
19
 
17
20
 
18
21
  class ModelCapabilities(BaseModel):
19
- completion_chat: Optional[bool] = True
22
+ completion_chat: Optional[bool] = False
20
23
 
21
- completion_fim: Optional[bool] = False
24
+ function_calling: Optional[bool] = False
22
25
 
23
- function_calling: Optional[bool] = True
26
+ completion_fim: Optional[bool] = False
24
27
 
25
28
  fine_tuning: Optional[bool] = False
26
29
 
27
30
  vision: Optional[bool] = False
28
31
 
32
+ ocr: Optional[bool] = False
33
+
29
34
  classification: Optional[bool] = False
35
+
36
+ moderation: Optional[bool] = False
37
+
38
+ audio: Optional[bool] = False
@@ -12,7 +12,7 @@ from datetime import datetime
12
12
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
13
13
  from mistralai.utils import get_discriminator
14
14
  from pydantic import Discriminator, Tag, model_serializer
15
- from typing import List, Literal, Optional, Union
15
+ from typing import Any, Dict, List, Literal, Optional, Union
16
16
  from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
17
17
 
18
18
 
@@ -60,6 +60,8 @@ class ModelConversationTypedDict(TypedDict):
60
60
  r"""Name given to the conversation."""
61
61
  description: NotRequired[Nullable[str]]
62
62
  r"""Description of the what the conversation is about."""
63
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
64
+ r"""Custom metadata for the conversation."""
63
65
  object: NotRequired[ModelConversationObject]
64
66
 
65
67
 
@@ -87,6 +89,9 @@ class ModelConversation(BaseModel):
87
89
  description: OptionalNullable[str] = UNSET
88
90
  r"""Description of the what the conversation is about."""
89
91
 
92
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET
93
+ r"""Custom metadata for the conversation."""
94
+
90
95
  object: Optional[ModelConversationObject] = "conversation"
91
96
 
92
97
  @model_serializer(mode="wrap")
@@ -97,9 +102,10 @@ class ModelConversation(BaseModel):
97
102
  "completion_args",
98
103
  "name",
99
104
  "description",
105
+ "metadata",
100
106
  "object",
101
107
  ]
102
- nullable_fields = ["instructions", "name", "description"]
108
+ nullable_fields = ["instructions", "name", "description", "metadata"]
103
109
  null_default_fields = []
104
110
 
105
111
  serialized = handler(self)
@@ -3,10 +3,11 @@
3
3
  from __future__ import annotations
4
4
  from .ocrimageobject import OCRImageObject, OCRImageObjectTypedDict
5
5
  from .ocrpagedimensions import OCRPageDimensions, OCRPageDimensionsTypedDict
6
- from mistralai.types import BaseModel, Nullable, UNSET_SENTINEL
6
+ from .ocrtableobject import OCRTableObject, OCRTableObjectTypedDict
7
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
7
8
  from pydantic import model_serializer
8
- from typing import List
9
- from typing_extensions import TypedDict
9
+ from typing import List, Optional
10
+ from typing_extensions import NotRequired, TypedDict
10
11
 
11
12
 
12
13
  class OCRPageObjectTypedDict(TypedDict):
@@ -18,6 +19,14 @@ class OCRPageObjectTypedDict(TypedDict):
18
19
  r"""List of all extracted images in the page"""
19
20
  dimensions: Nullable[OCRPageDimensionsTypedDict]
20
21
  r"""The dimensions of the PDF Page's screenshot image"""
22
+ tables: NotRequired[List[OCRTableObjectTypedDict]]
23
+ r"""List of all extracted tables in the page"""
24
+ hyperlinks: NotRequired[List[str]]
25
+ r"""List of all hyperlinks in the page"""
26
+ header: NotRequired[Nullable[str]]
27
+ r"""Header of the page"""
28
+ footer: NotRequired[Nullable[str]]
29
+ r"""Footer of the page"""
21
30
 
22
31
 
23
32
  class OCRPageObject(BaseModel):
@@ -33,10 +42,22 @@ class OCRPageObject(BaseModel):
33
42
  dimensions: Nullable[OCRPageDimensions]
34
43
  r"""The dimensions of the PDF Page's screenshot image"""
35
44
 
45
+ tables: Optional[List[OCRTableObject]] = None
46
+ r"""List of all extracted tables in the page"""
47
+
48
+ hyperlinks: Optional[List[str]] = None
49
+ r"""List of all hyperlinks in the page"""
50
+
51
+ header: OptionalNullable[str] = UNSET
52
+ r"""Header of the page"""
53
+
54
+ footer: OptionalNullable[str] = UNSET
55
+ r"""Footer of the page"""
56
+
36
57
  @model_serializer(mode="wrap")
37
58
  def serialize_model(self, handler):
38
- optional_fields = []
39
- nullable_fields = ["dimensions"]
59
+ optional_fields = ["tables", "hyperlinks", "header", "footer"]
60
+ nullable_fields = ["header", "footer", "dimensions"]
40
61
  null_default_fields = []
41
62
 
42
63
  serialized = handler(self)
@@ -7,7 +7,7 @@ from .imageurlchunk import ImageURLChunk, ImageURLChunkTypedDict
7
7
  from .responseformat import ResponseFormat, ResponseFormatTypedDict
8
8
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
9
9
  from pydantic import model_serializer
10
- from typing import List, Optional, Union
10
+ from typing import List, Literal, Optional, Union
11
11
  from typing_extensions import NotRequired, TypeAliasType, TypedDict
12
12
 
13
13
 
@@ -22,6 +22,9 @@ Document = TypeAliasType("Document", Union[FileChunk, ImageURLChunk, DocumentURL
22
22
  r"""Document to run OCR on"""
23
23
 
24
24
 
25
+ TableFormat = Literal["markdown", "html"]
26
+
27
+
25
28
  class OCRRequestTypedDict(TypedDict):
26
29
  model: Nullable[str]
27
30
  document: DocumentTypedDict
@@ -39,6 +42,9 @@ class OCRRequestTypedDict(TypedDict):
39
42
  r"""Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field"""
40
43
  document_annotation_format: NotRequired[Nullable[ResponseFormatTypedDict]]
41
44
  r"""Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field"""
45
+ table_format: NotRequired[Nullable[TableFormat]]
46
+ extract_header: NotRequired[bool]
47
+ extract_footer: NotRequired[bool]
42
48
 
43
49
 
44
50
  class OCRRequest(BaseModel):
@@ -67,6 +73,12 @@ class OCRRequest(BaseModel):
67
73
  document_annotation_format: OptionalNullable[ResponseFormat] = UNSET
68
74
  r"""Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field"""
69
75
 
76
+ table_format: OptionalNullable[TableFormat] = UNSET
77
+
78
+ extract_header: Optional[bool] = None
79
+
80
+ extract_footer: Optional[bool] = None
81
+
70
82
  @model_serializer(mode="wrap")
71
83
  def serialize_model(self, handler):
72
84
  optional_fields = [
@@ -77,6 +89,9 @@ class OCRRequest(BaseModel):
77
89
  "image_min_size",
78
90
  "bbox_annotation_format",
79
91
  "document_annotation_format",
92
+ "table_format",
93
+ "extract_header",
94
+ "extract_footer",
80
95
  ]
81
96
  nullable_fields = [
82
97
  "model",
@@ -86,6 +101,7 @@ class OCRRequest(BaseModel):
86
101
  "image_min_size",
87
102
  "bbox_annotation_format",
88
103
  "document_annotation_format",
104
+ "table_format",
89
105
  ]
90
106
  null_default_fields = []
91
107
 
@@ -0,0 +1,31 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from mistralai.types import BaseModel
5
+ import pydantic
6
+ from typing import Literal
7
+ from typing_extensions import Annotated, TypedDict
8
+
9
+
10
+ Format = Literal["markdown", "html"]
11
+ r"""Format of the table"""
12
+
13
+
14
+ class OCRTableObjectTypedDict(TypedDict):
15
+ id: str
16
+ r"""Table ID for extracted table in a page"""
17
+ content: str
18
+ r"""Content of the table in the given format"""
19
+ format_: Format
20
+ r"""Format of the table"""
21
+
22
+
23
+ class OCRTableObject(BaseModel):
24
+ id: str
25
+ r"""Table ID for extracted table in a page"""
26
+
27
+ content: str
28
+ r"""Content of the table in the given format"""
29
+
30
+ format_: Annotated[Format, pydantic.Field(alias="format")]
31
+ r"""Format of the table"""
@@ -10,11 +10,15 @@ from typing_extensions import Annotated, NotRequired, TypedDict
10
10
 
11
11
 
12
12
  class PredictionTypedDict(TypedDict):
13
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
14
+
13
15
  type: Literal["content"]
14
16
  content: NotRequired[str]
15
17
 
16
18
 
17
19
  class Prediction(BaseModel):
20
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
21
+
18
22
  TYPE: Annotated[
19
23
  Annotated[
20
24
  Optional[Literal["content"]], AfterValidator(validate_const("content"))
@@ -0,0 +1,7 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Literal
5
+
6
+
7
+ RequestSource = Literal["api", "playground", "agent_builder_v1"]
@@ -10,14 +10,16 @@ from typing_extensions import NotRequired, TypedDict
10
10
 
11
11
 
12
12
  class ResponseFormatTypedDict(TypedDict):
13
+ r"""Specify the format that the model must output. By default it will use `{ \"type\": \"text\" }`. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ \"type\": \"json_schema\" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide."""
14
+
13
15
  type: NotRequired[ResponseFormats]
14
- r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
15
16
  json_schema: NotRequired[Nullable[JSONSchemaTypedDict]]
16
17
 
17
18
 
18
19
  class ResponseFormat(BaseModel):
20
+ r"""Specify the format that the model must output. By default it will use `{ \"type\": \"text\" }`. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ \"type\": \"json_schema\" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide."""
21
+
19
22
  type: Optional[ResponseFormats] = None
20
- r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
21
23
 
22
24
  json_schema: OptionalNullable[JSONSchema] = UNSET
23
25
 
@@ -5,4 +5,3 @@ from typing import Literal
5
5
 
6
6
 
7
7
  ResponseFormats = Literal["text", "json_object", "json_schema"]
8
- r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
@@ -2,25 +2,56 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from .entitytype import EntityType
5
- from mistralai.types import BaseModel
5
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
6
6
  from mistralai.utils import validate_open_enum
7
+ from pydantic import model_serializer
7
8
  from pydantic.functional_validators import PlainValidator
8
- from typing_extensions import Annotated, TypedDict
9
+ from typing_extensions import Annotated, NotRequired, TypedDict
9
10
 
10
11
 
11
12
  class SharingDeleteTypedDict(TypedDict):
12
- org_id: str
13
13
  share_with_uuid: str
14
14
  r"""The id of the entity (user, workspace or organization) to share with"""
15
15
  share_with_type: EntityType
16
16
  r"""The type of entity, used to share a library."""
17
+ org_id: NotRequired[Nullable[str]]
17
18
 
18
19
 
19
20
  class SharingDelete(BaseModel):
20
- org_id: str
21
-
22
21
  share_with_uuid: str
23
22
  r"""The id of the entity (user, workspace or organization) to share with"""
24
23
 
25
24
  share_with_type: Annotated[EntityType, PlainValidator(validate_open_enum(False))]
26
25
  r"""The type of entity, used to share a library."""
26
+
27
+ org_id: OptionalNullable[str] = UNSET
28
+
29
+ @model_serializer(mode="wrap")
30
+ def serialize_model(self, handler):
31
+ optional_fields = ["org_id"]
32
+ nullable_fields = ["org_id"]
33
+ null_default_fields = []
34
+
35
+ serialized = handler(self)
36
+
37
+ m = {}
38
+
39
+ for n, f in type(self).model_fields.items():
40
+ k = f.alias or n
41
+ val = serialized.get(k)
42
+ serialized.pop(k, None)
43
+
44
+ optional_nullable = k in optional_fields and k in nullable_fields
45
+ is_set = (
46
+ self.__pydantic_fields_set__.intersection({n})
47
+ or k in null_default_fields
48
+ ) # pylint: disable=no-member
49
+
50
+ if val is not None and val != UNSET_SENTINEL:
51
+ m[k] = val
52
+ elif val != UNSET_SENTINEL and (
53
+ not k in optional_fields or (optional_nullable and is_set)
54
+ ):
55
+ m[k] = val
56
+
57
+ return m
@@ -3,24 +3,23 @@
3
3
  from __future__ import annotations
4
4
  from .entitytype import EntityType
5
5
  from .shareenum import ShareEnum
6
- from mistralai.types import BaseModel
6
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
7
7
  from mistralai.utils import validate_open_enum
8
+ from pydantic import model_serializer
8
9
  from pydantic.functional_validators import PlainValidator
9
- from typing_extensions import Annotated, TypedDict
10
+ from typing_extensions import Annotated, NotRequired, TypedDict
10
11
 
11
12
 
12
13
  class SharingInTypedDict(TypedDict):
13
- org_id: str
14
14
  level: ShareEnum
15
15
  share_with_uuid: str
16
16
  r"""The id of the entity (user, workspace or organization) to share with"""
17
17
  share_with_type: EntityType
18
18
  r"""The type of entity, used to share a library."""
19
+ org_id: NotRequired[Nullable[str]]
19
20
 
20
21
 
21
22
  class SharingIn(BaseModel):
22
- org_id: str
23
-
24
23
  level: Annotated[ShareEnum, PlainValidator(validate_open_enum(False))]
25
24
 
26
25
  share_with_uuid: str
@@ -28,3 +27,35 @@ class SharingIn(BaseModel):
28
27
 
29
28
  share_with_type: Annotated[EntityType, PlainValidator(validate_open_enum(False))]
30
29
  r"""The type of entity, used to share a library."""
30
+
31
+ org_id: OptionalNullable[str] = UNSET
32
+
33
+ @model_serializer(mode="wrap")
34
+ def serialize_model(self, handler):
35
+ optional_fields = ["org_id"]
36
+ nullable_fields = ["org_id"]
37
+ null_default_fields = []
38
+
39
+ serialized = handler(self)
40
+
41
+ m = {}
42
+
43
+ for n, f in type(self).model_fields.items():
44
+ k = f.alias or n
45
+ val = serialized.get(k)
46
+ serialized.pop(k, None)
47
+
48
+ optional_nullable = k in optional_fields and k in nullable_fields
49
+ is_set = (
50
+ self.__pydantic_fields_set__.intersection({n})
51
+ or k in null_default_fields
52
+ ) # pylint: disable=no-member
53
+
54
+ if val is not None and val != UNSET_SENTINEL:
55
+ m[k] = val
56
+ elif val != UNSET_SENTINEL and (
57
+ not k in optional_fields or (optional_nullable and is_set)
58
+ ):
59
+ m[k] = val
60
+
61
+ return m
@@ -11,7 +11,7 @@ class SharingOutTypedDict(TypedDict):
11
11
  org_id: str
12
12
  role: str
13
13
  share_with_type: str
14
- share_with_uuid: str
14
+ share_with_uuid: Nullable[str]
15
15
  user_id: NotRequired[Nullable[str]]
16
16
 
17
17
 
@@ -24,14 +24,14 @@ class SharingOut(BaseModel):
24
24
 
25
25
  share_with_type: str
26
26
 
27
- share_with_uuid: str
27
+ share_with_uuid: Nullable[str]
28
28
 
29
29
  user_id: OptionalNullable[str] = UNSET
30
30
 
31
31
  @model_serializer(mode="wrap")
32
32
  def serialize_model(self, handler):
33
33
  optional_fields = ["user_id"]
34
- nullable_fields = ["user_id"]
34
+ nullable_fields = ["user_id", "share_with_uuid"]
35
35
  null_default_fields = []
36
36
 
37
37
  serialized = handler(self)
@@ -4,16 +4,25 @@ from __future__ import annotations
4
4
  from .builtinconnectors import BuiltInConnectors
5
5
  from datetime import datetime
6
6
  from mistralai.types import BaseModel
7
- from typing import Literal, Optional
8
- from typing_extensions import NotRequired, TypedDict
7
+ from typing import Literal, Optional, Union
8
+ from typing_extensions import NotRequired, TypeAliasType, TypedDict
9
9
 
10
10
 
11
11
  ToolExecutionDeltaEventType = Literal["tool.execution.delta"]
12
12
 
13
+ ToolExecutionDeltaEventNameTypedDict = TypeAliasType(
14
+ "ToolExecutionDeltaEventNameTypedDict", Union[BuiltInConnectors, str]
15
+ )
16
+
17
+
18
+ ToolExecutionDeltaEventName = TypeAliasType(
19
+ "ToolExecutionDeltaEventName", Union[BuiltInConnectors, str]
20
+ )
21
+
13
22
 
14
23
  class ToolExecutionDeltaEventTypedDict(TypedDict):
15
24
  id: str
16
- name: BuiltInConnectors
25
+ name: ToolExecutionDeltaEventNameTypedDict
17
26
  arguments: str
18
27
  type: NotRequired[ToolExecutionDeltaEventType]
19
28
  created_at: NotRequired[datetime]
@@ -23,7 +32,7 @@ class ToolExecutionDeltaEventTypedDict(TypedDict):
23
32
  class ToolExecutionDeltaEvent(BaseModel):
24
33
  id: str
25
34
 
26
- name: BuiltInConnectors
35
+ name: ToolExecutionDeltaEventName
27
36
 
28
37
  arguments: str
29
38
 
@@ -4,16 +4,25 @@ from __future__ import annotations
4
4
  from .builtinconnectors import BuiltInConnectors
5
5
  from datetime import datetime
6
6
  from mistralai.types import BaseModel
7
- from typing import Any, Dict, Literal, Optional
8
- from typing_extensions import NotRequired, TypedDict
7
+ from typing import Any, Dict, Literal, Optional, Union
8
+ from typing_extensions import NotRequired, TypeAliasType, TypedDict
9
9
 
10
10
 
11
11
  ToolExecutionDoneEventType = Literal["tool.execution.done"]
12
12
 
13
+ ToolExecutionDoneEventNameTypedDict = TypeAliasType(
14
+ "ToolExecutionDoneEventNameTypedDict", Union[BuiltInConnectors, str]
15
+ )
16
+
17
+
18
+ ToolExecutionDoneEventName = TypeAliasType(
19
+ "ToolExecutionDoneEventName", Union[BuiltInConnectors, str]
20
+ )
21
+
13
22
 
14
23
  class ToolExecutionDoneEventTypedDict(TypedDict):
15
24
  id: str
16
- name: BuiltInConnectors
25
+ name: ToolExecutionDoneEventNameTypedDict
17
26
  type: NotRequired[ToolExecutionDoneEventType]
18
27
  created_at: NotRequired[datetime]
19
28
  output_index: NotRequired[int]
@@ -23,7 +32,7 @@ class ToolExecutionDoneEventTypedDict(TypedDict):
23
32
  class ToolExecutionDoneEvent(BaseModel):
24
33
  id: str
25
34
 
26
- name: BuiltInConnectors
35
+ name: ToolExecutionDoneEventName
27
36
 
28
37
  type: Optional[ToolExecutionDoneEventType] = "tool.execution.done"
29
38
 
@@ -5,17 +5,22 @@ from .builtinconnectors import BuiltInConnectors
5
5
  from datetime import datetime
6
6
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
7
7
  from pydantic import model_serializer
8
- from typing import Any, Dict, Literal, Optional
9
- from typing_extensions import NotRequired, TypedDict
8
+ from typing import Any, Dict, Literal, Optional, Union
9
+ from typing_extensions import NotRequired, TypeAliasType, TypedDict
10
10
 
11
11
 
12
12
  ToolExecutionEntryObject = Literal["entry"]
13
13
 
14
14
  ToolExecutionEntryType = Literal["tool.execution"]
15
15
 
16
+ NameTypedDict = TypeAliasType("NameTypedDict", Union[BuiltInConnectors, str])
17
+
18
+
19
+ Name = TypeAliasType("Name", Union[BuiltInConnectors, str])
20
+
16
21
 
17
22
  class ToolExecutionEntryTypedDict(TypedDict):
18
- name: BuiltInConnectors
23
+ name: NameTypedDict
19
24
  arguments: str
20
25
  object: NotRequired[ToolExecutionEntryObject]
21
26
  type: NotRequired[ToolExecutionEntryType]
@@ -26,7 +31,7 @@ class ToolExecutionEntryTypedDict(TypedDict):
26
31
 
27
32
 
28
33
  class ToolExecutionEntry(BaseModel):
29
- name: BuiltInConnectors
34
+ name: Name
30
35
 
31
36
  arguments: str
32
37
 
@@ -4,16 +4,25 @@ from __future__ import annotations
4
4
  from .builtinconnectors import BuiltInConnectors
5
5
  from datetime import datetime
6
6
  from mistralai.types import BaseModel
7
- from typing import Literal, Optional
8
- from typing_extensions import NotRequired, TypedDict
7
+ from typing import Literal, Optional, Union
8
+ from typing_extensions import NotRequired, TypeAliasType, TypedDict
9
9
 
10
10
 
11
11
  ToolExecutionStartedEventType = Literal["tool.execution.started"]
12
12
 
13
+ ToolExecutionStartedEventNameTypedDict = TypeAliasType(
14
+ "ToolExecutionStartedEventNameTypedDict", Union[BuiltInConnectors, str]
15
+ )
16
+
17
+
18
+ ToolExecutionStartedEventName = TypeAliasType(
19
+ "ToolExecutionStartedEventName", Union[BuiltInConnectors, str]
20
+ )
21
+
13
22
 
14
23
  class ToolExecutionStartedEventTypedDict(TypedDict):
15
24
  id: str
16
- name: BuiltInConnectors
25
+ name: ToolExecutionStartedEventNameTypedDict
17
26
  arguments: str
18
27
  type: NotRequired[ToolExecutionStartedEventType]
19
28
  created_at: NotRequired[datetime]
@@ -23,7 +32,7 @@ class ToolExecutionStartedEventTypedDict(TypedDict):
23
32
  class ToolExecutionStartedEvent(BaseModel):
24
33
  id: str
25
34
 
26
- name: BuiltInConnectors
35
+ name: ToolExecutionStartedEventName
27
36
 
28
37
  arguments: str
29
38
 
mistralai/models_.py CHANGED
@@ -73,18 +73,12 @@ class Models(BaseSDK):
73
73
  ),
74
74
  ),
75
75
  request=req,
76
- error_status_codes=["422", "4XX", "5XX"],
76
+ error_status_codes=["4XX", "5XX"],
77
77
  retry_config=retry_config,
78
78
  )
79
79
 
80
- response_data: Any = None
81
80
  if utils.match_response(http_res, "200", "application/json"):
82
81
  return unmarshal_json_response(models.ModelList, http_res)
83
- if utils.match_response(http_res, "422", "application/json"):
84
- response_data = unmarshal_json_response(
85
- models.HTTPValidationErrorData, http_res
86
- )
87
- raise models.HTTPValidationError(response_data, http_res)
88
82
  if utils.match_response(http_res, "4XX", "*"):
89
83
  http_res_text = utils.stream_to_text(http_res)
90
84
  raise models.SDKError("API error occurred", http_res, http_res_text)
@@ -155,18 +149,12 @@ class Models(BaseSDK):
155
149
  ),
156
150
  ),
157
151
  request=req,
158
- error_status_codes=["422", "4XX", "5XX"],
152
+ error_status_codes=["4XX", "5XX"],
159
153
  retry_config=retry_config,
160
154
  )
161
155
 
162
- response_data: Any = None
163
156
  if utils.match_response(http_res, "200", "application/json"):
164
157
  return unmarshal_json_response(models.ModelList, http_res)
165
- if utils.match_response(http_res, "422", "application/json"):
166
- response_data = unmarshal_json_response(
167
- models.HTTPValidationErrorData, http_res
168
- )
169
- raise models.HTTPValidationError(response_data, http_res)
170
158
  if utils.match_response(http_res, "4XX", "*"):
171
159
  http_res_text = await utils.stream_to_text_async(http_res)
172
160
  raise models.SDKError("API error occurred", http_res, http_res_text)