feat(ai): add Mistral provider and support optional API key for local endpoints#214
feat(ai): add Mistral provider and support optional API key for local endpoints#214FloChab wants to merge 2 commits into
Conversation
- Add Mistral to provider.ts (import, type, registry, createLanguageModel) - Add Mistral to scoring.ts schemas (createAiConfigSchema, updateAiConfigSchema) - Add @ai-sdk/mistral dependency Signed-off-by: Florian Chab <fchabreiron@gmail.com>
- Update createAiConfigSchema and updateAiConfigSchema to accept empty API key (min:0) - Modify createLanguageModel to handle empty API key for openai_compatible provider - Update AiConfigForm validation to not require API key for custom endpoints - Ensure API key is always included in request body (even if empty string) This enables local endpoints (Ollama, LM Studio, vLLM, etc.) to work without requiring an API key, while maintaining security for cloud providers. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai> Signed-off-by: Florian Chab <fchabreiron@gmail.com>
📝 WalkthroughWalkthroughAdds Mistral as a supported AI provider by introducing the ChangesMistral Provider and API Key Handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
server/utils/ai/provider.ts (1)
148-148: 🧹 Nitpick | 🔵 Trivial | 💤 Low valueConsider an empty string instead of
'dummy-key'for keyless endpoints.Using
'dummy-key'may cause confusing error messages from the OpenAI SDK or endpoint logs when debugging authentication issues. An empty string (apiKey || '') conveys "no key provided" more clearly.That said, this is a minor readability/debugging concern and the current approach is functionally correct for Ollama-style endpoints.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@server/utils/ai/provider.ts` at line 148, Replace the dummy key value with an empty string in the apiKey field assignment. Instead of using 'dummy-key' as the fallback value when apiKey is not provided, change it to an empty string. This makes it clearer in logs and error messages that no API key was provided for keyless endpoints, reducing confusion during debugging.app/components/AiConfigForm.vue (1)
148-152: 🧹 Nitpick | 🔵 Trivial | 💤 Low valueCondition is always true since
apiKeyis always defined.
form.value.apiKeyis initialized to''on line 72, soform.value.apiKey !== undefinedis always true. The condition could be removed, but since the intent is to always sendapiKey(per PR objectives: "API key is always included in the request body"), the behavior is correct.No change needed — just noting for clarity.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/components/AiConfigForm.vue` around lines 148 - 152, No change is required for this code. The reviewer has noted that while the condition `if (form.value.apiKey !== undefined)` in the body assignment is always true (since form.value.apiKey is initialized to an empty string on line 72), this behavior is intentional and correct according to the PR objectives which require the API key to always be included in the request body. The condition could be optionally removed for code clarity, but doing so is not necessary.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@app/components/AiConfigForm.vue`:
- Around line 148-152: No change is required for this code. The reviewer has
noted that while the condition `if (form.value.apiKey !== undefined)` in the
body assignment is always true (since form.value.apiKey is initialized to an
empty string on line 72), this behavior is intentional and correct according to
the PR objectives which require the API key to always be included in the request
body. The condition could be optionally removed for code clarity, but doing so
is not necessary.
In `@server/utils/ai/provider.ts`:
- Line 148: Replace the dummy key value with an empty string in the apiKey field
assignment. Instead of using 'dummy-key' as the fallback value when apiKey is
not provided, change it to an empty string. This makes it clearer in logs and
error messages that no API key was provided for keyless endpoints, reducing
confusion during debugging.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6a98bcd0-f2ef-45c2-881f-fbe35ead70e4
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (4)
app/components/AiConfigForm.vuepackage.jsonserver/utils/ai/provider.tsserver/utils/schemas/scoring.ts
Summary
What does this PR change?
1. Adds Mistral AI as a supported provider
@ai-sdk/mistralfor official Mistral API supportmistral-large-latest(powerful)mistral-medium-latest(recommended)mistral-small-latest(cheap)2. Allows optional API key for custom endpoints
openai_compatibleproviderWhy is this needed?
For Mistral: offer the ability to use Mistral AI models alongside existing providers (OpenAI, Anthropic, Google) for more choice and European-based privacy-focused options.
For optional API key: Local AI endpoints don't necessary require authentication, but the previous validation forced users to enter a dummy key. This creates a better UX for local/development setups while maintaining security for cloud providers.
Type of change
Validation
I tested locally - Verified:
I added/updated relevant documentation
I verified multi-tenant scoping and auth behavior for affected API paths (existing auth middleware unchanged)
DCO
Signed-off-by) viagit commit -sSummary by CodeRabbit
Release Notes
New Features
Improvements