Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ simple_model = "gemini-3-flash"
complex_model = "gemini-3-pro"
embeddings_model = "text-embedding-004"

[minimax]
simple_model = "MiniMax-M2.7"
complex_model = "MiniMax-M3"
embeddings_model = ""
protocol = "openai"
region = "global_en"

[minimax.endpoints.global_en]
openai_base_url = "https://api.minimax.io/v1"
anthropic_base_url = "https://api.minimax.io/anthropic"

[minimax.endpoints.cn_zh]
openai_base_url = "https://api.minimaxi.com/v1"
anthropic_base_url = "https://api.minimaxi.com/anthropic"

[tracing]
project = "rai"

Expand Down
47 changes: 44 additions & 3 deletions docs/setup/vendors.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Alternatively vendors can be configured manually in `config.toml` file.

The table summarizes vendor alternative for core AI service and optional RAI modules:

| Module | Open source | Alternative | Why to consider alternative? | More information |
| ----------------------------------------------- | ------------------ | ----------------------- | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [LLM service](#llm-model-configuration-in-rai) | Ollama | OpenAI, Bedrock | Overall performance of the LLM models, supported modalities and features | [LangChain models](https://docs.langchain4j.dev/integrations/language-models/) |
| Module | Open source | Alternative | Why to consider alternative? | More information |
| ----------------------------------------------- | ------------------ | -------------------------------- | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [LLM service](#llm-model-configuration-in-rai) | Ollama | OpenAI, Bedrock, MiniMax | Overall performance of the LLM models, supported modalities and features | [LangChain models](https://docs.langchain4j.dev/integrations/language-models/) |
| **Optional:** [Tracing tool](./tracing.md) | Langfuse | LangSmith | Better integration with LangChain | [Comparison](https://langfuse.com/faq/all/langsmith-alternative) |
| **Optional:** [Text to speech](#text-to-speech) | KokoroTTS, OpenTTS | ElevenLabs | Arguably, significantly better voice synthesis | <li> [KokoroTTS](https://huggingface.co/hexgrad/Kokoro-82M#usage) </li><li> [OpenTTS GitHub](https://github.com/synesthesiam/opentts) </li><li> [RAI voice interface][s2s] </li> |
| **Optional:** [Speech to text](#speech-to-text) | Whisper | OpenAI Whisper (hosted) | When suitable local GPU is not an option | <li> [Whisper GitHub](https://github.com/openai/whisper) </li><li> [RAI voice interface][s2s] </li> |
Expand Down Expand Up @@ -67,6 +67,47 @@ Ollama can be used to host models locally.

2. Use [RAI Configurator][configurator] -> `Model Selection` -> `bedrock` vendor

### MiniMax

MiniMax can be configured through either its OpenAI-compatible or Anthropic-compatible
chat API. Set the API key before starting RAI:

```bash
export MINIMAX_API_KEY="your-api-key"
```

The generated `config.toml` contains both supported regions and both protocols. Select the
active combination with `protocol` and `region`:

```toml
[vendor]
simple_model = "minimax"
complex_model = "minimax"

[minimax]
simple_model = "MiniMax-M2.7"
complex_model = "MiniMax-M3"
embeddings_model = ""
protocol = "openai"
region = "global_en"

[minimax.endpoints.global_en]
openai_base_url = "https://api.minimax.io/v1"
anthropic_base_url = "https://api.minimax.io/anthropic"

[minimax.endpoints.cn_zh]
openai_base_url = "https://api.minimaxi.com/v1"
anthropic_base_url = "https://api.minimaxi.com/anthropic"
```

The Anthropic-compatible base URL must end in `/anthropic`; the client appends the
`/v1/messages` request path. MiniMax does not provide an embeddings model in this
configuration, so keep `embeddings_model` assigned to a separate supported vendor.

See the [global API documentation](https://platform.minimax.io/docs/api-reference/api-overview)
or the [China API documentation](https://platform.minimaxi.com/docs/api-reference/api-overview)
for service-specific details.

## Complex LLM Model Configuration

For custom setups please use LangChain API.
Expand Down
3 changes: 2 additions & 1 deletion src/rai_core/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "rai_core"
version = "2.12.1"
version = "2.13.0"
description = "Core functionality for RAI framework"
readme = "README.md"
requires-python = ">=3.10,<3.13"
Expand All @@ -21,6 +21,7 @@ dependencies = [
"langchain>=1.0.0,<2.0.0",
"langchain-aws",
"langchain-openai",
"langchain-anthropic",
"langchain-ollama",
"langchain-google-genai",
"langchain-community",
Expand Down
15 changes: 15 additions & 0 deletions src/rai_core/rai/initialization/config_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@
complex_model = "gemini-3-pro"
embeddings_model = "text-embedding-004"

[minimax]
simple_model = "MiniMax-M2.7"
complex_model = "MiniMax-M3"
embeddings_model = ""
protocol = "openai"
region = "global_en"

[minimax.endpoints.global_en]
openai_base_url = "https://api.minimax.io/v1"
anthropic_base_url = "https://api.minimax.io/anthropic"

[minimax.endpoints.cn_zh]
openai_base_url = "https://api.minimaxi.com/v1"
anthropic_base_url = "https://api.minimaxi.com/anthropic"

[tracing]
project = "rai"

Expand Down
93 changes: 93 additions & 0 deletions src/rai_core/rai/initialization/model_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ class GoogleConfig(ModelConfig):
pass


@dataclass
class MiniMaxEndpointConfig:
openai_base_url: str
anthropic_base_url: str


@dataclass
class MiniMaxConfig(ModelConfig):
protocol: Literal["openai", "anthropic"]
region: str
endpoints: Dict[str, MiniMaxEndpointConfig]


@dataclass
class LangfuseConfig:
use_langfuse: bool
Expand All @@ -93,6 +106,7 @@ class RAIConfig:
openai: OpenAIConfig
ollama: OllamaConfig
google: GoogleConfig
minimax: MiniMaxConfig
tracing: TracingConfig


Expand All @@ -107,6 +121,14 @@ class RAIConfig:
simple_model="", complex_model="", embeddings_model="", base_url=""
)
_DEFAULT_GOOGLE = GoogleConfig(simple_model="", complex_model="", embeddings_model="")
_DEFAULT_MINIMAX = MiniMaxConfig(
simple_model="",
complex_model="",
embeddings_model="",
protocol="openai",
region="global_en",
endpoints={},
)
_DEFAULT_TRACING = TracingConfig(
project="",
langfuse=LangfuseConfig(use_langfuse=False, host=""),
Expand Down Expand Up @@ -140,6 +162,21 @@ def load_config(config_path: Optional[str] = None) -> RAIConfig:
if "google" in config_dict
else _DEFAULT_GOOGLE
)
if "minimax" in config_dict:
minimax_dict = config_dict["minimax"]
minimax = MiniMaxConfig(
simple_model=minimax_dict["simple_model"],
complex_model=minimax_dict["complex_model"],
embeddings_model=minimax_dict.get("embeddings_model", ""),
protocol=minimax_dict.get("protocol", "openai"),
region=minimax_dict.get("region", "global_en"),
endpoints={
region: MiniMaxEndpointConfig(**endpoint)
for region, endpoint in minimax_dict.get("endpoints", {}).items()
},
)
else:
minimax = _DEFAULT_MINIMAX

if "tracing" in config_dict:
tracing = TracingConfig(
Expand All @@ -156,10 +193,48 @@ def load_config(config_path: Optional[str] = None) -> RAIConfig:
openai=openai,
ollama=ollama,
google=google,
minimax=minimax,
tracing=tracing,
)


def _create_minimax_chat_model(
model: str,
model_config: MiniMaxConfig,
kwargs: Dict[str, Any],
) -> Any:
try:
endpoint = model_config.endpoints[model_config.region]
except KeyError as exc:
raise ValueError(
f"MiniMax endpoint is not configured for region: {model_config.region}"
) from exc

model_kwargs = dict(kwargs)
if "api_key" not in model_kwargs:
api_key = os.getenv("MINIMAX_API_KEY")
if api_key:
model_kwargs["api_key"] = api_key

if model_config.protocol == "openai":
from langchain_openai import ChatOpenAI

return ChatOpenAI(
model=model,
base_url=endpoint.openai_base_url,
**model_kwargs,
)
if model_config.protocol == "anthropic":
from langchain_anthropic import ChatAnthropic

return ChatAnthropic(
model=model,
base_url=endpoint.anthropic_base_url,
**model_kwargs,
)
raise ValueError(f"Unknown MiniMax protocol: {model_config.protocol}")


def get_llm_model_config_and_vendor(
model_type: Literal["simple_model", "complex_model"],
vendor: Optional[str] = None,
Expand Down Expand Up @@ -213,6 +288,12 @@ def get_llm_model(

model_config = cast(GoogleConfig, model_config)
return ChatGoogleGenerativeAI(model=model, **kwargs)
elif vendor == "minimax":
return _create_minimax_chat_model(
model,
cast(MiniMaxConfig, model_config),
kwargs,
)
else:
raise ValueError(f"Unknown LLM vendor: {vendor}")

Expand Down Expand Up @@ -255,6 +336,12 @@ def get_llm_model_direct(

model_config = cast(GoogleConfig, model_config)
return ChatGoogleGenerativeAI(model=model_name, **kwargs)
elif vendor == "minimax":
return _create_minimax_chat_model(
model_name,
cast(MiniMaxConfig, model_config),
kwargs,
)
else:
raise ValueError(f"Unknown LLM vendor: {vendor}")

Expand All @@ -268,6 +355,12 @@ def get_embeddings_model(

model_config = getattr(config, vendor)

if vendor == "minimax":
raise ValueError(
"MiniMax does not provide an embeddings model. "
"Configure embeddings with a separate supported vendor."
)

logger.info(f"Using embeddings model: {vendor}-{model_config.embeddings_model}")
if vendor == "openai":
from langchain_openai import OpenAIEmbeddings
Expand Down
Loading
Loading