Skip to content

feat: add MiniMax as alternative LLM provider#26

Open
octo-patch wants to merge 1 commit intojamwithai:mainfrom
octo-patch:feature/add-minimax-provider
Open

feat: add MiniMax as alternative LLM provider#26
octo-patch wants to merge 1 commit intojamwithai:mainfrom
octo-patch:feature/add-minimax-provider

Conversation

@octo-patch
Copy link
Copy Markdown

Summary

Add MiniMax as an alternative cloud LLM provider alongside Ollama, configurable via the LLM_PROVIDER environment variable.

Changes

  • MiniMaxClient (src/services/minimax/client.py): Full-featured client using MiniMax's OpenAI-compatible API with temperature clamping, think-tag stripping, streaming support, and RAG answer generation
  • LLM Factory (src/services/llm_factory.py): Provider-agnostic factory that returns OllamaClient or MiniMaxClient based on LLM_PROVIDER setting
  • Provider abstraction: Refactored agent nodes to use llm_client instead of ollama_client, enabling seamless provider switching across guardrail, grading, rewriting, and answer generation nodes
  • OllamaClient enhancement: Added get_langchain_model() method to OllamaClient for consistency with MiniMaxClient
  • Configuration: Added LLM_PROVIDER, MINIMAX_API_KEY, MINIMAX_MODEL, MINIMAX_BASE_URL env vars
  • Tests: 30 unit tests + 3 integration tests (all passing)
  • Documentation: Updated README, .env.example with MiniMax configuration

Supported Models

Model Description
MiniMax-M2.7 Peak performance, ultimate value (default)
MiniMax-M2.7-highspeed Same performance, faster and more agile

Usage

# Switch to MiniMax (in .env)
LLM_PROVIDER=minimax
MINIMAX_API_KEY=your_key_here

No code changes needed - the existing RAG pipeline, agentic workflows, and Telegram bot all work with MiniMax out of the box.

Files Changed (25 files, +1010/-45)

New files:

  • src/services/minimax/client.py - MiniMax client implementation
  • src/services/minimax/factory.py - MiniMax client factory
  • src/services/llm_factory.py - Provider-agnostic LLM factory
  • tests/unit/services/minimax/test_minimax_client.py - 25 unit tests
  • tests/unit/services/test_llm_factory.py - 5 unit tests
  • tests/integration/test_minimax_integration.py - 3 integration tests

Modified files:

  • Config, dependencies, routers, agent nodes, and documentation

API Reference

Test Plan

  • 30 unit tests pass (temperature clamping, think-tag stripping, client methods, factory)
  • 3 integration tests pass (health check, text generation, LangChain model)
  • Existing Ollama flow unchanged (default LLM_PROVIDER=ollama)
  • Verify with docker compose up and test RAG endpoints

Add MiniMax cloud LLM as a drop-in alternative to Ollama, configurable
via LLM_PROVIDER env var. MiniMax uses OpenAI-compatible API and supports
both standard and agentic RAG pipelines.

- Add MiniMaxClient with OpenAI-compatible API (MiniMax-M2.7, M2.7-highspeed)
- Add LLM_PROVIDER config for switching between ollama/minimax
- Add llm_factory.py for provider-agnostic client creation
- Refactor agent nodes to use llm_client instead of ollama_client
- Add temperature clamping and think-tag stripping for MiniMax
- Add langchain-openai dependency for ChatOpenAI integration
- Add get_langchain_model() to OllamaClient for agent node compatibility
- Add 30 unit tests and 3 integration tests
- Update .env.example, README, and health check with MiniMax support

Co-Authored-By: Octopus <liyuan851277048@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant