mistralai 1.11.1__py3-none-any.whl → 1.12.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 (39) hide show
  1. mistralai/_version.py +2 -2
  2. mistralai/audio.py +20 -0
  3. mistralai/conversations.py +48 -8
  4. mistralai/extra/__init__.py +48 -0
  5. mistralai/extra/exceptions.py +49 -4
  6. mistralai/extra/realtime/__init__.py +25 -0
  7. mistralai/extra/realtime/connection.py +207 -0
  8. mistralai/extra/realtime/transcription.py +271 -0
  9. mistralai/files.py +6 -0
  10. mistralai/mistral_agents.py +391 -8
  11. mistralai/models/__init__.py +103 -0
  12. mistralai/models/agentaliasresponse.py +23 -0
  13. mistralai/models/agentconversation.py +14 -4
  14. mistralai/models/agents_api_v1_agents_create_or_update_aliasop.py +26 -0
  15. mistralai/models/agents_api_v1_agents_get_versionop.py +2 -2
  16. mistralai/models/agents_api_v1_agents_getop.py +12 -3
  17. mistralai/models/agents_api_v1_agents_list_version_aliasesop.py +16 -0
  18. mistralai/models/audiotranscriptionrequest.py +8 -0
  19. mistralai/models/audiotranscriptionrequeststream.py +8 -0
  20. mistralai/models/conversationrequest.py +8 -2
  21. mistralai/models/conversationrestartrequest.py +18 -4
  22. mistralai/models/conversationrestartstreamrequest.py +20 -4
  23. mistralai/models/conversationstreamrequest.py +12 -2
  24. mistralai/models/files_api_routes_list_filesop.py +8 -1
  25. mistralai/models/mistralpromptmode.py +4 -0
  26. mistralai/models/modelcapabilities.py +3 -0
  27. mistralai/models/realtimetranscriptionerror.py +27 -0
  28. mistralai/models/realtimetranscriptionerrordetail.py +29 -0
  29. mistralai/models/realtimetranscriptionsession.py +20 -0
  30. mistralai/models/realtimetranscriptionsessioncreated.py +30 -0
  31. mistralai/models/realtimetranscriptionsessionupdated.py +30 -0
  32. mistralai/models/timestampgranularity.py +4 -1
  33. mistralai/models/transcriptionsegmentchunk.py +41 -2
  34. mistralai/models/transcriptionstreamsegmentdelta.py +38 -2
  35. mistralai/transcriptions.py +24 -0
  36. {mistralai-1.11.1.dist-info → mistralai-1.12.0.dist-info}/METADATA +6 -2
  37. {mistralai-1.11.1.dist-info → mistralai-1.12.0.dist-info}/RECORD +39 -28
  38. {mistralai-1.11.1.dist-info → mistralai-1.12.0.dist-info}/WHEEL +0 -0
  39. {mistralai-1.11.1.dist-info → mistralai-1.12.0.dist-info}/licenses/LICENSE +0 -0
@@ -19,6 +19,7 @@ class FilesAPIRoutesListFilesRequestTypedDict(TypedDict):
19
19
  source: NotRequired[Nullable[List[Source]]]
20
20
  search: NotRequired[Nullable[str]]
21
21
  purpose: NotRequired[Nullable[FilePurpose]]
22
+ mimetypes: NotRequired[Nullable[List[str]]]
22
23
 
23
24
 
24
25
  class FilesAPIRoutesListFilesRequest(BaseModel):
@@ -57,6 +58,11 @@ class FilesAPIRoutesListFilesRequest(BaseModel):
57
58
  FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
58
59
  ] = UNSET
59
60
 
61
+ mimetypes: Annotated[
62
+ OptionalNullable[List[str]],
63
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
64
+ ] = UNSET
65
+
60
66
  @model_serializer(mode="wrap")
61
67
  def serialize_model(self, handler):
62
68
  optional_fields = [
@@ -67,8 +73,9 @@ class FilesAPIRoutesListFilesRequest(BaseModel):
67
73
  "source",
68
74
  "search",
69
75
  "purpose",
76
+ "mimetypes",
70
77
  ]
71
- nullable_fields = ["sample_type", "source", "search", "purpose"]
78
+ nullable_fields = ["sample_type", "source", "search", "purpose", "mimetypes"]
72
79
  null_default_fields = []
73
80
 
74
81
  serialized = handler(self)
@@ -6,3 +6,7 @@ from typing import Literal, Union
6
6
 
7
7
 
8
8
  MistralPromptMode = Union[Literal["reasoning",], UnrecognizedStr]
9
+ r"""Available options to the prompt_mode argument on the chat completion endpoint.
10
+ Values represent high-level intent. Assignment to actual SPs is handled internally.
11
+ System prompt may include knowledge cutoff date, model capabilities, tone to use, safety guidelines, etc.
12
+ """
@@ -16,6 +16,7 @@ class ModelCapabilitiesTypedDict(TypedDict):
16
16
  classification: NotRequired[bool]
17
17
  moderation: NotRequired[bool]
18
18
  audio: NotRequired[bool]
19
+ audio_transcription: NotRequired[bool]
19
20
 
20
21
 
21
22
  class ModelCapabilities(BaseModel):
@@ -36,3 +37,5 @@ class ModelCapabilities(BaseModel):
36
37
  moderation: Optional[bool] = False
37
38
 
38
39
  audio: Optional[bool] = False
40
+
41
+ audio_transcription: Optional[bool] = False
@@ -0,0 +1,27 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .realtimetranscriptionerrordetail import (
5
+ RealtimeTranscriptionErrorDetail,
6
+ RealtimeTranscriptionErrorDetailTypedDict,
7
+ )
8
+ from mistralai.types import BaseModel
9
+ from mistralai.utils import validate_const
10
+ import pydantic
11
+ from pydantic.functional_validators import AfterValidator
12
+ from typing import Literal, Optional
13
+ from typing_extensions import Annotated, TypedDict
14
+
15
+
16
+ class RealtimeTranscriptionErrorTypedDict(TypedDict):
17
+ error: RealtimeTranscriptionErrorDetailTypedDict
18
+ type: Literal["error"]
19
+
20
+
21
+ class RealtimeTranscriptionError(BaseModel):
22
+ error: RealtimeTranscriptionErrorDetail
23
+
24
+ TYPE: Annotated[
25
+ Annotated[Optional[Literal["error"]], AfterValidator(validate_const("error"))],
26
+ pydantic.Field(alias="type"),
27
+ ] = "error"
@@ -0,0 +1,29 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from mistralai.types import BaseModel
5
+ from typing import Any, Dict, Union
6
+ from typing_extensions import TypeAliasType, TypedDict
7
+
8
+
9
+ MessageTypedDict = TypeAliasType("MessageTypedDict", Union[str, Dict[str, Any]])
10
+ r"""Human-readable error message."""
11
+
12
+
13
+ Message = TypeAliasType("Message", Union[str, Dict[str, Any]])
14
+ r"""Human-readable error message."""
15
+
16
+
17
+ class RealtimeTranscriptionErrorDetailTypedDict(TypedDict):
18
+ message: MessageTypedDict
19
+ r"""Human-readable error message."""
20
+ code: int
21
+ r"""Internal error code for debugging."""
22
+
23
+
24
+ class RealtimeTranscriptionErrorDetail(BaseModel):
25
+ message: Message
26
+ r"""Human-readable error message."""
27
+
28
+ code: int
29
+ r"""Internal error code for debugging."""
@@ -0,0 +1,20 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .audioformat import AudioFormat, AudioFormatTypedDict
5
+ from mistralai.types import BaseModel
6
+ from typing_extensions import TypedDict
7
+
8
+
9
+ class RealtimeTranscriptionSessionTypedDict(TypedDict):
10
+ request_id: str
11
+ model: str
12
+ audio_format: AudioFormatTypedDict
13
+
14
+
15
+ class RealtimeTranscriptionSession(BaseModel):
16
+ request_id: str
17
+
18
+ model: str
19
+
20
+ audio_format: AudioFormat
@@ -0,0 +1,30 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .realtimetranscriptionsession import (
5
+ RealtimeTranscriptionSession,
6
+ RealtimeTranscriptionSessionTypedDict,
7
+ )
8
+ from mistralai.types import BaseModel
9
+ from mistralai.utils import validate_const
10
+ import pydantic
11
+ from pydantic.functional_validators import AfterValidator
12
+ from typing import Literal, Optional
13
+ from typing_extensions import Annotated, TypedDict
14
+
15
+
16
+ class RealtimeTranscriptionSessionCreatedTypedDict(TypedDict):
17
+ session: RealtimeTranscriptionSessionTypedDict
18
+ type: Literal["session.created"]
19
+
20
+
21
+ class RealtimeTranscriptionSessionCreated(BaseModel):
22
+ session: RealtimeTranscriptionSession
23
+
24
+ TYPE: Annotated[
25
+ Annotated[
26
+ Optional[Literal["session.created"]],
27
+ AfterValidator(validate_const("session.created")),
28
+ ],
29
+ pydantic.Field(alias="type"),
30
+ ] = "session.created"
@@ -0,0 +1,30 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .realtimetranscriptionsession import (
5
+ RealtimeTranscriptionSession,
6
+ RealtimeTranscriptionSessionTypedDict,
7
+ )
8
+ from mistralai.types import BaseModel
9
+ from mistralai.utils import validate_const
10
+ import pydantic
11
+ from pydantic.functional_validators import AfterValidator
12
+ from typing import Literal, Optional
13
+ from typing_extensions import Annotated, TypedDict
14
+
15
+
16
+ class RealtimeTranscriptionSessionUpdatedTypedDict(TypedDict):
17
+ session: RealtimeTranscriptionSessionTypedDict
18
+ type: Literal["session.updated"]
19
+
20
+
21
+ class RealtimeTranscriptionSessionUpdated(BaseModel):
22
+ session: RealtimeTranscriptionSession
23
+
24
+ TYPE: Annotated[
25
+ Annotated[
26
+ Optional[Literal["session.updated"]],
27
+ AfterValidator(validate_const("session.updated")),
28
+ ],
29
+ pydantic.Field(alias="type"),
30
+ ] = "session.updated"
@@ -4,4 +4,7 @@ from __future__ import annotations
4
4
  from typing import Literal
5
5
 
6
6
 
7
- TimestampGranularity = Literal["segment",]
7
+ TimestampGranularity = Literal[
8
+ "segment",
9
+ "word",
10
+ ]
@@ -1,9 +1,9 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from mistralai.types import BaseModel
4
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
5
  import pydantic
6
- from pydantic import ConfigDict
6
+ from pydantic import ConfigDict, model_serializer
7
7
  from typing import Any, Dict, Literal, Optional
8
8
  from typing_extensions import NotRequired, TypedDict
9
9
 
@@ -15,6 +15,8 @@ class TranscriptionSegmentChunkTypedDict(TypedDict):
15
15
  text: str
16
16
  start: float
17
17
  end: float
18
+ score: NotRequired[Nullable[float]]
19
+ speaker_id: NotRequired[Nullable[str]]
18
20
  type: NotRequired[Type]
19
21
 
20
22
 
@@ -30,6 +32,10 @@ class TranscriptionSegmentChunk(BaseModel):
30
32
 
31
33
  end: float
32
34
 
35
+ score: OptionalNullable[float] = UNSET
36
+
37
+ speaker_id: OptionalNullable[str] = UNSET
38
+
33
39
  type: Optional[Type] = "transcription_segment"
34
40
 
35
41
  @property
@@ -39,3 +45,36 @@ class TranscriptionSegmentChunk(BaseModel):
39
45
  @additional_properties.setter
40
46
  def additional_properties(self, value):
41
47
  self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
48
+
49
+ @model_serializer(mode="wrap")
50
+ def serialize_model(self, handler):
51
+ optional_fields = ["score", "speaker_id", "type"]
52
+ nullable_fields = ["score", "speaker_id"]
53
+ null_default_fields = []
54
+
55
+ serialized = handler(self)
56
+
57
+ m = {}
58
+
59
+ for n, f in type(self).model_fields.items():
60
+ k = f.alias or n
61
+ val = serialized.get(k)
62
+ serialized.pop(k, None)
63
+
64
+ optional_nullable = k in optional_fields and k in nullable_fields
65
+ is_set = (
66
+ self.__pydantic_fields_set__.intersection({n})
67
+ or k in null_default_fields
68
+ ) # pylint: disable=no-member
69
+
70
+ if val is not None and val != UNSET_SENTINEL:
71
+ m[k] = val
72
+ elif val != UNSET_SENTINEL and (
73
+ not k in optional_fields or (optional_nullable and is_set)
74
+ ):
75
+ m[k] = val
76
+
77
+ for k, v in serialized.items():
78
+ m[k] = v
79
+
80
+ return m
@@ -1,9 +1,9 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from mistralai.types import BaseModel
4
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
5
  import pydantic
6
- from pydantic import ConfigDict
6
+ from pydantic import ConfigDict, model_serializer
7
7
  from typing import Any, Dict, Literal, Optional
8
8
  from typing_extensions import NotRequired, TypedDict
9
9
 
@@ -15,6 +15,7 @@ class TranscriptionStreamSegmentDeltaTypedDict(TypedDict):
15
15
  text: str
16
16
  start: float
17
17
  end: float
18
+ speaker_id: NotRequired[Nullable[str]]
18
19
  type: NotRequired[TranscriptionStreamSegmentDeltaType]
19
20
 
20
21
 
@@ -30,6 +31,8 @@ class TranscriptionStreamSegmentDelta(BaseModel):
30
31
 
31
32
  end: float
32
33
 
34
+ speaker_id: OptionalNullable[str] = UNSET
35
+
33
36
  type: Optional[TranscriptionStreamSegmentDeltaType] = "transcription.segment"
34
37
 
35
38
  @property
@@ -39,3 +42,36 @@ class TranscriptionStreamSegmentDelta(BaseModel):
39
42
  @additional_properties.setter
40
43
  def additional_properties(self, value):
41
44
  self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
45
+
46
+ @model_serializer(mode="wrap")
47
+ def serialize_model(self, handler):
48
+ optional_fields = ["speaker_id", "type"]
49
+ nullable_fields = ["speaker_id"]
50
+ null_default_fields = []
51
+
52
+ serialized = handler(self)
53
+
54
+ m = {}
55
+
56
+ for n, f in type(self).model_fields.items():
57
+ k = f.alias or n
58
+ val = serialized.get(k)
59
+ serialized.pop(k, None)
60
+
61
+ optional_nullable = k in optional_fields and k in nullable_fields
62
+ is_set = (
63
+ self.__pydantic_fields_set__.intersection({n})
64
+ or k in null_default_fields
65
+ ) # pylint: disable=no-member
66
+
67
+ if val is not None and val != UNSET_SENTINEL:
68
+ m[k] = val
69
+ elif val != UNSET_SENTINEL and (
70
+ not k in optional_fields or (optional_nullable and is_set)
71
+ ):
72
+ m[k] = val
73
+
74
+ for k, v in serialized.items():
75
+ m[k] = v
76
+
77
+ return m
@@ -25,6 +25,8 @@ class Transcriptions(BaseSDK):
25
25
  file_id: OptionalNullable[str] = UNSET,
26
26
  language: OptionalNullable[str] = UNSET,
27
27
  temperature: OptionalNullable[float] = UNSET,
28
+ diarize: Optional[bool] = False,
29
+ context_bias: Optional[List[str]] = None,
28
30
  timestamp_granularities: Optional[
29
31
  List[models_timestampgranularity.TimestampGranularity]
30
32
  ] = None,
@@ -41,6 +43,8 @@ class Transcriptions(BaseSDK):
41
43
  :param file_id: ID of a file uploaded to /v1/files
42
44
  :param language: Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
43
45
  :param temperature:
46
+ :param diarize:
47
+ :param context_bias:
44
48
  :param timestamp_granularities: Granularities of timestamps to include in the response.
45
49
  :param retries: Override the default retry configuration for this method
46
50
  :param server_url: Override the default server URL for this method
@@ -64,6 +68,8 @@ class Transcriptions(BaseSDK):
64
68
  file_id=file_id,
65
69
  language=language,
66
70
  temperature=temperature,
71
+ diarize=diarize,
72
+ context_bias=context_bias,
67
73
  timestamp_granularities=timestamp_granularities,
68
74
  )
69
75
 
@@ -130,6 +136,8 @@ class Transcriptions(BaseSDK):
130
136
  file_id: OptionalNullable[str] = UNSET,
131
137
  language: OptionalNullable[str] = UNSET,
132
138
  temperature: OptionalNullable[float] = UNSET,
139
+ diarize: Optional[bool] = False,
140
+ context_bias: Optional[List[str]] = None,
133
141
  timestamp_granularities: Optional[
134
142
  List[models_timestampgranularity.TimestampGranularity]
135
143
  ] = None,
@@ -146,6 +154,8 @@ class Transcriptions(BaseSDK):
146
154
  :param file_id: ID of a file uploaded to /v1/files
147
155
  :param language: Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
148
156
  :param temperature:
157
+ :param diarize:
158
+ :param context_bias:
149
159
  :param timestamp_granularities: Granularities of timestamps to include in the response.
150
160
  :param retries: Override the default retry configuration for this method
151
161
  :param server_url: Override the default server URL for this method
@@ -169,6 +179,8 @@ class Transcriptions(BaseSDK):
169
179
  file_id=file_id,
170
180
  language=language,
171
181
  temperature=temperature,
182
+ diarize=diarize,
183
+ context_bias=context_bias,
172
184
  timestamp_granularities=timestamp_granularities,
173
185
  )
174
186
 
@@ -235,6 +247,8 @@ class Transcriptions(BaseSDK):
235
247
  file_id: OptionalNullable[str] = UNSET,
236
248
  language: OptionalNullable[str] = UNSET,
237
249
  temperature: OptionalNullable[float] = UNSET,
250
+ diarize: Optional[bool] = False,
251
+ context_bias: Optional[List[str]] = None,
238
252
  timestamp_granularities: Optional[
239
253
  List[models_timestampgranularity.TimestampGranularity]
240
254
  ] = None,
@@ -251,6 +265,8 @@ class Transcriptions(BaseSDK):
251
265
  :param file_id: ID of a file uploaded to /v1/files
252
266
  :param language: Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
253
267
  :param temperature:
268
+ :param diarize:
269
+ :param context_bias:
254
270
  :param timestamp_granularities: Granularities of timestamps to include in the response.
255
271
  :param retries: Override the default retry configuration for this method
256
272
  :param server_url: Override the default server URL for this method
@@ -274,6 +290,8 @@ class Transcriptions(BaseSDK):
274
290
  file_id=file_id,
275
291
  language=language,
276
292
  temperature=temperature,
293
+ diarize=diarize,
294
+ context_bias=context_bias,
277
295
  timestamp_granularities=timestamp_granularities,
278
296
  )
279
297
 
@@ -350,6 +368,8 @@ class Transcriptions(BaseSDK):
350
368
  file_id: OptionalNullable[str] = UNSET,
351
369
  language: OptionalNullable[str] = UNSET,
352
370
  temperature: OptionalNullable[float] = UNSET,
371
+ diarize: Optional[bool] = False,
372
+ context_bias: Optional[List[str]] = None,
353
373
  timestamp_granularities: Optional[
354
374
  List[models_timestampgranularity.TimestampGranularity]
355
375
  ] = None,
@@ -366,6 +386,8 @@ class Transcriptions(BaseSDK):
366
386
  :param file_id: ID of a file uploaded to /v1/files
367
387
  :param language: Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
368
388
  :param temperature:
389
+ :param diarize:
390
+ :param context_bias:
369
391
  :param timestamp_granularities: Granularities of timestamps to include in the response.
370
392
  :param retries: Override the default retry configuration for this method
371
393
  :param server_url: Override the default server URL for this method
@@ -389,6 +411,8 @@ class Transcriptions(BaseSDK):
389
411
  file_id=file_id,
390
412
  language=language,
391
413
  temperature=temperature,
414
+ diarize=diarize,
415
+ context_bias=context_bias,
392
416
  timestamp_granularities=timestamp_granularities,
393
417
  )
394
418
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mistralai
3
- Version: 1.11.1
3
+ Version: 1.12.0
4
4
  Summary: Python Client SDK for the Mistral AI API.
5
5
  Project-URL: Repository, https://github.com/mistralai/client-python.git
6
6
  Author: Mistral
@@ -24,6 +24,8 @@ Requires-Dist: mcp<2.0,>=1.0; extra == 'agents'
24
24
  Provides-Extra: gcp
25
25
  Requires-Dist: google-auth>=2.27.0; extra == 'gcp'
26
26
  Requires-Dist: requests>=2.32.3; extra == 'gcp'
27
+ Provides-Extra: realtime
28
+ Requires-Dist: websockets>=13.0; extra == 'realtime'
27
29
  Description-Content-Type: text/markdown
28
30
 
29
31
  # Mistral Python Client
@@ -503,6 +505,8 @@ The documentation for the GCP SDK is available [here](packages/mistralai_gcp/REA
503
505
  * [update_version](docs/sdks/mistralagents/README.md#update_version) - Update an agent version.
504
506
  * [list_versions](docs/sdks/mistralagents/README.md#list_versions) - List all versions of an agent.
505
507
  * [get_version](docs/sdks/mistralagents/README.md#get_version) - Retrieve a specific version of an agent.
508
+ * [create_version_alias](docs/sdks/mistralagents/README.md#create_version_alias) - Create or update an agent version alias.
509
+ * [list_version_aliases](docs/sdks/mistralagents/README.md#list_version_aliases) - List all aliases for an agent.
506
510
 
507
511
  ### [Beta.Conversations](docs/sdks/conversations/README.md)
508
512
 
@@ -780,7 +784,7 @@ with Mistral(
780
784
 
781
785
 
782
786
  **Inherit from [`MistralError`](./src/mistralai/models/mistralerror.py)**:
783
- * [`HTTPValidationError`](./src/mistralai/models/httpvalidationerror.py): Validation Error. Status code `422`. Applicable to 50 of 72 methods.*
787
+ * [`HTTPValidationError`](./src/mistralai/models/httpvalidationerror.py): Validation Error. Status code `422`. Applicable to 52 of 74 methods.*
784
788
  * [`ResponseValidationError`](./src/mistralai/models/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
785
789
 
786
790
  </details>