-
Notifications
You must be signed in to change notification settings - Fork 253
feat: add MiniMax as first-class LLM provider #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -169,6 +169,25 @@ class StandardMetric(str, Enum): | |||||||||||||||||||
| ] | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| # ============================================ | ||||||||||||||||||||
| # MiniMax Provider Support | ||||||||||||||||||||
| # ============================================ | ||||||||||||||||||||
|
|
||||||||||||||||||||
| MINIMAX_API_BASE = "https://api.minimax.io/v1" | ||||||||||||||||||||
|
|
||||||||||||||||||||
| MINIMAX_MODELS = { | ||||||||||||||||||||
| "MiniMax-M2.7": {"context_window": 1_000_000}, | ||||||||||||||||||||
| "MiniMax-M2.7-highspeed": {"context_window": 1_000_000}, | ||||||||||||||||||||
| "MiniMax-M2.5": {"context_window": 204_000}, | ||||||||||||||||||||
| "MiniMax-M2.5-highspeed": {"context_window": 204_000}, | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| def _is_minimax_model(model_id: str) -> bool: | ||||||||||||||||||||
| """Check if a model ID uses the ``minimax/`` provider prefix.""" | ||||||||||||||||||||
| return model_id.startswith("minimax/") | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| # ============================================ | ||||||||||||||||||||
| # Configuration Helpers | ||||||||||||||||||||
| # ============================================ | ||||||||||||||||||||
|
|
@@ -512,8 +531,9 @@ def get_routing_for_model(config: RoutingConfig | None, model_id: str) -> tuple[ | |||||||||||||||||||
|
|
||||||||||||||||||||
| Lookup order: | ||||||||||||||||||||
| 1. Check if model_id is in 'models' mapping → use that provider's config | ||||||||||||||||||||
| 2. Else use 'default' config if present | ||||||||||||||||||||
| 3. Else return (None, {}) for LiteLLM's default routing | ||||||||||||||||||||
| 2. If model_id uses ``minimax/`` prefix → auto-route to MiniMax API | ||||||||||||||||||||
| 3. Else use 'default' config if present | ||||||||||||||||||||
| 4. Else return (None, {}) for LiteLLM's default routing | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Args: | ||||||||||||||||||||
| config: Routing configuration (or None if no config loaded) | ||||||||||||||||||||
|
|
@@ -524,29 +544,34 @@ def get_routing_for_model(config: RoutingConfig | None, model_id: str) -> tuple[ | |||||||||||||||||||
| - api_base: Base URL for API requests (None = use LiteLLM default) | ||||||||||||||||||||
| - headers: Dict of HTTP headers to include in requests | ||||||||||||||||||||
| """ | ||||||||||||||||||||
| # If no config provided, use LiteLLM defaults | ||||||||||||||||||||
| if config is None: | ||||||||||||||||||||
| return None, {} | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Check if model has explicit provider mapping | ||||||||||||||||||||
| if model_id in config.models: | ||||||||||||||||||||
| # Check if model has explicit provider mapping (highest priority) | ||||||||||||||||||||
| if config is not None and model_id in config.models: | ||||||||||||||||||||
| provider_name = config.models[model_id] | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if provider_name not in config.providers: | ||||||||||||||||||||
| # This should have been caught by validation, but handle gracefully | ||||||||||||||||||||
| logging.getLogger(__name__).warning( | ||||||||||||||||||||
| f"Model '{model_id}' references non-existent provider '{provider_name}'. Using default routing." | ||||||||||||||||||||
| ) | ||||||||||||||||||||
|
Comment on lines
551
to
554
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: plexe/config.py
Line: 551-554
Comment:
**Misleading warning message when an explicit mapping references a non-existent provider**
When `model_id` is a `minimax/` model AND its explicit provider mapping resolves to a non-existent provider, the warning says **"Using default routing"** but execution then falls through to the MiniMax auto-routing branch — not the `config.default` path. The log message will mislead anyone debugging the routing decision.
```suggestion
logging.getLogger(__name__).warning(
f"Model '{model_id}' references non-existent provider '{provider_name}'. "
"Falling through to next routing step."
)
```
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||||||||||
| provider_config = config.default | ||||||||||||||||||||
| else: | ||||||||||||||||||||
| provider_config = config.providers[provider_name] | ||||||||||||||||||||
| logging.getLogger(__name__).debug(f"Model '{model_id}' → provider '{provider_name}'") | ||||||||||||||||||||
| else: | ||||||||||||||||||||
| # No explicit mapping, use default | ||||||||||||||||||||
| provider_config = config.default | ||||||||||||||||||||
| logging.getLogger(__name__).debug(f"Model '{model_id}' → default routing") | ||||||||||||||||||||
| return provider_config.api_base, provider_config.headers | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Auto-route minimax/ prefix to MiniMax API | ||||||||||||||||||||
| if _is_minimax_model(model_id): | ||||||||||||||||||||
| api_key = os.getenv("MINIMAX_API_KEY", "") | ||||||||||||||||||||
| headers = {"Authorization": f"Bearer {api_key}"} if api_key else {} | ||||||||||||||||||||
| logging.getLogger(__name__).debug(f"Model '{model_id}' → MiniMax auto-routing") | ||||||||||||||||||||
| return MINIMAX_API_BASE, headers | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # If no config provided, use LiteLLM defaults | ||||||||||||||||||||
| if config is None: | ||||||||||||||||||||
| return None, {} | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Use default routing config | ||||||||||||||||||||
| provider_config = config.default | ||||||||||||||||||||
| logging.getLogger(__name__).debug(f"Model '{model_id}' → default routing") | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # If no applicable config found, use LiteLLM defaults | ||||||||||||||||||||
| if provider_config is None: | ||||||||||||||||||||
| return None, {} | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MINIMAX_MODELSis dead code — never consumed by production codeMINIMAX_MODELSis defined and exported but is only referenced in the testtest_minimax_models_constant, which just asserts the constant has certain keys. No production code path (routing, validation, context-window capping, etc.) reads from it. Either wire it intoget_routing_for_model/PlexeLiteLLMModelto serve a real purpose (e.g. rejecting unknown model IDs or surfacing context-window metadata), or remove it to keep the codebase lean per the project's "prefer deleting code over adding code" principle.Prompt To Fix With AI