mistralai 1.9.11__py3-none-any.whl → 1.10.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. mistralai/_hooks/registration.py +5 -0
  2. mistralai/_hooks/tracing.py +50 -0
  3. mistralai/_version.py +2 -2
  4. mistralai/accesses.py +8 -8
  5. mistralai/agents.py +29 -17
  6. mistralai/chat.py +41 -29
  7. mistralai/conversations.py +294 -62
  8. mistralai/documents.py +19 -3
  9. mistralai/embeddings.py +6 -6
  10. mistralai/extra/observability/__init__.py +15 -0
  11. mistralai/extra/observability/otel.py +393 -0
  12. mistralai/extra/run/tools.py +28 -16
  13. mistralai/files.py +6 -0
  14. mistralai/fim.py +17 -5
  15. mistralai/mistral_agents.py +229 -1
  16. mistralai/mistral_jobs.py +10 -10
  17. mistralai/models/__init__.py +69 -2
  18. mistralai/models/agent.py +15 -2
  19. mistralai/models/agentconversation.py +11 -3
  20. mistralai/models/agentcreationrequest.py +6 -2
  21. mistralai/models/agents_api_v1_agents_deleteop.py +16 -0
  22. mistralai/models/agents_api_v1_agents_getop.py +40 -3
  23. mistralai/models/agents_api_v1_agents_listop.py +72 -2
  24. mistralai/models/agents_api_v1_conversations_deleteop.py +18 -0
  25. mistralai/models/agents_api_v1_conversations_listop.py +39 -2
  26. mistralai/models/agentscompletionrequest.py +21 -6
  27. mistralai/models/agentscompletionstreamrequest.py +21 -6
  28. mistralai/models/agentupdaterequest.py +18 -2
  29. mistralai/models/audiotranscriptionrequest.py +2 -0
  30. mistralai/models/batchjobin.py +10 -0
  31. mistralai/models/chatcompletionrequest.py +22 -5
  32. mistralai/models/chatcompletionstreamrequest.py +22 -5
  33. mistralai/models/conversationrequest.py +15 -4
  34. mistralai/models/conversationrestartrequest.py +50 -2
  35. mistralai/models/conversationrestartstreamrequest.py +50 -2
  36. mistralai/models/conversationstreamrequest.py +15 -4
  37. mistralai/models/documentout.py +26 -10
  38. mistralai/models/documentupdatein.py +24 -3
  39. mistralai/models/embeddingrequest.py +8 -8
  40. mistralai/models/files_api_routes_list_filesop.py +7 -0
  41. mistralai/models/fimcompletionrequest.py +8 -9
  42. mistralai/models/fimcompletionstreamrequest.py +8 -9
  43. mistralai/models/libraries_documents_list_v1op.py +15 -2
  44. mistralai/models/libraryout.py +10 -7
  45. mistralai/models/listfilesout.py +35 -4
  46. mistralai/models/modelcapabilities.py +13 -4
  47. mistralai/models/modelconversation.py +8 -2
  48. mistralai/models/ocrpageobject.py +26 -5
  49. mistralai/models/ocrrequest.py +17 -1
  50. mistralai/models/ocrtableobject.py +31 -0
  51. mistralai/models/prediction.py +4 -0
  52. mistralai/models/requestsource.py +7 -0
  53. mistralai/models/responseformat.py +4 -2
  54. mistralai/models/responseformats.py +0 -1
  55. mistralai/models/sharingdelete.py +36 -5
  56. mistralai/models/sharingin.py +36 -5
  57. mistralai/models/sharingout.py +3 -3
  58. mistralai/models/toolexecutiondeltaevent.py +13 -4
  59. mistralai/models/toolexecutiondoneevent.py +13 -4
  60. mistralai/models/toolexecutionentry.py +9 -4
  61. mistralai/models/toolexecutionstartedevent.py +13 -4
  62. mistralai/models_.py +2 -14
  63. mistralai/ocr.py +18 -0
  64. mistralai/transcriptions.py +4 -4
  65. {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/METADATA +30 -12
  66. {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/RECORD +68 -61
  67. {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/WHEEL +0 -0
  68. {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/licenses/LICENSE +0 -0
@@ -15,7 +15,7 @@ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_
15
15
  from mistralai.utils import get_discriminator, validate_open_enum
16
16
  from pydantic import Discriminator, Tag, model_serializer
17
17
  from pydantic.functional_validators import PlainValidator
18
- from typing import List, Optional, Union
18
+ from typing import Any, Dict, List, Optional, Union
19
19
  from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
20
20
 
21
21
 
@@ -77,16 +77,19 @@ class AgentsCompletionRequestTypedDict(TypedDict):
77
77
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
78
78
  random_seed: NotRequired[Nullable[int]]
79
79
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
80
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
80
81
  response_format: NotRequired[ResponseFormatTypedDict]
82
+ r"""Specify the format that the model must output. By default it will use `{ \"type\": \"text\" }`. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ \"type\": \"json_schema\" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide."""
81
83
  tools: NotRequired[Nullable[List[ToolTypedDict]]]
82
84
  tool_choice: NotRequired[AgentsCompletionRequestToolChoiceTypedDict]
83
85
  presence_penalty: NotRequired[float]
84
- r"""presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
86
+ r"""The `presence_penalty` determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
85
87
  frequency_penalty: NotRequired[float]
86
- r"""frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
88
+ r"""The `frequency_penalty` penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
87
89
  n: NotRequired[Nullable[int]]
88
90
  r"""Number of completions to return for each request, input tokens are only billed once."""
89
91
  prediction: NotRequired[PredictionTypedDict]
92
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
90
93
  parallel_tool_calls: NotRequired[bool]
91
94
  prompt_mode: NotRequired[Nullable[MistralPromptMode]]
92
95
  r"""Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used."""
@@ -111,22 +114,26 @@ class AgentsCompletionRequest(BaseModel):
111
114
  random_seed: OptionalNullable[int] = UNSET
112
115
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
113
116
 
117
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET
118
+
114
119
  response_format: Optional[ResponseFormat] = None
120
+ r"""Specify the format that the model must output. By default it will use `{ \"type\": \"text\" }`. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ \"type\": \"json_schema\" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide."""
115
121
 
116
122
  tools: OptionalNullable[List[Tool]] = UNSET
117
123
 
118
124
  tool_choice: Optional[AgentsCompletionRequestToolChoice] = None
119
125
 
120
126
  presence_penalty: Optional[float] = None
121
- r"""presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
127
+ r"""The `presence_penalty` determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
122
128
 
123
129
  frequency_penalty: Optional[float] = None
124
- r"""frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
130
+ r"""The `frequency_penalty` penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
125
131
 
126
132
  n: OptionalNullable[int] = UNSET
127
133
  r"""Number of completions to return for each request, input tokens are only billed once."""
128
134
 
129
135
  prediction: Optional[Prediction] = None
136
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
130
137
 
131
138
  parallel_tool_calls: Optional[bool] = None
132
139
 
@@ -142,6 +149,7 @@ class AgentsCompletionRequest(BaseModel):
142
149
  "stream",
143
150
  "stop",
144
151
  "random_seed",
152
+ "metadata",
145
153
  "response_format",
146
154
  "tools",
147
155
  "tool_choice",
@@ -152,7 +160,14 @@ class AgentsCompletionRequest(BaseModel):
152
160
  "parallel_tool_calls",
153
161
  "prompt_mode",
154
162
  ]
155
- nullable_fields = ["max_tokens", "random_seed", "tools", "n", "prompt_mode"]
163
+ nullable_fields = [
164
+ "max_tokens",
165
+ "random_seed",
166
+ "metadata",
167
+ "tools",
168
+ "n",
169
+ "prompt_mode",
170
+ ]
156
171
  null_default_fields = []
157
172
 
158
173
  serialized = handler(self)
@@ -15,7 +15,7 @@ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_
15
15
  from mistralai.utils import get_discriminator, validate_open_enum
16
16
  from pydantic import Discriminator, Tag, model_serializer
17
17
  from pydantic.functional_validators import PlainValidator
18
- from typing import List, Optional, Union
18
+ from typing import Any, Dict, List, Optional, Union
19
19
  from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
20
20
 
21
21
 
@@ -76,16 +76,19 @@ class AgentsCompletionStreamRequestTypedDict(TypedDict):
76
76
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
77
77
  random_seed: NotRequired[Nullable[int]]
78
78
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
79
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
79
80
  response_format: NotRequired[ResponseFormatTypedDict]
81
+ r"""Specify the format that the model must output. By default it will use `{ \"type\": \"text\" }`. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ \"type\": \"json_schema\" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide."""
80
82
  tools: NotRequired[Nullable[List[ToolTypedDict]]]
81
83
  tool_choice: NotRequired[AgentsCompletionStreamRequestToolChoiceTypedDict]
82
84
  presence_penalty: NotRequired[float]
83
- r"""presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
85
+ r"""The `presence_penalty` determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
84
86
  frequency_penalty: NotRequired[float]
85
- r"""frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
87
+ r"""The `frequency_penalty` penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
86
88
  n: NotRequired[Nullable[int]]
87
89
  r"""Number of completions to return for each request, input tokens are only billed once."""
88
90
  prediction: NotRequired[PredictionTypedDict]
91
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
89
92
  parallel_tool_calls: NotRequired[bool]
90
93
  prompt_mode: NotRequired[Nullable[MistralPromptMode]]
91
94
  r"""Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used."""
@@ -109,22 +112,26 @@ class AgentsCompletionStreamRequest(BaseModel):
109
112
  random_seed: OptionalNullable[int] = UNSET
110
113
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
111
114
 
115
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET
116
+
112
117
  response_format: Optional[ResponseFormat] = None
118
+ r"""Specify the format that the model must output. By default it will use `{ \"type\": \"text\" }`. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ \"type\": \"json_schema\" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide."""
113
119
 
114
120
  tools: OptionalNullable[List[Tool]] = UNSET
115
121
 
116
122
  tool_choice: Optional[AgentsCompletionStreamRequestToolChoice] = None
117
123
 
118
124
  presence_penalty: Optional[float] = None
119
- r"""presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
125
+ r"""The `presence_penalty` determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
120
126
 
121
127
  frequency_penalty: Optional[float] = None
122
- r"""frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
128
+ r"""The `frequency_penalty` penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
123
129
 
124
130
  n: OptionalNullable[int] = UNSET
125
131
  r"""Number of completions to return for each request, input tokens are only billed once."""
126
132
 
127
133
  prediction: Optional[Prediction] = None
134
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
128
135
 
129
136
  parallel_tool_calls: Optional[bool] = None
130
137
 
@@ -140,6 +147,7 @@ class AgentsCompletionStreamRequest(BaseModel):
140
147
  "stream",
141
148
  "stop",
142
149
  "random_seed",
150
+ "metadata",
143
151
  "response_format",
144
152
  "tools",
145
153
  "tool_choice",
@@ -150,7 +158,14 @@ class AgentsCompletionStreamRequest(BaseModel):
150
158
  "parallel_tool_calls",
151
159
  "prompt_mode",
152
160
  ]
153
- nullable_fields = ["max_tokens", "random_seed", "tools", "n", "prompt_mode"]
161
+ nullable_fields = [
162
+ "max_tokens",
163
+ "random_seed",
164
+ "metadata",
165
+ "tools",
166
+ "n",
167
+ "prompt_mode",
168
+ ]
154
169
  null_default_fields = []
155
170
 
156
171
  serialized = handler(self)
@@ -11,7 +11,7 @@ from .websearchtool import WebSearchTool, WebSearchToolTypedDict
11
11
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
12
12
  from mistralai.utils import get_discriminator
13
13
  from pydantic import Discriminator, Tag, model_serializer
14
- from typing import List, Optional, Union
14
+ from typing import Any, Dict, List, Optional, Union
15
15
  from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
16
16
 
17
17
 
@@ -52,6 +52,8 @@ class AgentUpdateRequestTypedDict(TypedDict):
52
52
  name: NotRequired[Nullable[str]]
53
53
  description: NotRequired[Nullable[str]]
54
54
  handoffs: NotRequired[Nullable[List[str]]]
55
+ deployment_chat: NotRequired[Nullable[bool]]
56
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
55
57
 
56
58
 
57
59
  class AgentUpdateRequest(BaseModel):
@@ -72,6 +74,10 @@ class AgentUpdateRequest(BaseModel):
72
74
 
73
75
  handoffs: OptionalNullable[List[str]] = UNSET
74
76
 
77
+ deployment_chat: OptionalNullable[bool] = UNSET
78
+
79
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET
80
+
75
81
  @model_serializer(mode="wrap")
76
82
  def serialize_model(self, handler):
77
83
  optional_fields = [
@@ -82,8 +88,18 @@ class AgentUpdateRequest(BaseModel):
82
88
  "name",
83
89
  "description",
84
90
  "handoffs",
91
+ "deployment_chat",
92
+ "metadata",
93
+ ]
94
+ nullable_fields = [
95
+ "instructions",
96
+ "model",
97
+ "name",
98
+ "description",
99
+ "handoffs",
100
+ "deployment_chat",
101
+ "metadata",
85
102
  ]
86
- nullable_fields = ["instructions", "model", "name", "description", "handoffs"]
87
103
  null_default_fields = []
88
104
 
89
105
  serialized = handler(self)
@@ -14,6 +14,7 @@ from typing_extensions import Annotated, NotRequired, TypedDict
14
14
 
15
15
  class AudioTranscriptionRequestTypedDict(TypedDict):
16
16
  model: str
17
+ r"""ID of the model to be used."""
17
18
  file: NotRequired[FileTypedDict]
18
19
  file_url: NotRequired[Nullable[str]]
19
20
  r"""Url of a file to be transcribed"""
@@ -29,6 +30,7 @@ class AudioTranscriptionRequestTypedDict(TypedDict):
29
30
 
30
31
  class AudioTranscriptionRequest(BaseModel):
31
32
  model: Annotated[str, FieldMetadata(multipart=True)]
33
+ r"""ID of the model to be used."""
32
34
 
33
35
  file: Annotated[
34
36
  Optional[File], FieldMetadata(multipart=MultipartFormMetadata(file=True))
@@ -12,25 +12,35 @@ from typing_extensions import Annotated, NotRequired, TypedDict
12
12
 
13
13
  class BatchJobInTypedDict(TypedDict):
14
14
  input_files: List[str]
15
+ r"""The list of input files to be used for batch inference, these files should be `jsonl` files, containing the input data corresponding to the bory request for the batch inference in a \"body\" field. An example of such file is the following: ```json {\"custom_id\": \"0\", \"body\": {\"max_tokens\": 100, \"messages\": [{\"role\": \"user\", \"content\": \"What is the best French cheese?\"}]}} {\"custom_id\": \"1\", \"body\": {\"max_tokens\": 100, \"messages\": [{\"role\": \"user\", \"content\": \"What is the best French wine?\"}]}} ```"""
15
16
  endpoint: APIEndpoint
16
17
  model: NotRequired[Nullable[str]]
18
+ r"""The model to be used for batch inference."""
17
19
  agent_id: NotRequired[Nullable[str]]
20
+ r"""In case you want to use a specific agent from the **deprecated** agents api for batch inference, you can specify the agent ID here."""
18
21
  metadata: NotRequired[Nullable[Dict[str, str]]]
22
+ r"""The metadata of your choice to be associated with the batch inference job."""
19
23
  timeout_hours: NotRequired[int]
24
+ r"""The timeout in hours for the batch inference job."""
20
25
 
21
26
 
22
27
  class BatchJobIn(BaseModel):
23
28
  input_files: List[str]
29
+ r"""The list of input files to be used for batch inference, these files should be `jsonl` files, containing the input data corresponding to the bory request for the batch inference in a \"body\" field. An example of such file is the following: ```json {\"custom_id\": \"0\", \"body\": {\"max_tokens\": 100, \"messages\": [{\"role\": \"user\", \"content\": \"What is the best French cheese?\"}]}} {\"custom_id\": \"1\", \"body\": {\"max_tokens\": 100, \"messages\": [{\"role\": \"user\", \"content\": \"What is the best French wine?\"}]}} ```"""
24
30
 
25
31
  endpoint: Annotated[APIEndpoint, PlainValidator(validate_open_enum(False))]
26
32
 
27
33
  model: OptionalNullable[str] = UNSET
34
+ r"""The model to be used for batch inference."""
28
35
 
29
36
  agent_id: OptionalNullable[str] = UNSET
37
+ r"""In case you want to use a specific agent from the **deprecated** agents api for batch inference, you can specify the agent ID here."""
30
38
 
31
39
  metadata: OptionalNullable[Dict[str, str]] = UNSET
40
+ r"""The metadata of your choice to be associated with the batch inference job."""
32
41
 
33
42
  timeout_hours: Optional[int] = 24
43
+ r"""The timeout in hours for the batch inference job."""
34
44
 
35
45
  @model_serializer(mode="wrap")
36
46
  def serialize_model(self, handler):
@@ -15,7 +15,7 @@ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_
15
15
  from mistralai.utils import get_discriminator, validate_open_enum
16
16
  from pydantic import Discriminator, Tag, model_serializer
17
17
  from pydantic.functional_validators import PlainValidator
18
- from typing import List, Optional, Union
18
+ from typing import Any, Dict, List, Optional, Union
19
19
  from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
20
20
 
21
21
 
@@ -53,11 +53,13 @@ ChatCompletionRequestToolChoiceTypedDict = TypeAliasType(
53
53
  "ChatCompletionRequestToolChoiceTypedDict",
54
54
  Union[ToolChoiceTypedDict, ToolChoiceEnum],
55
55
  )
56
+ r"""Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `any` or `required` means the model must call one or more tools. Specifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool."""
56
57
 
57
58
 
58
59
  ChatCompletionRequestToolChoice = TypeAliasType(
59
60
  "ChatCompletionRequestToolChoice", Union[ToolChoice, ToolChoiceEnum]
60
61
  )
62
+ r"""Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `any` or `required` means the model must call one or more tools. Specifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool."""
61
63
 
62
64
 
63
65
  class ChatCompletionRequestTypedDict(TypedDict):
@@ -77,17 +79,23 @@ class ChatCompletionRequestTypedDict(TypedDict):
77
79
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
78
80
  random_seed: NotRequired[Nullable[int]]
79
81
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
82
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
80
83
  response_format: NotRequired[ResponseFormatTypedDict]
84
+ r"""Specify the format that the model must output. By default it will use `{ \"type\": \"text\" }`. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ \"type\": \"json_schema\" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide."""
81
85
  tools: NotRequired[Nullable[List[ToolTypedDict]]]
86
+ r"""A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for."""
82
87
  tool_choice: NotRequired[ChatCompletionRequestToolChoiceTypedDict]
88
+ r"""Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `any` or `required` means the model must call one or more tools. Specifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool."""
83
89
  presence_penalty: NotRequired[float]
84
- r"""presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
90
+ r"""The `presence_penalty` determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
85
91
  frequency_penalty: NotRequired[float]
86
- r"""frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
92
+ r"""The `frequency_penalty` penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
87
93
  n: NotRequired[Nullable[int]]
88
94
  r"""Number of completions to return for each request, input tokens are only billed once."""
89
95
  prediction: NotRequired[PredictionTypedDict]
96
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
90
97
  parallel_tool_calls: NotRequired[bool]
98
+ r"""Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel."""
91
99
  prompt_mode: NotRequired[Nullable[MistralPromptMode]]
92
100
  r"""Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used."""
93
101
  safe_prompt: NotRequired[bool]
@@ -119,24 +127,31 @@ class ChatCompletionRequest(BaseModel):
119
127
  random_seed: OptionalNullable[int] = UNSET
120
128
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
121
129
 
130
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET
131
+
122
132
  response_format: Optional[ResponseFormat] = None
133
+ r"""Specify the format that the model must output. By default it will use `{ \"type\": \"text\" }`. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ \"type\": \"json_schema\" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide."""
123
134
 
124
135
  tools: OptionalNullable[List[Tool]] = UNSET
136
+ r"""A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for."""
125
137
 
126
138
  tool_choice: Optional[ChatCompletionRequestToolChoice] = None
139
+ r"""Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `any` or `required` means the model must call one or more tools. Specifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool."""
127
140
 
128
141
  presence_penalty: Optional[float] = None
129
- r"""presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
142
+ r"""The `presence_penalty` determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
130
143
 
131
144
  frequency_penalty: Optional[float] = None
132
- r"""frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
145
+ r"""The `frequency_penalty` penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
133
146
 
134
147
  n: OptionalNullable[int] = UNSET
135
148
  r"""Number of completions to return for each request, input tokens are only billed once."""
136
149
 
137
150
  prediction: Optional[Prediction] = None
151
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
138
152
 
139
153
  parallel_tool_calls: Optional[bool] = None
154
+ r"""Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel."""
140
155
 
141
156
  prompt_mode: Annotated[
142
157
  OptionalNullable[MistralPromptMode], PlainValidator(validate_open_enum(False))
@@ -155,6 +170,7 @@ class ChatCompletionRequest(BaseModel):
155
170
  "stream",
156
171
  "stop",
157
172
  "random_seed",
173
+ "metadata",
158
174
  "response_format",
159
175
  "tools",
160
176
  "tool_choice",
@@ -170,6 +186,7 @@ class ChatCompletionRequest(BaseModel):
170
186
  "temperature",
171
187
  "max_tokens",
172
188
  "random_seed",
189
+ "metadata",
173
190
  "tools",
174
191
  "n",
175
192
  "prompt_mode",
@@ -15,7 +15,7 @@ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_
15
15
  from mistralai.utils import get_discriminator, validate_open_enum
16
16
  from pydantic import Discriminator, Tag, model_serializer
17
17
  from pydantic.functional_validators import PlainValidator
18
- from typing import List, Optional, Union
18
+ from typing import Any, Dict, List, Optional, Union
19
19
  from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
20
20
 
21
21
 
@@ -57,11 +57,13 @@ ChatCompletionStreamRequestToolChoiceTypedDict = TypeAliasType(
57
57
  "ChatCompletionStreamRequestToolChoiceTypedDict",
58
58
  Union[ToolChoiceTypedDict, ToolChoiceEnum],
59
59
  )
60
+ r"""Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `any` or `required` means the model must call one or more tools. Specifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool."""
60
61
 
61
62
 
62
63
  ChatCompletionStreamRequestToolChoice = TypeAliasType(
63
64
  "ChatCompletionStreamRequestToolChoice", Union[ToolChoice, ToolChoiceEnum]
64
65
  )
66
+ r"""Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `any` or `required` means the model must call one or more tools. Specifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool."""
65
67
 
66
68
 
67
69
  class ChatCompletionStreamRequestTypedDict(TypedDict):
@@ -80,17 +82,23 @@ class ChatCompletionStreamRequestTypedDict(TypedDict):
80
82
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
81
83
  random_seed: NotRequired[Nullable[int]]
82
84
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
85
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
83
86
  response_format: NotRequired[ResponseFormatTypedDict]
87
+ r"""Specify the format that the model must output. By default it will use `{ \"type\": \"text\" }`. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ \"type\": \"json_schema\" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide."""
84
88
  tools: NotRequired[Nullable[List[ToolTypedDict]]]
89
+ r"""A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for."""
85
90
  tool_choice: NotRequired[ChatCompletionStreamRequestToolChoiceTypedDict]
91
+ r"""Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `any` or `required` means the model must call one or more tools. Specifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool."""
86
92
  presence_penalty: NotRequired[float]
87
- r"""presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
93
+ r"""The `presence_penalty` determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
88
94
  frequency_penalty: NotRequired[float]
89
- r"""frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
95
+ r"""The `frequency_penalty` penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
90
96
  n: NotRequired[Nullable[int]]
91
97
  r"""Number of completions to return for each request, input tokens are only billed once."""
92
98
  prediction: NotRequired[PredictionTypedDict]
99
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
93
100
  parallel_tool_calls: NotRequired[bool]
101
+ r"""Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel."""
94
102
  prompt_mode: NotRequired[Nullable[MistralPromptMode]]
95
103
  r"""Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used."""
96
104
  safe_prompt: NotRequired[bool]
@@ -121,24 +129,31 @@ class ChatCompletionStreamRequest(BaseModel):
121
129
  random_seed: OptionalNullable[int] = UNSET
122
130
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
123
131
 
132
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET
133
+
124
134
  response_format: Optional[ResponseFormat] = None
135
+ r"""Specify the format that the model must output. By default it will use `{ \"type\": \"text\" }`. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ \"type\": \"json_schema\" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide."""
125
136
 
126
137
  tools: OptionalNullable[List[Tool]] = UNSET
138
+ r"""A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for."""
127
139
 
128
140
  tool_choice: Optional[ChatCompletionStreamRequestToolChoice] = None
141
+ r"""Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `any` or `required` means the model must call one or more tools. Specifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool."""
129
142
 
130
143
  presence_penalty: Optional[float] = None
131
- r"""presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
144
+ r"""The `presence_penalty` determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
132
145
 
133
146
  frequency_penalty: Optional[float] = None
134
- r"""frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
147
+ r"""The `frequency_penalty` penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
135
148
 
136
149
  n: OptionalNullable[int] = UNSET
137
150
  r"""Number of completions to return for each request, input tokens are only billed once."""
138
151
 
139
152
  prediction: Optional[Prediction] = None
153
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
140
154
 
141
155
  parallel_tool_calls: Optional[bool] = None
156
+ r"""Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel."""
142
157
 
143
158
  prompt_mode: Annotated[
144
159
  OptionalNullable[MistralPromptMode], PlainValidator(validate_open_enum(False))
@@ -157,6 +172,7 @@ class ChatCompletionStreamRequest(BaseModel):
157
172
  "stream",
158
173
  "stop",
159
174
  "random_seed",
175
+ "metadata",
160
176
  "response_format",
161
177
  "tools",
162
178
  "tool_choice",
@@ -172,6 +188,7 @@ class ChatCompletionStreamRequest(BaseModel):
172
188
  "temperature",
173
189
  "max_tokens",
174
190
  "random_seed",
191
+ "metadata",
175
192
  "tools",
176
193
  "n",
177
194
  "prompt_mode",
@@ -12,7 +12,7 @@ from .websearchtool import WebSearchTool, WebSearchToolTypedDict
12
12
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
13
13
  from mistralai.utils import get_discriminator
14
14
  from pydantic import Discriminator, Tag, model_serializer
15
- from typing import List, Literal, Optional, Union
15
+ from typing import Any, Dict, List, Literal, Optional, Union
16
16
  from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
17
17
 
18
18
 
@@ -50,11 +50,14 @@ class ConversationRequestTypedDict(TypedDict):
50
50
  store: NotRequired[Nullable[bool]]
51
51
  handoff_execution: NotRequired[Nullable[HandoffExecution]]
52
52
  instructions: NotRequired[Nullable[str]]
53
- tools: NotRequired[Nullable[List[ToolsTypedDict]]]
53
+ tools: NotRequired[List[ToolsTypedDict]]
54
+ r"""List of tools which are available to the model during the conversation."""
54
55
  completion_args: NotRequired[Nullable[CompletionArgsTypedDict]]
55
56
  name: NotRequired[Nullable[str]]
56
57
  description: NotRequired[Nullable[str]]
58
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
57
59
  agent_id: NotRequired[Nullable[str]]
60
+ agent_version: NotRequired[Nullable[int]]
58
61
  model: NotRequired[Nullable[str]]
59
62
 
60
63
 
@@ -69,7 +72,8 @@ class ConversationRequest(BaseModel):
69
72
 
70
73
  instructions: OptionalNullable[str] = UNSET
71
74
 
72
- tools: OptionalNullable[List[Tools]] = UNSET
75
+ tools: Optional[List[Tools]] = None
76
+ r"""List of tools which are available to the model during the conversation."""
73
77
 
74
78
  completion_args: OptionalNullable[CompletionArgs] = UNSET
75
79
 
@@ -77,8 +81,12 @@ class ConversationRequest(BaseModel):
77
81
 
78
82
  description: OptionalNullable[str] = UNSET
79
83
 
84
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET
85
+
80
86
  agent_id: OptionalNullable[str] = UNSET
81
87
 
88
+ agent_version: OptionalNullable[int] = UNSET
89
+
82
90
  model: OptionalNullable[str] = UNSET
83
91
 
84
92
  @model_serializer(mode="wrap")
@@ -92,18 +100,21 @@ class ConversationRequest(BaseModel):
92
100
  "completion_args",
93
101
  "name",
94
102
  "description",
103
+ "metadata",
95
104
  "agent_id",
105
+ "agent_version",
96
106
  "model",
97
107
  ]
98
108
  nullable_fields = [
99
109
  "store",
100
110
  "handoff_execution",
101
111
  "instructions",
102
- "tools",
103
112
  "completion_args",
104
113
  "name",
105
114
  "description",
115
+ "metadata",
106
116
  "agent_id",
117
+ "agent_version",
107
118
  "model",
108
119
  ]
109
120
  null_default_fields = []
@@ -3,8 +3,9 @@
3
3
  from __future__ import annotations
4
4
  from .completionargs import CompletionArgs, CompletionArgsTypedDict
5
5
  from .conversationinputs import ConversationInputs, ConversationInputsTypedDict
6
- from mistralai.types import BaseModel
7
- from typing import Literal, Optional
6
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
7
+ from pydantic import model_serializer
8
+ from typing import Any, Dict, Literal, Optional
8
9
  from typing_extensions import NotRequired, TypedDict
9
10
 
10
11
 
@@ -22,6 +23,10 @@ class ConversationRestartRequestTypedDict(TypedDict):
22
23
  handoff_execution: NotRequired[ConversationRestartRequestHandoffExecution]
23
24
  completion_args: NotRequired[CompletionArgsTypedDict]
24
25
  r"""White-listed arguments from the completion API"""
26
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
27
+ r"""Custom metadata for the conversation."""
28
+ agent_version: NotRequired[Nullable[int]]
29
+ r"""Specific version of the agent to use when restarting. If not provided, uses the current version."""
25
30
 
26
31
 
27
32
  class ConversationRestartRequest(BaseModel):
@@ -40,3 +45,46 @@ class ConversationRestartRequest(BaseModel):
40
45
 
41
46
  completion_args: Optional[CompletionArgs] = None
42
47
  r"""White-listed arguments from the completion API"""
48
+
49
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET
50
+ r"""Custom metadata for the conversation."""
51
+
52
+ agent_version: OptionalNullable[int] = UNSET
53
+ r"""Specific version of the agent to use when restarting. If not provided, uses the current version."""
54
+
55
+ @model_serializer(mode="wrap")
56
+ def serialize_model(self, handler):
57
+ optional_fields = [
58
+ "stream",
59
+ "store",
60
+ "handoff_execution",
61
+ "completion_args",
62
+ "metadata",
63
+ "agent_version",
64
+ ]
65
+ nullable_fields = ["metadata", "agent_version"]
66
+ null_default_fields = []
67
+
68
+ serialized = handler(self)
69
+
70
+ m = {}
71
+
72
+ for n, f in type(self).model_fields.items():
73
+ k = f.alias or n
74
+ val = serialized.get(k)
75
+ serialized.pop(k, None)
76
+
77
+ optional_nullable = k in optional_fields and k in nullable_fields
78
+ is_set = (
79
+ self.__pydantic_fields_set__.intersection({n})
80
+ or k in null_default_fields
81
+ ) # pylint: disable=no-member
82
+
83
+ if val is not None and val != UNSET_SENTINEL:
84
+ m[k] = val
85
+ elif val != UNSET_SENTINEL and (
86
+ not k in optional_fields or (optional_nullable and is_set)
87
+ ):
88
+ m[k] = val
89
+
90
+ return m