-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(api): migrate Mistral provider to AI SDK #11089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(api): migrate Mistral provider to AI SDK #11089
Conversation
- Replace @mistralai/mistralai SDK with @ai-sdk/mistral v3.0.0 - Use streamText and generateText from AI SDK v6 - Add comprehensive test suite with 23 tests - Maintain support for Codestral models with custom base URL EXT-692
Review completed. One new issue identified.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Address review comment - ensure temperature defaults to 1 (MISTRAL_DEFAULT_TEMPERATURE) instead of 0 from getModelParams to match original behavior.
|
@roomote please fix the compile and knip errors |
Fixed the reported issues. All local checks passed. |
|
@roomote can you resolve the conflicts with main one more time? |
Resolved merge conflicts with main. All local checks passed. |
| // Process the full stream to get all events including reasoning | ||
| for await (const part of result.fullStream) { | ||
| for (const chunk of processAiSdkStreamPart(part)) { | ||
| yield chunk | ||
| } | ||
| } | ||
|
|
||
| return { id, info, maxTokens, temperature } | ||
| // Yield usage metrics at the end | ||
| const usage = await result.usage | ||
| if (usage) { | ||
| yield this.processUsageMetrics(usage) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike the other AI SDK providers (Fireworks, Cerebras, DeepSeek, Groq), the Mistral handler is missing error handling for AI SDK errors. The stream processing should be wrapped in a try/catch that uses handleAiSdkError to properly transform errors like AI_RetryError and AI_APICallError into user-friendly messages with preserved status codes. Also add handleAiSdkError to the imports on line 15.
| // Process the full stream to get all events including reasoning | |
| for await (const part of result.fullStream) { | |
| for (const chunk of processAiSdkStreamPart(part)) { | |
| yield chunk | |
| } | |
| } | |
| return { id, info, maxTokens, temperature } | |
| // Yield usage metrics at the end | |
| const usage = await result.usage | |
| if (usage) { | |
| yield this.processUsageMetrics(usage) | |
| } | |
| try { | |
| // Process the full stream to get all events including reasoning | |
| for await (const part of result.fullStream) { | |
| for (const chunk of processAiSdkStreamPart(part)) { | |
| yield chunk | |
| } | |
| } | |
| // Yield usage metrics at the end | |
| const usage = await result.usage | |
| if (usage) { | |
| yield this.processUsageMetrics(usage) | |
| } | |
| } catch (error) { | |
| // Handle AI SDK errors (AI_RetryError, AI_APICallError, etc.) | |
| throw handleAiSdkError(error, "Mistral") | |
| } |
Fix it with Roo Code or mention @roomote and request a fix.
Summary
Migrate the Mistral provider from using the direct
@mistralai/mistralaiSDK to the AI SDK's dedicated@ai-sdk/mistralpackage.Changes
1.
src/api/providers/mistral.ts@mistralai/mistralaiSDK with@ai-sdk/mistralcreateMistralto create the provider instancestreamTextandgenerateTextfrom the AI SDK v6 for completions2.
src/package.json@ai-sdk/mistral: ^3.0.0to dependencies (v3.x required for AI SDK v6 compatibility)3.
src/api/providers/__tests__/mistral.spec.tsTesting
Linear
Resolves EXT-692
Important
Migrates Mistral provider to AI SDK, updating dependencies and tests for compatibility.
@mistralai/mistralaito@ai-sdk/mistralinmistral.ts.createMistral,streamText, andgenerateTextfor handling completions.mistral.spec.tsto mock new SDK functions and verify behavior.@ai-sdk/mistral: ^3.0.0topackage.jsonfor AI SDK v6 compatibility.This description was created by
for 3efb7ec. You can customize this summary. It will automatically update as commits are pushed.