mistralai 1.9.11__py3-none-any.whl → 1.10.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 (151) hide show
  1. mistralai/_hooks/registration.py +5 -0
  2. mistralai/_hooks/tracing.py +75 -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/classifiers.py +13 -1
  8. mistralai/conversations.py +294 -62
  9. mistralai/documents.py +19 -3
  10. mistralai/embeddings.py +13 -7
  11. mistralai/extra/README.md +1 -1
  12. mistralai/extra/mcp/auth.py +10 -11
  13. mistralai/extra/mcp/base.py +17 -16
  14. mistralai/extra/mcp/sse.py +13 -15
  15. mistralai/extra/mcp/stdio.py +5 -6
  16. mistralai/extra/observability/__init__.py +15 -0
  17. mistralai/extra/observability/otel.py +372 -0
  18. mistralai/extra/run/context.py +33 -43
  19. mistralai/extra/run/result.py +29 -30
  20. mistralai/extra/run/tools.py +34 -23
  21. mistralai/extra/struct_chat.py +15 -8
  22. mistralai/extra/utils/response_format.py +5 -3
  23. mistralai/files.py +6 -0
  24. mistralai/fim.py +17 -5
  25. mistralai/mistral_agents.py +229 -1
  26. mistralai/mistral_jobs.py +39 -13
  27. mistralai/models/__init__.py +99 -3
  28. mistralai/models/agent.py +15 -2
  29. mistralai/models/agentconversation.py +11 -3
  30. mistralai/models/agentcreationrequest.py +6 -2
  31. mistralai/models/agents_api_v1_agents_deleteop.py +16 -0
  32. mistralai/models/agents_api_v1_agents_getop.py +40 -3
  33. mistralai/models/agents_api_v1_agents_listop.py +72 -2
  34. mistralai/models/agents_api_v1_conversations_deleteop.py +18 -0
  35. mistralai/models/agents_api_v1_conversations_listop.py +39 -2
  36. mistralai/models/agentscompletionrequest.py +21 -6
  37. mistralai/models/agentscompletionstreamrequest.py +21 -6
  38. mistralai/models/agentupdaterequest.py +18 -2
  39. mistralai/models/audioencoding.py +13 -0
  40. mistralai/models/audioformat.py +19 -0
  41. mistralai/models/audiotranscriptionrequest.py +2 -0
  42. mistralai/models/batchjobin.py +26 -5
  43. mistralai/models/batchjobout.py +5 -0
  44. mistralai/models/batchrequest.py +48 -0
  45. mistralai/models/chatcompletionrequest.py +22 -5
  46. mistralai/models/chatcompletionstreamrequest.py +22 -5
  47. mistralai/models/classificationrequest.py +37 -3
  48. mistralai/models/conversationrequest.py +15 -4
  49. mistralai/models/conversationrestartrequest.py +50 -2
  50. mistralai/models/conversationrestartstreamrequest.py +50 -2
  51. mistralai/models/conversationstreamrequest.py +15 -4
  52. mistralai/models/documentout.py +26 -10
  53. mistralai/models/documentupdatein.py +24 -3
  54. mistralai/models/embeddingrequest.py +19 -11
  55. mistralai/models/files_api_routes_list_filesop.py +7 -0
  56. mistralai/models/fimcompletionrequest.py +8 -9
  57. mistralai/models/fimcompletionstreamrequest.py +8 -9
  58. mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +40 -3
  59. mistralai/models/libraries_documents_list_v1op.py +15 -2
  60. mistralai/models/libraryout.py +10 -7
  61. mistralai/models/listfilesout.py +35 -4
  62. mistralai/models/modelcapabilities.py +13 -4
  63. mistralai/models/modelconversation.py +8 -2
  64. mistralai/models/ocrpageobject.py +26 -5
  65. mistralai/models/ocrrequest.py +17 -1
  66. mistralai/models/ocrtableobject.py +31 -0
  67. mistralai/models/prediction.py +4 -0
  68. mistralai/models/requestsource.py +7 -0
  69. mistralai/models/responseformat.py +4 -2
  70. mistralai/models/responseformats.py +0 -1
  71. mistralai/models/sharingdelete.py +36 -5
  72. mistralai/models/sharingin.py +36 -5
  73. mistralai/models/sharingout.py +3 -3
  74. mistralai/models/toolexecutiondeltaevent.py +13 -4
  75. mistralai/models/toolexecutiondoneevent.py +13 -4
  76. mistralai/models/toolexecutionentry.py +9 -4
  77. mistralai/models/toolexecutionstartedevent.py +13 -4
  78. mistralai/models/toolfilechunk.py +11 -4
  79. mistralai/models/toolreferencechunk.py +13 -4
  80. mistralai/models_.py +2 -14
  81. mistralai/ocr.py +18 -0
  82. mistralai/transcriptions.py +4 -4
  83. {mistralai-1.9.11.dist-info → mistralai-1.10.1.dist-info}/METADATA +162 -152
  84. {mistralai-1.9.11.dist-info → mistralai-1.10.1.dist-info}/RECORD +168 -144
  85. {mistralai-1.9.11.dist-info → mistralai-1.10.1.dist-info}/WHEEL +1 -1
  86. mistralai_azure/_version.py +3 -3
  87. mistralai_azure/basesdk.py +15 -5
  88. mistralai_azure/chat.py +59 -98
  89. mistralai_azure/models/__init__.py +50 -3
  90. mistralai_azure/models/chatcompletionrequest.py +16 -4
  91. mistralai_azure/models/chatcompletionstreamrequest.py +16 -4
  92. mistralai_azure/models/httpvalidationerror.py +11 -6
  93. mistralai_azure/models/mistralazureerror.py +26 -0
  94. mistralai_azure/models/no_response_error.py +13 -0
  95. mistralai_azure/models/prediction.py +4 -0
  96. mistralai_azure/models/responseformat.py +4 -2
  97. mistralai_azure/models/responseformats.py +0 -1
  98. mistralai_azure/models/responsevalidationerror.py +25 -0
  99. mistralai_azure/models/sdkerror.py +30 -14
  100. mistralai_azure/models/systemmessage.py +7 -3
  101. mistralai_azure/models/systemmessagecontentchunks.py +21 -0
  102. mistralai_azure/models/thinkchunk.py +35 -0
  103. mistralai_azure/ocr.py +15 -36
  104. mistralai_azure/utils/__init__.py +18 -5
  105. mistralai_azure/utils/eventstreaming.py +10 -0
  106. mistralai_azure/utils/serializers.py +3 -2
  107. mistralai_azure/utils/unmarshal_json_response.py +24 -0
  108. mistralai_gcp/_hooks/types.py +7 -0
  109. mistralai_gcp/_version.py +4 -4
  110. mistralai_gcp/basesdk.py +27 -25
  111. mistralai_gcp/chat.py +75 -98
  112. mistralai_gcp/fim.py +39 -74
  113. mistralai_gcp/httpclient.py +6 -16
  114. mistralai_gcp/models/__init__.py +321 -116
  115. mistralai_gcp/models/assistantmessage.py +1 -1
  116. mistralai_gcp/models/chatcompletionrequest.py +36 -7
  117. mistralai_gcp/models/chatcompletionresponse.py +6 -6
  118. mistralai_gcp/models/chatcompletionstreamrequest.py +36 -7
  119. mistralai_gcp/models/completionresponsestreamchoice.py +1 -1
  120. mistralai_gcp/models/deltamessage.py +1 -1
  121. mistralai_gcp/models/fimcompletionrequest.py +3 -9
  122. mistralai_gcp/models/fimcompletionresponse.py +6 -6
  123. mistralai_gcp/models/fimcompletionstreamrequest.py +3 -9
  124. mistralai_gcp/models/httpvalidationerror.py +11 -6
  125. mistralai_gcp/models/imageurl.py +1 -1
  126. mistralai_gcp/models/jsonschema.py +1 -1
  127. mistralai_gcp/models/mistralgcperror.py +26 -0
  128. mistralai_gcp/models/mistralpromptmode.py +8 -0
  129. mistralai_gcp/models/no_response_error.py +13 -0
  130. mistralai_gcp/models/prediction.py +4 -0
  131. mistralai_gcp/models/responseformat.py +5 -3
  132. mistralai_gcp/models/responseformats.py +0 -1
  133. mistralai_gcp/models/responsevalidationerror.py +25 -0
  134. mistralai_gcp/models/sdkerror.py +30 -14
  135. mistralai_gcp/models/systemmessage.py +7 -3
  136. mistralai_gcp/models/systemmessagecontentchunks.py +21 -0
  137. mistralai_gcp/models/thinkchunk.py +35 -0
  138. mistralai_gcp/models/toolmessage.py +1 -1
  139. mistralai_gcp/models/usageinfo.py +71 -8
  140. mistralai_gcp/models/usermessage.py +1 -1
  141. mistralai_gcp/sdk.py +12 -10
  142. mistralai_gcp/sdkconfiguration.py +0 -7
  143. mistralai_gcp/types/basemodel.py +3 -3
  144. mistralai_gcp/utils/__init__.py +143 -45
  145. mistralai_gcp/utils/datetimes.py +23 -0
  146. mistralai_gcp/utils/enums.py +67 -27
  147. mistralai_gcp/utils/eventstreaming.py +10 -0
  148. mistralai_gcp/utils/forms.py +49 -28
  149. mistralai_gcp/utils/serializers.py +33 -3
  150. mistralai_gcp/utils/unmarshal_json_response.py +24 -0
  151. {mistralai-1.9.11.dist-info → mistralai-1.10.1.dist-info}/licenses/LICENSE +0 -0
@@ -15,9 +15,19 @@ from urllib.parse import parse_qs, urlparse
15
15
 
16
16
  class BaseSDK:
17
17
  sdk_configuration: SDKConfiguration
18
+ parent_ref: Optional[object] = None
19
+ """
20
+ Reference to the root SDK instance, if any. This will prevent it from
21
+ being garbage collected while there are active streams.
22
+ """
18
23
 
19
- def __init__(self, sdk_config: SDKConfiguration) -> None:
24
+ def __init__(
25
+ self,
26
+ sdk_config: SDKConfiguration,
27
+ parent_ref: Optional[object] = None,
28
+ ) -> None:
20
29
  self.sdk_configuration = sdk_config
30
+ self.parent_ref = parent_ref
21
31
 
22
32
  def _get_url(self, base_url, url_variables):
23
33
  sdk_url, sdk_variables = self.sdk_configuration.get_server_details()
@@ -244,7 +254,7 @@ class BaseSDK:
244
254
 
245
255
  if http_res is None:
246
256
  logger.debug("Raising no response SDK error")
247
- raise models.SDKError("No response received")
257
+ raise models.NoResponseError("No response received")
248
258
 
249
259
  logger.debug(
250
260
  "Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
@@ -265,7 +275,7 @@ class BaseSDK:
265
275
  http_res = result
266
276
  else:
267
277
  logger.debug("Raising unexpected SDK error")
268
- raise models.SDKError("Unexpected error occurred")
278
+ raise models.SDKError("Unexpected error occurred", http_res)
269
279
 
270
280
  return http_res
271
281
 
@@ -316,7 +326,7 @@ class BaseSDK:
316
326
 
317
327
  if http_res is None:
318
328
  logger.debug("Raising no response SDK error")
319
- raise models.SDKError("No response received")
329
+ raise models.NoResponseError("No response received")
320
330
 
321
331
  logger.debug(
322
332
  "Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
@@ -337,7 +347,7 @@ class BaseSDK:
337
347
  http_res = result
338
348
  else:
339
349
  logger.debug("Raising unexpected SDK error")
340
- raise models.SDKError("Unexpected error occurred")
350
+ raise models.SDKError("Unexpected error occurred", http_res)
341
351
 
342
352
  return http_res
343
353
 
mistralai_azure/chat.py CHANGED
@@ -5,6 +5,7 @@ from mistralai_azure import models, utils
5
5
  from mistralai_azure._hooks import HookContext
6
6
  from mistralai_azure.types import OptionalNullable, UNSET
7
7
  from mistralai_azure.utils import eventstreaming
8
+ from mistralai_azure.utils.unmarshal_json_response import unmarshal_json_response
8
9
  from typing import Any, List, Mapping, Optional, Union
9
10
 
10
11
 
@@ -60,14 +61,14 @@ class Chat(BaseSDK):
60
61
  :param stream:
61
62
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
62
63
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
63
- :param response_format:
64
- :param tools:
65
- :param tool_choice:
66
- :param presence_penalty: 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.
67
- :param frequency_penalty: 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.
64
+ :param response_format: 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.
65
+ :param tools: A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for.
66
+ :param tool_choice: 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.
67
+ :param presence_penalty: 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.
68
+ :param frequency_penalty: 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.
68
69
  :param n: Number of completions to return for each request, input tokens are only billed once.
69
- :param prediction:
70
- :param parallel_tool_calls:
70
+ :param prediction: Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
71
+ :param parallel_tool_calls: Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel.
71
72
  :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.
72
73
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
73
74
  :param retries: Override the default retry configuration for this method
@@ -159,32 +160,23 @@ class Chat(BaseSDK):
159
160
  http_res,
160
161
  lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
161
162
  sentinel="[DONE]",
163
+ client_ref=self,
162
164
  )
163
165
  if utils.match_response(http_res, "422", "application/json"):
164
166
  http_res_text = utils.stream_to_text(http_res)
165
- response_data = utils.unmarshal_json(
166
- http_res_text, models.HTTPValidationErrorData
167
+ response_data = unmarshal_json_response(
168
+ models.HTTPValidationErrorData, http_res, http_res_text
167
169
  )
168
- raise models.HTTPValidationError(data=response_data)
170
+ raise models.HTTPValidationError(response_data, http_res, http_res_text)
169
171
  if utils.match_response(http_res, "4XX", "*"):
170
172
  http_res_text = utils.stream_to_text(http_res)
171
- raise models.SDKError(
172
- "API error occurred", http_res.status_code, http_res_text, http_res
173
- )
173
+ raise models.SDKError("API error occurred", http_res, http_res_text)
174
174
  if utils.match_response(http_res, "5XX", "*"):
175
175
  http_res_text = utils.stream_to_text(http_res)
176
- raise models.SDKError(
177
- "API error occurred", http_res.status_code, http_res_text, http_res
178
- )
176
+ raise models.SDKError("API error occurred", http_res, http_res_text)
179
177
 
180
- content_type = http_res.headers.get("Content-Type")
181
178
  http_res_text = utils.stream_to_text(http_res)
182
- raise models.SDKError(
183
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
184
- http_res.status_code,
185
- http_res_text,
186
- http_res,
187
- )
179
+ raise models.SDKError("Unexpected response received", http_res, http_res_text)
188
180
 
189
181
  async def stream_async(
190
182
  self,
@@ -235,14 +227,14 @@ class Chat(BaseSDK):
235
227
  :param stream:
236
228
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
237
229
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
238
- :param response_format:
239
- :param tools:
240
- :param tool_choice:
241
- :param presence_penalty: 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.
242
- :param frequency_penalty: 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.
230
+ :param response_format: 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.
231
+ :param tools: A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for.
232
+ :param tool_choice: 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.
233
+ :param presence_penalty: 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.
234
+ :param frequency_penalty: 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.
243
235
  :param n: Number of completions to return for each request, input tokens are only billed once.
244
- :param prediction:
245
- :param parallel_tool_calls:
236
+ :param prediction: Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
237
+ :param parallel_tool_calls: Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel.
246
238
  :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.
247
239
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
248
240
  :param retries: Override the default retry configuration for this method
@@ -334,32 +326,23 @@ class Chat(BaseSDK):
334
326
  http_res,
335
327
  lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
336
328
  sentinel="[DONE]",
329
+ client_ref=self,
337
330
  )
338
331
  if utils.match_response(http_res, "422", "application/json"):
339
332
  http_res_text = await utils.stream_to_text_async(http_res)
340
- response_data = utils.unmarshal_json(
341
- http_res_text, models.HTTPValidationErrorData
333
+ response_data = unmarshal_json_response(
334
+ models.HTTPValidationErrorData, http_res, http_res_text
342
335
  )
343
- raise models.HTTPValidationError(data=response_data)
336
+ raise models.HTTPValidationError(response_data, http_res, http_res_text)
344
337
  if utils.match_response(http_res, "4XX", "*"):
345
338
  http_res_text = await utils.stream_to_text_async(http_res)
346
- raise models.SDKError(
347
- "API error occurred", http_res.status_code, http_res_text, http_res
348
- )
339
+ raise models.SDKError("API error occurred", http_res, http_res_text)
349
340
  if utils.match_response(http_res, "5XX", "*"):
350
341
  http_res_text = await utils.stream_to_text_async(http_res)
351
- raise models.SDKError(
352
- "API error occurred", http_res.status_code, http_res_text, http_res
353
- )
342
+ raise models.SDKError("API error occurred", http_res, http_res_text)
354
343
 
355
- content_type = http_res.headers.get("Content-Type")
356
344
  http_res_text = await utils.stream_to_text_async(http_res)
357
- raise models.SDKError(
358
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
359
- http_res.status_code,
360
- http_res_text,
361
- http_res,
362
- )
345
+ raise models.SDKError("Unexpected response received", http_res, http_res_text)
363
346
 
364
347
  def complete(
365
348
  self,
@@ -416,14 +399,14 @@ class Chat(BaseSDK):
416
399
  :param stream: Whether to stream back partial progress. If set, tokens will be sent as data-only server-side events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
417
400
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
418
401
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
419
- :param response_format:
420
- :param tools:
421
- :param tool_choice:
422
- :param presence_penalty: 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.
423
- :param frequency_penalty: 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.
402
+ :param response_format: 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.
403
+ :param tools: A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for.
404
+ :param tool_choice: 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.
405
+ :param presence_penalty: 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.
406
+ :param frequency_penalty: 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.
424
407
  :param n: Number of completions to return for each request, input tokens are only billed once.
425
- :param prediction:
426
- :param parallel_tool_calls:
408
+ :param prediction: Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
409
+ :param parallel_tool_calls: Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel.
427
410
  :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.
428
411
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
429
412
  :param retries: Override the default retry configuration for this method
@@ -512,33 +495,22 @@ class Chat(BaseSDK):
512
495
 
513
496
  response_data: Any = None
514
497
  if utils.match_response(http_res, "200", "application/json"):
515
- return utils.unmarshal_json(
516
- http_res.text, Optional[models.ChatCompletionResponse]
498
+ return unmarshal_json_response(
499
+ Optional[models.ChatCompletionResponse], http_res
517
500
  )
518
501
  if utils.match_response(http_res, "422", "application/json"):
519
- response_data = utils.unmarshal_json(
520
- http_res.text, models.HTTPValidationErrorData
502
+ response_data = unmarshal_json_response(
503
+ models.HTTPValidationErrorData, http_res
521
504
  )
522
- raise models.HTTPValidationError(data=response_data)
505
+ raise models.HTTPValidationError(response_data, http_res)
523
506
  if utils.match_response(http_res, "4XX", "*"):
524
507
  http_res_text = utils.stream_to_text(http_res)
525
- raise models.SDKError(
526
- "API error occurred", http_res.status_code, http_res_text, http_res
527
- )
508
+ raise models.SDKError("API error occurred", http_res, http_res_text)
528
509
  if utils.match_response(http_res, "5XX", "*"):
529
510
  http_res_text = utils.stream_to_text(http_res)
530
- raise models.SDKError(
531
- "API error occurred", http_res.status_code, http_res_text, http_res
532
- )
511
+ raise models.SDKError("API error occurred", http_res, http_res_text)
533
512
 
534
- content_type = http_res.headers.get("Content-Type")
535
- http_res_text = utils.stream_to_text(http_res)
536
- raise models.SDKError(
537
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
538
- http_res.status_code,
539
- http_res_text,
540
- http_res,
541
- )
513
+ raise models.SDKError("Unexpected response received", http_res)
542
514
 
543
515
  async def complete_async(
544
516
  self,
@@ -595,14 +567,14 @@ class Chat(BaseSDK):
595
567
  :param stream: Whether to stream back partial progress. If set, tokens will be sent as data-only server-side events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
596
568
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
597
569
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
598
- :param response_format:
599
- :param tools:
600
- :param tool_choice:
601
- :param presence_penalty: 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.
602
- :param frequency_penalty: 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.
570
+ :param response_format: 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.
571
+ :param tools: A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for.
572
+ :param tool_choice: 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.
573
+ :param presence_penalty: 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.
574
+ :param frequency_penalty: 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.
603
575
  :param n: Number of completions to return for each request, input tokens are only billed once.
604
- :param prediction:
605
- :param parallel_tool_calls:
576
+ :param prediction: Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
577
+ :param parallel_tool_calls: Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel.
606
578
  :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.
607
579
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
608
580
  :param retries: Override the default retry configuration for this method
@@ -691,30 +663,19 @@ class Chat(BaseSDK):
691
663
 
692
664
  response_data: Any = None
693
665
  if utils.match_response(http_res, "200", "application/json"):
694
- return utils.unmarshal_json(
695
- http_res.text, Optional[models.ChatCompletionResponse]
666
+ return unmarshal_json_response(
667
+ Optional[models.ChatCompletionResponse], http_res
696
668
  )
697
669
  if utils.match_response(http_res, "422", "application/json"):
698
- response_data = utils.unmarshal_json(
699
- http_res.text, models.HTTPValidationErrorData
670
+ response_data = unmarshal_json_response(
671
+ models.HTTPValidationErrorData, http_res
700
672
  )
701
- raise models.HTTPValidationError(data=response_data)
673
+ raise models.HTTPValidationError(response_data, http_res)
702
674
  if utils.match_response(http_res, "4XX", "*"):
703
675
  http_res_text = await utils.stream_to_text_async(http_res)
704
- raise models.SDKError(
705
- "API error occurred", http_res.status_code, http_res_text, http_res
706
- )
676
+ raise models.SDKError("API error occurred", http_res, http_res_text)
707
677
  if utils.match_response(http_res, "5XX", "*"):
708
678
  http_res_text = await utils.stream_to_text_async(http_res)
709
- raise models.SDKError(
710
- "API error occurred", http_res.status_code, http_res_text, http_res
711
- )
679
+ raise models.SDKError("API error occurred", http_res, http_res_text)
712
680
 
713
- content_type = http_res.headers.get("Content-Type")
714
- http_res_text = await utils.stream_to_text_async(http_res)
715
- raise models.SDKError(
716
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
717
- http_res.status_code,
718
- http_res_text,
719
- http_res,
720
- )
681
+ raise models.SDKError("Unexpected response received", http_res)
@@ -1,7 +1,10 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
+ from .mistralazureerror import MistralAzureError
3
4
  from typing import TYPE_CHECKING
4
5
  from importlib import import_module
6
+ import builtins
7
+ import sys
5
8
 
6
9
  if TYPE_CHECKING:
7
10
  from .assistantmessage import (
@@ -79,6 +82,7 @@ if TYPE_CHECKING:
79
82
  )
80
83
  from .jsonschema import JSONSchema, JSONSchemaTypedDict
81
84
  from .mistralpromptmode import MistralPromptMode
85
+ from .no_response_error import NoResponseError
82
86
  from .ocrimageobject import OCRImageObject, OCRImageObjectTypedDict
83
87
  from .ocrpagedimensions import OCRPageDimensions, OCRPageDimensionsTypedDict
84
88
  from .ocrpageobject import OCRPageObject, OCRPageObjectTypedDict
@@ -93,6 +97,7 @@ if TYPE_CHECKING:
93
97
  )
94
98
  from .responseformat import ResponseFormat, ResponseFormatTypedDict
95
99
  from .responseformats import ResponseFormats
100
+ from .responsevalidationerror import ResponseValidationError
96
101
  from .sdkerror import SDKError
97
102
  from .security import Security, SecurityTypedDict
98
103
  from .systemmessage import (
@@ -102,7 +107,18 @@ if TYPE_CHECKING:
102
107
  SystemMessageContentTypedDict,
103
108
  SystemMessageTypedDict,
104
109
  )
110
+ from .systemmessagecontentchunks import (
111
+ SystemMessageContentChunks,
112
+ SystemMessageContentChunksTypedDict,
113
+ )
105
114
  from .textchunk import TextChunk, TextChunkTypedDict, Type
115
+ from .thinkchunk import (
116
+ ThinkChunk,
117
+ ThinkChunkType,
118
+ ThinkChunkTypedDict,
119
+ Thinking,
120
+ ThinkingTypedDict,
121
+ )
106
122
  from .tool import Tool, ToolTypedDict
107
123
  from .toolcall import ToolCall, ToolCallTypedDict
108
124
  from .toolchoice import ToolChoice, ToolChoiceTypedDict
@@ -196,7 +212,9 @@ __all__ = [
196
212
  "LocTypedDict",
197
213
  "Messages",
198
214
  "MessagesTypedDict",
215
+ "MistralAzureError",
199
216
  "MistralPromptMode",
217
+ "NoResponseError",
200
218
  "OCRImageObject",
201
219
  "OCRImageObjectTypedDict",
202
220
  "OCRPageDimensions",
@@ -217,6 +235,7 @@ __all__ = [
217
235
  "ResponseFormat",
218
236
  "ResponseFormatTypedDict",
219
237
  "ResponseFormats",
238
+ "ResponseValidationError",
220
239
  "Role",
221
240
  "SDKError",
222
241
  "Security",
@@ -225,10 +244,17 @@ __all__ = [
225
244
  "StopTypedDict",
226
245
  "SystemMessage",
227
246
  "SystemMessageContent",
247
+ "SystemMessageContentChunks",
248
+ "SystemMessageContentChunksTypedDict",
228
249
  "SystemMessageContentTypedDict",
229
250
  "SystemMessageTypedDict",
230
251
  "TextChunk",
231
252
  "TextChunkTypedDict",
253
+ "ThinkChunk",
254
+ "ThinkChunkType",
255
+ "ThinkChunkTypedDict",
256
+ "Thinking",
257
+ "ThinkingTypedDict",
232
258
  "Tool",
233
259
  "ToolCall",
234
260
  "ToolCallTypedDict",
@@ -319,6 +345,7 @@ _dynamic_imports: dict[str, str] = {
319
345
  "JSONSchema": ".jsonschema",
320
346
  "JSONSchemaTypedDict": ".jsonschema",
321
347
  "MistralPromptMode": ".mistralpromptmode",
348
+ "NoResponseError": ".no_response_error",
322
349
  "OCRImageObject": ".ocrimageobject",
323
350
  "OCRImageObjectTypedDict": ".ocrimageobject",
324
351
  "OCRPageDimensions": ".ocrpagedimensions",
@@ -341,6 +368,7 @@ _dynamic_imports: dict[str, str] = {
341
368
  "ResponseFormat": ".responseformat",
342
369
  "ResponseFormatTypedDict": ".responseformat",
343
370
  "ResponseFormats": ".responseformats",
371
+ "ResponseValidationError": ".responsevalidationerror",
344
372
  "SDKError": ".sdkerror",
345
373
  "Security": ".security",
346
374
  "SecurityTypedDict": ".security",
@@ -349,9 +377,16 @@ _dynamic_imports: dict[str, str] = {
349
377
  "SystemMessageContent": ".systemmessage",
350
378
  "SystemMessageContentTypedDict": ".systemmessage",
351
379
  "SystemMessageTypedDict": ".systemmessage",
380
+ "SystemMessageContentChunks": ".systemmessagecontentchunks",
381
+ "SystemMessageContentChunksTypedDict": ".systemmessagecontentchunks",
352
382
  "TextChunk": ".textchunk",
353
383
  "TextChunkTypedDict": ".textchunk",
354
384
  "Type": ".textchunk",
385
+ "ThinkChunk": ".thinkchunk",
386
+ "ThinkChunkType": ".thinkchunk",
387
+ "ThinkChunkTypedDict": ".thinkchunk",
388
+ "Thinking": ".thinkchunk",
389
+ "ThinkingTypedDict": ".thinkchunk",
355
390
  "Tool": ".tool",
356
391
  "ToolTypedDict": ".tool",
357
392
  "ToolCall": ".toolcall",
@@ -379,6 +414,18 @@ _dynamic_imports: dict[str, str] = {
379
414
  }
380
415
 
381
416
 
417
+ def dynamic_import(modname, retries=3):
418
+ for attempt in range(retries):
419
+ try:
420
+ return import_module(modname, __package__)
421
+ except KeyError:
422
+ # Clear any half-initialized module and retry
423
+ sys.modules.pop(modname, None)
424
+ if attempt == retries - 1:
425
+ break
426
+ raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
427
+
428
+
382
429
  def __getattr__(attr_name: str) -> object:
383
430
  module_name = _dynamic_imports.get(attr_name)
384
431
  if module_name is None:
@@ -387,7 +434,7 @@ def __getattr__(attr_name: str) -> object:
387
434
  )
388
435
 
389
436
  try:
390
- module = import_module(module_name, __package__)
437
+ module = dynamic_import(module_name)
391
438
  result = getattr(module, attr_name)
392
439
  return result
393
440
  except ImportError as e:
@@ -401,5 +448,5 @@ def __getattr__(attr_name: str) -> object:
401
448
 
402
449
 
403
450
  def __dir__():
404
- lazy_attrs = list(_dynamic_imports.keys())
405
- return sorted(lazy_attrs)
451
+ lazy_attrs = builtins.list(_dynamic_imports.keys())
452
+ return builtins.sorted(lazy_attrs)
@@ -63,11 +63,13 @@ ChatCompletionRequestToolChoiceTypedDict = TypeAliasType(
63
63
  "ChatCompletionRequestToolChoiceTypedDict",
64
64
  Union[ToolChoiceTypedDict, ToolChoiceEnum],
65
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."""
66
67
 
67
68
 
68
69
  ChatCompletionRequestToolChoice = TypeAliasType(
69
70
  "ChatCompletionRequestToolChoice", Union[ToolChoice, ToolChoiceEnum]
70
71
  )
72
+ 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."""
71
73
 
72
74
 
73
75
  class ChatCompletionRequestTypedDict(TypedDict):
@@ -88,16 +90,21 @@ class ChatCompletionRequestTypedDict(TypedDict):
88
90
  random_seed: NotRequired[Nullable[int]]
89
91
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
90
92
  response_format: NotRequired[ResponseFormatTypedDict]
93
+ 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."""
91
94
  tools: NotRequired[Nullable[List[ToolTypedDict]]]
95
+ r"""A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for."""
92
96
  tool_choice: NotRequired[ChatCompletionRequestToolChoiceTypedDict]
97
+ 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."""
93
98
  presence_penalty: NotRequired[float]
94
- 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."""
99
+ 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."""
95
100
  frequency_penalty: NotRequired[float]
96
- 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."""
101
+ 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."""
97
102
  n: NotRequired[Nullable[int]]
98
103
  r"""Number of completions to return for each request, input tokens are only billed once."""
99
104
  prediction: NotRequired[PredictionTypedDict]
105
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
100
106
  parallel_tool_calls: NotRequired[bool]
107
+ r"""Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel."""
101
108
  prompt_mode: NotRequired[Nullable[MistralPromptMode]]
102
109
  r"""Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used."""
103
110
  safe_prompt: NotRequired[bool]
@@ -130,23 +137,28 @@ class ChatCompletionRequest(BaseModel):
130
137
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
131
138
 
132
139
  response_format: Optional[ResponseFormat] = None
140
+ 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."""
133
141
 
134
142
  tools: OptionalNullable[List[Tool]] = UNSET
143
+ r"""A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for."""
135
144
 
136
145
  tool_choice: Optional[ChatCompletionRequestToolChoice] = None
146
+ 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."""
137
147
 
138
148
  presence_penalty: Optional[float] = None
139
- 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."""
149
+ 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."""
140
150
 
141
151
  frequency_penalty: Optional[float] = None
142
- 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."""
152
+ 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."""
143
153
 
144
154
  n: OptionalNullable[int] = UNSET
145
155
  r"""Number of completions to return for each request, input tokens are only billed once."""
146
156
 
147
157
  prediction: Optional[Prediction] = None
158
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
148
159
 
149
160
  parallel_tool_calls: Optional[bool] = None
161
+ r"""Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel."""
150
162
 
151
163
  prompt_mode: Annotated[
152
164
  OptionalNullable[MistralPromptMode], PlainValidator(validate_open_enum(False))
@@ -59,11 +59,13 @@ ChatCompletionStreamRequestToolChoiceTypedDict = TypeAliasType(
59
59
  "ChatCompletionStreamRequestToolChoiceTypedDict",
60
60
  Union[ToolChoiceTypedDict, ToolChoiceEnum],
61
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."""
62
63
 
63
64
 
64
65
  ChatCompletionStreamRequestToolChoice = TypeAliasType(
65
66
  "ChatCompletionStreamRequestToolChoice", Union[ToolChoice, ToolChoiceEnum]
66
67
  )
68
+ 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."""
67
69
 
68
70
 
69
71
  class ChatCompletionStreamRequestTypedDict(TypedDict):
@@ -83,16 +85,21 @@ class ChatCompletionStreamRequestTypedDict(TypedDict):
83
85
  random_seed: NotRequired[Nullable[int]]
84
86
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
85
87
  response_format: NotRequired[ResponseFormatTypedDict]
88
+ 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."""
86
89
  tools: NotRequired[Nullable[List[ToolTypedDict]]]
90
+ r"""A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for."""
87
91
  tool_choice: NotRequired[ChatCompletionStreamRequestToolChoiceTypedDict]
92
+ 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."""
88
93
  presence_penalty: NotRequired[float]
89
- 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."""
94
+ 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."""
90
95
  frequency_penalty: NotRequired[float]
91
- 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."""
96
+ 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."""
92
97
  n: NotRequired[Nullable[int]]
93
98
  r"""Number of completions to return for each request, input tokens are only billed once."""
94
99
  prediction: NotRequired[PredictionTypedDict]
100
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
95
101
  parallel_tool_calls: NotRequired[bool]
102
+ r"""Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel."""
96
103
  prompt_mode: NotRequired[Nullable[MistralPromptMode]]
97
104
  r"""Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used."""
98
105
  safe_prompt: NotRequired[bool]
@@ -124,23 +131,28 @@ class ChatCompletionStreamRequest(BaseModel):
124
131
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
125
132
 
126
133
  response_format: Optional[ResponseFormat] = None
134
+ 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."""
127
135
 
128
136
  tools: OptionalNullable[List[Tool]] = UNSET
137
+ r"""A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for."""
129
138
 
130
139
  tool_choice: Optional[ChatCompletionStreamRequestToolChoice] = None
140
+ 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."""
131
141
 
132
142
  presence_penalty: Optional[float] = None
133
- 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."""
143
+ 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."""
134
144
 
135
145
  frequency_penalty: Optional[float] = None
136
- 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."""
146
+ 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."""
137
147
 
138
148
  n: OptionalNullable[int] = UNSET
139
149
  r"""Number of completions to return for each request, input tokens are only billed once."""
140
150
 
141
151
  prediction: Optional[Prediction] = None
152
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
142
153
 
143
154
  parallel_tool_calls: Optional[bool] = None
155
+ r"""Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel."""
144
156
 
145
157
  prompt_mode: Annotated[
146
158
  OptionalNullable[MistralPromptMode], PlainValidator(validate_open_enum(False))