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
@@ -1,5 +1,6 @@
1
1
  from .custom_user_agent import CustomUserAgentHook
2
2
  from .deprecation_warning import DeprecationWarningHook
3
+ from .tracing import TracingHook
3
4
  from .types import Hooks
4
5
 
5
6
  # This file is only ever generated once on the first generation and then is free to be modified.
@@ -13,5 +14,9 @@ def init_hooks(hooks: Hooks):
13
14
  with an instance of a hook that implements that specific Hook interface
14
15
  Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
15
16
  """
17
+ tracing_hook = TracingHook()
16
18
  hooks.register_before_request_hook(CustomUserAgentHook())
17
19
  hooks.register_after_success_hook(DeprecationWarningHook())
20
+ hooks.register_after_success_hook(tracing_hook)
21
+ hooks.register_before_request_hook(tracing_hook)
22
+ hooks.register_after_error_hook(tracing_hook)
@@ -0,0 +1,50 @@
1
+ import logging
2
+ from typing import Optional, Tuple, Union
3
+
4
+ import httpx
5
+ from opentelemetry.trace import Span
6
+
7
+ from ..extra.observability.otel import (
8
+ get_or_create_otel_tracer,
9
+ get_response_and_error,
10
+ get_traced_request_and_span,
11
+ get_traced_response,
12
+ )
13
+ from .types import (
14
+ AfterErrorContext,
15
+ AfterErrorHook,
16
+ AfterSuccessContext,
17
+ AfterSuccessHook,
18
+ BeforeRequestContext,
19
+ BeforeRequestHook,
20
+ )
21
+
22
+ logger = logging.getLogger(__name__)
23
+
24
+
25
+ class TracingHook(BeforeRequestHook, AfterSuccessHook, AfterErrorHook):
26
+ def __init__(self) -> None:
27
+ self.tracing_enabled, self.tracer = get_or_create_otel_tracer()
28
+ self.request_span: Optional[Span] = None
29
+
30
+ def before_request(
31
+ self, hook_ctx: BeforeRequestContext, request: httpx.Request
32
+ ) -> Union[httpx.Request, Exception]:
33
+ request, self.request_span = get_traced_request_and_span(tracing_enabled=self.tracing_enabled, tracer=self.tracer, span=self.request_span, operation_id=hook_ctx.operation_id, request=request)
34
+ return request
35
+
36
+ def after_success(
37
+ self, hook_ctx: AfterSuccessContext, response: httpx.Response
38
+ ) -> Union[httpx.Response, Exception]:
39
+ response = get_traced_response(tracing_enabled=self.tracing_enabled, tracer=self.tracer, span=self.request_span, operation_id=hook_ctx.operation_id, response=response)
40
+ return response
41
+
42
+ def after_error(
43
+ self,
44
+ hook_ctx: AfterErrorContext,
45
+ response: Optional[httpx.Response],
46
+ error: Optional[Exception],
47
+ ) -> Union[Tuple[Optional[httpx.Response], Optional[Exception]], Exception]:
48
+ if response:
49
+ response, error = get_response_and_error(tracing_enabled=self.tracing_enabled, tracer=self.tracer, span=self.request_span, operation_id=hook_ctx.operation_id, response=response, error=error)
50
+ return response, error
mistralai/_version.py CHANGED
@@ -3,10 +3,10 @@
3
3
  import importlib.metadata
4
4
 
5
5
  __title__: str = "mistralai"
6
- __version__: str = "1.9.11"
6
+ __version__: str = "1.10.0"
7
7
  __openapi_doc_version__: str = "1.0.0"
8
8
  __gen_version__: str = "2.687.13"
9
- __user_agent__: str = "speakeasy-sdk/python 1.9.11 2.687.13 1.0.0 mistralai"
9
+ __user_agent__: str = "speakeasy-sdk/python 1.10.0 2.687.13 1.0.0 mistralai"
10
10
 
11
11
  try:
12
12
  if __package__ is not None:
mistralai/accesses.py CHANGED
@@ -194,10 +194,10 @@ class Accesses(BaseSDK):
194
194
  self,
195
195
  *,
196
196
  library_id: str,
197
- org_id: str,
198
197
  level: models.ShareEnum,
199
198
  share_with_uuid: str,
200
199
  share_with_type: models.EntityType,
200
+ org_id: OptionalNullable[str] = UNSET,
201
201
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
202
202
  server_url: Optional[str] = None,
203
203
  timeout_ms: Optional[int] = None,
@@ -208,10 +208,10 @@ class Accesses(BaseSDK):
208
208
  Given a library id, you can create or update the access level of an entity. You have to be owner of the library to share a library. An owner cannot change their own role. A library cannot be shared outside of the organization.
209
209
 
210
210
  :param library_id:
211
- :param org_id:
212
211
  :param level:
213
212
  :param share_with_uuid: The id of the entity (user, workspace or organization) to share with
214
213
  :param share_with_type: The type of entity, used to share a library.
214
+ :param org_id:
215
215
  :param retries: Override the default retry configuration for this method
216
216
  :param server_url: Override the default server URL for this method
217
217
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -300,10 +300,10 @@ class Accesses(BaseSDK):
300
300
  self,
301
301
  *,
302
302
  library_id: str,
303
- org_id: str,
304
303
  level: models.ShareEnum,
305
304
  share_with_uuid: str,
306
305
  share_with_type: models.EntityType,
306
+ org_id: OptionalNullable[str] = UNSET,
307
307
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
308
308
  server_url: Optional[str] = None,
309
309
  timeout_ms: Optional[int] = None,
@@ -314,10 +314,10 @@ class Accesses(BaseSDK):
314
314
  Given a library id, you can create or update the access level of an entity. You have to be owner of the library to share a library. An owner cannot change their own role. A library cannot be shared outside of the organization.
315
315
 
316
316
  :param library_id:
317
- :param org_id:
318
317
  :param level:
319
318
  :param share_with_uuid: The id of the entity (user, workspace or organization) to share with
320
319
  :param share_with_type: The type of entity, used to share a library.
320
+ :param org_id:
321
321
  :param retries: Override the default retry configuration for this method
322
322
  :param server_url: Override the default server URL for this method
323
323
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -406,9 +406,9 @@ class Accesses(BaseSDK):
406
406
  self,
407
407
  *,
408
408
  library_id: str,
409
- org_id: str,
410
409
  share_with_uuid: str,
411
410
  share_with_type: models.EntityType,
411
+ org_id: OptionalNullable[str] = UNSET,
412
412
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
413
413
  server_url: Optional[str] = None,
414
414
  timeout_ms: Optional[int] = None,
@@ -419,9 +419,9 @@ class Accesses(BaseSDK):
419
419
  Given a library id, you can delete the access level of an entity. An owner cannot delete it's own access. You have to be the owner of the library to delete an acces other than yours.
420
420
 
421
421
  :param library_id:
422
- :param org_id:
423
422
  :param share_with_uuid: The id of the entity (user, workspace or organization) to share with
424
423
  :param share_with_type: The type of entity, used to share a library.
424
+ :param org_id:
425
425
  :param retries: Override the default retry configuration for this method
426
426
  :param server_url: Override the default server URL for this method
427
427
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -509,9 +509,9 @@ class Accesses(BaseSDK):
509
509
  self,
510
510
  *,
511
511
  library_id: str,
512
- org_id: str,
513
512
  share_with_uuid: str,
514
513
  share_with_type: models.EntityType,
514
+ org_id: OptionalNullable[str] = UNSET,
515
515
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
516
516
  server_url: Optional[str] = None,
517
517
  timeout_ms: Optional[int] = None,
@@ -522,9 +522,9 @@ class Accesses(BaseSDK):
522
522
  Given a library id, you can delete the access level of an entity. An owner cannot delete it's own access. You have to be the owner of the library to delete an acces other than yours.
523
523
 
524
524
  :param library_id:
525
- :param org_id:
526
525
  :param share_with_uuid: The id of the entity (user, workspace or organization) to share with
527
526
  :param share_with_type: The type of entity, used to share a library.
527
+ :param org_id:
528
528
  :param retries: Override the default retry configuration for this method
529
529
  :param server_url: Override the default server URL for this method
530
530
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
mistralai/agents.py CHANGED
@@ -6,7 +6,7 @@ from mistralai._hooks import HookContext
6
6
  from mistralai.types import OptionalNullable, UNSET
7
7
  from mistralai.utils import eventstreaming, get_security_from_env
8
8
  from mistralai.utils.unmarshal_json_response import unmarshal_json_response
9
- from typing import Any, List, Mapping, Optional, Union
9
+ from typing import Any, Dict, List, Mapping, Optional, Union
10
10
 
11
11
 
12
12
  class Agents(BaseSDK):
@@ -29,6 +29,7 @@ class Agents(BaseSDK):
29
29
  ]
30
30
  ] = None,
31
31
  random_seed: OptionalNullable[int] = UNSET,
32
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
32
33
  response_format: Optional[
33
34
  Union[models.ResponseFormat, models.ResponseFormatTypedDict]
34
35
  ] = None,
@@ -62,13 +63,14 @@ class Agents(BaseSDK):
62
63
  :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.
63
64
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
64
65
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
65
- :param response_format:
66
+ :param metadata:
67
+ :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.
66
68
  :param tools:
67
69
  :param tool_choice:
68
- :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.
69
- :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.
70
+ :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.
71
+ :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.
70
72
  :param n: Number of completions to return for each request, input tokens are only billed once.
71
- :param prediction:
73
+ :param prediction: Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
72
74
  :param parallel_tool_calls:
73
75
  :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.
74
76
  :param retries: Override the default retry configuration for this method
@@ -91,6 +93,7 @@ class Agents(BaseSDK):
91
93
  stream=stream,
92
94
  stop=stop,
93
95
  random_seed=random_seed,
96
+ metadata=metadata,
94
97
  messages=utils.get_pydantic_model(
95
98
  messages, List[models.AgentsCompletionRequestMessages]
96
99
  ),
@@ -188,6 +191,7 @@ class Agents(BaseSDK):
188
191
  ]
189
192
  ] = None,
190
193
  random_seed: OptionalNullable[int] = UNSET,
194
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
191
195
  response_format: Optional[
192
196
  Union[models.ResponseFormat, models.ResponseFormatTypedDict]
193
197
  ] = None,
@@ -221,13 +225,14 @@ class Agents(BaseSDK):
221
225
  :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.
222
226
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
223
227
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
224
- :param response_format:
228
+ :param metadata:
229
+ :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.
225
230
  :param tools:
226
231
  :param tool_choice:
227
- :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.
228
- :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.
232
+ :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.
233
+ :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.
229
234
  :param n: Number of completions to return for each request, input tokens are only billed once.
230
- :param prediction:
235
+ :param prediction: Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
231
236
  :param parallel_tool_calls:
232
237
  :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.
233
238
  :param retries: Override the default retry configuration for this method
@@ -250,6 +255,7 @@ class Agents(BaseSDK):
250
255
  stream=stream,
251
256
  stop=stop,
252
257
  random_seed=random_seed,
258
+ metadata=metadata,
253
259
  messages=utils.get_pydantic_model(
254
260
  messages, List[models.AgentsCompletionRequestMessages]
255
261
  ),
@@ -347,6 +353,7 @@ class Agents(BaseSDK):
347
353
  ]
348
354
  ] = None,
349
355
  random_seed: OptionalNullable[int] = UNSET,
356
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
350
357
  response_format: Optional[
351
358
  Union[models.ResponseFormat, models.ResponseFormatTypedDict]
352
359
  ] = None,
@@ -382,13 +389,14 @@ class Agents(BaseSDK):
382
389
  :param stream:
383
390
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
384
391
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
385
- :param response_format:
392
+ :param metadata:
393
+ :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.
386
394
  :param tools:
387
395
  :param tool_choice:
388
- :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.
389
- :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.
396
+ :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.
397
+ :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.
390
398
  :param n: Number of completions to return for each request, input tokens are only billed once.
391
- :param prediction:
399
+ :param prediction: Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
392
400
  :param parallel_tool_calls:
393
401
  :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.
394
402
  :param retries: Override the default retry configuration for this method
@@ -411,6 +419,7 @@ class Agents(BaseSDK):
411
419
  stream=stream,
412
420
  stop=stop,
413
421
  random_seed=random_seed,
422
+ metadata=metadata,
414
423
  messages=utils.get_pydantic_model(
415
424
  messages, List[models.AgentsCompletionStreamRequestMessages]
416
425
  ),
@@ -516,6 +525,7 @@ class Agents(BaseSDK):
516
525
  ]
517
526
  ] = None,
518
527
  random_seed: OptionalNullable[int] = UNSET,
528
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
519
529
  response_format: Optional[
520
530
  Union[models.ResponseFormat, models.ResponseFormatTypedDict]
521
531
  ] = None,
@@ -551,13 +561,14 @@ class Agents(BaseSDK):
551
561
  :param stream:
552
562
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
553
563
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
554
- :param response_format:
564
+ :param metadata:
565
+ :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.
555
566
  :param tools:
556
567
  :param tool_choice:
557
- :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.
558
- :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.
568
+ :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.
569
+ :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.
559
570
  :param n: Number of completions to return for each request, input tokens are only billed once.
560
- :param prediction:
571
+ :param prediction: Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
561
572
  :param parallel_tool_calls:
562
573
  :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.
563
574
  :param retries: Override the default retry configuration for this method
@@ -580,6 +591,7 @@ class Agents(BaseSDK):
580
591
  stream=stream,
581
592
  stop=stop,
582
593
  random_seed=random_seed,
594
+ metadata=metadata,
583
595
  messages=utils.get_pydantic_model(
584
596
  messages, List[models.AgentsCompletionStreamRequestMessages]
585
597
  ),
mistralai/chat.py CHANGED
@@ -6,7 +6,7 @@ from mistralai._hooks import HookContext
6
6
  from mistralai.types import OptionalNullable, UNSET
7
7
  from mistralai.utils import eventstreaming, get_security_from_env
8
8
  from mistralai.utils.unmarshal_json_response import unmarshal_json_response
9
- from typing import Any, List, Mapping, Optional, Union
9
+ from typing import Any, Dict, List, Mapping, Optional, Union
10
10
 
11
11
  # region imports
12
12
  from typing import Type
@@ -105,6 +105,7 @@ class Chat(BaseSDK):
105
105
  stream: Optional[bool] = False,
106
106
  stop: Optional[Union[models.Stop, models.StopTypedDict]] = None,
107
107
  random_seed: OptionalNullable[int] = UNSET,
108
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
108
109
  response_format: Optional[
109
110
  Union[models.ResponseFormat, models.ResponseFormatTypedDict]
110
111
  ] = None,
@@ -141,14 +142,15 @@ class Chat(BaseSDK):
141
142
  :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.
142
143
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
143
144
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
144
- :param response_format:
145
- :param tools:
146
- :param tool_choice:
147
- :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.
148
- :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.
145
+ :param metadata:
146
+ :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.
147
+ :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.
148
+ :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.
149
+ :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.
150
+ :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.
149
151
  :param n: Number of completions to return for each request, input tokens are only billed once.
150
- :param prediction:
151
- :param parallel_tool_calls:
152
+ :param prediction: Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
153
+ :param parallel_tool_calls: Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel.
152
154
  :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.
153
155
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
154
156
  :param retries: Override the default retry configuration for this method
@@ -174,6 +176,7 @@ class Chat(BaseSDK):
174
176
  stream=stream,
175
177
  stop=stop,
176
178
  random_seed=random_seed,
179
+ metadata=metadata,
177
180
  messages=utils.get_pydantic_model(messages, List[models.Messages]),
178
181
  response_format=utils.get_pydantic_model(
179
182
  response_format, Optional[models.ResponseFormat]
@@ -263,6 +266,7 @@ class Chat(BaseSDK):
263
266
  stream: Optional[bool] = False,
264
267
  stop: Optional[Union[models.Stop, models.StopTypedDict]] = None,
265
268
  random_seed: OptionalNullable[int] = UNSET,
269
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
266
270
  response_format: Optional[
267
271
  Union[models.ResponseFormat, models.ResponseFormatTypedDict]
268
272
  ] = None,
@@ -299,14 +303,15 @@ class Chat(BaseSDK):
299
303
  :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.
300
304
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
301
305
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
302
- :param response_format:
303
- :param tools:
304
- :param tool_choice:
305
- :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.
306
- :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.
306
+ :param metadata:
307
+ :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.
308
+ :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.
309
+ :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.
310
+ :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.
311
+ :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.
307
312
  :param n: Number of completions to return for each request, input tokens are only billed once.
308
- :param prediction:
309
- :param parallel_tool_calls:
313
+ :param prediction: Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
314
+ :param parallel_tool_calls: Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel.
310
315
  :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.
311
316
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
312
317
  :param retries: Override the default retry configuration for this method
@@ -332,6 +337,7 @@ class Chat(BaseSDK):
332
337
  stream=stream,
333
338
  stop=stop,
334
339
  random_seed=random_seed,
340
+ metadata=metadata,
335
341
  messages=utils.get_pydantic_model(messages, List[models.Messages]),
336
342
  response_format=utils.get_pydantic_model(
337
343
  response_format, Optional[models.ResponseFormat]
@@ -429,6 +435,7 @@ class Chat(BaseSDK):
429
435
  ]
430
436
  ] = None,
431
437
  random_seed: OptionalNullable[int] = UNSET,
438
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
432
439
  response_format: Optional[
433
440
  Union[models.ResponseFormat, models.ResponseFormatTypedDict]
434
441
  ] = None,
@@ -467,14 +474,15 @@ class Chat(BaseSDK):
467
474
  :param stream:
468
475
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
469
476
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
470
- :param response_format:
471
- :param tools:
472
- :param tool_choice:
473
- :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.
474
- :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.
477
+ :param metadata:
478
+ :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.
479
+ :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.
480
+ :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.
481
+ :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.
482
+ :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.
475
483
  :param n: Number of completions to return for each request, input tokens are only billed once.
476
- :param prediction:
477
- :param parallel_tool_calls:
484
+ :param prediction: Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
485
+ :param parallel_tool_calls: Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel.
478
486
  :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.
479
487
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
480
488
  :param retries: Override the default retry configuration for this method
@@ -500,6 +508,7 @@ class Chat(BaseSDK):
500
508
  stream=stream,
501
509
  stop=stop,
502
510
  random_seed=random_seed,
511
+ metadata=metadata,
503
512
  messages=utils.get_pydantic_model(
504
513
  messages, List[models.ChatCompletionStreamRequestMessages]
505
514
  ),
@@ -607,6 +616,7 @@ class Chat(BaseSDK):
607
616
  ]
608
617
  ] = None,
609
618
  random_seed: OptionalNullable[int] = UNSET,
619
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET,
610
620
  response_format: Optional[
611
621
  Union[models.ResponseFormat, models.ResponseFormatTypedDict]
612
622
  ] = None,
@@ -645,14 +655,15 @@ class Chat(BaseSDK):
645
655
  :param stream:
646
656
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
647
657
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
648
- :param response_format:
649
- :param tools:
650
- :param tool_choice:
651
- :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.
652
- :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.
658
+ :param metadata:
659
+ :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.
660
+ :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.
661
+ :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.
662
+ :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.
663
+ :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.
653
664
  :param n: Number of completions to return for each request, input tokens are only billed once.
654
- :param prediction:
655
- :param parallel_tool_calls:
665
+ :param prediction: Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
666
+ :param parallel_tool_calls: Whether to enable parallel function calling during tool use, when enabled the model can call multiple tools in parallel.
656
667
  :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.
657
668
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
658
669
  :param retries: Override the default retry configuration for this method
@@ -678,6 +689,7 @@ class Chat(BaseSDK):
678
689
  stream=stream,
679
690
  stop=stop,
680
691
  random_seed=random_seed,
692
+ metadata=metadata,
681
693
  messages=utils.get_pydantic_model(
682
694
  messages, List[models.ChatCompletionStreamRequestMessages]
683
695
  ),