feat(llm): add MiniMax as an authenticated cloud LLM provider - #254
octo-patch wants to merge 1 commit into
Conversation
Add MiniMax (MiniMax-M3 default, MiniMax-M2.7 selectable) as an authenticated cloud LLM provider wired into the existing selection, key-resolution, model-default, and adapter seams. - LLMProvider union gains 'minimax'; auto-detected via MINIMAX_API_KEY and forceable with WIGOLO_LLM_PROVIDER=minimax - default model MiniMax-M3 (WIGOLO_LLM_MODEL_MINIMAX override) - OpenAI-compatible regional endpoints: global (default) and mainland China, chosen via WIGOLO_MINIMAX_REGION or WIGOLO_MINIMAX_BASE_URL - structured (extract) and free-form text adapters; key resolves through the keychain -> file -> env chain - authenticated (Bearer header), distinct from the keyless custom-URL backend which is left unchanged Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds MiniMax as an LLM provider with region-aware endpoints, model and API-key selection, JSON extraction with schema-validation retry, free-text completion support, fallback dispatch, and unit tests. ChangesMiniMax provider integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant extractWithLLM
participant callMiniMax
participant MiniMaxAPI
participant SchemaValidator
extractWithLLM->>callMiniMax: extraction options and API key
callMiniMax->>MiniMaxAPI: JSON-object completion request
MiniMaxAPI-->>callMiniMax: assistant JSON content
callMiniMax->>SchemaValidator: validate parsed values
SchemaValidator-->>callMiniMax: validation result
callMiniMax->>MiniMaxAPI: retry prompt with validation errors
MiniMaxAPI-->>callMiniMax: corrected assistant JSON content
callMiniMax-->>extractWithLLM: standardized extraction result
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 (1)
src/integrations/cloud/llm/minimax.ts (1)
96-121: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winConsider capping
max_tokensin the extraction call.
runOncenever setsmax_tokens/max_completion_tokens, unlikecallMiniMaxTextintext-adapters.tswhich defaults toDEFAULT_MAX_TOKENS. Without a cap, a runaway or verbose model response (across the initial call and the retry) could inflate latency/cost unexpectedly.♻️ Proposed fix
const response = await client.chat.completions.create( { model, messages, response_format: { type: 'json_object' }, + max_tokens: 2000, }, { signal }, );🤖 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 `@src/integrations/cloud/llm/minimax.ts` around lines 96 - 121, Update the request parameters in runOnce to set the same bounded token limit used by callMiniMaxText, reusing DEFAULT_MAX_TOKENS or the established equivalent. Ensure the cap applies to both the initial extraction call and its retry without changing the existing response parsing behavior.
🤖 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 `@src/integrations/cloud/llm/minimax.ts`:
- Around line 96-121: Update the request parameters in runOnce to set the same
bounded token limit used by callMiniMaxText, reusing DEFAULT_MAX_TOKENS or the
established equivalent. Ensure the cap applies to both the initial extraction
call and its retry without changing the existing response parsing behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6a69c558-bf65-40c5-afea-5fe25d248bd8
📒 Files selected for processing (10)
src/extraction/llm-fallback.tssrc/integrations/cloud/llm/minimax.tssrc/integrations/cloud/llm/model-select.tssrc/integrations/cloud/llm/select.tssrc/integrations/cloud/llm/text-adapters.tssrc/integrations/cloud/llm/types.tssrc/security/key-store.tstests/unit/extraction/llm/minimax.test.tstests/unit/extraction/llm/select.test.tstests/unit/extraction/llm/types.test.ts
|
Hi @octo-patch — thank you for this PR, and I'm sorry it's been sitting here without a proper review. I've been heads-down building some pretty big features and improvements for wigolo, and as a solo dev, shipping that while also reviewing and maintaining every issue and PR has been genuinely hard. This one isn't forgotten — it just hasn't had the attention it deserves yet. I'd really appreciate your patience here. I'm going to work through the open PRs and issues properly over the next few weeks (sooner if I can free up), and I'll follow up right here. In the meantime, the wigolo Discord is open if you'd like to follow what's being built, ask questions, or nudge me directly: https://discord.gg/BkUUgz2bNF Thanks again for contributing, and for understanding — it genuinely means a lot. 🙏 |
Reason: Add MiniMax as an authenticated cloud LLM provider (MiniMax-M3 / MiniMax-M2.7) with global and CN OpenAI-compatible endpoints.
What
Adds MiniMax as a first-class authenticated cloud LLM provider, wired into the same selection, key-resolution, model-default, and adapter seams as the existing providers.
types.ts):LLMProvidernow includesminimax.select.ts):minimaxadded to the auto-detect order (lowest priority) withMINIMAX_API_KEYas its env var;WIGOLO_LLM_PROVIDER=minimaxforces it explicitly.model-select.ts): default modelMiniMax-M3, overridable viaWIGOLO_LLM_MODEL_MINIMAX.MiniMax-M2.7is selectable via that var or a per-call override.minimax.tsprovides the structured (extract) adapter and the OpenAI-compatible endpoint resolution; a matching free-form text adapter is added intext-adapters.tsand registered in the text-adapter map, and the structured adapter is registered in the extract fallback map.https://api.minimax.io/v1, default) and mainland China (https://api.minimaxi.com/v1). Region is chosen withWIGOLO_MINIMAX_REGION(global_en|cn_zh) or the base URL is overridden wholesale withWIGOLO_MINIMAX_BASE_URL.key-store.ts):minimaxis added to the keystore providers so its key resolves through the keychain → file → env chain. Like the other env-supported-but-not-wizard-surfaced provider, it is intentionally not added to the TUI picker.MiniMax is authenticated: the SDK attaches an
Authorization: Bearerheader from the resolved key. This is distinct from the existing keyless custom-URL backend, which sends noAuthorizationheader and remains unchanged.The structured adapter uses
response_format: { type: 'json_object' }plus local schema validation with one retry, because the endpoint does not implement strict server-side JSON-schema enforcement.Tests
tests/unit/extraction/llm/minimax.test.ts: regional base-URL resolution (default/global/CN/override), model metadata (default + both models), structured call parsing, model override, json_object usage, validation retry, and error paths.tests/unit/extraction/llm/select.test.ts: added auto-detect and explicit-override cases for the new provider.tests/unit/extraction/llm/types.test.ts: updated the provider-union assertion.Checks run
npm run lint(tsc --noEmit) — passednpm run build(tsup + tsc) — passednpx vitest run tests/unit/extraction/llm tests/unit/security/key-store.test.ts tests/unit/cli/tui/actions/provider-actions.test.ts— passed (99 tests)Summary by CodeRabbit
New Features
Tests