Director icon indicating copy to clipboard operation
Director copied to clipboard

Add MiniMax as LLM provider

Open octo-patch opened this issue 8 months ago • 1 comments

Summary

Adds MiniMax as a 5th LLM provider alongside OpenAI, Anthropic, Google AI, and VideoDB Proxy.

MiniMax provides an OpenAI-compatible API, making integration seamless with the existing provider architecture. This PR adds support for:

  • MiniMax-M2.7 (latest, 1M context window) - default model
  • MiniMax-M2.5 (204K context window)
  • MiniMax-M2.5-highspeed (204K context, optimized for speed)

Changes

  • backend/director/llm/minimax.py — New MiniMax provider with MiniMaxConfig, MiniMaxChatModel enum, and MiniMax class extending BaseLLM. Includes temperature clamping to [0, 1] and think-tag stripping for M2.7 reasoning output.
  • backend/director/constants.py — Add MINIMAX to LLMType enum and MINIMAX_ to EnvPrefix enum.
  • backend/director/llm/__init__.py — Add MiniMax to get_default_llm() factory with MINIMAX_API_KEY auto-detection.
  • backend/.env.sample — Add MINIMAX_API_KEY configuration.
  • README.md — Mention MiniMax in supported LLM providers list.
  • backend/tests/test_minimax.py — 35 unit tests covering config, model enum, message/tool formatting, chat completions, think-tag stripping, factory detection, and error handling.
  • backend/tests/test_minimax_integration.py — 3 integration tests (simple chat, JSON response format, tool calling) that run against the real MiniMax API.

Configuration

# Set MiniMax API key (auto-detected by get_default_llm)
MINIMAX_API_KEY=your-api-key

# Optional: override default model
MINIMAX_CHAT_MODEL=MiniMax-M2.5-highspeed

# Optional: force MiniMax as default provider
DEFAULT_LLM=minimax

Test plan

  • [x] 35 unit tests pass (pytest tests/test_minimax.py)
  • [x] 3 integration tests pass against real MiniMax API
  • [ ] Verify existing OpenAI/Anthropic/GoogleAI providers still work
  • [ ] Test with DEFAULT_LLM=minimax in a local Director instance

No new dependencies required — MiniMax uses the existing openai SDK via its OpenAI-compatible API endpoint.

Summary by CodeRabbit

Release Notes

  • New Features

    • MiniMax added as a supported LLM provider with full feature support including tool calling and structured responses.
  • Documentation

    • README updated to explicitly list all supported LLM providers: OpenAI, Anthropic, Google Gemini, and MiniMax.

octo-patch avatar Mar 24 '26 10:03 octo-patch

📝 Walkthrough

Walkthrough

A new MiniMax LLM provider integration is added to enable MiniMax as an LLM service option alongside existing providers. The implementation includes environment configuration, enum constants, client initialization with OpenAI-compatible API, message and tool formatting helpers, comprehensive unit tests, and integration test coverage.

Changes

Cohort / File(s) Summary
Documentation & Configuration
README.md, backend/.env.sample, backend/director/constants.py
Updated README to list MiniMax as a supported provider; added MINIMAX_API_KEY environment variable placeholder; introduced LLMType.MINIMAX and EnvPrefix.MINIMAX_ enum members.
LLM Provider Implementation
backend/director/llm/minimax.py, backend/director/llm/__init__.py
Implemented MiniMax LLM class with MiniMaxConfig, MiniMaxChatModel enum, and chat_completions() method supporting tool calling and JSON response format. Added message/tool formatting helpers and think-tag stripping. Extended get_default_llm() to conditionally return MiniMax() based on MINIMAX_API_KEY availability and DEFAULT_LLM setting.
Unit & Integration Tests
backend/tests/test_minimax.py, backend/tests/test_minimax_integration.py
Added 373 lines of unit tests covering config validation, temperature clamping, message/tool formatting, think-tag stripping, chat completions with mocking, and provider selection logic. Added 85 lines of integration tests for simple chat, JSON responses, and tool calling (conditionally skipped without MINIMAX_API_KEY).

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant LLM as MiniMax LLM
    participant Client as OpenAI Client
    participant API as MiniMax API
    
    App->>LLM: chat_completions(messages, tools, response_format)
    LLM->>LLM: _format_messages(messages)
    LLM->>LLM: _format_tools(tools)
    LLM->>Client: client.chat.completions.create()
    Client->>API: POST /v1/chat/completions
    API-->>Client: Response (content, tool_calls, usage)
    Client-->>LLM: ChatCompletion object
    LLM->>LLM: _strip_think_tags(content)
    LLM->>LLM: Parse tool_calls JSON arguments
    LLM-->>App: LLMResponse (status, content, tool_calls, usage)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • ankit-v-3
  • ashish-spext

Poem

🐰 A MiniMax hops into the warren, With OpenAI's compatible call, Temperature clamped, think-tags swept clean, Tools shaped just right for all, Our LLM family grows strong! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 24.49% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding MiniMax as a new LLM provider, which is the primary objective and focus of all file modifications.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests

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.

❤️ Share

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

coderabbitai[bot] avatar Mar 24 '26 10:03 coderabbitai[bot]