23 Commits

Author SHA1 Message Date
4c7f1cde0a feat: streaming Conversations API support (v1.2.0)
Add conversation_stream module with full streaming support for the
Mistral Conversations API:

- ConversationEvent enum matching API SSE event types: ResponseStarted,
  MessageOutput (text deltas), FunctionCall, ResponseDone (with usage),
  ResponseError, tool execution, agent handoff events
- parse_sse_line() handles SSE format (skips event: lines, parses
  data: JSON, handles [DONE] and comments)
- accumulate() collects streaming events into a ConversationResponse
- create_conversation_stream_async() and
  append_conversation_stream_async() client methods
- Byte-boundary buffering in sse_to_conversation_events — handles
  JSON split across TCP frames
- Integration tests hit real Mistral API: create stream, append stream,
  stream/non-stream output equivalence
2026-03-24 21:16:39 +00:00
a29c3c0109 feat: add Agents API, Conversations API, and multimodal support (v1.1.0)
Agents API (beta): create, get, update, delete, list agents with tools,
handoffs, completion args, and guardrails support.

Conversations API (beta): create, append, history, messages, restart,
delete, list conversations. Supports agent-backed and model-only
conversations with function calling and handoff execution modes.

Multimodal: ChatMessageContent enum (Text/Parts) with ContentPart
variants for text and image_url. Backwards-compatible constructors.
new_user_message_with_images() for mixed content messages.

Chat: reasoning field on ChatResponseChoice for Magistral models.
HTTP: PATCH methods for agent updates.

81 tests (30 live API integration + 35 serde unit + 16 existing).
2026-03-21 20:58:25 +00:00
ce96bcfeeb test: update all tests for v1.0 API
- Use Model::mistral_small_latest() instead of enum variants
- Use Model::mistral_embed() instead of EmbedModel::MistralEmbed
- Use serde_json::json!() for tool parameter schemas
- Update ChatParams for Option<f32> temperature field
- Update streaming test comments for new delta.content type
2026-03-20 17:57:44 +00:00
francois-caddet
161b33c725 feat(constants): update model constants (#17)
* feat(Model)!: Update model constants

- Add new models Mistral Nemo and Codestral Mamba
- Add aliases to models constant to be deserialized seemlessly from the versioned forme (e.g.: "mistral-large-2407")
- The commonly named Mistral Large 2 is now `constants::Model::MistralLargeLatest` when the old one is `Model::MistralLarge`

* tests(Model): Update the tests to check the new model variants.
2024-08-27 09:25:59 +02:00
Federico G. Schwindt
8e9f7a5386 feat: mark Function trait as Send (#12)
Allow to use Client in places that are also Send.
2024-07-24 20:16:11 +02:00
Federico G. Schwindt
3afeec1d58 feat: implement the Debug trait for Client (#11)
This is useful if you want to include client::Client in your own
implementation and derive Debug.
2024-07-24 20:08:25 +02:00
Ivan Gabriele
30156c5273 test: remove useless setup in constants test 2024-06-22 14:02:52 +02:00
Ivan Gabriele
ecd0c3028f feat(constants): add OpenMixtral8x22b, MistralTiny & CodestralLatest to Model enum 2024-06-22 13:22:57 +02:00
Ivan Gabriele
cf68a77320 feat(chat)!: change safe_prompt, temperature & top_p to non-Option types
BREAKING CHANGE:
- `Chat::ChatParams.safe_prompt` & `Chat::ChatRequest.safe_prompt` are now `bool` instead of `Option<bool>`. Default is `false`.
- `Chat::ChatParams.temperature` & `Chat::ChatRequest.temperature` are now `f32` instead of `Option<f32>`. Default is `0.7`.
- `Chat::ChatParams.top_p` & `Chat::ChatRequest.top_p` are now `f32` instead of `Option<f32>`. Default is `1.0`.
2024-06-07 16:00:10 +02:00
Ivan Gabriele
e61ace9a18 test(chat): simplify chat response message content check to cover variations 2024-06-07 14:36:49 +02:00
Ivan Gabriele
74bf8a96ee feat!: add function calling support to client.chat() & client.chat_async()
BREAKING CHANGE: Too many to count in this version. Check the README examples.
2024-03-09 11:40:07 +01:00
Ivan Gabriele
ef5d475e2d fix!: fix failure when api key as param and not env
BREAKING CHANGE:

- Rename `ClientError.ApiKeyError` to `MissingApiKey`.
- Rename `ClientError.ReadResponseTextError` to `ClientError.UnreadableResponseText`.
2024-03-04 21:12:08 +01:00
Ivan Gabriele
4a4219d3ea feat!: add client.chat_stream() method
BREAKING CHANGE: You can't set the `stream` option for `client.chat*()`.

Either use `client.chat_stream()` if you want to use streams
or use `client.chat()` / `client.chat_async()` otherwise.
2024-03-04 08:16:10 +01:00
Ivan Gabriele
3c228914f7 feat: add client.embeddings_async() method 2024-03-04 06:39:21 +01:00
Ivan Gabriele
b69f7c617c feat: add client.list_models_async() method 2024-03-04 06:33:38 +01:00
Ivan Gabriele
1dd59f6704 feat: add client.chat_async() method 2024-03-04 04:57:48 +01:00
Ivan Gabriele
33876183e4 feat!: wrap Client::new() return in a Result
BREAKING CHANGE: `Client::new()` now returns a `Result`.
2024-03-04 04:43:22 +01:00
Ivan Gabriele
1deab88251 feat!: add missing api key error
BREAKING CHANGE: `APIError` is renamed to `ApiError`.
2024-03-04 04:30:13 +01:00
Ivan Gabriele
f44d951247 feat!: add client.embeddings() method
BREAKING CHANGE: Models are now enforced by `Model` & `EmbedModel` enums.
2024-03-04 03:16:59 +01:00
Ivan Gabriele
814b9918b3 feat: add client.list_models() method 2024-03-03 19:42:00 +01:00
Ivan Gabriele
7de2b19b98 feat!: simplify chat completion call
BREAKING CHANGE: Chat completions must now be called directly from client.chat() without building a request in between.
2024-03-03 19:14:01 +01:00
Ivan Gabriele
b30e88c5f7 ci(github): add missing MISTRAL_API_KEY env 2024-03-03 15:29:17 +01:00
Ivan Gabriele
7d3b438d16 feat: add chat completion without streaming 2024-03-03 15:20:30 +01:00