Skip to content

Commit 08c7956

Browse files
mistral-warden[bot]maiengineeringandreaonofrei01
authored
chore: sync generated SDK from upstream (#642)
* chore: sync generated SDK from upstream @ ed06004b Generated upstream and copied here. Do not edit in this repository; changes are overwritten by the next sync. * chore: drop MIGRATION.md change and connector overlay * docs(readme): announce voice agents and point the PyPI readme at v3 --------- Co-authored-by: Buildkite CI <engineering@mistral.ai> Co-authored-by: andreaonofrei01 <andrea.onofrei@mistral.ai>
1 parent b52629e commit 08c7956

421 files changed

Lines changed: 20235 additions & 2138 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.speakeasy/gen.lock‎

Lines changed: 1469 additions & 465 deletions
Large diffs are not rendered by default.

‎.speakeasy/gen.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ generation:
3232
generateNewTests: false
3333
skipResponseBodyAssertions: false
3434
python:
35-
version: 3.2.0
35+
version: 3.3.0
3636
additionalDependencies:
3737
dev:
3838
pytest: ^8.2.2

‎.speakeasy/workflow.lock‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ sources:
1616
- speakeasy-mistralai-gcp-sdk-26292830187-1
1717
mistral-openapi:
1818
sourceNamespace: mistral-openapi
19-
sourceRevisionDigest: sha256:70a19eb0e9b0dc04c743393a6ccd1f9f3dee19a2515497be1553e49723224a5a
20-
sourceBlobDigest: sha256:9d5e60c1d8d4b518dd474b43aa3c51973b5036c4b077054e0f9efb7260f5add3
19+
sourceRevisionDigest: sha256:737a06c43b796b229aef805b4ed327462a1a4138338150f67c7850f29f4af2fa
20+
sourceBlobDigest: sha256:8d3f6691a81272f7b3de1464ba815f35bf3bf4b8040c896c253ef1fb7438ab70
2121
tags:
2222
- latest
2323
- 1.0.0
@@ -39,10 +39,10 @@ targets:
3939
mistralai-sdk:
4040
source: mistral-openapi
4141
sourceNamespace: mistral-openapi
42-
sourceRevisionDigest: sha256:70a19eb0e9b0dc04c743393a6ccd1f9f3dee19a2515497be1553e49723224a5a
43-
sourceBlobDigest: sha256:9d5e60c1d8d4b518dd474b43aa3c51973b5036c4b077054e0f9efb7260f5add3
42+
sourceRevisionDigest: sha256:737a06c43b796b229aef805b4ed327462a1a4138338150f67c7850f29f4af2fa
43+
sourceBlobDigest: sha256:8d3f6691a81272f7b3de1464ba815f35bf3bf4b8040c896c253ef1fb7438ab70
4444
codeSamplesNamespace: mistral-openapi-python-code-samples
45-
codeSamplesRevisionDigest: sha256:f56eb82503ad8298d6c12c9accd1658a915c4c10f06587cfe9cc29ac297ac4c6
45+
codeSamplesRevisionDigest: sha256:31edb14c43e740b30ffa7b8cba090f5469526b63e94ffac9a6b60e1375319557
4646
workflow:
4747
workflowVersion: 1.0.0
4848
speakeasyVersion: 1.796.4

‎README-PYPI.md‎

Lines changed: 125 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Mistral Python Client
22

3-
## Migrating from v1
3+
## New: Voice Agents
44

5-
If you are upgrading from v1 to v2, check the [migration guide](https://github.com/mistralai/client-python/blob/main/MIGRATION.md) for details on breaking changes and how to update your code.
5+
Build live voice agents with the SDK. `client.audio.sessions.init()` opens a real-time, bidirectional voice session with speech-to-text, text-to-speech and tool calls, and `client.audio.agents` saves agent configurations to reuse across sessions. Install the extra with `pip install "mistralai[voice-agents]"`, then see [Voice Agents](#voice-agents) below and the [voice agents guide](https://github.com/mistralai/client-python/blob/main/src/mistralai/extra/voice_agents/README.md).
6+
7+
## Migrating to v3
8+
9+
This is v3 of the SDK. If you are upgrading from v2, check the [migration guide](https://github.com/mistralai/client-python/blob/main/MIGRATION.md) for the breaking changes and how to update your code. It also covers upgrading from v1 to v2.
610

711
## API Key Setup
812

@@ -40,13 +44,15 @@ Mistral AI API: Our Chat Completion and Embeddings APIs specification. Create yo
4044
## Table of Contents
4145
<!-- $toc-max-depth=2 -->
4246
* [Mistral Python Client](#mistral-python-client)
43-
* [Migrating from v1](#migrating-from-v1)
47+
* [New: Voice Agents](#new-voice-agents)
48+
* [Migrating to v3](#migrating-to-v3)
4449
* [API Key Setup](#api-key-setup)
4550
* [SDK Installation](#sdk-installation)
4651
* [SDK Example Usage](#sdk-example-usage)
4752
* [Providers' SDKs Example Usage](#providers-sdks-example-usage)
4853
* [Available Resources and Operations](#available-resources-and-operations)
4954
* [Server-sent event streaming](#server-sent-event-streaming)
55+
* [Json Streaming](#json-streaming)
5056
* [Pagination](#pagination)
5157
* [File uploads](#file-uploads)
5258
* [Retries](#retries)
@@ -58,6 +64,7 @@ Mistral AI API: Our Chat Completion and Embeddings APIs specification. Create yo
5864
* [Debugging](#debugging)
5965
* [IDE Support](#ide-support)
6066
* [Telemetry & Observability](#telemetry-observability)
67+
* [Voice Agents](#voice-agents)
6168
* [Development](#development)
6269
* [Contributions](#contributions)
6370

@@ -140,6 +147,17 @@ pip install "mistralai[agents]"
140147

141148
> Note: These features require Python 3.10+ (the SDK minimum).
142149
150+
### Voice agents extra dependencies
151+
152+
Holding a live voice conversation with an agent requires the `voice-agents` extra:
153+
154+
```bash
155+
pip install "mistralai[voice-agents]"
156+
```
157+
158+
See [Voice Agents](#voice-agents) below, and
159+
[voice-agent usage and migration](https://github.com/mistralai/client-python/blob/main/src/mistralai/extra/voice_agents/README.md).
160+
143161
### Additional packages
144162

145163
Additional `mistralai-*` packages (e.g. `mistralai-workflows`) can be installed separately and are available under the `mistralai` namespace:
@@ -480,6 +498,22 @@ print(res.choices[0].message.content)
480498
* [complete](https://github.com/mistralai/client-python/blob/main/docs/sdks/agents/README.md#complete) - Agents Completion
481499
* [stream](https://github.com/mistralai/client-python/blob/main/docs/sdks/agents/README.md#stream) - Stream Agents completion
482500

501+
### [Audio.Agents](https://github.com/mistralai/client-python/blob/main/docs/sdks/audioagents/README.md)
502+
503+
* [list](https://github.com/mistralai/client-python/blob/main/docs/sdks/audioagents/README.md#list) - List audio agents
504+
* [create](https://github.com/mistralai/client-python/blob/main/docs/sdks/audioagents/README.md#create) - Create an audio agent
505+
* [get](https://github.com/mistralai/client-python/blob/main/docs/sdks/audioagents/README.md#get) - Get an audio agent
506+
* [update](https://github.com/mistralai/client-python/blob/main/docs/sdks/audioagents/README.md#update) - Update an audio agent
507+
* [delete](https://github.com/mistralai/client-python/blob/main/docs/sdks/audioagents/README.md#delete) - Delete an audio agent
508+
* [list_versions](https://github.com/mistralai/client-python/blob/main/docs/sdks/audioagents/README.md#list_versions) - List audio agent versions
509+
* [list_sessions](https://github.com/mistralai/client-python/blob/main/docs/sdks/audioagents/README.md#list_sessions) - List audio agent sessions
510+
511+
### [Audio.Sessions](https://github.com/mistralai/client-python/blob/main/docs/sdks/audiosessions/README.md)
512+
513+
* [create](https://github.com/mistralai/client-python/blob/main/docs/sdks/audiosessions/README.md#create) - Create an agent session
514+
* [get](https://github.com/mistralai/client-python/blob/main/docs/sdks/audiosessions/README.md#get) - Get session status
515+
* [close](https://github.com/mistralai/client-python/blob/main/docs/sdks/audiosessions/README.md#close) - Stop an agent session
516+
483517
### [Audio.Speech](https://github.com/mistralai/client-python/blob/main/docs/sdks/speech/README.md)
484518

485519
* [complete](https://github.com/mistralai/client-python/blob/main/docs/sdks/speech/README.md#complete) - Speech
@@ -720,6 +754,9 @@ print(res.choices[0].message.content)
720754
* [read](https://github.com/mistralai/client-python/blob/main/docs/sdks/managedindexes/README.md#read) - Read chunks within a span
721755
* [grep](https://github.com/mistralai/client-python/blob/main/docs/sdks/managedindexes/README.md#grep) - Grep for a pattern within a source
722756
* [get_chunk](https://github.com/mistralai/client-python/blob/main/docs/sdks/managedindexes/README.md#get_chunk) - Get a single chunk by id
757+
* [get_index_summary](https://github.com/mistralai/client-python/blob/main/docs/sdks/managedindexes/README.md#get_index_summary) - Get Managed Index Summary
758+
* [generate_index_summary](https://github.com/mistralai/client-python/blob/main/docs/sdks/managedindexes/README.md#generate_index_summary) - Generate a summary field for a managed index
759+
* [set_index_summary](https://github.com/mistralai/client-python/blob/main/docs/sdks/managedindexes/README.md#set_index_summary) - Set Managed Index Summary
723760

724761
### [Beta.Rag.SearchIndexes](https://github.com/mistralai/client-python/blob/main/docs/sdks/searchindexes/README.md)
725762

@@ -806,9 +843,9 @@ print(res.choices[0].message.content)
806843

807844
* [process](https://github.com/mistralai/client-python/blob/main/docs/sdks/ocr/README.md#process) - OCR
808845

809-
### [Realtime.Sessions](https://github.com/mistralai/client-python/blob/main/docs/sdks/sessions/README.md)
846+
### [Realtime.Sessions](https://github.com/mistralai/client-python/blob/main/docs/sdks/realtimesessions/README.md)
810847

811-
* [create](https://github.com/mistralai/client-python/blob/main/docs/sdks/sessions/README.md#create) - Create Client Session
848+
* [create](https://github.com/mistralai/client-python/blob/main/docs/sdks/realtimesessions/README.md#create) - Create Client Session
812849

813850
### [Workflows](https://github.com/mistralai/client-python/blob/main/docs/sdks/workflows/README.md)
814851

@@ -934,6 +971,41 @@ with Mistral(
934971
[context-manager]: https://book.pythontips.com/en/latest/context_managers.html
935972
<!-- End Server-sent event streaming [eventstream] -->
936973

974+
<!-- Start Json Streaming [jsonl] -->
975+
## Json Streaming
976+
977+
Json Streaming ([jsonl][jsonl-format] / [x-ndjson][x-ndjson]) content type can be used to stream content from certain operations. These operations will expose the stream as [Generator][generator] that
978+
can be consumed using a simple `for` loop. The loop will
979+
terminate when the server no longer has any events to send and closes the
980+
underlying connection.
981+
982+
The stream is also a [Context Manager][context-manager] and can be used with the `with` statement and will close the
983+
underlying connection when the context is exited.
984+
985+
```python
986+
from mistralai.client import Mistral
987+
import os
988+
989+
990+
with Mistral(
991+
api_key=os.getenv("MISTRAL_API_KEY", ""),
992+
) as mistral:
993+
994+
res = mistral.beta.rag.managed_indexes.generate_index_summary(language="en", index_name="<value>", force=False)
995+
996+
with res as jsonl_stream:
997+
for event in jsonl_stream:
998+
# handle event
999+
print(event, flush=True)
1000+
1001+
```
1002+
1003+
[jsonl-format]: https://jsonlines.org/
1004+
[x-ndjson]: https://github.com/ndjson/ndjson-spec
1005+
[generator]: https://book.pythontips.com/en/latest/generators.html
1006+
[context-manager]: https://book.pythontips.com/en/latest/context_managers.html
1007+
<!-- End Json Streaming [jsonl] -->
1008+
9371009
<!-- Start Pagination [pagination] -->
9381010
## Pagination
9391011

@@ -1099,8 +1171,8 @@ with Mistral(
10991171

11001172

11011173
**Inherit from [`MistralError`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/mistralerror.py)**:
1102-
* [`HTTPValidationError`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/httpvalidationerror.py): Validation Error. Status code `422`. Applicable to 165 of 275 methods.*
1103-
* [`ObservabilityError`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/observabilityerror.py): Bad Request - Invalid request parameters or data. Applicable to 65 of 275 methods.*
1174+
* [`HTTPValidationError`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/httpvalidationerror.py): Validation Error. Status code `422`. Applicable to 178 of 288 methods.*
1175+
* [`ObservabilityError`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/observabilityerror.py): Bad Request - Invalid request parameters or data. Applicable to 65 of 288 methods.*
11041176
* [`ResponseValidationError`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
11051177

11061178
</details>
@@ -1491,6 +1563,52 @@ configure_telemetry(
14911563

14921564
Runnable examples live in [`examples/mistral/observability`](https://github.com/mistralai/client-python/blob/main/examples/mistral/observability).
14931565

1566+
## Voice Agents
1567+
1568+
`client.audio.sessions.init()` opens a live, bidirectional voice session on top of the generated `audio.sessions` REST methods, which stay available for plain session CRUD. Install the extra; system audio also needs PortAudio (`brew install portaudio` on macOS).
1569+
1570+
```bash
1571+
pip install "mistralai[voice-agents]"
1572+
```
1573+
1574+
```python
1575+
import asyncio
1576+
1577+
from mistralai.client import Mistral
1578+
from mistralai.extra.voice_agents import DefaultAudioInterface, WebSearchTool, function_tool
1579+
1580+
1581+
@function_tool(filler={"text": "Let me check the weather."}, timeout_ms=15000)
1582+
async def get_weather(city: str) -> dict[str, object]:
1583+
"""Return the current weather for a city."""
1584+
return {"city": city, "temp_c": 21, "conditions": "sunny"}
1585+
1586+
1587+
async def main() -> None:
1588+
async with Mistral() as client:
1589+
session = await client.audio.sessions.init(
1590+
stt={"model": "voxtral-mini-transcribe-realtime-3"},
1591+
tts={"model": "voxtral-mini-tts-3"},
1592+
instructions="Be concise. Use get_weather for weather.",
1593+
welcome_message="Hey. Ask me about the weather somewhere.",
1594+
tools=[WebSearchTool(), get_weather],
1595+
audio_interface=DefaultAudioInterface(),
1596+
)
1597+
session.on("transcript", lambda event: print(event.role, event.content))
1598+
session.on("error", lambda event: print(event.model_dump_json()))
1599+
async with session:
1600+
await session.wait()
1601+
1602+
1603+
asyncio.run(main())
1604+
```
1605+
1606+
`init()` creates the remote session and returns it ready to connect; it does not join the room or open audio. Register callbacks, then call `await session.connect()` or enter `async with session` within the session's join window. `await session.close()` gives the session up without connecting. A missing microphone or a missing extra fails `init()` before any session is created.
1607+
1608+
Omit `audio_interface` to drive 48 kHz mono signed 16-bit PCM yourself: register an `audio` callback and call `session.send_audio()` after `connect()`.
1609+
1610+
Tool declarations, saved agents and versions, event semantics and migration from the standalone `mistralai-voice-agents` package are covered in [the voice agents guide](https://github.com/mistralai/client-python/blob/main/src/mistralai/extra/voice_agents/README.md). The runnable examples live in [`examples/audio/voice_agents`](https://github.com/mistralai/client-python/blob/main/examples/audio/voice_agents).
1611+
14941612

14951613
# Development
14961614

0 commit comments

Comments
 (0)