fix(mistral): update imports for mistralai v2 SDK - #1020
Merged
Merged
Conversation
The mistralai v2 SDK moved all types under a `mistralai.client` namespace and renamed several batch-related types. This bumps the minimum version to >=2.0.0 and updates all import paths accordingly. Fixes #1018 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
njbrake
had a problem deploying
to
integration-tests
April 13, 2026 09:55 — with
GitHub Actions
Failure
njbrake
had a problem deploying
to
integration-tests
April 13, 2026 09:55 — with
GitHub Actions
Failure
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
njbrake
had a problem deploying
to
integration-tests
April 13, 2026 09:56 — with
GitHub Actions
Failure
njbrake
had a problem deploying
to
integration-tests
April 13, 2026 09:56 — with
GitHub Actions
Failure
mistralai v2 pins opentelemetry-semantic-conventions<0.61, which is incompatible with opentelemetry-sdk 1.40.0 (requires ==0.61b0). Relaxing the platform extra's floor to >=1.30.0 lets the resolver pick sdk 1.39.x which pairs with sem-conventions 0.60b1 in mistralai's range. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
njbrake
temporarily deployed
to
integration-tests
April 13, 2026 10:01 — with
GitHub Actions
Inactive
njbrake
temporarily deployed
to
integration-tests
April 13, 2026 10:01 — with
GitHub Actions
Inactive
Codecov Report❌ Patch coverage is
... and 6 files with indirect coverage changes 🚀 New features to boost your workflow:
|
peteski22
added a commit
that referenced
this pull request
Apr 14, 2026
…nversion The mistralai v2 SDK (introduced in #1020) types `choice.message` as `AssistantMessage | None`, but `_create_mistral_completion_from_response` dereferenced `message_data.content` and `message_data.tool_calls` without a None guard. This produced five `union-attr` errors under mypy strict mode and left CI in a flaky state (whichever resolver shuffled mistralai's typing first broke the lint job). Add an explicit `ValueError` guard so the converter fails loudly rather than silently emitting a truncated `ChatCompletion`, plus a unit test that covers the new path.
9 tasks
peteski22
added a commit
that referenced
this pull request
Apr 14, 2026
…nversion The mistralai v2 SDK (introduced in #1020) types `choice.message` as `AssistantMessage | None`, but `_create_mistral_completion_from_response` dereferenced `message_data.content` and `message_data.tool_calls` without a None guard. This produced five `union-attr` errors under mypy strict mode and left CI in a flaky state (whichever resolver shuffled mistralai's typing first broke the lint job). Add an explicit `ValueError` guard so the converter fails loudly rather than silently emitting a truncated `ChatCompletion`, plus a unit test that covers the new path.
peteski22
added a commit
that referenced
this pull request
Apr 14, 2026
## Description The mistralai v2 SDK (adopted in #1020) types `choice.message` as `AssistantMessage | None`, but `_create_mistral_completion_from_response` dereferenced `message_data.content` and `message_data.tool_calls` without a None guard. This produced five `union-attr` errors under mypy strict mode: ``` src/any_llm/providers/mistral/utils.py:174: error: Item "None" of "AssistantMessage | None" has no attribute "content" [union-attr] src/any_llm/providers/mistral/utils.py:175: error: ... [union-attr] src/any_llm/providers/mistral/utils.py:181: error: ... [union-attr] src/any_llm/providers/mistral/utils.py:183: error: ... [union-attr] src/any_llm/providers/mistral/utils.py:201: error: ... [union-attr] ``` The lint job on `main` has been intermittently failing since #1020 merged — whichever CI run hit the resolver state where mistralai's tightened typing was visible would fail. The most recent failure is on PR #1028. ### Fix Add an explicit `ValueError` guard at the top of the loop so the converter fails loudly rather than silently emitting a truncated `ChatCompletion`. A real chat-completion choice always carries a message; if the SDK ever hands us `None`, we want to know rather than drop the choice silently. Includes a unit test that covers the new guard path. ## PR Type - 🐛 Bug Fix ## Relevant issues Regression introduced by #1020 (`fix(mistral): update imports for mistralai v2 SDK`). ## Checklist - [x] I understand the code I am submitting. - [x] I have added unit tests that prove my fix/feature works - [x] I have run this code locally and verified it fixes the issue. - [x] New and existing tests pass locally - [x] Documentation was updated where necessary - [x] I have read and followed the [contribution guidelines](https://github.com/mozilla-ai/any-llm/blob/main/CONTRIBUTING.md) - [x] **AI Usage:** - [x] AI was used for drafting/refactoring. ## AI Usage Information - AI Model used: Claude Opus 4.6 (1M context) - AI Developer Tool used: Claude Code - Any other info you'd like to share: - [ ] I am an AI Agent filling out this form (check box if true)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The mistralai v2 SDK (released 2026-03-10) moved all types under a
mistralai.clientnamespace and renamed several batch-related types (BatchJobOut->BatchJob,BatchJobsOut->ListBatchJobsResponse). Error types moved frommistralai.modelstomistralai.client.errors.This PR bumps the minimum version to
>=2.0.0and updates all import paths accordingly. It also fixes_convert_models_listto handle v2'sUnknownModelListDatatype which lacksid/created/owned_byfields, and updates response format tests to handle v2's dict return fromresponse_format_from_pydantic_model.PR Type
Relevant issues
Fixes #1018
Checklist
AI Usage Information
AI Model used: Claude Opus 4.6
AI Developer Tool used: Claude Code
Any other info you'd like to share: Used to investigate v2 import path changes and update all references
I am an AI Agent filling out this form (check box if true)