feat: add MiniMax as first-class LLM provider#958
feat: add MiniMax as first-class LLM provider#958octo-patch wants to merge 1 commit intoChatGPTBox-dev:masterfrom
Conversation
Add MiniMax AI (https://www.minimax.io) as a built-in LLM provider with three models: MiniMax-M2.7, MiniMax-M2.5, and MiniMax-M2.5-highspeed (204K context). MiniMax offers an OpenAI-compatible API, so the implementation reuses the existing OpenAI compat layer. Changes: - Add minimax-api.mjs API handler via OpenAI-compat wrapper - Register model keys, model entries, and ModelGroup in config - Add isUsingMiniMaxApiModel predicate and minimaxApiKey config - Wire routing in background/index.mjs executeApi() - Add MiniMax API key input in popup settings UI - Update README to mention MiniMax - Add 5 unit tests for API handler - Add 2 config predicate tests - Add 5 integration tests for model registration
📝 WalkthroughWalkthroughThis PR introduces MiniMax API support across the extension by adding three MiniMax model variants to the configuration registry, implementing API integration that delegates to an OpenAI-compatible endpoint, updating the background executor to dispatch MiniMax requests, extending the UI for API credential input, and providing comprehensive integration and unit tests to validate the new provider integration. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces MiniMax AI as a new Large Language Model (LLM) provider, expanding the application's compatibility with various AI services. This integration allows users to leverage MiniMax's models, M2.7, M2.5, and M2.5-highspeed, through an OpenAI-compatible API, enhancing the range of available AI capabilities within the application. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
Review Summary by QodoAdd MiniMax as first-class LLM provider with three models
WalkthroughsDescription• Add MiniMax AI as first-class LLM provider with three models - MiniMax-M2.7 (flagship), MiniMax-M2.5, MiniMax-M2.5-highspeed (204K context) • Implement OpenAI-compatible API handler reusing existing abstraction layer • Register MiniMax models in config with ModelGroup and predicate function • Wire MiniMax routing in background service and add UI settings input • Add 12 comprehensive tests (5 unit, 2 config, 5 integration) Diagramflowchart LR
A["MiniMax API<br/>https://api.minimax.io/v1"] -->|"OpenAI-compat wrapper"| B["minimax-api.mjs<br/>Handler"]
B --> C["Config Registration<br/>Models + ModelGroups"]
C --> D["Background Router<br/>executeApi routing"]
D --> E["UI Settings<br/>API key input"]
F["12 Tests<br/>Unit + Integration"] -.->|"validates"| C
File Changes1. src/services/apis/minimax-api.mjs
|
Code Review by Qodo
1. Missing MiniMax API Key locale
|
There was a problem hiding this comment.
Code Review
This pull request adds MiniMax as a new LLM provider, following the pattern of other OpenAI-compatible providers in the project. The changes are well-structured, including configuration, API handling, UI, and tests. I have a couple of suggestions to improve documentation clarity and user experience.
| - 📓 Summarize any page with right-click menu. (<kbd>Alt</kbd>+<kbd>B</kbd>) | ||
| - 📖 Independent conversation page. (<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>H</kbd>) | ||
| - 🔗 Multiple API support (Web API for Free and Plus users, GPT-3.5, GPT-4, Claude, New Bing, Moonshot, Self-Hosted, Azure etc.). | ||
| - 🔗 Multiple API support (Web API for Free and Plus users, GPT-3.5, GPT-4, Claude, New Bing, Moonshot, MiniMax, DeepSeek, Self-Hosted, Azure etc.). |
There was a problem hiding this comment.
The list of supported APIs is getting long. To improve readability and make it easier for users to find a specific provider, consider sorting the list of API providers alphabetically.
| - 🔗 Multiple API support (Web API for Free and Plus users, GPT-3.5, GPT-4, Claude, New Bing, Moonshot, MiniMax, DeepSeek, Self-Hosted, Azure etc.). | |
| - 🔗 Multiple API support (Web API for Free and Plus users, Azure, Claude, DeepSeek, GPT-3.5, GPT-4, MiniMax, Moonshot, New Bing, Self-Hosted, etc.). |
| {isUsingMiniMaxApiModel(config) && ( | ||
| <input | ||
| type="password" | ||
| value={config.minimaxApiKey} | ||
| placeholder={t('MiniMax API Key')} | ||
| onChange={(e) => { | ||
| const apiKey = e.target.value | ||
| updateConfig({ minimaxApiKey: apiKey }) | ||
| }} | ||
| /> | ||
| )} |
There was a problem hiding this comment.
For a better user experience, consider adding a 'Get' button next to the API key input that links to the MiniMax API key page. This is consistent with how API keys for other providers like OpenAI and Moonshot are handled in the UI.
The URL for MiniMax API keys is: https://api.minimax.io/user-center/api-keys
{isUsingMiniMaxApiModel(config) && (
<span style="display: flex; gap: 5px;">
<input
style="width: 100%;"
type="password"
value={config.minimaxApiKey}
placeholder={t('MiniMax API Key')}
onChange={(e) => {
const apiKey = e.target.value
updateConfig({ minimaxApiKey: apiKey })
}}
/>
{config.minimaxApiKey.length === 0 ? (
<a
href="https://api.minimax.io/user-center/api-keys"
target="_blank"
rel="nofollow noopener noreferrer"
>
<button style="white-space: nowrap;" type="button">
{t('Get')}
</button>
</a>
) : null}
</span>
)}There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/services/apis/minimax-api.test.mjs (1)
17-21: Consider extracting shared storage defaults to reduce test duplication.A small helper constant would make these tests easier to maintain.
♻️ Optional refactor sketch
+const defaultStorageConfig = { + maxConversationContextLength: 3, + maxResponseTokenLength: 128, + temperature: 0.5, +} + test('generateAnswersWithMiniMaxApi aggregates SSE deltas and posts messages', async (t) => { t.mock.method(console, 'debug', () => {}) - setStorage({ - maxConversationContextLength: 3, - maxResponseTokenLength: 128, - temperature: 0.5, - }) + setStorage(defaultStorageConfig)Also applies to: 59-63, 101-105, 132-136, 165-169
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unit/services/apis/minimax-api.test.mjs` around lines 17 - 21, Extract the repeated storage settings into a single shared constant (e.g., DEFAULT_TEST_STORAGE) and import or reference it in these tests; replace the inline setStorage({ maxConversationContextLength: 3, maxResponseTokenLength: 256, temperature: 0.7 }) calls with setStorage({ ...DEFAULT_TEST_STORAGE, /* overrides if needed */ }) so setStorage in tests like minimax-api.test.mjs reuses the shared defaults and individual tests can still override specific fields.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/unit/services/apis/minimax-api.test.mjs`:
- Around line 17-21: Extract the repeated storage settings into a single shared
constant (e.g., DEFAULT_TEST_STORAGE) and import or reference it in these tests;
replace the inline setStorage({ maxConversationContextLength: 3,
maxResponseTokenLength: 256, temperature: 0.7 }) calls with setStorage({
...DEFAULT_TEST_STORAGE, /* overrides if needed */ }) so setStorage in tests
like minimax-api.test.mjs reuses the shared defaults and individual tests can
still override specific fields.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 446ba33d-fd82-44f2-8881-518a4af0913d
📒 Files selected for processing (8)
README.mdsrc/background/index.mjssrc/config/index.mjssrc/popup/sections/GeneralPart.jsxsrc/services/apis/minimax-api.mjstests/integration/minimax-api.test.mjstests/unit/config/config-predicates.test.mjstests/unit/services/apis/minimax-api.test.mjs
| {isUsingMiniMaxApiModel(config) && ( | ||
| <input | ||
| type="password" | ||
| value={config.minimaxApiKey} | ||
| placeholder={t('MiniMax API Key')} | ||
| onChange={(e) => { | ||
| const apiKey = e.target.value | ||
| updateConfig({ minimaxApiKey: apiKey }) | ||
| }} | ||
| /> |
There was a problem hiding this comment.
1. Missing minimax api key locale 📘 Rule violation ⚙ Maintainability
The settings UI introduces a new localized string key MiniMax API Key but no corresponding entry exists in the English locale (and therefore cannot be propagated). This can cause missing/incorrect UI text and violates the localization key propagation requirement.
Agent Prompt
## Issue description
The UI adds a new i18n key `MiniMax API Key` but it is not present in the English locale file (and thus not propagated to other locales), violating localization requirements.
## Issue Context
`GeneralPart.jsx` uses `t('MiniMax API Key')` for the MiniMax API key input placeholder. Existing providers commonly reuse `t('API Key')`, which is already translated.
## Fix Focus Areas
- src/popup/sections/GeneralPart.jsx[346-355]
- src/_locales/en/main.json[84-90]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| await generateAnswersWithMiniMaxApi(port, 'Hello', session, 'sk-minimax-test') | ||
|
|
||
| assert.equal(capturedInput, 'https://api.minimax.io/v1/chat/completions') | ||
| assert.equal(capturedInit.method, 'POST') | ||
| assert.equal(capturedInit.headers.Authorization, 'Bearer sk-minimax-test') | ||
|
|
There was a problem hiding this comment.
2. Api-like keys in tests 📘 Rule violation ⛨ Security
The MiniMax API unit tests include committed API-key-like strings (e.g., sk-minimax-test, sk-test, sk-bad). This violates the no-secrets policy and can trigger secret scanners or be mistaken for real credentials.
Agent Prompt
## Issue description
Unit tests commit API-key-like strings (e.g., `sk-*`) directly in the repo, which violates the no-secrets policy and may be flagged by secret scanners.
## Issue Context
The tests only need a stable placeholder value to assert the `Authorization: Bearer ...` header, not a realistic key format.
## Fix Focus Areas
- tests/unit/services/apis/minimax-api.test.mjs[41-46]
- tests/unit/services/apis/minimax-api.test.mjs[79-80]
- tests/unit/services/apis/minimax-api.test.mjs[123-125]
- tests/unit/services/apis/minimax-api.test.mjs[151-152]
- tests/unit/services/apis/minimax-api.test.mjs[182-184]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Summary
Add MiniMax AI as a built-in LLM provider, following the same OpenAI-compatible pattern used by DeepSeek and Moonshot.
Models added:
Changes
src/services/apis/minimax-api.mjs— API handler reusinggenerateAnswersWithOpenAiApiCompatwith MiniMax base URLsrc/config/index.mjs— Model keys, model entries, ModelGroup registration,minimaxApiKeyconfig, andisUsingMiniMaxApiModelpredicatesrc/background/index.mjs— Routing for MiniMax models inexecuteApi()src/popup/sections/GeneralPart.jsx— MiniMax API key input in settings UIREADME.md— Updated API support list to include MiniMaxTests
isUsingMiniMaxApiModeldetection + exported keys)All 327 tests pass (315 existing + 12 new).
Test plan
Summary by CodeRabbit
New Features
Documentation