mistralai 1.9.7__py3-none-any.whl → 1.9.10__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 (48) hide show
  1. mistralai/_version.py +2 -2
  2. mistralai/embeddings.py +6 -0
  3. mistralai/models/__init__.py +11 -0
  4. mistralai/models/apiendpoint.py +5 -0
  5. mistralai/models/embeddingrequest.py +5 -1
  6. mistralai/models/encodingformat.py +7 -0
  7. mistralai/models/systemmessage.py +7 -3
  8. mistralai/models/systemmessagecontentchunks.py +21 -0
  9. {mistralai-1.9.7.dist-info → mistralai-1.9.10.dist-info}/METADATA +1 -1
  10. {mistralai-1.9.7.dist-info → mistralai-1.9.10.dist-info}/RECORD +48 -35
  11. mistralai_azure/_hooks/types.py +7 -0
  12. mistralai_azure/_version.py +3 -3
  13. mistralai_azure/basesdk.py +12 -20
  14. mistralai_azure/chat.py +16 -0
  15. mistralai_azure/httpclient.py +6 -16
  16. mistralai_azure/models/__init__.py +298 -103
  17. mistralai_azure/models/assistantmessage.py +1 -1
  18. mistralai_azure/models/chatcompletionrequest.py +20 -3
  19. mistralai_azure/models/chatcompletionresponse.py +6 -6
  20. mistralai_azure/models/chatcompletionstreamrequest.py +20 -3
  21. mistralai_azure/models/completionresponsestreamchoice.py +1 -1
  22. mistralai_azure/models/deltamessage.py +1 -1
  23. mistralai_azure/models/documenturlchunk.py +62 -0
  24. mistralai_azure/models/filechunk.py +23 -0
  25. mistralai_azure/models/imageurl.py +1 -1
  26. mistralai_azure/models/jsonschema.py +1 -1
  27. mistralai_azure/models/mistralpromptmode.py +8 -0
  28. mistralai_azure/models/ocrimageobject.py +89 -0
  29. mistralai_azure/models/ocrpagedimensions.py +25 -0
  30. mistralai_azure/models/ocrpageobject.py +64 -0
  31. mistralai_azure/models/ocrrequest.py +120 -0
  32. mistralai_azure/models/ocrresponse.py +68 -0
  33. mistralai_azure/models/ocrusageinfo.py +57 -0
  34. mistralai_azure/models/responseformat.py +1 -1
  35. mistralai_azure/models/toolmessage.py +1 -1
  36. mistralai_azure/models/usageinfo.py +71 -8
  37. mistralai_azure/models/usermessage.py +1 -1
  38. mistralai_azure/ocr.py +271 -0
  39. mistralai_azure/sdk.py +45 -17
  40. mistralai_azure/sdkconfiguration.py +0 -7
  41. mistralai_azure/types/basemodel.py +3 -3
  42. mistralai_azure/utils/__init__.py +130 -45
  43. mistralai_azure/utils/datetimes.py +23 -0
  44. mistralai_azure/utils/enums.py +67 -27
  45. mistralai_azure/utils/forms.py +49 -28
  46. mistralai_azure/utils/serializers.py +32 -3
  47. {mistralai-1.9.7.dist-info → mistralai-1.9.10.dist-info}/LICENSE +0 -0
  48. {mistralai-1.9.7.dist-info → mistralai-1.9.10.dist-info}/WHEEL +0 -0
mistralai_azure/chat.py CHANGED
@@ -41,6 +41,7 @@ class Chat(BaseSDK):
41
41
  Union[models.Prediction, models.PredictionTypedDict]
42
42
  ] = None,
43
43
  parallel_tool_calls: Optional[bool] = None,
44
+ prompt_mode: OptionalNullable[models.MistralPromptMode] = UNSET,
44
45
  safe_prompt: Optional[bool] = None,
45
46
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
46
47
  server_url: Optional[str] = None,
@@ -67,6 +68,7 @@ class Chat(BaseSDK):
67
68
  :param n: Number of completions to return for each request, input tokens are only billed once.
68
69
  :param prediction:
69
70
  :param parallel_tool_calls:
71
+ :param prompt_mode: Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used.
70
72
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
71
73
  :param retries: Override the default retry configuration for this method
72
74
  :param server_url: Override the default server URL for this method
@@ -106,6 +108,7 @@ class Chat(BaseSDK):
106
108
  prediction, Optional[models.Prediction]
107
109
  ),
108
110
  parallel_tool_calls=parallel_tool_calls,
111
+ prompt_mode=prompt_mode,
109
112
  safe_prompt=safe_prompt,
110
113
  )
111
114
 
@@ -138,6 +141,7 @@ class Chat(BaseSDK):
138
141
 
139
142
  http_res = self.do_request(
140
143
  hook_ctx=HookContext(
144
+ config=self.sdk_configuration,
141
145
  base_url=base_url or "",
142
146
  operation_id="stream_chat",
143
147
  oauth2_scopes=[],
@@ -212,6 +216,7 @@ class Chat(BaseSDK):
212
216
  Union[models.Prediction, models.PredictionTypedDict]
213
217
  ] = None,
214
218
  parallel_tool_calls: Optional[bool] = None,
219
+ prompt_mode: OptionalNullable[models.MistralPromptMode] = UNSET,
215
220
  safe_prompt: Optional[bool] = None,
216
221
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
217
222
  server_url: Optional[str] = None,
@@ -238,6 +243,7 @@ class Chat(BaseSDK):
238
243
  :param n: Number of completions to return for each request, input tokens are only billed once.
239
244
  :param prediction:
240
245
  :param parallel_tool_calls:
246
+ :param prompt_mode: Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used.
241
247
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
242
248
  :param retries: Override the default retry configuration for this method
243
249
  :param server_url: Override the default server URL for this method
@@ -277,6 +283,7 @@ class Chat(BaseSDK):
277
283
  prediction, Optional[models.Prediction]
278
284
  ),
279
285
  parallel_tool_calls=parallel_tool_calls,
286
+ prompt_mode=prompt_mode,
280
287
  safe_prompt=safe_prompt,
281
288
  )
282
289
 
@@ -309,6 +316,7 @@ class Chat(BaseSDK):
309
316
 
310
317
  http_res = await self.do_request_async(
311
318
  hook_ctx=HookContext(
319
+ config=self.sdk_configuration,
312
320
  base_url=base_url or "",
313
321
  operation_id="stream_chat",
314
322
  oauth2_scopes=[],
@@ -391,6 +399,7 @@ class Chat(BaseSDK):
391
399
  Union[models.Prediction, models.PredictionTypedDict]
392
400
  ] = None,
393
401
  parallel_tool_calls: Optional[bool] = None,
402
+ prompt_mode: OptionalNullable[models.MistralPromptMode] = UNSET,
394
403
  safe_prompt: Optional[bool] = None,
395
404
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
396
405
  server_url: Optional[str] = None,
@@ -415,6 +424,7 @@ class Chat(BaseSDK):
415
424
  :param n: Number of completions to return for each request, input tokens are only billed once.
416
425
  :param prediction:
417
426
  :param parallel_tool_calls:
427
+ :param prompt_mode: Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used.
418
428
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
419
429
  :param retries: Override the default retry configuration for this method
420
430
  :param server_url: Override the default server URL for this method
@@ -456,6 +466,7 @@ class Chat(BaseSDK):
456
466
  prediction, Optional[models.Prediction]
457
467
  ),
458
468
  parallel_tool_calls=parallel_tool_calls,
469
+ prompt_mode=prompt_mode,
459
470
  safe_prompt=safe_prompt,
460
471
  )
461
472
 
@@ -488,6 +499,7 @@ class Chat(BaseSDK):
488
499
 
489
500
  http_res = self.do_request(
490
501
  hook_ctx=HookContext(
502
+ config=self.sdk_configuration,
491
503
  base_url=base_url or "",
492
504
  operation_id="chat_completion_v1_chat_completions_post",
493
505
  oauth2_scopes=[],
@@ -566,6 +578,7 @@ class Chat(BaseSDK):
566
578
  Union[models.Prediction, models.PredictionTypedDict]
567
579
  ] = None,
568
580
  parallel_tool_calls: Optional[bool] = None,
581
+ prompt_mode: OptionalNullable[models.MistralPromptMode] = UNSET,
569
582
  safe_prompt: Optional[bool] = None,
570
583
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
571
584
  server_url: Optional[str] = None,
@@ -590,6 +603,7 @@ class Chat(BaseSDK):
590
603
  :param n: Number of completions to return for each request, input tokens are only billed once.
591
604
  :param prediction:
592
605
  :param parallel_tool_calls:
606
+ :param prompt_mode: Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used.
593
607
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
594
608
  :param retries: Override the default retry configuration for this method
595
609
  :param server_url: Override the default server URL for this method
@@ -631,6 +645,7 @@ class Chat(BaseSDK):
631
645
  prediction, Optional[models.Prediction]
632
646
  ),
633
647
  parallel_tool_calls=parallel_tool_calls,
648
+ prompt_mode=prompt_mode,
634
649
  safe_prompt=safe_prompt,
635
650
  )
636
651
 
@@ -663,6 +678,7 @@ class Chat(BaseSDK):
663
678
 
664
679
  http_res = await self.do_request_async(
665
680
  hook_ctx=HookContext(
681
+ config=self.sdk_configuration,
666
682
  base_url=base_url or "",
667
683
  operation_id="chat_completion_v1_chat_completions_post",
668
684
  oauth2_scopes=[],
@@ -2,7 +2,6 @@
2
2
 
3
3
  # pyright: reportReturnType = false
4
4
  import asyncio
5
- from concurrent.futures import ThreadPoolExecutor
6
5
  from typing_extensions import Protocol, runtime_checkable
7
6
  import httpx
8
7
  from typing import Any, Optional, Union
@@ -116,21 +115,12 @@ def close_clients(
116
115
  pass
117
116
 
118
117
  if async_client is not None and not async_client_supplied:
119
- is_async = False
120
118
  try:
121
- asyncio.get_running_loop()
122
- is_async = True
119
+ loop = asyncio.get_running_loop()
120
+ asyncio.run_coroutine_threadsafe(async_client.aclose(), loop)
123
121
  except RuntimeError:
124
- pass
125
-
126
- try:
127
- # If this function is called in an async loop then start another
128
- # loop in a separate thread to close the async http client.
129
- if is_async:
130
- with ThreadPoolExecutor(max_workers=1) as executor:
131
- future = executor.submit(asyncio.run, async_client.aclose())
132
- future.result()
133
- else:
122
+ try:
134
123
  asyncio.run(async_client.aclose())
135
- except Exception:
136
- pass
124
+ except RuntimeError:
125
+ # best effort
126
+ pass
@@ -1,109 +1,134 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
- from .assistantmessage import (
4
- AssistantMessage,
5
- AssistantMessageContent,
6
- AssistantMessageContentTypedDict,
7
- AssistantMessageRole,
8
- AssistantMessageTypedDict,
9
- )
10
- from .chatcompletionchoice import (
11
- ChatCompletionChoice,
12
- ChatCompletionChoiceFinishReason,
13
- ChatCompletionChoiceTypedDict,
14
- )
15
- from .chatcompletionrequest import (
16
- ChatCompletionRequest,
17
- ChatCompletionRequestMessages,
18
- ChatCompletionRequestMessagesTypedDict,
19
- ChatCompletionRequestStop,
20
- ChatCompletionRequestStopTypedDict,
21
- ChatCompletionRequestToolChoice,
22
- ChatCompletionRequestToolChoiceTypedDict,
23
- ChatCompletionRequestTypedDict,
24
- )
25
- from .chatcompletionresponse import (
26
- ChatCompletionResponse,
27
- ChatCompletionResponseTypedDict,
28
- )
29
- from .chatcompletionstreamrequest import (
30
- ChatCompletionStreamRequest,
31
- ChatCompletionStreamRequestToolChoice,
32
- ChatCompletionStreamRequestToolChoiceTypedDict,
33
- ChatCompletionStreamRequestTypedDict,
34
- Messages,
35
- MessagesTypedDict,
36
- Stop,
37
- StopTypedDict,
38
- )
39
- from .completionchunk import CompletionChunk, CompletionChunkTypedDict
40
- from .completionevent import CompletionEvent, CompletionEventTypedDict
41
- from .completionresponsestreamchoice import (
42
- CompletionResponseStreamChoice,
43
- CompletionResponseStreamChoiceTypedDict,
44
- FinishReason,
45
- )
46
- from .contentchunk import ContentChunk, ContentChunkTypedDict
47
- from .deltamessage import Content, ContentTypedDict, DeltaMessage, DeltaMessageTypedDict
48
- from .function import Function, FunctionTypedDict
49
- from .functioncall import (
50
- Arguments,
51
- ArgumentsTypedDict,
52
- FunctionCall,
53
- FunctionCallTypedDict,
54
- )
55
- from .functionname import FunctionName, FunctionNameTypedDict
56
- from .httpvalidationerror import HTTPValidationError, HTTPValidationErrorData
57
- from .imageurl import ImageURL, ImageURLTypedDict
58
- from .imageurlchunk import (
59
- ImageURLChunk,
60
- ImageURLChunkImageURL,
61
- ImageURLChunkImageURLTypedDict,
62
- ImageURLChunkType,
63
- ImageURLChunkTypedDict,
64
- )
65
- from .jsonschema import JSONSchema, JSONSchemaTypedDict
66
- from .prediction import Prediction, PredictionTypedDict
67
- from .referencechunk import ReferenceChunk, ReferenceChunkType, ReferenceChunkTypedDict
68
- from .responseformat import ResponseFormat, ResponseFormatTypedDict
69
- from .responseformats import ResponseFormats
70
- from .sdkerror import SDKError
71
- from .security import Security, SecurityTypedDict
72
- from .systemmessage import (
73
- Role,
74
- SystemMessage,
75
- SystemMessageContent,
76
- SystemMessageContentTypedDict,
77
- SystemMessageTypedDict,
78
- )
79
- from .textchunk import TextChunk, TextChunkTypedDict, Type
80
- from .tool import Tool, ToolTypedDict
81
- from .toolcall import ToolCall, ToolCallTypedDict
82
- from .toolchoice import ToolChoice, ToolChoiceTypedDict
83
- from .toolchoiceenum import ToolChoiceEnum
84
- from .toolmessage import (
85
- ToolMessage,
86
- ToolMessageContent,
87
- ToolMessageContentTypedDict,
88
- ToolMessageRole,
89
- ToolMessageTypedDict,
90
- )
91
- from .tooltypes import ToolTypes
92
- from .usageinfo import UsageInfo, UsageInfoTypedDict
93
- from .usermessage import (
94
- UserMessage,
95
- UserMessageContent,
96
- UserMessageContentTypedDict,
97
- UserMessageRole,
98
- UserMessageTypedDict,
99
- )
100
- from .validationerror import (
101
- Loc,
102
- LocTypedDict,
103
- ValidationError,
104
- ValidationErrorTypedDict,
105
- )
3
+ from typing import TYPE_CHECKING
4
+ from importlib import import_module
106
5
 
6
+ if TYPE_CHECKING:
7
+ from .assistantmessage import (
8
+ AssistantMessage,
9
+ AssistantMessageContent,
10
+ AssistantMessageContentTypedDict,
11
+ AssistantMessageRole,
12
+ AssistantMessageTypedDict,
13
+ )
14
+ from .chatcompletionchoice import (
15
+ ChatCompletionChoice,
16
+ ChatCompletionChoiceFinishReason,
17
+ ChatCompletionChoiceTypedDict,
18
+ )
19
+ from .chatcompletionrequest import (
20
+ ChatCompletionRequest,
21
+ ChatCompletionRequestMessages,
22
+ ChatCompletionRequestMessagesTypedDict,
23
+ ChatCompletionRequestStop,
24
+ ChatCompletionRequestStopTypedDict,
25
+ ChatCompletionRequestToolChoice,
26
+ ChatCompletionRequestToolChoiceTypedDict,
27
+ ChatCompletionRequestTypedDict,
28
+ )
29
+ from .chatcompletionresponse import (
30
+ ChatCompletionResponse,
31
+ ChatCompletionResponseTypedDict,
32
+ )
33
+ from .chatcompletionstreamrequest import (
34
+ ChatCompletionStreamRequest,
35
+ ChatCompletionStreamRequestToolChoice,
36
+ ChatCompletionStreamRequestToolChoiceTypedDict,
37
+ ChatCompletionStreamRequestTypedDict,
38
+ Messages,
39
+ MessagesTypedDict,
40
+ Stop,
41
+ StopTypedDict,
42
+ )
43
+ from .completionchunk import CompletionChunk, CompletionChunkTypedDict
44
+ from .completionevent import CompletionEvent, CompletionEventTypedDict
45
+ from .completionresponsestreamchoice import (
46
+ CompletionResponseStreamChoice,
47
+ CompletionResponseStreamChoiceTypedDict,
48
+ FinishReason,
49
+ )
50
+ from .contentchunk import ContentChunk, ContentChunkTypedDict
51
+ from .deltamessage import (
52
+ Content,
53
+ ContentTypedDict,
54
+ DeltaMessage,
55
+ DeltaMessageTypedDict,
56
+ )
57
+ from .documenturlchunk import (
58
+ DocumentURLChunk,
59
+ DocumentURLChunkType,
60
+ DocumentURLChunkTypedDict,
61
+ )
62
+ from .filechunk import FileChunk, FileChunkTypedDict
63
+ from .function import Function, FunctionTypedDict
64
+ from .functioncall import (
65
+ Arguments,
66
+ ArgumentsTypedDict,
67
+ FunctionCall,
68
+ FunctionCallTypedDict,
69
+ )
70
+ from .functionname import FunctionName, FunctionNameTypedDict
71
+ from .httpvalidationerror import HTTPValidationError, HTTPValidationErrorData
72
+ from .imageurl import ImageURL, ImageURLTypedDict
73
+ from .imageurlchunk import (
74
+ ImageURLChunk,
75
+ ImageURLChunkImageURL,
76
+ ImageURLChunkImageURLTypedDict,
77
+ ImageURLChunkType,
78
+ ImageURLChunkTypedDict,
79
+ )
80
+ from .jsonschema import JSONSchema, JSONSchemaTypedDict
81
+ from .mistralpromptmode import MistralPromptMode
82
+ from .ocrimageobject import OCRImageObject, OCRImageObjectTypedDict
83
+ from .ocrpagedimensions import OCRPageDimensions, OCRPageDimensionsTypedDict
84
+ from .ocrpageobject import OCRPageObject, OCRPageObjectTypedDict
85
+ from .ocrrequest import Document, DocumentTypedDict, OCRRequest, OCRRequestTypedDict
86
+ from .ocrresponse import OCRResponse, OCRResponseTypedDict
87
+ from .ocrusageinfo import OCRUsageInfo, OCRUsageInfoTypedDict
88
+ from .prediction import Prediction, PredictionTypedDict
89
+ from .referencechunk import (
90
+ ReferenceChunk,
91
+ ReferenceChunkType,
92
+ ReferenceChunkTypedDict,
93
+ )
94
+ from .responseformat import ResponseFormat, ResponseFormatTypedDict
95
+ from .responseformats import ResponseFormats
96
+ from .sdkerror import SDKError
97
+ from .security import Security, SecurityTypedDict
98
+ from .systemmessage import (
99
+ Role,
100
+ SystemMessage,
101
+ SystemMessageContent,
102
+ SystemMessageContentTypedDict,
103
+ SystemMessageTypedDict,
104
+ )
105
+ from .textchunk import TextChunk, TextChunkTypedDict, Type
106
+ from .tool import Tool, ToolTypedDict
107
+ from .toolcall import ToolCall, ToolCallTypedDict
108
+ from .toolchoice import ToolChoice, ToolChoiceTypedDict
109
+ from .toolchoiceenum import ToolChoiceEnum
110
+ from .toolmessage import (
111
+ ToolMessage,
112
+ ToolMessageContent,
113
+ ToolMessageContentTypedDict,
114
+ ToolMessageRole,
115
+ ToolMessageTypedDict,
116
+ )
117
+ from .tooltypes import ToolTypes
118
+ from .usageinfo import UsageInfo, UsageInfoTypedDict
119
+ from .usermessage import (
120
+ UserMessage,
121
+ UserMessageContent,
122
+ UserMessageContentTypedDict,
123
+ UserMessageRole,
124
+ UserMessageTypedDict,
125
+ )
126
+ from .validationerror import (
127
+ Loc,
128
+ LocTypedDict,
129
+ ValidationError,
130
+ ValidationErrorTypedDict,
131
+ )
107
132
 
108
133
  __all__ = [
109
134
  "Arguments",
@@ -142,6 +167,13 @@ __all__ = [
142
167
  "ContentTypedDict",
143
168
  "DeltaMessage",
144
169
  "DeltaMessageTypedDict",
170
+ "Document",
171
+ "DocumentTypedDict",
172
+ "DocumentURLChunk",
173
+ "DocumentURLChunkType",
174
+ "DocumentURLChunkTypedDict",
175
+ "FileChunk",
176
+ "FileChunkTypedDict",
145
177
  "FinishReason",
146
178
  "Function",
147
179
  "FunctionCall",
@@ -164,6 +196,19 @@ __all__ = [
164
196
  "LocTypedDict",
165
197
  "Messages",
166
198
  "MessagesTypedDict",
199
+ "MistralPromptMode",
200
+ "OCRImageObject",
201
+ "OCRImageObjectTypedDict",
202
+ "OCRPageDimensions",
203
+ "OCRPageDimensionsTypedDict",
204
+ "OCRPageObject",
205
+ "OCRPageObjectTypedDict",
206
+ "OCRRequest",
207
+ "OCRRequestTypedDict",
208
+ "OCRResponse",
209
+ "OCRResponseTypedDict",
210
+ "OCRUsageInfo",
211
+ "OCRUsageInfoTypedDict",
167
212
  "Prediction",
168
213
  "PredictionTypedDict",
169
214
  "ReferenceChunk",
@@ -208,3 +253,153 @@ __all__ = [
208
253
  "ValidationError",
209
254
  "ValidationErrorTypedDict",
210
255
  ]
256
+
257
+ _dynamic_imports: dict[str, str] = {
258
+ "AssistantMessage": ".assistantmessage",
259
+ "AssistantMessageContent": ".assistantmessage",
260
+ "AssistantMessageContentTypedDict": ".assistantmessage",
261
+ "AssistantMessageRole": ".assistantmessage",
262
+ "AssistantMessageTypedDict": ".assistantmessage",
263
+ "ChatCompletionChoice": ".chatcompletionchoice",
264
+ "ChatCompletionChoiceFinishReason": ".chatcompletionchoice",
265
+ "ChatCompletionChoiceTypedDict": ".chatcompletionchoice",
266
+ "ChatCompletionRequest": ".chatcompletionrequest",
267
+ "ChatCompletionRequestMessages": ".chatcompletionrequest",
268
+ "ChatCompletionRequestMessagesTypedDict": ".chatcompletionrequest",
269
+ "ChatCompletionRequestStop": ".chatcompletionrequest",
270
+ "ChatCompletionRequestStopTypedDict": ".chatcompletionrequest",
271
+ "ChatCompletionRequestToolChoice": ".chatcompletionrequest",
272
+ "ChatCompletionRequestToolChoiceTypedDict": ".chatcompletionrequest",
273
+ "ChatCompletionRequestTypedDict": ".chatcompletionrequest",
274
+ "ChatCompletionResponse": ".chatcompletionresponse",
275
+ "ChatCompletionResponseTypedDict": ".chatcompletionresponse",
276
+ "ChatCompletionStreamRequest": ".chatcompletionstreamrequest",
277
+ "ChatCompletionStreamRequestToolChoice": ".chatcompletionstreamrequest",
278
+ "ChatCompletionStreamRequestToolChoiceTypedDict": ".chatcompletionstreamrequest",
279
+ "ChatCompletionStreamRequestTypedDict": ".chatcompletionstreamrequest",
280
+ "Messages": ".chatcompletionstreamrequest",
281
+ "MessagesTypedDict": ".chatcompletionstreamrequest",
282
+ "Stop": ".chatcompletionstreamrequest",
283
+ "StopTypedDict": ".chatcompletionstreamrequest",
284
+ "CompletionChunk": ".completionchunk",
285
+ "CompletionChunkTypedDict": ".completionchunk",
286
+ "CompletionEvent": ".completionevent",
287
+ "CompletionEventTypedDict": ".completionevent",
288
+ "CompletionResponseStreamChoice": ".completionresponsestreamchoice",
289
+ "CompletionResponseStreamChoiceTypedDict": ".completionresponsestreamchoice",
290
+ "FinishReason": ".completionresponsestreamchoice",
291
+ "ContentChunk": ".contentchunk",
292
+ "ContentChunkTypedDict": ".contentchunk",
293
+ "Content": ".deltamessage",
294
+ "ContentTypedDict": ".deltamessage",
295
+ "DeltaMessage": ".deltamessage",
296
+ "DeltaMessageTypedDict": ".deltamessage",
297
+ "DocumentURLChunk": ".documenturlchunk",
298
+ "DocumentURLChunkType": ".documenturlchunk",
299
+ "DocumentURLChunkTypedDict": ".documenturlchunk",
300
+ "FileChunk": ".filechunk",
301
+ "FileChunkTypedDict": ".filechunk",
302
+ "Function": ".function",
303
+ "FunctionTypedDict": ".function",
304
+ "Arguments": ".functioncall",
305
+ "ArgumentsTypedDict": ".functioncall",
306
+ "FunctionCall": ".functioncall",
307
+ "FunctionCallTypedDict": ".functioncall",
308
+ "FunctionName": ".functionname",
309
+ "FunctionNameTypedDict": ".functionname",
310
+ "HTTPValidationError": ".httpvalidationerror",
311
+ "HTTPValidationErrorData": ".httpvalidationerror",
312
+ "ImageURL": ".imageurl",
313
+ "ImageURLTypedDict": ".imageurl",
314
+ "ImageURLChunk": ".imageurlchunk",
315
+ "ImageURLChunkImageURL": ".imageurlchunk",
316
+ "ImageURLChunkImageURLTypedDict": ".imageurlchunk",
317
+ "ImageURLChunkType": ".imageurlchunk",
318
+ "ImageURLChunkTypedDict": ".imageurlchunk",
319
+ "JSONSchema": ".jsonschema",
320
+ "JSONSchemaTypedDict": ".jsonschema",
321
+ "MistralPromptMode": ".mistralpromptmode",
322
+ "OCRImageObject": ".ocrimageobject",
323
+ "OCRImageObjectTypedDict": ".ocrimageobject",
324
+ "OCRPageDimensions": ".ocrpagedimensions",
325
+ "OCRPageDimensionsTypedDict": ".ocrpagedimensions",
326
+ "OCRPageObject": ".ocrpageobject",
327
+ "OCRPageObjectTypedDict": ".ocrpageobject",
328
+ "Document": ".ocrrequest",
329
+ "DocumentTypedDict": ".ocrrequest",
330
+ "OCRRequest": ".ocrrequest",
331
+ "OCRRequestTypedDict": ".ocrrequest",
332
+ "OCRResponse": ".ocrresponse",
333
+ "OCRResponseTypedDict": ".ocrresponse",
334
+ "OCRUsageInfo": ".ocrusageinfo",
335
+ "OCRUsageInfoTypedDict": ".ocrusageinfo",
336
+ "Prediction": ".prediction",
337
+ "PredictionTypedDict": ".prediction",
338
+ "ReferenceChunk": ".referencechunk",
339
+ "ReferenceChunkType": ".referencechunk",
340
+ "ReferenceChunkTypedDict": ".referencechunk",
341
+ "ResponseFormat": ".responseformat",
342
+ "ResponseFormatTypedDict": ".responseformat",
343
+ "ResponseFormats": ".responseformats",
344
+ "SDKError": ".sdkerror",
345
+ "Security": ".security",
346
+ "SecurityTypedDict": ".security",
347
+ "Role": ".systemmessage",
348
+ "SystemMessage": ".systemmessage",
349
+ "SystemMessageContent": ".systemmessage",
350
+ "SystemMessageContentTypedDict": ".systemmessage",
351
+ "SystemMessageTypedDict": ".systemmessage",
352
+ "TextChunk": ".textchunk",
353
+ "TextChunkTypedDict": ".textchunk",
354
+ "Type": ".textchunk",
355
+ "Tool": ".tool",
356
+ "ToolTypedDict": ".tool",
357
+ "ToolCall": ".toolcall",
358
+ "ToolCallTypedDict": ".toolcall",
359
+ "ToolChoice": ".toolchoice",
360
+ "ToolChoiceTypedDict": ".toolchoice",
361
+ "ToolChoiceEnum": ".toolchoiceenum",
362
+ "ToolMessage": ".toolmessage",
363
+ "ToolMessageContent": ".toolmessage",
364
+ "ToolMessageContentTypedDict": ".toolmessage",
365
+ "ToolMessageRole": ".toolmessage",
366
+ "ToolMessageTypedDict": ".toolmessage",
367
+ "ToolTypes": ".tooltypes",
368
+ "UsageInfo": ".usageinfo",
369
+ "UsageInfoTypedDict": ".usageinfo",
370
+ "UserMessage": ".usermessage",
371
+ "UserMessageContent": ".usermessage",
372
+ "UserMessageContentTypedDict": ".usermessage",
373
+ "UserMessageRole": ".usermessage",
374
+ "UserMessageTypedDict": ".usermessage",
375
+ "Loc": ".validationerror",
376
+ "LocTypedDict": ".validationerror",
377
+ "ValidationError": ".validationerror",
378
+ "ValidationErrorTypedDict": ".validationerror",
379
+ }
380
+
381
+
382
+ def __getattr__(attr_name: str) -> object:
383
+ module_name = _dynamic_imports.get(attr_name)
384
+ if module_name is None:
385
+ raise AttributeError(
386
+ f"No {attr_name} found in _dynamic_imports for module name -> {__name__} "
387
+ )
388
+
389
+ try:
390
+ module = import_module(module_name, __package__)
391
+ result = getattr(module, attr_name)
392
+ return result
393
+ except ImportError as e:
394
+ raise ImportError(
395
+ f"Failed to import {attr_name} from {module_name}: {e}"
396
+ ) from e
397
+ except AttributeError as e:
398
+ raise AttributeError(
399
+ f"Failed to get {attr_name} from {module_name}: {e}"
400
+ ) from e
401
+
402
+
403
+ def __dir__():
404
+ lazy_attrs = list(_dynamic_imports.keys())
405
+ return sorted(lazy_attrs)
@@ -56,7 +56,7 @@ class AssistantMessage(BaseModel):
56
56
 
57
57
  m = {}
58
58
 
59
- for n, f in self.model_fields.items():
59
+ for n, f in type(self).model_fields.items():
60
60
  k = f.alias or n
61
61
  val = serialized.get(k)
62
62
  serialized.pop(k, None)
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
5
+ from .mistralpromptmode import MistralPromptMode
5
6
  from .prediction import Prediction, PredictionTypedDict
6
7
  from .responseformat import ResponseFormat, ResponseFormatTypedDict
7
8
  from .systemmessage import SystemMessage, SystemMessageTypedDict
@@ -17,8 +18,9 @@ from mistralai_azure.types import (
17
18
  UNSET,
18
19
  UNSET_SENTINEL,
19
20
  )
20
- from mistralai_azure.utils import get_discriminator
21
+ from mistralai_azure.utils import get_discriminator, validate_open_enum
21
22
  from pydantic import Discriminator, Tag, model_serializer
23
+ from pydantic.functional_validators import PlainValidator
22
24
  from typing import List, Optional, Union
23
25
  from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
24
26
 
@@ -96,6 +98,8 @@ class ChatCompletionRequestTypedDict(TypedDict):
96
98
  r"""Number of completions to return for each request, input tokens are only billed once."""
97
99
  prediction: NotRequired[PredictionTypedDict]
98
100
  parallel_tool_calls: NotRequired[bool]
101
+ prompt_mode: NotRequired[Nullable[MistralPromptMode]]
102
+ r"""Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used."""
99
103
  safe_prompt: NotRequired[bool]
100
104
  r"""Whether to inject a safety prompt before all conversations."""
101
105
 
@@ -144,6 +148,11 @@ class ChatCompletionRequest(BaseModel):
144
148
 
145
149
  parallel_tool_calls: Optional[bool] = None
146
150
 
151
+ prompt_mode: Annotated[
152
+ OptionalNullable[MistralPromptMode], PlainValidator(validate_open_enum(False))
153
+ ] = UNSET
154
+ r"""Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used."""
155
+
147
156
  safe_prompt: Optional[bool] = None
148
157
  r"""Whether to inject a safety prompt before all conversations."""
149
158
 
@@ -165,16 +174,24 @@ class ChatCompletionRequest(BaseModel):
165
174
  "n",
166
175
  "prediction",
167
176
  "parallel_tool_calls",
177
+ "prompt_mode",
168
178
  "safe_prompt",
169
179
  ]
170
- nullable_fields = ["temperature", "max_tokens", "random_seed", "tools", "n"]
180
+ nullable_fields = [
181
+ "temperature",
182
+ "max_tokens",
183
+ "random_seed",
184
+ "tools",
185
+ "n",
186
+ "prompt_mode",
187
+ ]
171
188
  null_default_fields = []
172
189
 
173
190
  serialized = handler(self)
174
191
 
175
192
  m = {}
176
193
 
177
- for n, f in self.model_fields.items():
194
+ for n, f in type(self).model_fields.items():
178
195
  k = f.alias or n
179
196
  val = serialized.get(k)
180
197
  serialized.pop(k, None)
@@ -4,8 +4,8 @@ from __future__ import annotations
4
4
  from .chatcompletionchoice import ChatCompletionChoice, ChatCompletionChoiceTypedDict
5
5
  from .usageinfo import UsageInfo, UsageInfoTypedDict
6
6
  from mistralai_azure.types import BaseModel
7
- from typing import List, Optional
8
- from typing_extensions import NotRequired, TypedDict
7
+ from typing import List
8
+ from typing_extensions import TypedDict
9
9
 
10
10
 
11
11
  class ChatCompletionResponseTypedDict(TypedDict):
@@ -13,8 +13,8 @@ class ChatCompletionResponseTypedDict(TypedDict):
13
13
  object: str
14
14
  model: str
15
15
  usage: UsageInfoTypedDict
16
- created: NotRequired[int]
17
- choices: NotRequired[List[ChatCompletionChoiceTypedDict]]
16
+ created: int
17
+ choices: List[ChatCompletionChoiceTypedDict]
18
18
 
19
19
 
20
20
  class ChatCompletionResponse(BaseModel):
@@ -26,6 +26,6 @@ class ChatCompletionResponse(BaseModel):
26
26
 
27
27
  usage: UsageInfo
28
28
 
29
- created: Optional[int] = None
29
+ created: int
30
30
 
31
- choices: Optional[List[ChatCompletionChoice]] = None
31
+ choices: List[ChatCompletionChoice]