mistralai 1.10.1__py3-none-any.whl → 1.11.1__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 (233) hide show
  1. mistralai/_version.py +3 -3
  2. mistralai/accesses.py +22 -12
  3. mistralai/agents.py +88 -44
  4. mistralai/basesdk.py +6 -0
  5. mistralai/chat.py +96 -40
  6. mistralai/classifiers.py +35 -22
  7. mistralai/conversations.py +186 -64
  8. mistralai/documents.py +72 -26
  9. mistralai/embeddings.py +17 -8
  10. mistralai/files.py +58 -24
  11. mistralai/fim.py +20 -12
  12. mistralai/httpclient.py +0 -1
  13. mistralai/jobs.py +65 -26
  14. mistralai/libraries.py +20 -10
  15. mistralai/mistral_agents.py +438 -30
  16. mistralai/mistral_jobs.py +33 -14
  17. mistralai/models/__init__.py +16 -0
  18. mistralai/models/agent.py +1 -1
  19. mistralai/models/agentconversation.py +1 -1
  20. mistralai/models/agenthandoffdoneevent.py +1 -1
  21. mistralai/models/agenthandoffentry.py +3 -2
  22. mistralai/models/agenthandoffstartedevent.py +1 -1
  23. mistralai/models/agents_api_v1_agents_get_versionop.py +21 -0
  24. mistralai/models/agents_api_v1_agents_list_versionsop.py +33 -0
  25. mistralai/models/agents_api_v1_agents_listop.py +4 -0
  26. mistralai/models/agentscompletionrequest.py +2 -5
  27. mistralai/models/agentscompletionstreamrequest.py +2 -5
  28. mistralai/models/archiveftmodelout.py +1 -1
  29. mistralai/models/assistantmessage.py +1 -1
  30. mistralai/models/audiochunk.py +1 -1
  31. mistralai/models/audioencoding.py +6 -1
  32. mistralai/models/audioformat.py +2 -4
  33. mistralai/models/basemodelcard.py +1 -1
  34. mistralai/models/batchjobin.py +2 -4
  35. mistralai/models/batchjobout.py +1 -1
  36. mistralai/models/batchjobsout.py +1 -1
  37. mistralai/models/chatcompletionchoice.py +10 -5
  38. mistralai/models/chatcompletionrequest.py +2 -5
  39. mistralai/models/chatcompletionstreamrequest.py +2 -5
  40. mistralai/models/classifierdetailedjobout.py +4 -2
  41. mistralai/models/classifierftmodelout.py +3 -2
  42. mistralai/models/classifierjobout.py +4 -2
  43. mistralai/models/codeinterpretertool.py +1 -1
  44. mistralai/models/completiondetailedjobout.py +5 -2
  45. mistralai/models/completionftmodelout.py +3 -2
  46. mistralai/models/completionjobout.py +5 -2
  47. mistralai/models/completionresponsestreamchoice.py +9 -8
  48. mistralai/models/conversationappendrequest.py +4 -1
  49. mistralai/models/conversationappendstreamrequest.py +4 -1
  50. mistralai/models/conversationhistory.py +2 -1
  51. mistralai/models/conversationmessages.py +1 -1
  52. mistralai/models/conversationrequest.py +5 -1
  53. mistralai/models/conversationresponse.py +2 -1
  54. mistralai/models/conversationrestartrequest.py +4 -1
  55. mistralai/models/conversationrestartstreamrequest.py +4 -1
  56. mistralai/models/conversationstreamrequest.py +5 -1
  57. mistralai/models/documentlibrarytool.py +1 -1
  58. mistralai/models/documenturlchunk.py +1 -1
  59. mistralai/models/embeddingdtype.py +7 -1
  60. mistralai/models/encodingformat.py +4 -1
  61. mistralai/models/entitytype.py +8 -1
  62. mistralai/models/filepurpose.py +8 -1
  63. mistralai/models/files_api_routes_list_filesop.py +4 -11
  64. mistralai/models/files_api_routes_upload_fileop.py +2 -6
  65. mistralai/models/fileschema.py +3 -5
  66. mistralai/models/finetuneablemodeltype.py +4 -1
  67. mistralai/models/ftclassifierlossfunction.py +4 -1
  68. mistralai/models/ftmodelcard.py +1 -1
  69. mistralai/models/functioncallentry.py +3 -2
  70. mistralai/models/functioncallevent.py +1 -1
  71. mistralai/models/functionresultentry.py +3 -2
  72. mistralai/models/functiontool.py +1 -1
  73. mistralai/models/githubrepositoryin.py +1 -1
  74. mistralai/models/githubrepositoryout.py +1 -1
  75. mistralai/models/httpvalidationerror.py +4 -2
  76. mistralai/models/imagegenerationtool.py +1 -1
  77. mistralai/models/imageurlchunk.py +1 -1
  78. mistralai/models/jobsout.py +1 -1
  79. mistralai/models/legacyjobmetadataout.py +1 -1
  80. mistralai/models/messageinputentry.py +9 -3
  81. mistralai/models/messageoutputentry.py +6 -3
  82. mistralai/models/messageoutputevent.py +4 -2
  83. mistralai/models/mistralerror.py +11 -7
  84. mistralai/models/mistralpromptmode.py +1 -1
  85. mistralai/models/modelconversation.py +1 -1
  86. mistralai/models/no_response_error.py +5 -1
  87. mistralai/models/ocrrequest.py +11 -1
  88. mistralai/models/ocrtableobject.py +4 -1
  89. mistralai/models/referencechunk.py +1 -1
  90. mistralai/models/requestsource.py +5 -1
  91. mistralai/models/responsedoneevent.py +1 -1
  92. mistralai/models/responseerrorevent.py +1 -1
  93. mistralai/models/responseformats.py +5 -1
  94. mistralai/models/responsestartedevent.py +1 -1
  95. mistralai/models/responsevalidationerror.py +2 -0
  96. mistralai/models/retrievefileout.py +3 -5
  97. mistralai/models/sampletype.py +7 -1
  98. mistralai/models/sdkerror.py +2 -0
  99. mistralai/models/shareenum.py +7 -1
  100. mistralai/models/sharingdelete.py +2 -4
  101. mistralai/models/sharingin.py +3 -5
  102. mistralai/models/source.py +8 -1
  103. mistralai/models/systemmessage.py +1 -1
  104. mistralai/models/textchunk.py +1 -1
  105. mistralai/models/thinkchunk.py +1 -1
  106. mistralai/models/timestampgranularity.py +1 -1
  107. mistralai/models/tool.py +2 -6
  108. mistralai/models/toolcall.py +2 -6
  109. mistralai/models/toolchoice.py +2 -6
  110. mistralai/models/toolchoiceenum.py +6 -1
  111. mistralai/models/toolexecutiondeltaevent.py +2 -1
  112. mistralai/models/toolexecutiondoneevent.py +2 -1
  113. mistralai/models/toolexecutionentry.py +4 -2
  114. mistralai/models/toolexecutionstartedevent.py +2 -1
  115. mistralai/models/toolfilechunk.py +2 -1
  116. mistralai/models/toolmessage.py +1 -1
  117. mistralai/models/toolreferencechunk.py +2 -1
  118. mistralai/models/tooltypes.py +1 -1
  119. mistralai/models/transcriptionsegmentchunk.py +1 -1
  120. mistralai/models/transcriptionstreamdone.py +1 -1
  121. mistralai/models/transcriptionstreamlanguage.py +1 -1
  122. mistralai/models/transcriptionstreamsegmentdelta.py +1 -1
  123. mistralai/models/transcriptionstreamtextdelta.py +1 -1
  124. mistralai/models/unarchiveftmodelout.py +1 -1
  125. mistralai/models/uploadfileout.py +3 -5
  126. mistralai/models/usermessage.py +1 -1
  127. mistralai/models/wandbintegration.py +1 -1
  128. mistralai/models/wandbintegrationout.py +1 -1
  129. mistralai/models/websearchpremiumtool.py +1 -1
  130. mistralai/models/websearchtool.py +1 -1
  131. mistralai/models_.py +24 -12
  132. mistralai/ocr.py +38 -10
  133. mistralai/sdk.py +2 -2
  134. mistralai/transcriptions.py +28 -12
  135. mistralai/types/basemodel.py +41 -3
  136. mistralai/utils/__init__.py +0 -3
  137. mistralai/utils/annotations.py +32 -8
  138. mistralai/utils/enums.py +60 -0
  139. mistralai/utils/forms.py +21 -10
  140. mistralai/utils/queryparams.py +14 -2
  141. mistralai/utils/requestbodies.py +3 -3
  142. mistralai/utils/retries.py +69 -5
  143. mistralai/utils/serializers.py +0 -20
  144. mistralai/utils/unmarshal_json_response.py +15 -1
  145. {mistralai-1.10.1.dist-info → mistralai-1.11.1.dist-info}/METADATA +24 -31
  146. {mistralai-1.10.1.dist-info → mistralai-1.11.1.dist-info}/RECORD +233 -230
  147. mistralai_azure/_version.py +3 -3
  148. mistralai_azure/basesdk.py +6 -0
  149. mistralai_azure/chat.py +27 -15
  150. mistralai_azure/httpclient.py +0 -1
  151. mistralai_azure/models/__init__.py +16 -1
  152. mistralai_azure/models/assistantmessage.py +1 -1
  153. mistralai_azure/models/chatcompletionchoice.py +10 -7
  154. mistralai_azure/models/chatcompletionrequest.py +8 -6
  155. mistralai_azure/models/chatcompletionstreamrequest.py +8 -6
  156. mistralai_azure/models/completionresponsestreamchoice.py +11 -7
  157. mistralai_azure/models/documenturlchunk.py +1 -1
  158. mistralai_azure/models/httpvalidationerror.py +4 -2
  159. mistralai_azure/models/imageurlchunk.py +1 -1
  160. mistralai_azure/models/mistralazureerror.py +11 -7
  161. mistralai_azure/models/mistralpromptmode.py +1 -1
  162. mistralai_azure/models/no_response_error.py +5 -1
  163. mistralai_azure/models/ocrpageobject.py +32 -5
  164. mistralai_azure/models/ocrrequest.py +20 -1
  165. mistralai_azure/models/ocrtableobject.py +34 -0
  166. mistralai_azure/models/referencechunk.py +1 -1
  167. mistralai_azure/models/responseformats.py +5 -1
  168. mistralai_azure/models/responsevalidationerror.py +2 -0
  169. mistralai_azure/models/sdkerror.py +2 -0
  170. mistralai_azure/models/systemmessage.py +1 -1
  171. mistralai_azure/models/textchunk.py +1 -1
  172. mistralai_azure/models/thinkchunk.py +1 -1
  173. mistralai_azure/models/tool.py +2 -6
  174. mistralai_azure/models/toolcall.py +2 -6
  175. mistralai_azure/models/toolchoice.py +2 -6
  176. mistralai_azure/models/toolchoiceenum.py +6 -1
  177. mistralai_azure/models/toolmessage.py +1 -1
  178. mistralai_azure/models/tooltypes.py +1 -1
  179. mistralai_azure/models/usermessage.py +1 -1
  180. mistralai_azure/ocr.py +26 -6
  181. mistralai_azure/types/basemodel.py +41 -3
  182. mistralai_azure/utils/__init__.py +0 -3
  183. mistralai_azure/utils/annotations.py +32 -8
  184. mistralai_azure/utils/enums.py +60 -0
  185. mistralai_azure/utils/forms.py +21 -10
  186. mistralai_azure/utils/queryparams.py +14 -2
  187. mistralai_azure/utils/requestbodies.py +3 -3
  188. mistralai_azure/utils/retries.py +69 -5
  189. mistralai_azure/utils/serializers.py +0 -20
  190. mistralai_azure/utils/unmarshal_json_response.py +15 -1
  191. mistralai_gcp/_version.py +3 -3
  192. mistralai_gcp/basesdk.py +6 -0
  193. mistralai_gcp/chat.py +27 -15
  194. mistralai_gcp/fim.py +27 -15
  195. mistralai_gcp/httpclient.py +0 -1
  196. mistralai_gcp/models/assistantmessage.py +1 -1
  197. mistralai_gcp/models/chatcompletionchoice.py +10 -7
  198. mistralai_gcp/models/chatcompletionrequest.py +8 -6
  199. mistralai_gcp/models/chatcompletionstreamrequest.py +8 -6
  200. mistralai_gcp/models/completionresponsestreamchoice.py +11 -7
  201. mistralai_gcp/models/fimcompletionrequest.py +6 -1
  202. mistralai_gcp/models/fimcompletionstreamrequest.py +6 -1
  203. mistralai_gcp/models/httpvalidationerror.py +4 -2
  204. mistralai_gcp/models/imageurlchunk.py +1 -1
  205. mistralai_gcp/models/mistralgcperror.py +11 -7
  206. mistralai_gcp/models/mistralpromptmode.py +1 -1
  207. mistralai_gcp/models/no_response_error.py +5 -1
  208. mistralai_gcp/models/referencechunk.py +1 -1
  209. mistralai_gcp/models/responseformats.py +5 -1
  210. mistralai_gcp/models/responsevalidationerror.py +2 -0
  211. mistralai_gcp/models/sdkerror.py +2 -0
  212. mistralai_gcp/models/systemmessage.py +1 -1
  213. mistralai_gcp/models/textchunk.py +1 -1
  214. mistralai_gcp/models/thinkchunk.py +1 -1
  215. mistralai_gcp/models/tool.py +2 -6
  216. mistralai_gcp/models/toolcall.py +2 -6
  217. mistralai_gcp/models/toolchoice.py +2 -6
  218. mistralai_gcp/models/toolchoiceenum.py +6 -1
  219. mistralai_gcp/models/toolmessage.py +1 -1
  220. mistralai_gcp/models/tooltypes.py +1 -1
  221. mistralai_gcp/models/usermessage.py +1 -1
  222. mistralai_gcp/types/basemodel.py +41 -3
  223. mistralai_gcp/utils/__init__.py +0 -3
  224. mistralai_gcp/utils/annotations.py +32 -8
  225. mistralai_gcp/utils/enums.py +60 -0
  226. mistralai_gcp/utils/forms.py +21 -10
  227. mistralai_gcp/utils/queryparams.py +14 -2
  228. mistralai_gcp/utils/requestbodies.py +3 -3
  229. mistralai_gcp/utils/retries.py +69 -5
  230. mistralai_gcp/utils/serializers.py +0 -20
  231. mistralai_gcp/utils/unmarshal_json_response.py +15 -1
  232. {mistralai-1.10.1.dist-info → mistralai-1.11.1.dist-info}/WHEEL +0 -0
  233. {mistralai-1.10.1.dist-info → mistralai-1.11.1.dist-info}/licenses/LICENSE +0 -0
@@ -3,10 +3,17 @@
3
3
  from __future__ import annotations
4
4
  from .ocrimageobject import OCRImageObject, OCRImageObjectTypedDict
5
5
  from .ocrpagedimensions import OCRPageDimensions, OCRPageDimensionsTypedDict
6
- from mistralai_azure.types import BaseModel, Nullable, UNSET_SENTINEL
6
+ from .ocrtableobject import OCRTableObject, OCRTableObjectTypedDict
7
+ from mistralai_azure.types import (
8
+ BaseModel,
9
+ Nullable,
10
+ OptionalNullable,
11
+ UNSET,
12
+ UNSET_SENTINEL,
13
+ )
7
14
  from pydantic import model_serializer
8
- from typing import List
9
- from typing_extensions import TypedDict
15
+ from typing import List, Optional
16
+ from typing_extensions import NotRequired, TypedDict
10
17
 
11
18
 
12
19
  class OCRPageObjectTypedDict(TypedDict):
@@ -18,6 +25,14 @@ class OCRPageObjectTypedDict(TypedDict):
18
25
  r"""List of all extracted images in the page"""
19
26
  dimensions: Nullable[OCRPageDimensionsTypedDict]
20
27
  r"""The dimensions of the PDF Page's screenshot image"""
28
+ tables: NotRequired[List[OCRTableObjectTypedDict]]
29
+ r"""List of all extracted tables in the page"""
30
+ hyperlinks: NotRequired[List[str]]
31
+ r"""List of all hyperlinks in the page"""
32
+ header: NotRequired[Nullable[str]]
33
+ r"""Header of the page"""
34
+ footer: NotRequired[Nullable[str]]
35
+ r"""Footer of the page"""
21
36
 
22
37
 
23
38
  class OCRPageObject(BaseModel):
@@ -33,10 +48,22 @@ class OCRPageObject(BaseModel):
33
48
  dimensions: Nullable[OCRPageDimensions]
34
49
  r"""The dimensions of the PDF Page's screenshot image"""
35
50
 
51
+ tables: Optional[List[OCRTableObject]] = None
52
+ r"""List of all extracted tables in the page"""
53
+
54
+ hyperlinks: Optional[List[str]] = None
55
+ r"""List of all hyperlinks in the page"""
56
+
57
+ header: OptionalNullable[str] = UNSET
58
+ r"""Header of the page"""
59
+
60
+ footer: OptionalNullable[str] = UNSET
61
+ r"""Footer of the page"""
62
+
36
63
  @model_serializer(mode="wrap")
37
64
  def serialize_model(self, handler):
38
- optional_fields = []
39
- nullable_fields = ["dimensions"]
65
+ optional_fields = ["tables", "hyperlinks", "header", "footer"]
66
+ nullable_fields = ["header", "footer", "dimensions"]
40
67
  null_default_fields = []
41
68
 
42
69
  serialized = handler(self)
@@ -13,7 +13,7 @@ from mistralai_azure.types import (
13
13
  UNSET_SENTINEL,
14
14
  )
15
15
  from pydantic import model_serializer
16
- from typing import List, Optional, Union
16
+ from typing import List, Literal, Optional, Union
17
17
  from typing_extensions import NotRequired, TypeAliasType, TypedDict
18
18
 
19
19
 
@@ -28,6 +28,12 @@ Document = TypeAliasType("Document", Union[FileChunk, ImageURLChunk, DocumentURL
28
28
  r"""Document to run OCR on"""
29
29
 
30
30
 
31
+ TableFormat = Literal[
32
+ "markdown",
33
+ "html",
34
+ ]
35
+
36
+
31
37
  class OCRRequestTypedDict(TypedDict):
32
38
  model: Nullable[str]
33
39
  document: DocumentTypedDict
@@ -45,6 +51,9 @@ class OCRRequestTypedDict(TypedDict):
45
51
  r"""Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field"""
46
52
  document_annotation_format: NotRequired[Nullable[ResponseFormatTypedDict]]
47
53
  r"""Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field"""
54
+ table_format: NotRequired[Nullable[TableFormat]]
55
+ extract_header: NotRequired[bool]
56
+ extract_footer: NotRequired[bool]
48
57
 
49
58
 
50
59
  class OCRRequest(BaseModel):
@@ -73,6 +82,12 @@ class OCRRequest(BaseModel):
73
82
  document_annotation_format: OptionalNullable[ResponseFormat] = UNSET
74
83
  r"""Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field"""
75
84
 
85
+ table_format: OptionalNullable[TableFormat] = UNSET
86
+
87
+ extract_header: Optional[bool] = None
88
+
89
+ extract_footer: Optional[bool] = None
90
+
76
91
  @model_serializer(mode="wrap")
77
92
  def serialize_model(self, handler):
78
93
  optional_fields = [
@@ -83,6 +98,9 @@ class OCRRequest(BaseModel):
83
98
  "image_min_size",
84
99
  "bbox_annotation_format",
85
100
  "document_annotation_format",
101
+ "table_format",
102
+ "extract_header",
103
+ "extract_footer",
86
104
  ]
87
105
  nullable_fields = [
88
106
  "model",
@@ -92,6 +110,7 @@ class OCRRequest(BaseModel):
92
110
  "image_min_size",
93
111
  "bbox_annotation_format",
94
112
  "document_annotation_format",
113
+ "table_format",
95
114
  ]
96
115
  null_default_fields = []
97
116
 
@@ -0,0 +1,34 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from mistralai_azure.types import BaseModel
5
+ import pydantic
6
+ from typing import Literal
7
+ from typing_extensions import Annotated, TypedDict
8
+
9
+
10
+ Format = Literal[
11
+ "markdown",
12
+ "html",
13
+ ]
14
+ r"""Format of the table"""
15
+
16
+
17
+ class OCRTableObjectTypedDict(TypedDict):
18
+ id: str
19
+ r"""Table ID for extracted table in a page"""
20
+ content: str
21
+ r"""Content of the table in the given format"""
22
+ format_: Format
23
+ r"""Format of the table"""
24
+
25
+
26
+ class OCRTableObject(BaseModel):
27
+ id: str
28
+ r"""Table ID for extracted table in a page"""
29
+
30
+ content: str
31
+ r"""Content of the table in the given format"""
32
+
33
+ format_: Annotated[Format, pydantic.Field(alias="format")]
34
+ r"""Format of the table"""
@@ -6,7 +6,7 @@ from typing import List, Literal, Optional
6
6
  from typing_extensions import NotRequired, TypedDict
7
7
 
8
8
 
9
- ReferenceChunkType = Literal["reference"]
9
+ ReferenceChunkType = Literal["reference",]
10
10
 
11
11
 
12
12
  class ReferenceChunkTypedDict(TypedDict):
@@ -4,4 +4,8 @@ from __future__ import annotations
4
4
  from typing import Literal
5
5
 
6
6
 
7
- ResponseFormats = Literal["text", "json_object", "json_schema"]
7
+ ResponseFormats = Literal[
8
+ "text",
9
+ "json_object",
10
+ "json_schema",
11
+ ]
@@ -2,10 +2,12 @@
2
2
 
3
3
  import httpx
4
4
  from typing import Optional
5
+ from dataclasses import dataclass
5
6
 
6
7
  from mistralai_azure.models import MistralAzureError
7
8
 
8
9
 
10
+ @dataclass(unsafe_hash=True)
9
11
  class ResponseValidationError(MistralAzureError):
10
12
  """Error raised when there is a type mismatch between the response data and the expected Pydantic model."""
11
13
 
@@ -2,12 +2,14 @@
2
2
 
3
3
  import httpx
4
4
  from typing import Optional
5
+ from dataclasses import dataclass
5
6
 
6
7
  from mistralai_azure.models import MistralAzureError
7
8
 
8
9
  MAX_MESSAGE_LEN = 10_000
9
10
 
10
11
 
12
+ @dataclass(unsafe_hash=True)
11
13
  class SDKError(MistralAzureError):
12
14
  """The fallback error class if no more specific error class is matched."""
13
15
 
@@ -21,7 +21,7 @@ SystemMessageContent = TypeAliasType(
21
21
  )
22
22
 
23
23
 
24
- Role = Literal["system"]
24
+ Role = Literal["system",]
25
25
 
26
26
 
27
27
  class SystemMessageTypedDict(TypedDict):
@@ -6,7 +6,7 @@ from typing import Literal, Optional
6
6
  from typing_extensions import NotRequired, TypedDict
7
7
 
8
8
 
9
- Type = Literal["text"]
9
+ Type = Literal["text",]
10
10
 
11
11
 
12
12
  class TextChunkTypedDict(TypedDict):
@@ -16,7 +16,7 @@ ThinkingTypedDict = TypeAliasType(
16
16
  Thinking = TypeAliasType("Thinking", Union[ReferenceChunk, TextChunk])
17
17
 
18
18
 
19
- ThinkChunkType = Literal["thinking"]
19
+ ThinkChunkType = Literal["thinking",]
20
20
 
21
21
 
22
22
  class ThinkChunkTypedDict(TypedDict):
@@ -4,10 +4,8 @@ from __future__ import annotations
4
4
  from .function import Function, FunctionTypedDict
5
5
  from .tooltypes import ToolTypes
6
6
  from mistralai_azure.types import BaseModel
7
- from mistralai_azure.utils import validate_open_enum
8
- from pydantic.functional_validators import PlainValidator
9
7
  from typing import Optional
10
- from typing_extensions import Annotated, NotRequired, TypedDict
8
+ from typing_extensions import NotRequired, TypedDict
11
9
 
12
10
 
13
11
  class ToolTypedDict(TypedDict):
@@ -18,6 +16,4 @@ class ToolTypedDict(TypedDict):
18
16
  class Tool(BaseModel):
19
17
  function: Function
20
18
 
21
- type: Annotated[Optional[ToolTypes], PlainValidator(validate_open_enum(False))] = (
22
- None
23
- )
19
+ type: Optional[ToolTypes] = None
@@ -4,10 +4,8 @@ from __future__ import annotations
4
4
  from .functioncall import FunctionCall, FunctionCallTypedDict
5
5
  from .tooltypes import ToolTypes
6
6
  from mistralai_azure.types import BaseModel
7
- from mistralai_azure.utils import validate_open_enum
8
- from pydantic.functional_validators import PlainValidator
9
7
  from typing import Optional
10
- from typing_extensions import Annotated, NotRequired, TypedDict
8
+ from typing_extensions import NotRequired, TypedDict
11
9
 
12
10
 
13
11
  class ToolCallTypedDict(TypedDict):
@@ -22,8 +20,6 @@ class ToolCall(BaseModel):
22
20
 
23
21
  id: Optional[str] = "null"
24
22
 
25
- type: Annotated[Optional[ToolTypes], PlainValidator(validate_open_enum(False))] = (
26
- None
27
- )
23
+ type: Optional[ToolTypes] = None
28
24
 
29
25
  index: Optional[int] = 0
@@ -4,10 +4,8 @@ from __future__ import annotations
4
4
  from .functionname import FunctionName, FunctionNameTypedDict
5
5
  from .tooltypes import ToolTypes
6
6
  from mistralai_azure.types import BaseModel
7
- from mistralai_azure.utils import validate_open_enum
8
- from pydantic.functional_validators import PlainValidator
9
7
  from typing import Optional
10
- from typing_extensions import Annotated, NotRequired, TypedDict
8
+ from typing_extensions import NotRequired, TypedDict
11
9
 
12
10
 
13
11
  class ToolChoiceTypedDict(TypedDict):
@@ -24,6 +22,4 @@ class ToolChoice(BaseModel):
24
22
  function: FunctionName
25
23
  r"""this restriction of `Function` is used to select a specific function to call"""
26
24
 
27
- type: Annotated[Optional[ToolTypes], PlainValidator(validate_open_enum(False))] = (
28
- None
29
- )
25
+ type: Optional[ToolTypes] = None
@@ -4,4 +4,9 @@ from __future__ import annotations
4
4
  from typing import Literal
5
5
 
6
6
 
7
- ToolChoiceEnum = Literal["auto", "none", "any", "required"]
7
+ ToolChoiceEnum = Literal[
8
+ "auto",
9
+ "none",
10
+ "any",
11
+ "required",
12
+ ]
@@ -22,7 +22,7 @@ ToolMessageContentTypedDict = TypeAliasType(
22
22
  ToolMessageContent = TypeAliasType("ToolMessageContent", Union[str, List[ContentChunk]])
23
23
 
24
24
 
25
- ToolMessageRole = Literal["tool"]
25
+ ToolMessageRole = Literal["tool",]
26
26
 
27
27
 
28
28
  class ToolMessageTypedDict(TypedDict):
@@ -5,4 +5,4 @@ from mistralai_azure.types import UnrecognizedStr
5
5
  from typing import Literal, Union
6
6
 
7
7
 
8
- ToolTypes = Union[Literal["function"], UnrecognizedStr]
8
+ ToolTypes = Union[Literal["function",], UnrecognizedStr]
@@ -16,7 +16,7 @@ UserMessageContentTypedDict = TypeAliasType(
16
16
  UserMessageContent = TypeAliasType("UserMessageContent", Union[str, List[ContentChunk]])
17
17
 
18
18
 
19
- UserMessageRole = Literal["user"]
19
+ UserMessageRole = Literal["user",]
20
20
 
21
21
 
22
22
  class UserMessageTypedDict(TypedDict):
mistralai_azure/ocr.py CHANGED
@@ -25,11 +25,14 @@ class Ocr(BaseSDK):
25
25
  document_annotation_format: OptionalNullable[
26
26
  Union[models.ResponseFormat, models.ResponseFormatTypedDict]
27
27
  ] = UNSET,
28
+ table_format: OptionalNullable[models.TableFormat] = UNSET,
29
+ extract_header: Optional[bool] = None,
30
+ extract_footer: Optional[bool] = None,
28
31
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
29
32
  server_url: Optional[str] = None,
30
33
  timeout_ms: Optional[int] = None,
31
34
  http_headers: Optional[Mapping[str, str]] = None,
32
- ) -> Optional[models.OCRResponse]:
35
+ ) -> models.OCRResponse:
33
36
  r"""OCR
34
37
 
35
38
  :param model:
@@ -41,6 +44,9 @@ class Ocr(BaseSDK):
41
44
  :param image_min_size: Minimum height and width of image to extract
42
45
  :param bbox_annotation_format: Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field
43
46
  :param document_annotation_format: Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field
47
+ :param table_format:
48
+ :param extract_header:
49
+ :param extract_footer:
44
50
  :param retries: Override the default retry configuration for this method
45
51
  :param server_url: Override the default server URL for this method
46
52
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -70,6 +76,9 @@ class Ocr(BaseSDK):
70
76
  document_annotation_format=utils.get_pydantic_model(
71
77
  document_annotation_format, OptionalNullable[models.ResponseFormat]
72
78
  ),
79
+ table_format=table_format,
80
+ extract_header=extract_header,
81
+ extract_footer=extract_footer,
73
82
  )
74
83
 
75
84
  req = self._build_request(
@@ -88,6 +97,7 @@ class Ocr(BaseSDK):
88
97
  get_serialized_body=lambda: utils.serialize_request_body(
89
98
  request, False, False, "json", models.OCRRequest
90
99
  ),
100
+ allow_empty_value=None,
91
101
  timeout_ms=timeout_ms,
92
102
  )
93
103
 
@@ -104,7 +114,7 @@ class Ocr(BaseSDK):
104
114
  config=self.sdk_configuration,
105
115
  base_url=base_url or "",
106
116
  operation_id="ocr_v1_ocr_post",
107
- oauth2_scopes=[],
117
+ oauth2_scopes=None,
108
118
  security_source=self.sdk_configuration.security,
109
119
  ),
110
120
  request=req,
@@ -114,7 +124,7 @@ class Ocr(BaseSDK):
114
124
 
115
125
  response_data: Any = None
116
126
  if utils.match_response(http_res, "200", "application/json"):
117
- return unmarshal_json_response(Optional[models.OCRResponse], http_res)
127
+ return unmarshal_json_response(models.OCRResponse, http_res)
118
128
  if utils.match_response(http_res, "422", "application/json"):
119
129
  response_data = unmarshal_json_response(
120
130
  models.HTTPValidationErrorData, http_res
@@ -145,11 +155,14 @@ class Ocr(BaseSDK):
145
155
  document_annotation_format: OptionalNullable[
146
156
  Union[models.ResponseFormat, models.ResponseFormatTypedDict]
147
157
  ] = UNSET,
158
+ table_format: OptionalNullable[models.TableFormat] = UNSET,
159
+ extract_header: Optional[bool] = None,
160
+ extract_footer: Optional[bool] = None,
148
161
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
149
162
  server_url: Optional[str] = None,
150
163
  timeout_ms: Optional[int] = None,
151
164
  http_headers: Optional[Mapping[str, str]] = None,
152
- ) -> Optional[models.OCRResponse]:
165
+ ) -> models.OCRResponse:
153
166
  r"""OCR
154
167
 
155
168
  :param model:
@@ -161,6 +174,9 @@ class Ocr(BaseSDK):
161
174
  :param image_min_size: Minimum height and width of image to extract
162
175
  :param bbox_annotation_format: Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field
163
176
  :param document_annotation_format: Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field
177
+ :param table_format:
178
+ :param extract_header:
179
+ :param extract_footer:
164
180
  :param retries: Override the default retry configuration for this method
165
181
  :param server_url: Override the default server URL for this method
166
182
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -190,6 +206,9 @@ class Ocr(BaseSDK):
190
206
  document_annotation_format=utils.get_pydantic_model(
191
207
  document_annotation_format, OptionalNullable[models.ResponseFormat]
192
208
  ),
209
+ table_format=table_format,
210
+ extract_header=extract_header,
211
+ extract_footer=extract_footer,
193
212
  )
194
213
 
195
214
  req = self._build_request_async(
@@ -208,6 +227,7 @@ class Ocr(BaseSDK):
208
227
  get_serialized_body=lambda: utils.serialize_request_body(
209
228
  request, False, False, "json", models.OCRRequest
210
229
  ),
230
+ allow_empty_value=None,
211
231
  timeout_ms=timeout_ms,
212
232
  )
213
233
 
@@ -224,7 +244,7 @@ class Ocr(BaseSDK):
224
244
  config=self.sdk_configuration,
225
245
  base_url=base_url or "",
226
246
  operation_id="ocr_v1_ocr_post",
227
- oauth2_scopes=[],
247
+ oauth2_scopes=None,
228
248
  security_source=self.sdk_configuration.security,
229
249
  ),
230
250
  request=req,
@@ -234,7 +254,7 @@ class Ocr(BaseSDK):
234
254
 
235
255
  response_data: Any = None
236
256
  if utils.match_response(http_res, "200", "application/json"):
237
- return unmarshal_json_response(Optional[models.OCRResponse], http_res)
257
+ return unmarshal_json_response(models.OCRResponse, http_res)
238
258
  if utils.match_response(http_res, "422", "application/json"):
239
259
  response_data = unmarshal_json_response(
240
260
  models.HTTPValidationErrorData, http_res
@@ -2,7 +2,8 @@
2
2
 
3
3
  from pydantic import ConfigDict, model_serializer
4
4
  from pydantic import BaseModel as PydanticBaseModel
5
- from typing import TYPE_CHECKING, Literal, Optional, TypeVar, Union
5
+ from pydantic_core import core_schema
6
+ from typing import TYPE_CHECKING, Any, Literal, Optional, TypeVar, Union
6
7
  from typing_extensions import TypeAliasType, TypeAlias
7
8
 
8
9
 
@@ -35,5 +36,42 @@ else:
35
36
  "OptionalNullable", Union[Optional[Nullable[T]], Unset], type_params=(T,)
36
37
  )
37
38
 
38
- UnrecognizedInt: TypeAlias = int
39
- UnrecognizedStr: TypeAlias = str
39
+
40
+ class UnrecognizedStr(str):
41
+ @classmethod
42
+ def __get_pydantic_core_schema__(cls, _source_type: Any, _handler: Any) -> core_schema.CoreSchema:
43
+ # Make UnrecognizedStr only work in lax mode, not strict mode
44
+ # This makes it a "fallback" option when more specific types (like Literals) don't match
45
+ def validate_lax(v: Any) -> 'UnrecognizedStr':
46
+ if isinstance(v, cls):
47
+ return v
48
+ return cls(str(v))
49
+
50
+ # Use lax_or_strict_schema where strict always fails
51
+ # This forces Pydantic to prefer other union members in strict mode
52
+ # and only fall back to UnrecognizedStr in lax mode
53
+ return core_schema.lax_or_strict_schema(
54
+ lax_schema=core_schema.chain_schema([
55
+ core_schema.str_schema(),
56
+ core_schema.no_info_plain_validator_function(validate_lax)
57
+ ]),
58
+ strict_schema=core_schema.none_schema(), # Always fails in strict mode
59
+ )
60
+
61
+
62
+ class UnrecognizedInt(int):
63
+ @classmethod
64
+ def __get_pydantic_core_schema__(cls, _source_type: Any, _handler: Any) -> core_schema.CoreSchema:
65
+ # Make UnrecognizedInt only work in lax mode, not strict mode
66
+ # This makes it a "fallback" option when more specific types (like Literals) don't match
67
+ def validate_lax(v: Any) -> 'UnrecognizedInt':
68
+ if isinstance(v, cls):
69
+ return v
70
+ return cls(int(v))
71
+ return core_schema.lax_or_strict_schema(
72
+ lax_schema=core_schema.chain_schema([
73
+ core_schema.int_schema(),
74
+ core_schema.no_info_plain_validator_function(validate_lax)
75
+ ]),
76
+ strict_schema=core_schema.none_schema(), # Always fails in strict mode
77
+ )
@@ -41,7 +41,6 @@ if TYPE_CHECKING:
41
41
  validate_decimal,
42
42
  validate_float,
43
43
  validate_int,
44
- validate_open_enum,
45
44
  )
46
45
  from .url import generate_url, template_url, remove_suffix
47
46
  from .values import (
@@ -102,7 +101,6 @@ __all__ = [
102
101
  "validate_const",
103
102
  "validate_float",
104
103
  "validate_int",
105
- "validate_open_enum",
106
104
  "cast_partial",
107
105
  ]
108
106
 
@@ -155,7 +153,6 @@ _dynamic_imports: dict[str, str] = {
155
153
  "validate_const": ".serializers",
156
154
  "validate_float": ".serializers",
157
155
  "validate_int": ".serializers",
158
- "validate_open_enum": ".serializers",
159
156
  "cast_partial": ".values",
160
157
  }
161
158
 
@@ -3,6 +3,7 @@
3
3
  from enum import Enum
4
4
  from typing import Any, Optional
5
5
 
6
+
6
7
  def get_discriminator(model: Any, fieldname: str, key: str) -> str:
7
8
  """
8
9
  Recursively search for the discriminator attribute in a model.
@@ -25,31 +26,54 @@ def get_discriminator(model: Any, fieldname: str, key: str) -> str:
25
26
 
26
27
  if isinstance(field, dict):
27
28
  if key in field:
28
- return f'{field[key]}'
29
+ return f"{field[key]}"
29
30
 
30
31
  if hasattr(field, fieldname):
31
32
  attr = getattr(field, fieldname)
32
33
  if isinstance(attr, Enum):
33
- return f'{attr.value}'
34
- return f'{attr}'
34
+ return f"{attr.value}"
35
+ return f"{attr}"
35
36
 
36
37
  if hasattr(field, upper_fieldname):
37
38
  attr = getattr(field, upper_fieldname)
38
39
  if isinstance(attr, Enum):
39
- return f'{attr.value}'
40
- return f'{attr}'
40
+ return f"{attr.value}"
41
+ return f"{attr}"
41
42
 
42
43
  return None
43
44
 
45
+ def search_nested_discriminator(obj: Any) -> Optional[str]:
46
+ """Recursively search for discriminator in nested structures."""
47
+ # First try direct field lookup
48
+ discriminator = get_field_discriminator(obj)
49
+ if discriminator is not None:
50
+ return discriminator
51
+
52
+ # If it's a dict, search in nested values
53
+ if isinstance(obj, dict):
54
+ for value in obj.values():
55
+ if isinstance(value, list):
56
+ # Search in list items
57
+ for item in value:
58
+ nested_discriminator = search_nested_discriminator(item)
59
+ if nested_discriminator is not None:
60
+ return nested_discriminator
61
+ elif isinstance(value, dict):
62
+ # Search in nested dict
63
+ nested_discriminator = search_nested_discriminator(value)
64
+ if nested_discriminator is not None:
65
+ return nested_discriminator
66
+
67
+ return None
44
68
 
45
69
  if isinstance(model, list):
46
70
  for field in model:
47
- discriminator = get_field_discriminator(field)
71
+ discriminator = search_nested_discriminator(field)
48
72
  if discriminator is not None:
49
73
  return discriminator
50
74
 
51
- discriminator = get_field_discriminator(model)
75
+ discriminator = search_nested_discriminator(model)
52
76
  if discriminator is not None:
53
77
  return discriminator
54
78
 
55
- raise ValueError(f'Could not find discriminator field {fieldname} in {model}')
79
+ raise ValueError(f"Could not find discriminator field {fieldname} in {model}")