Skip to content

feat(provider): add mistral#72

Merged
bzp2010 merged 1 commit into
mainfrom
bzp/feat-mistral-provider
May 3, 2026
Merged

feat(provider): add mistral#72
bzp2010 merged 1 commit into
mainfrom
bzp/feat-mistral-provider

Conversation

@bzp2010
Copy link
Copy Markdown
Collaborator

@bzp2010 bzp2010 commented May 3, 2026

Summary by CodeRabbit

New Features

  • Added Mistral as a provider option, configurable with an API key and optional custom endpoint.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

📝 Walkthrough

Walkthrough

This PR adds support for a new Mistral provider across the codebase. Changes include schema validation for the provider type, configuration structures, provider implementation with macro registration, authentication wiring, and UI localization for both English and Chinese locales.

Changes

Mistral Provider Integration

Layer / File(s) Summary
Provider Type Definition
src/config/entities/providers-schema.json, src/config/entities/providers.rs
Schema enum updated to recognize "mistral" as a valid provider type; schema routes mistral to openai_compatible validation. ProviderConfig enum gains Mistral(configs::MistralProviderConfig) variant and maps to identifiers::MISTRAL.
Provider Implementation
src/gateway/providers/mistral.rs
New file defines MistralProviderConfig with required api_key and optional api_base; provider! macro registers Mistral with https://api.mistral.ai base URL, bearer authentication, and tool_args_may_be_object quirk enabled.
Provider Module & Registry
src/gateway/providers/mod.rs
Mistral module declared and publicly re-exported; identifier constant and config struct added to identifiers and configs modules; provider registered in default_provider_registry().
Authentication & URL Handling
src/proxy/provider.rs
provider_auth_and_base_url extended with branch for ProviderConfig::Mistral, extracting API key and optional base URL override.
Localization
ui/src/i18n/locales/en.json, ui/src/i18n/locales/zh-CN.json
Provider display label "Mistral" added to English and Simplified Chinese locale files.
UI Type Support
ui/src/lib/api/types.ts
PROVIDER_TYPE_VARIANTS extended with 'mistral'; Provider discriminated union includes new variant with type: 'mistral' and ApiBaseProviderConfig.
Validation Tests
src/config/entities/providers.rs, src/proxy/provider.rs
Schema validation test added for mistral provider; authentication/URL handling test verifies API key and optional base URL parsing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
E2e Test Quality Review ⚠️ Warning PR fails E2E test completeness requirement - no integration tests for complete Mistral business flow and test assertion convention violations. Implement Mistral E2E test in tests/proxy/mistral-chat-completions.test.ts and update assert_eq! to pretty_assertions::assert_eq! per project conventions.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(provider): add mistral' directly and clearly summarizes the main change: adding support for the Mistral provider across the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Check ✅ Passed MistralProviderConfig properly excludes Debug derive to prevent accidental logging of api_key, following secure patterns used by existing providers.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bzp/feat-mistral-provider

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
ui/src/i18n/locales/zh-CN.json (1)

149-159: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

补齐 providers.form.types 里的 mistral 文案

当前只在 models.form.providers 增加了 mistral,但 providers.form.types 仍缺失(约 Line 220)。这会导致模型提供商类型下拉可能显示未翻译 key。

Suggested patch
       "types": {
         "openai": "OpenAI",
         "openrouter": "OpenRouter",
         "groq": "Groq",
+        "mistral": "Mistral",
         "azure": "Azure OpenAI",
         "anthropic": "Anthropic",
         "gemini": "Gemini",
         "deepseek": "DeepSeek",
         "bedrock": "AWS Bedrock"
       }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/src/i18n/locales/zh-CN.json` around lines 149 - 159, Add the missing
"mistral" translation under the providers.form.types object in the zh-CN locale
so the provider type dropdown shows the Chinese label; locate the
providers.form.types block in ui/src/i18n/locales/zh-CN.json and add a "mistral"
key with the appropriate Chinese string (matching the style used for other
providers like "mistral" in providers or "mistral" elsewhere).
ui/src/i18n/locales/en.json (1)

149-159: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add mistral to providers.form.types as well

You added the model-form provider label, but the provider-form type label map still lacks mistral (around Line 220). This can surface untranslated key text in the provider type selector.

Suggested patch
       "types": {
         "openai": "OpenAI",
         "openrouter": "OpenRouter",
         "groq": "Groq",
+        "mistral": "Mistral",
         "azure": "Azure OpenAI",
         "anthropic": "Anthropic",
         "gemini": "Gemini",
         "deepseek": "DeepSeek",
         "bedrock": "AWS Bedrock"
       }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/src/i18n/locales/en.json` around lines 149 - 159, The providers.form.types
map in the en.json locale is missing the "mistral" key, causing untranslated
text in the provider type selector; add an entry "mistral": "Mistral" to the
providers.form.types object (the same label used in providers) so the
provider-form type label map includes Mistral and matches the providers mapping.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/gateway/providers/mod.rs`:
- Line 75: Replace the std assert_eq! used in the test assertion for
registry.get("mistral").unwrap().name() with pretty_assertions::assert_eq!:
import the macro (use pretty_assertions::assert_eq;) at the top of the test
module and update the assertion call so the test uses
pretty_assertions::assert_eq!(registry.get("mistral").unwrap().name(),
"mistral"); keeping the same operands and preserving the unwrap() and .name()
chain.

In `@src/proxy/provider.rs`:
- Around line 230-244: The test
provider_auth_and_base_url_returns_mistral_api_key_and_optional_base_url uses
std's assert_eq! macros; replace those with pretty_assertions::assert_eq! to
follow project test conventions (update the two assertions that check
auth.api_key_for("mistral") and base_url_override.as_ref().map(Url::as_str)
accordingly) and add a use pretty_assertions::assert_eq; import at the top of
the test module if it's not already present.

---

Outside diff comments:
In `@ui/src/i18n/locales/en.json`:
- Around line 149-159: The providers.form.types map in the en.json locale is
missing the "mistral" key, causing untranslated text in the provider type
selector; add an entry "mistral": "Mistral" to the providers.form.types object
(the same label used in providers) so the provider-form type label map includes
Mistral and matches the providers mapping.

In `@ui/src/i18n/locales/zh-CN.json`:
- Around line 149-159: Add the missing "mistral" translation under the
providers.form.types object in the zh-CN locale so the provider type dropdown
shows the Chinese label; locate the providers.form.types block in
ui/src/i18n/locales/zh-CN.json and add a "mistral" key with the appropriate
Chinese string (matching the style used for other providers like "mistral" in
providers or "mistral" elsewhere).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 57e1791b-e30c-4586-8c54-aebe9e9b5629

📥 Commits

Reviewing files that changed from the base of the PR and between a57cde7 and 5560881.

📒 Files selected for processing (8)
  • src/config/entities/providers-schema.json
  • src/config/entities/providers.rs
  • src/gateway/providers/mistral.rs
  • src/gateway/providers/mod.rs
  • src/proxy/provider.rs
  • ui/src/i18n/locales/en.json
  • ui/src/i18n/locales/zh-CN.json
  • ui/src/lib/api/types.ts

Comment thread src/gateway/providers/mod.rs
Comment thread src/proxy/provider.rs
@bzp2010 bzp2010 merged commit 28fb54a into main May 3, 2026
3 checks passed
@bzp2010 bzp2010 deleted the bzp/feat-mistral-provider branch May 3, 2026 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant