feat(providers): add MiniMax provider support#265
Conversation
- Add MiniMax chat model provider using OpenAI-compatible API - Clamp temperature to (0.0, 1.0] range (MiniMax rejects temperature=0) - Add MINIMAX_API_KEY and MINIMAX_BASE_URL environment variable support - Add unit tests for provider, temperature clamping, and interface assertions - Register MiniMax provider in main.go and document in CLAUDE.md and .env.template
📝 WalkthroughWalkthroughMiniMax provider support is being integrated into the application. Changes include adding environment variable templates, updating documentation, registering the provider in the main application, implementing a new MiniMax provider that wraps an OpenAI-compatible client with temperature handling logic, and adding comprehensive test coverage. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
Greptile SummaryThis PR adds MiniMax as a new OpenAI-compatible provider, closely following the established ZAI provider pattern. The implementation is clean and well-structured, with correct registration, environment variable support, and documentation updates. The notable addition over other compatible providers is Key changes:
Issue to resolve:
Confidence Score: 4/5Safe to merge after fixing the missing upper-bound temperature clamp. The implementation is otherwise complete and correct — it mirrors the well-tested ZAI provider pattern, registration is wired up properly, and the lower-bound temperature fix is tested. The one concrete gap (no upper-bound clamp despite an explicit API constraint of (0.0, 1.0]) would cause API-level failures for callers who pass temperature > 1.0, but is a targeted, easy fix before merge. internal/providers/minimax/minimax.go — clampTemperature needs an upper-bound guard; minimax_test.go needs a matching test case. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant GoModel Gateway
participant MiniMax Provider
participant MiniMax API
Client->>GoModel Gateway: POST /v1/chat/completions (temperature may be 0 or >1)
GoModel Gateway->>MiniMax Provider: ChatCompletion(req)
MiniMax Provider->>MiniMax Provider: clampTemperature(req)<br/>0 → 1.0 | >1.0 → (not clamped ⚠️)
MiniMax Provider->>MiniMax API: POST /chat/completions<br/>Authorization: Bearer {MINIMAX_API_KEY}
MiniMax API-->>MiniMax Provider: JSON response
MiniMax Provider-->>GoModel Gateway: *core.ChatResponse
GoModel Gateway-->>Client: OpenAI-compatible response
Reviews (1): Last reviewed commit: "feat(providers): add MiniMax provider su..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/providers/minimax/minimax_test.go`:
- Around line 54-94: Add a new test mirroring
TestChatCompletion_ClampsZeroTemperature that verifies temperatures >1 are
clamped to 1; create e.g. TestChatCompletion_ClampsAboveOne that uses
NewWithHTTPClient and provider.ChatCompletion with Temperature set to 1.5 and
asserts the captured request body (gotBody) does not contain `"temperature":1.5`
and does contain `"temperature":1`; reference the same test server handler
pattern and core.ChatRequest/ChatCompletion call to locate where to insert this
complementary upper-bound assertion for clampTemperature.
In `@internal/providers/minimax/minimax.go`:
- Around line 69-79: clampTemperature currently only maps non-positive
temperatures to defaultTemperature but does not enforce the documented upper
bound; update clampTemperature (in minimax.go) to ensure any req.Temperature >
1.0 is set to 1.0 (keep using defaultTemperature when nil or <= 0), e.g. copy
req into cloned := *req, compute t := *req.Temperature with bounds t =
max(min(t, 1.0), smallestPositive) or set to defaultTemperature when <= 0,
assign cloned.Temperature = &t and return &cloned; also add a unit test in
minimax_test.go for Temperature > 1.0 to verify clamping.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: 4909225d-9a6b-4d37-9bdc-f66dbb472944
📒 Files selected for processing (5)
.env.templateCLAUDE.mdcmd/gomodel/main.gointernal/providers/minimax/minimax.gointernal/providers/minimax/minimax_test.go
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@octo-patch Thank you! That's a good increment! Feel free to message me about any suggestion or any issues you encounter. Merging! |
Summary
https://api.minimax.io/v1)(0.0, 1.0]— zero values are automatically remapped to the default1.0MINIMAX_API_KEYandMINIMAX_BASE_URLenvironment variable supportmain.goand document inCLAUDE.mdand.env.templateSupported Models
MiniMax-M2.7MiniMax-M2.7-highspeedAPI Reference
Configuration
Summary by CodeRabbit
Release Notes
New Features
Documentation
MINIMAX_API_KEYandMINIMAX_BASE_URL).Chores