diff --git a/crates/http-api-bindings/src/chat/mod.rs b/crates/http-api-bindings/src/chat/mod.rs index 58e09d295bef..5d78a1856e5e 100644 --- a/crates/http-api-bindings/src/chat/mod.rs +++ b/crates/http-api-bindings/src/chat/mod.rs @@ -25,7 +25,7 @@ pub async fn create(model: &HttpModelConfig) -> Arc { .with_http_client(create_reqwest_client(api_endpoint)), ) } - "openai/chat" | "mistral/chat" => { + "openai/chat" | "mistral/chat" | "minimax/chat" => { let config = OpenAIConfig::default() .with_api_base(api_endpoint) .with_api_key(model.api_key.clone().unwrap_or_default()); diff --git a/crates/tabby-inference/src/chat.rs b/crates/tabby-inference/src/chat.rs index b76b0b2f9f89..e814e2e100e6 100644 --- a/crates/tabby-inference/src/chat.rs +++ b/crates/tabby-inference/src/chat.rs @@ -66,6 +66,15 @@ impl ExtendedOpenAIConfig { "openai/chat" => { request = process_request_openai(request); } + "minimax/chat" => { + // MiniMax temperature must be in (0.0, 1.0]; default to 1.0 if unset or zero + request.temperature = Some( + request + .temperature + .map(|t| if t <= 0.0 { 1.0 } else { t.min(1.0) }) + .unwrap_or(1.0), + ); + } _ => {} } @@ -144,3 +153,73 @@ impl ChatCompletionStream for async_openai_alt::Client ExtendedOpenAIConfig { + ExtendedOpenAIConfig::builder() + .base(OpenAIConfig::default()) + .kind(kind.to_string()) + .model_name("test-model") + .supported_models(None) + .build() + .unwrap() + } + + fn make_request(model: &str, temperature: Option) -> CreateChatCompletionRequest { + let mut req = CreateChatCompletionRequest::default(); + req.model = model.to_string(); + req.temperature = temperature; + req + } + + #[test] + fn test_minimax_temperature_clamped_to_default_when_zero() { + let config = make_config("minimax/chat"); + let req = make_request("MiniMax-M2.7", Some(0.0)); + let processed = config.process_request(req); + assert_eq!(processed.temperature, Some(1.0)); + } + + #[test] + fn test_minimax_temperature_clamped_to_default_when_negative() { + let config = make_config("minimax/chat"); + let req = make_request("MiniMax-M2.7", Some(-0.5)); + let processed = config.process_request(req); + assert_eq!(processed.temperature, Some(1.0)); + } + + #[test] + fn test_minimax_temperature_clamped_to_max_when_above_one() { + let config = make_config("minimax/chat"); + let req = make_request("MiniMax-M2.7", Some(1.5)); + let processed = config.process_request(req); + assert_eq!(processed.temperature, Some(1.0)); + } + + #[test] + fn test_minimax_temperature_preserved_when_valid() { + let config = make_config("minimax/chat"); + let req = make_request("MiniMax-M2.7", Some(0.7)); + let processed = config.process_request(req); + assert_eq!(processed.temperature, Some(0.7)); + } + + #[test] + fn test_minimax_temperature_defaults_when_none() { + let config = make_config("minimax/chat"); + let req = make_request("MiniMax-M2.7", None); + let processed = config.process_request(req); + assert_eq!(processed.temperature, Some(1.0)); + } + + #[test] + fn test_minimax_model_fallback_when_empty() { + let config = make_config("minimax/chat"); + let req = make_request("", Some(0.5)); + let processed = config.process_request(req); + assert_eq!(processed.model, "test-model"); + } +} diff --git a/website/docs/references/models-http-api/minimax.md b/website/docs/references/models-http-api/minimax.md new file mode 100644 index 000000000000..d02c2143b5a7 --- /dev/null +++ b/website/docs/references/models-http-api/minimax.md @@ -0,0 +1,53 @@ +# MiniMax + +[MiniMax](https://www.minimax.io/) is an AI company that develops large language models for general tasks. Their models include [MiniMax-M2.7](https://platform.minimax.io/docs/api-reference/text-openai-api) for high-performance language understanding and generation. + +## Chat model + +MiniMax provides an OpenAI-compatible chat API interface. Tabby includes a dedicated `minimax/chat` kind that handles MiniMax-specific constraints such as temperature clamping. + +```toml title="~/.tabby/config.toml" +[model.chat.http] +kind = "minimax/chat" +model_name = "MiniMax-M2.7" +api_endpoint = "https://api.minimax.io/v1" +api_key = "your-minimax-api-key" +``` + +You can also configure multi-model support to switch between available models: + +```toml title="~/.tabby/config.toml" +[model.chat.http] +kind = "minimax/chat" +model_name = "MiniMax-M2.7" +supported_models = ["MiniMax-M2.7", "MiniMax-M2.7-highspeed"] +api_endpoint = "https://api.minimax.io/v1" +api_key = "your-minimax-api-key" +``` + +For users in mainland China, use the domestic endpoint: + +```toml title="~/.tabby/config.toml" +[model.chat.http] +kind = "minimax/chat" +model_name = "MiniMax-M2.7" +api_endpoint = "https://api.minimaxi.com/v1" +api_key = "your-minimax-api-key" +``` + +## Completion model + +MiniMax does not currently offer a dedicated completion (FIM) API endpoint. + +## Embeddings model + +MiniMax does not currently offer embedding model APIs. + +## Available Models + +| Model | Context Length | Max Output | +|---|---|---| +| `MiniMax-M2.7` | 204K | 192K | +| `MiniMax-M2.7-highspeed` | 204K | 192K | + +For the latest model list and pricing, visit [MiniMax Platform](https://platform.minimax.io/).