feat: add MiniMax as alternative LLM provider
Summary
- Add multi-provider LLM factory (llm_provider.py) with auto-detection from API keys
- MiniMax M2.7 / M2.7-highspeed supported via OpenAI-compatible API with temperature clamping
- New env vars: LLM_PROVIDER, LLM_BASE_URL, LLM_TEMPERATURE, MINIMAX_API_KEY
- Updated .env.example and README model table with MiniMax docs
Changes
| File | Change |
|---|---|
| apps/agent/src/llm_provider.py | New provider factory with presets, auto-detection, temp clamping |
| apps/agent/main.py | Replace hardcoded ChatOpenAI() with create_llm() factory |
| .env.example | Add MiniMax API key and provider config docs |
| README.md | Add MiniMax M2.7 to model table + usage instructions |
| apps/agent/tests/ | 28 unit tests + 3 integration tests |
How it works
Set MINIMAX_API_KEY in your .env and the provider is auto-detected. Defaults to MiniMax-M2.7 (1M context window).
Existing OpenAI usage is fully backward-compatible.
Test plan
- [x] 28 unit tests covering provider detection, presets, factory, temperature clamping, edge cases
- [x] 3 integration tests against real MiniMax API (basic completion, streaming, multi-turn)
- [ ] Manual verification with make dev using MiniMax M2.7 for generative UI
Good catch @JiwaniZakir! Fixed in the latest push:
- Explicit error for missing API key: When a provider is explicitly selected via
LLM_PROVIDERbut its API key env var is not set, the code now raises a clearValueErrorinstead of silently falling back toOPENAI_API_KEY. - Provider validation: Unrecognized
LLM_PROVIDERvalues now raise aValueErrorwith a list of supported providers.
The OPENAI_API_KEY fallback is only used when auto-detecting the provider (no explicit LLM_PROVIDER set).
The temperature clamping logic in llm_provider.py is worth documenting explicitly in .env.example — MiniMax clamps to [0.01, 1.0] which is a non-obvious constraint that will silently alter behavior if someone passes temperature=0 expecting deterministic output. Consider raising a warning log when clamping occurs rather than silently adjusting the value. The auto-detection from API key presence is clean, but priority order matters if someone has both OPENAI_API_KEY and MINIMAX_API_KEY set — the README should clarify that LLM_PROVIDER takes precedence to avoid surprises.