mistralai 1.0.0rc1__py3-none-any.whl → 1.0.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 (114) hide show
  1. mistralai/agents.py +434 -0
  2. mistralai/basesdk.py +43 -6
  3. mistralai/chat.py +29 -34
  4. mistralai/client.py +1 -1
  5. mistralai/embeddings.py +4 -4
  6. mistralai/files.py +10 -10
  7. mistralai/fim.py +17 -18
  8. mistralai/fine_tuning.py +10 -849
  9. mistralai/jobs.py +844 -0
  10. mistralai/models/__init__.py +6 -4
  11. mistralai/models/agentscompletionrequest.py +96 -0
  12. mistralai/models/agentscompletionstreamrequest.py +92 -0
  13. mistralai/models/assistantmessage.py +4 -9
  14. mistralai/models/chatcompletionchoice.py +4 -15
  15. mistralai/models/chatcompletionrequest.py +25 -30
  16. mistralai/models/chatcompletionstreamrequest.py +25 -30
  17. mistralai/models/completionresponsestreamchoice.py +4 -9
  18. mistralai/models/delete_model_v1_models_model_id_deleteop.py +2 -0
  19. mistralai/models/deltamessage.py +7 -12
  20. mistralai/models/detailedjobout.py +4 -9
  21. mistralai/models/embeddingrequest.py +12 -17
  22. mistralai/models/eventout.py +4 -9
  23. mistralai/models/fileschema.py +4 -9
  24. mistralai/models/fimcompletionrequest.py +19 -24
  25. mistralai/models/fimcompletionstreamrequest.py +19 -24
  26. mistralai/models/ftmodelout.py +4 -9
  27. mistralai/models/functioncall.py +9 -3
  28. mistralai/models/githubrepositoryin.py +4 -9
  29. mistralai/models/githubrepositoryout.py +4 -9
  30. mistralai/models/httpvalidationerror.py +1 -1
  31. mistralai/models/jobin.py +4 -9
  32. mistralai/models/jobmetadataout.py +4 -9
  33. mistralai/models/jobout.py +4 -9
  34. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +2 -0
  35. mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +1 -59
  36. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +4 -9
  37. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +2 -0
  38. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +2 -0
  39. mistralai/models/legacyjobmetadataout.py +4 -9
  40. mistralai/models/metricout.py +4 -9
  41. mistralai/models/modelcard.py +4 -9
  42. mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -0
  43. mistralai/models/retrievefileout.py +4 -9
  44. mistralai/models/security.py +4 -4
  45. mistralai/models/systemmessage.py +6 -6
  46. mistralai/models/toolmessage.py +4 -9
  47. mistralai/models/trainingparameters.py +4 -9
  48. mistralai/models/trainingparametersin.py +4 -9
  49. mistralai/models/updateftmodelin.py +4 -9
  50. mistralai/models/uploadfileout.py +4 -9
  51. mistralai/models/usermessage.py +6 -6
  52. mistralai/models/validationerror.py +6 -6
  53. mistralai/models/wandbintegration.py +4 -9
  54. mistralai/models/wandbintegrationout.py +4 -9
  55. mistralai/models_.py +24 -24
  56. mistralai/sdk.py +14 -6
  57. mistralai/sdkconfiguration.py +5 -4
  58. mistralai/types/basemodel.py +10 -6
  59. mistralai/utils/__init__.py +4 -0
  60. mistralai/utils/eventstreaming.py +8 -9
  61. mistralai/utils/logger.py +16 -0
  62. mistralai/utils/retries.py +2 -2
  63. mistralai/utils/security.py +5 -2
  64. {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/METADATA +153 -69
  65. {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/RECORD +114 -107
  66. mistralai_azure/basesdk.py +42 -4
  67. mistralai_azure/chat.py +15 -20
  68. mistralai_azure/models/__init__.py +3 -3
  69. mistralai_azure/models/assistantmessage.py +4 -9
  70. mistralai_azure/models/chatcompletionchoice.py +4 -15
  71. mistralai_azure/models/chatcompletionrequest.py +21 -26
  72. mistralai_azure/models/chatcompletionstreamrequest.py +21 -26
  73. mistralai_azure/models/completionresponsestreamchoice.py +4 -9
  74. mistralai_azure/models/deltamessage.py +7 -12
  75. mistralai_azure/models/functioncall.py +9 -3
  76. mistralai_azure/models/httpvalidationerror.py +1 -1
  77. mistralai_azure/models/systemmessage.py +6 -6
  78. mistralai_azure/models/toolmessage.py +4 -9
  79. mistralai_azure/models/usermessage.py +6 -6
  80. mistralai_azure/models/validationerror.py +6 -6
  81. mistralai_azure/sdk.py +7 -2
  82. mistralai_azure/sdkconfiguration.py +5 -4
  83. mistralai_azure/types/basemodel.py +10 -6
  84. mistralai_azure/utils/__init__.py +4 -0
  85. mistralai_azure/utils/eventstreaming.py +8 -9
  86. mistralai_azure/utils/logger.py +16 -0
  87. mistralai_azure/utils/retries.py +2 -2
  88. mistralai_gcp/basesdk.py +42 -4
  89. mistralai_gcp/chat.py +12 -17
  90. mistralai_gcp/fim.py +12 -13
  91. mistralai_gcp/models/__init__.py +3 -3
  92. mistralai_gcp/models/assistantmessage.py +4 -9
  93. mistralai_gcp/models/chatcompletionchoice.py +4 -15
  94. mistralai_gcp/models/chatcompletionrequest.py +23 -28
  95. mistralai_gcp/models/chatcompletionstreamrequest.py +23 -28
  96. mistralai_gcp/models/completionresponsestreamchoice.py +4 -9
  97. mistralai_gcp/models/deltamessage.py +7 -12
  98. mistralai_gcp/models/fimcompletionrequest.py +19 -24
  99. mistralai_gcp/models/fimcompletionstreamrequest.py +19 -24
  100. mistralai_gcp/models/functioncall.py +9 -3
  101. mistralai_gcp/models/httpvalidationerror.py +1 -1
  102. mistralai_gcp/models/systemmessage.py +6 -6
  103. mistralai_gcp/models/toolmessage.py +4 -9
  104. mistralai_gcp/models/usermessage.py +6 -6
  105. mistralai_gcp/models/validationerror.py +6 -6
  106. mistralai_gcp/sdk.py +9 -0
  107. mistralai_gcp/sdkconfiguration.py +5 -4
  108. mistralai_gcp/types/basemodel.py +10 -6
  109. mistralai_gcp/utils/__init__.py +4 -0
  110. mistralai_gcp/utils/eventstreaming.py +8 -9
  111. mistralai_gcp/utils/logger.py +16 -0
  112. mistralai_gcp/utils/retries.py +2 -2
  113. {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/LICENSE +0 -0
  114. {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/WHEEL +0 -0
mistralai_azure/chat.py CHANGED
@@ -1,10 +1,9 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from mistralai_azure import models
4
+ from mistralai_azure import models, utils
5
5
  from mistralai_azure._hooks import HookContext
6
6
  from mistralai_azure.types import OptionalNullable, UNSET
7
- import mistralai_azure.utils as utils
8
7
  from mistralai_azure.utils import eventstreaming
9
8
  from typing import Any, AsyncGenerator, Generator, List, Optional, Union
10
9
 
@@ -25,8 +24,8 @@ class Chat(BaseSDK):
25
24
  random_seed: OptionalNullable[int] = UNSET,
26
25
  response_format: Optional[Union[models.ResponseFormat, models.ResponseFormatTypedDict]] = None,
27
26
  tools: OptionalNullable[Union[List[models.Tool], List[models.ToolTypedDict]]] = UNSET,
28
- safe_prompt: Optional[bool] = False,
29
27
  tool_choice: Optional[models.ToolChoice] = "auto",
28
+ safe_prompt: Optional[bool] = False,
30
29
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
31
30
  server_url: Optional[str] = None,
32
31
  timeout_ms: Optional[int] = None,
@@ -46,8 +45,8 @@ class Chat(BaseSDK):
46
45
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
47
46
  :param response_format:
48
47
  :param tools:
49
- :param safe_prompt: Whether to inject a safety prompt before all conversations.
50
48
  :param tool_choice:
49
+ :param safe_prompt: Whether to inject a safety prompt before all conversations.
51
50
  :param retries: Override the default retry configuration for this method
52
51
  :param server_url: Override the default server URL for this method
53
52
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -72,8 +71,8 @@ class Chat(BaseSDK):
72
71
  messages=utils.get_pydantic_model(messages, List[models.Messages]),
73
72
  response_format=utils.get_pydantic_model(response_format, Optional[models.ResponseFormat]),
74
73
  tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tool]]),
75
- safe_prompt=safe_prompt,
76
74
  tool_choice=tool_choice,
75
+ safe_prompt=safe_prompt,
77
76
  )
78
77
 
79
78
  req = self.build_request(
@@ -141,8 +140,8 @@ class Chat(BaseSDK):
141
140
  random_seed: OptionalNullable[int] = UNSET,
142
141
  response_format: Optional[Union[models.ResponseFormat, models.ResponseFormatTypedDict]] = None,
143
142
  tools: OptionalNullable[Union[List[models.Tool], List[models.ToolTypedDict]]] = UNSET,
144
- safe_prompt: Optional[bool] = False,
145
143
  tool_choice: Optional[models.ToolChoice] = "auto",
144
+ safe_prompt: Optional[bool] = False,
146
145
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
147
146
  server_url: Optional[str] = None,
148
147
  timeout_ms: Optional[int] = None,
@@ -162,8 +161,8 @@ class Chat(BaseSDK):
162
161
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
163
162
  :param response_format:
164
163
  :param tools:
165
- :param safe_prompt: Whether to inject a safety prompt before all conversations.
166
164
  :param tool_choice:
165
+ :param safe_prompt: Whether to inject a safety prompt before all conversations.
167
166
  :param retries: Override the default retry configuration for this method
168
167
  :param server_url: Override the default server URL for this method
169
168
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -188,8 +187,8 @@ class Chat(BaseSDK):
188
187
  messages=utils.get_pydantic_model(messages, List[models.Messages]),
189
188
  response_format=utils.get_pydantic_model(response_format, Optional[models.ResponseFormat]),
190
189
  tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tool]]),
191
- safe_prompt=safe_prompt,
192
190
  tool_choice=tool_choice,
191
+ safe_prompt=safe_prompt,
193
192
  )
194
193
 
195
194
  req = self.build_request(
@@ -244,7 +243,7 @@ class Chat(BaseSDK):
244
243
 
245
244
 
246
245
 
247
- def create(
246
+ def complete(
248
247
  self, *,
249
248
  messages: Union[List[models.ChatCompletionRequestMessages], List[models.ChatCompletionRequestMessagesTypedDict]],
250
249
  model: OptionalNullable[str] = "azureai",
@@ -257,16 +256,14 @@ class Chat(BaseSDK):
257
256
  random_seed: OptionalNullable[int] = UNSET,
258
257
  response_format: Optional[Union[models.ResponseFormat, models.ResponseFormatTypedDict]] = None,
259
258
  tools: OptionalNullable[Union[List[models.Tool], List[models.ToolTypedDict]]] = UNSET,
260
- safe_prompt: Optional[bool] = False,
261
259
  tool_choice: Optional[models.ChatCompletionRequestToolChoice] = "auto",
260
+ safe_prompt: Optional[bool] = False,
262
261
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
263
262
  server_url: Optional[str] = None,
264
263
  timeout_ms: Optional[int] = None,
265
264
  ) -> Optional[models.ChatCompletionResponse]:
266
265
  r"""Chat Completion
267
266
 
268
- Chat Completion
269
-
270
267
  :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
271
268
  :param model: The ID of the model to use for this request.
272
269
  :param temperature: What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both.
@@ -278,8 +275,8 @@ class Chat(BaseSDK):
278
275
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
279
276
  :param response_format:
280
277
  :param tools:
281
- :param safe_prompt: Whether to inject a safety prompt before all conversations.
282
278
  :param tool_choice:
279
+ :param safe_prompt: Whether to inject a safety prompt before all conversations.
283
280
  :param retries: Override the default retry configuration for this method
284
281
  :param server_url: Override the default server URL for this method
285
282
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -304,8 +301,8 @@ class Chat(BaseSDK):
304
301
  messages=utils.get_pydantic_model(messages, List[models.ChatCompletionRequestMessages]),
305
302
  response_format=utils.get_pydantic_model(response_format, Optional[models.ResponseFormat]),
306
303
  tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tool]]),
307
- safe_prompt=safe_prompt,
308
304
  tool_choice=tool_choice,
305
+ safe_prompt=safe_prompt,
309
306
  )
310
307
 
311
308
  req = self.build_request(
@@ -359,7 +356,7 @@ class Chat(BaseSDK):
359
356
 
360
357
 
361
358
 
362
- async def create_async(
359
+ async def complete_async(
363
360
  self, *,
364
361
  messages: Union[List[models.ChatCompletionRequestMessages], List[models.ChatCompletionRequestMessagesTypedDict]],
365
362
  model: OptionalNullable[str] = "azureai",
@@ -372,16 +369,14 @@ class Chat(BaseSDK):
372
369
  random_seed: OptionalNullable[int] = UNSET,
373
370
  response_format: Optional[Union[models.ResponseFormat, models.ResponseFormatTypedDict]] = None,
374
371
  tools: OptionalNullable[Union[List[models.Tool], List[models.ToolTypedDict]]] = UNSET,
375
- safe_prompt: Optional[bool] = False,
376
372
  tool_choice: Optional[models.ChatCompletionRequestToolChoice] = "auto",
373
+ safe_prompt: Optional[bool] = False,
377
374
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
378
375
  server_url: Optional[str] = None,
379
376
  timeout_ms: Optional[int] = None,
380
377
  ) -> Optional[models.ChatCompletionResponse]:
381
378
  r"""Chat Completion
382
379
 
383
- Chat Completion
384
-
385
380
  :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
386
381
  :param model: The ID of the model to use for this request.
387
382
  :param temperature: What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both.
@@ -393,8 +388,8 @@ class Chat(BaseSDK):
393
388
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
394
389
  :param response_format:
395
390
  :param tools:
396
- :param safe_prompt: Whether to inject a safety prompt before all conversations.
397
391
  :param tool_choice:
392
+ :param safe_prompt: Whether to inject a safety prompt before all conversations.
398
393
  :param retries: Override the default retry configuration for this method
399
394
  :param server_url: Override the default server URL for this method
400
395
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -419,8 +414,8 @@ class Chat(BaseSDK):
419
414
  messages=utils.get_pydantic_model(messages, List[models.ChatCompletionRequestMessages]),
420
415
  response_format=utils.get_pydantic_model(response_format, Optional[models.ResponseFormat]),
421
416
  tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tool]]),
422
- safe_prompt=safe_prompt,
423
417
  tool_choice=tool_choice,
418
+ safe_prompt=safe_prompt,
424
419
  )
425
420
 
426
421
  req = self.build_request(
@@ -1,7 +1,7 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .assistantmessage import AssistantMessage, AssistantMessageRole, AssistantMessageTypedDict
4
- from .chatcompletionchoice import ChatCompletionChoice, ChatCompletionChoiceFinishReason, ChatCompletionChoiceTypedDict, Message, MessageTypedDict
4
+ from .chatcompletionchoice import ChatCompletionChoice, ChatCompletionChoiceFinishReason, ChatCompletionChoiceTypedDict
5
5
  from .chatcompletionrequest import ChatCompletionRequest, ChatCompletionRequestMessages, ChatCompletionRequestMessagesTypedDict, ChatCompletionRequestStop, ChatCompletionRequestStopTypedDict, ChatCompletionRequestToolChoice, ChatCompletionRequestTypedDict
6
6
  from .chatcompletionresponse import ChatCompletionResponse, ChatCompletionResponseTypedDict
7
7
  from .chatcompletionstreamrequest import ChatCompletionStreamRequest, ChatCompletionStreamRequestTypedDict, Messages, MessagesTypedDict, Stop, StopTypedDict, ToolChoice
@@ -11,7 +11,7 @@ from .completionresponsestreamchoice import CompletionResponseStreamChoice, Comp
11
11
  from .contentchunk import ContentChunk, ContentChunkTypedDict
12
12
  from .deltamessage import DeltaMessage, DeltaMessageTypedDict
13
13
  from .function import Function, FunctionTypedDict
14
- from .functioncall import FunctionCall, FunctionCallTypedDict
14
+ from .functioncall import Arguments, ArgumentsTypedDict, FunctionCall, FunctionCallTypedDict
15
15
  from .httpvalidationerror import HTTPValidationError, HTTPValidationErrorData
16
16
  from .responseformat import ResponseFormat, ResponseFormatTypedDict, ResponseFormats
17
17
  from .sdkerror import SDKError
@@ -25,4 +25,4 @@ from .usageinfo import UsageInfo, UsageInfoTypedDict
25
25
  from .usermessage import UserMessage, UserMessageContent, UserMessageContentTypedDict, UserMessageRole, UserMessageTypedDict
26
26
  from .validationerror import Loc, LocTypedDict, ValidationError, ValidationErrorTypedDict
27
27
 
28
- __all__ = ["AssistantMessage", "AssistantMessageRole", "AssistantMessageTypedDict", "ChatCompletionChoice", "ChatCompletionChoiceFinishReason", "ChatCompletionChoiceTypedDict", "ChatCompletionRequest", "ChatCompletionRequestMessages", "ChatCompletionRequestMessagesTypedDict", "ChatCompletionRequestStop", "ChatCompletionRequestStopTypedDict", "ChatCompletionRequestToolChoice", "ChatCompletionRequestTypedDict", "ChatCompletionResponse", "ChatCompletionResponseTypedDict", "ChatCompletionStreamRequest", "ChatCompletionStreamRequestTypedDict", "CompletionChunk", "CompletionChunkTypedDict", "CompletionEvent", "CompletionEventTypedDict", "CompletionResponseStreamChoice", "CompletionResponseStreamChoiceTypedDict", "Content", "ContentChunk", "ContentChunkTypedDict", "ContentTypedDict", "DeltaMessage", "DeltaMessageTypedDict", "FinishReason", "Function", "FunctionCall", "FunctionCallTypedDict", "FunctionTypedDict", "HTTPValidationError", "HTTPValidationErrorData", "Loc", "LocTypedDict", "Message", "MessageTypedDict", "Messages", "MessagesTypedDict", "ResponseFormat", "ResponseFormatTypedDict", "ResponseFormats", "Role", "SDKError", "Security", "SecurityTypedDict", "Stop", "StopTypedDict", "SystemMessage", "SystemMessageTypedDict", "TextChunk", "TextChunkTypedDict", "Tool", "ToolCall", "ToolCallTypedDict", "ToolChoice", "ToolMessage", "ToolMessageRole", "ToolMessageTypedDict", "ToolTypedDict", "UsageInfo", "UsageInfoTypedDict", "UserMessage", "UserMessageContent", "UserMessageContentTypedDict", "UserMessageRole", "UserMessageTypedDict", "ValidationError", "ValidationErrorTypedDict"]
28
+ __all__ = ["Arguments", "ArgumentsTypedDict", "AssistantMessage", "AssistantMessageRole", "AssistantMessageTypedDict", "ChatCompletionChoice", "ChatCompletionChoiceFinishReason", "ChatCompletionChoiceTypedDict", "ChatCompletionRequest", "ChatCompletionRequestMessages", "ChatCompletionRequestMessagesTypedDict", "ChatCompletionRequestStop", "ChatCompletionRequestStopTypedDict", "ChatCompletionRequestToolChoice", "ChatCompletionRequestTypedDict", "ChatCompletionResponse", "ChatCompletionResponseTypedDict", "ChatCompletionStreamRequest", "ChatCompletionStreamRequestTypedDict", "CompletionChunk", "CompletionChunkTypedDict", "CompletionEvent", "CompletionEventTypedDict", "CompletionResponseStreamChoice", "CompletionResponseStreamChoiceTypedDict", "Content", "ContentChunk", "ContentChunkTypedDict", "ContentTypedDict", "DeltaMessage", "DeltaMessageTypedDict", "FinishReason", "Function", "FunctionCall", "FunctionCallTypedDict", "FunctionTypedDict", "HTTPValidationError", "HTTPValidationErrorData", "Loc", "LocTypedDict", "Messages", "MessagesTypedDict", "ResponseFormat", "ResponseFormatTypedDict", "ResponseFormats", "Role", "SDKError", "Security", "SecurityTypedDict", "Stop", "StopTypedDict", "SystemMessage", "SystemMessageTypedDict", "TextChunk", "TextChunkTypedDict", "Tool", "ToolCall", "ToolCallTypedDict", "ToolChoice", "ToolMessage", "ToolMessageRole", "ToolMessageTypedDict", "ToolTypedDict", "UsageInfo", "UsageInfoTypedDict", "UserMessage", "UserMessageContent", "UserMessageContentTypedDict", "UserMessageRole", "UserMessageTypedDict", "ValidationError", "ValidationErrorTypedDict"]
@@ -39,18 +39,13 @@ class AssistantMessage(BaseModel):
39
39
  k = f.alias or n
40
40
  val = serialized.get(k)
41
41
 
42
+ optional_nullable = k in optional_fields and k in nullable_fields
43
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
44
+
42
45
  if val is not None and val != UNSET_SENTINEL:
43
46
  m[k] = val
44
47
  elif val != UNSET_SENTINEL and (
45
- not k in optional_fields
46
- or (
47
- k in optional_fields
48
- and k in nullable_fields
49
- and (
50
- self.__pydantic_fields_set__.intersection({n})
51
- or k in null_default_fields
52
- ) # pylint: disable=no-member
53
- )
48
+ not k in optional_fields or (optional_nullable and is_set)
54
49
  ):
55
50
  m[k] = val
56
51
 
@@ -2,14 +2,9 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
5
- from .systemmessage import SystemMessage, SystemMessageTypedDict
6
- from .toolmessage import ToolMessage, ToolMessageTypedDict
7
- from .usermessage import UserMessage, UserMessageTypedDict
8
5
  from mistralai_azure.types import BaseModel
9
- from mistralai_azure.utils import get_discriminator
10
- from pydantic import Discriminator, Tag
11
- from typing import Literal, Optional, TypedDict, Union
12
- from typing_extensions import Annotated, NotRequired
6
+ from typing import Literal, Optional, TypedDict
7
+ from typing_extensions import NotRequired
13
8
 
14
9
 
15
10
  ChatCompletionChoiceFinishReason = Literal["stop", "length", "model_length", "error", "tool_calls"]
@@ -17,17 +12,11 @@ ChatCompletionChoiceFinishReason = Literal["stop", "length", "model_length", "er
17
12
  class ChatCompletionChoiceTypedDict(TypedDict):
18
13
  index: int
19
14
  finish_reason: ChatCompletionChoiceFinishReason
20
- message: NotRequired[MessageTypedDict]
15
+ message: NotRequired[AssistantMessageTypedDict]
21
16
 
22
17
 
23
18
  class ChatCompletionChoice(BaseModel):
24
19
  index: int
25
20
  finish_reason: ChatCompletionChoiceFinishReason
26
- message: Optional[Message] = None
21
+ message: Optional[AssistantMessage] = None
27
22
 
28
-
29
- MessageTypedDict = Union[SystemMessageTypedDict, UserMessageTypedDict, AssistantMessageTypedDict, ToolMessageTypedDict]
30
-
31
-
32
- Message = Annotated[Union[Annotated[AssistantMessage, Tag("assistant")], Annotated[SystemMessage, Tag("system")], Annotated[ToolMessage, Tag("tool")], Annotated[UserMessage, Tag("user")]], Discriminator(lambda m: get_discriminator(m, "role", "role"))]
33
-
@@ -14,6 +14,20 @@ from typing import List, Literal, Optional, TypedDict, Union
14
14
  from typing_extensions import Annotated, NotRequired
15
15
 
16
16
 
17
+ ChatCompletionRequestStopTypedDict = Union[str, List[str]]
18
+ r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
19
+
20
+
21
+ ChatCompletionRequestStop = Union[str, List[str]]
22
+ r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
23
+
24
+
25
+ ChatCompletionRequestMessagesTypedDict = Union[SystemMessageTypedDict, UserMessageTypedDict, AssistantMessageTypedDict, ToolMessageTypedDict]
26
+
27
+
28
+ ChatCompletionRequestMessages = Annotated[Union[Annotated[AssistantMessage, Tag("assistant")], Annotated[SystemMessage, Tag("system")], Annotated[ToolMessage, Tag("tool")], Annotated[UserMessage, Tag("user")]], Discriminator(lambda m: get_discriminator(m, "role", "role"))]
29
+
30
+
17
31
  ChatCompletionRequestToolChoice = Literal["auto", "none", "any"]
18
32
 
19
33
  class ChatCompletionRequestTypedDict(TypedDict):
@@ -37,9 +51,9 @@ class ChatCompletionRequestTypedDict(TypedDict):
37
51
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
38
52
  response_format: NotRequired[ResponseFormatTypedDict]
39
53
  tools: NotRequired[Nullable[List[ToolTypedDict]]]
54
+ tool_choice: NotRequired[ChatCompletionRequestToolChoice]
40
55
  safe_prompt: NotRequired[bool]
41
56
  r"""Whether to inject a safety prompt before all conversations."""
42
- tool_choice: NotRequired[ChatCompletionRequestToolChoice]
43
57
 
44
58
 
45
59
  class ChatCompletionRequest(BaseModel):
@@ -63,13 +77,13 @@ class ChatCompletionRequest(BaseModel):
63
77
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
64
78
  response_format: Optional[ResponseFormat] = None
65
79
  tools: OptionalNullable[List[Tool]] = UNSET
80
+ tool_choice: Optional[ChatCompletionRequestToolChoice] = "auto"
66
81
  safe_prompt: Optional[bool] = False
67
82
  r"""Whether to inject a safety prompt before all conversations."""
68
- tool_choice: Optional[ChatCompletionRequestToolChoice] = "auto"
69
83
 
70
84
  @model_serializer(mode="wrap")
71
85
  def serialize_model(self, handler):
72
- optional_fields = ["model", "temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "response_format", "tools", "safe_prompt", "tool_choice"]
86
+ optional_fields = ["model", "temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "response_format", "tools", "tool_choice", "safe_prompt"]
73
87
  nullable_fields = ["model", "max_tokens", "min_tokens", "random_seed", "tools"]
74
88
  null_default_fields = []
75
89
 
@@ -81,34 +95,15 @@ class ChatCompletionRequest(BaseModel):
81
95
  k = f.alias or n
82
96
  val = serialized.get(k)
83
97
 
98
+ optional_nullable = k in optional_fields and k in nullable_fields
99
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
100
+
84
101
  if val is not None and val != UNSET_SENTINEL:
85
102
  m[k] = val
86
103
  elif val != UNSET_SENTINEL and (
87
- not k in optional_fields
88
- or (
89
- k in optional_fields
90
- and k in nullable_fields
91
- and (
92
- self.__pydantic_fields_set__.intersection({n})
93
- or k in null_default_fields
94
- ) # pylint: disable=no-member
95
- )
104
+ not k in optional_fields or (optional_nullable and is_set)
96
105
  ):
97
106
  m[k] = val
98
107
 
99
108
  return m
100
109
 
101
-
102
- ChatCompletionRequestStopTypedDict = Union[str, List[str]]
103
- r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
104
-
105
-
106
- ChatCompletionRequestStop = Union[str, List[str]]
107
- r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
108
-
109
-
110
- ChatCompletionRequestMessagesTypedDict = Union[SystemMessageTypedDict, UserMessageTypedDict, AssistantMessageTypedDict, ToolMessageTypedDict]
111
-
112
-
113
- ChatCompletionRequestMessages = Annotated[Union[Annotated[AssistantMessage, Tag("assistant")], Annotated[SystemMessage, Tag("system")], Annotated[ToolMessage, Tag("tool")], Annotated[UserMessage, Tag("user")]], Discriminator(lambda m: get_discriminator(m, "role", "role"))]
114
-
@@ -14,6 +14,20 @@ from typing import List, Literal, Optional, TypedDict, Union
14
14
  from typing_extensions import Annotated, NotRequired
15
15
 
16
16
 
17
+ StopTypedDict = Union[str, List[str]]
18
+ r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
19
+
20
+
21
+ Stop = Union[str, List[str]]
22
+ r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
23
+
24
+
25
+ MessagesTypedDict = Union[SystemMessageTypedDict, UserMessageTypedDict, AssistantMessageTypedDict, ToolMessageTypedDict]
26
+
27
+
28
+ Messages = Annotated[Union[Annotated[AssistantMessage, Tag("assistant")], Annotated[SystemMessage, Tag("system")], Annotated[ToolMessage, Tag("tool")], Annotated[UserMessage, Tag("user")]], Discriminator(lambda m: get_discriminator(m, "role", "role"))]
29
+
30
+
17
31
  ToolChoice = Literal["auto", "none", "any"]
18
32
 
19
33
  class ChatCompletionStreamRequestTypedDict(TypedDict):
@@ -36,9 +50,9 @@ class ChatCompletionStreamRequestTypedDict(TypedDict):
36
50
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
37
51
  response_format: NotRequired[ResponseFormatTypedDict]
38
52
  tools: NotRequired[Nullable[List[ToolTypedDict]]]
53
+ tool_choice: NotRequired[ToolChoice]
39
54
  safe_prompt: NotRequired[bool]
40
55
  r"""Whether to inject a safety prompt before all conversations."""
41
- tool_choice: NotRequired[ToolChoice]
42
56
 
43
57
 
44
58
  class ChatCompletionStreamRequest(BaseModel):
@@ -61,13 +75,13 @@ class ChatCompletionStreamRequest(BaseModel):
61
75
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
62
76
  response_format: Optional[ResponseFormat] = None
63
77
  tools: OptionalNullable[List[Tool]] = UNSET
78
+ tool_choice: Optional[ToolChoice] = "auto"
64
79
  safe_prompt: Optional[bool] = False
65
80
  r"""Whether to inject a safety prompt before all conversations."""
66
- tool_choice: Optional[ToolChoice] = "auto"
67
81
 
68
82
  @model_serializer(mode="wrap")
69
83
  def serialize_model(self, handler):
70
- optional_fields = ["model", "temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "response_format", "tools", "safe_prompt", "tool_choice"]
84
+ optional_fields = ["model", "temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "response_format", "tools", "tool_choice", "safe_prompt"]
71
85
  nullable_fields = ["model", "max_tokens", "min_tokens", "random_seed", "tools"]
72
86
  null_default_fields = []
73
87
 
@@ -79,34 +93,15 @@ class ChatCompletionStreamRequest(BaseModel):
79
93
  k = f.alias or n
80
94
  val = serialized.get(k)
81
95
 
96
+ optional_nullable = k in optional_fields and k in nullable_fields
97
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
98
+
82
99
  if val is not None and val != UNSET_SENTINEL:
83
100
  m[k] = val
84
101
  elif val != UNSET_SENTINEL and (
85
- not k in optional_fields
86
- or (
87
- k in optional_fields
88
- and k in nullable_fields
89
- and (
90
- self.__pydantic_fields_set__.intersection({n})
91
- or k in null_default_fields
92
- ) # pylint: disable=no-member
93
- )
102
+ not k in optional_fields or (optional_nullable and is_set)
94
103
  ):
95
104
  m[k] = val
96
105
 
97
106
  return m
98
107
 
99
-
100
- StopTypedDict = Union[str, List[str]]
101
- r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
102
-
103
-
104
- Stop = Union[str, List[str]]
105
- r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
106
-
107
-
108
- MessagesTypedDict = Union[SystemMessageTypedDict, UserMessageTypedDict, AssistantMessageTypedDict, ToolMessageTypedDict]
109
-
110
-
111
- Messages = Annotated[Union[Annotated[AssistantMessage, Tag("assistant")], Annotated[SystemMessage, Tag("system")], Annotated[ToolMessage, Tag("tool")], Annotated[UserMessage, Tag("user")]], Discriminator(lambda m: get_discriminator(m, "role", "role"))]
112
-
@@ -34,18 +34,13 @@ class CompletionResponseStreamChoice(BaseModel):
34
34
  k = f.alias or n
35
35
  val = serialized.get(k)
36
36
 
37
+ optional_nullable = k in optional_fields and k in nullable_fields
38
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
39
+
37
40
  if val is not None and val != UNSET_SENTINEL:
38
41
  m[k] = val
39
42
  elif val != UNSET_SENTINEL and (
40
- not k in optional_fields
41
- or (
42
- k in optional_fields
43
- and k in nullable_fields
44
- and (
45
- self.__pydantic_fields_set__.intersection({n})
46
- or k in null_default_fields
47
- ) # pylint: disable=no-member
48
- )
43
+ not k in optional_fields or (optional_nullable and is_set)
49
44
  ):
50
45
  m[k] = val
51
46
 
@@ -4,20 +4,20 @@ from __future__ import annotations
4
4
  from .toolcall import ToolCall, ToolCallTypedDict
5
5
  from mistralai_azure.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
6
6
  from pydantic import model_serializer
7
- from typing import Optional, TypedDict
7
+ from typing import List, Optional, TypedDict
8
8
  from typing_extensions import NotRequired
9
9
 
10
10
 
11
11
  class DeltaMessageTypedDict(TypedDict):
12
12
  role: NotRequired[str]
13
13
  content: NotRequired[str]
14
- tool_calls: NotRequired[Nullable[ToolCallTypedDict]]
14
+ tool_calls: NotRequired[Nullable[List[ToolCallTypedDict]]]
15
15
 
16
16
 
17
17
  class DeltaMessage(BaseModel):
18
18
  role: Optional[str] = None
19
19
  content: Optional[str] = None
20
- tool_calls: OptionalNullable[ToolCall] = UNSET
20
+ tool_calls: OptionalNullable[List[ToolCall]] = UNSET
21
21
 
22
22
  @model_serializer(mode="wrap")
23
23
  def serialize_model(self, handler):
@@ -33,18 +33,13 @@ class DeltaMessage(BaseModel):
33
33
  k = f.alias or n
34
34
  val = serialized.get(k)
35
35
 
36
+ optional_nullable = k in optional_fields and k in nullable_fields
37
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
38
+
36
39
  if val is not None and val != UNSET_SENTINEL:
37
40
  m[k] = val
38
41
  elif val != UNSET_SENTINEL and (
39
- not k in optional_fields
40
- or (
41
- k in optional_fields
42
- and k in nullable_fields
43
- and (
44
- self.__pydantic_fields_set__.intersection({n})
45
- or k in null_default_fields
46
- ) # pylint: disable=no-member
47
- )
42
+ not k in optional_fields or (optional_nullable and is_set)
48
43
  ):
49
44
  m[k] = val
50
45
 
@@ -2,15 +2,21 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from mistralai_azure.types import BaseModel
5
- from typing import TypedDict
5
+ from typing import Any, Dict, TypedDict, Union
6
+
7
+
8
+ ArgumentsTypedDict = Union[Dict[str, Any], str]
9
+
10
+
11
+ Arguments = Union[Dict[str, Any], str]
6
12
 
7
13
 
8
14
  class FunctionCallTypedDict(TypedDict):
9
15
  name: str
10
- arguments: str
16
+ arguments: ArgumentsTypedDict
11
17
 
12
18
 
13
19
  class FunctionCall(BaseModel):
14
20
  name: str
15
- arguments: str
21
+ arguments: Arguments
16
22
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from .validationerror import ValidationError
5
+ from mistralai_azure import utils
5
6
  from mistralai_azure.types import BaseModel
6
- import mistralai_azure.utils as utils
7
7
  from typing import List, Optional
8
8
 
9
9
  class HTTPValidationErrorData(BaseModel):
@@ -7,6 +7,12 @@ from typing import List, Literal, Optional, TypedDict, Union
7
7
  from typing_extensions import NotRequired
8
8
 
9
9
 
10
+ ContentTypedDict = Union[str, List[ContentChunkTypedDict]]
11
+
12
+
13
+ Content = Union[str, List[ContentChunk]]
14
+
15
+
10
16
  Role = Literal["system"]
11
17
 
12
18
  class SystemMessageTypedDict(TypedDict):
@@ -18,9 +24,3 @@ class SystemMessage(BaseModel):
18
24
  content: Content
19
25
  role: Optional[Role] = "system"
20
26
 
21
-
22
- ContentTypedDict = Union[str, List[ContentChunkTypedDict]]
23
-
24
-
25
- Content = Union[str, List[ContentChunk]]
26
-
@@ -36,18 +36,13 @@ class ToolMessage(BaseModel):
36
36
  k = f.alias or n
37
37
  val = serialized.get(k)
38
38
 
39
+ optional_nullable = k in optional_fields and k in nullable_fields
40
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
41
+
39
42
  if val is not None and val != UNSET_SENTINEL:
40
43
  m[k] = val
41
44
  elif val != UNSET_SENTINEL and (
42
- not k in optional_fields
43
- or (
44
- k in optional_fields
45
- and k in nullable_fields
46
- and (
47
- self.__pydantic_fields_set__.intersection({n})
48
- or k in null_default_fields
49
- ) # pylint: disable=no-member
50
- )
45
+ not k in optional_fields or (optional_nullable and is_set)
51
46
  ):
52
47
  m[k] = val
53
48
 
@@ -7,6 +7,12 @@ from typing import List, Literal, Optional, TypedDict, Union
7
7
  from typing_extensions import NotRequired
8
8
 
9
9
 
10
+ UserMessageContentTypedDict = Union[str, List[TextChunkTypedDict]]
11
+
12
+
13
+ UserMessageContent = Union[str, List[TextChunk]]
14
+
15
+
10
16
  UserMessageRole = Literal["user"]
11
17
 
12
18
  class UserMessageTypedDict(TypedDict):
@@ -18,9 +24,3 @@ class UserMessage(BaseModel):
18
24
  content: UserMessageContent
19
25
  role: Optional[UserMessageRole] = "user"
20
26
 
21
-
22
- UserMessageContentTypedDict = Union[str, List[TextChunkTypedDict]]
23
-
24
-
25
- UserMessageContent = Union[str, List[TextChunk]]
26
-
@@ -5,6 +5,12 @@ from mistralai_azure.types import BaseModel
5
5
  from typing import List, TypedDict, Union
6
6
 
7
7
 
8
+ LocTypedDict = Union[str, int]
9
+
10
+
11
+ Loc = Union[str, int]
12
+
13
+
8
14
  class ValidationErrorTypedDict(TypedDict):
9
15
  loc: List[LocTypedDict]
10
16
  msg: str
@@ -16,9 +22,3 @@ class ValidationError(BaseModel):
16
22
  msg: str
17
23
  type: str
18
24
 
19
-
20
- LocTypedDict = Union[str, int]
21
-
22
-
23
- Loc = Union[str, int]
24
-