mirror of
https://github.com/AstrBotDevs/AstrBot.git
synced 2026-09-24 16:39:52 +08:00
feat: add MiniMax Token Plan provider with hardcoded model list (#7609)
* feat: add MiniMax Token Plan provider with hardcoded model list (fix #7585) - Add new provider 'minimax_token_plan' for MiniMax Token Plan users - Inherit ProviderAnthropic to reuse all chat/completion logic - Hardcode api_base to https://api.minimaxi.com/anthropic - get_models() returns hardcoded list: MiniMax-M2.7, M2.5, M2.1, M2 - Highspeed models excluded (require premium tier) - Reason for hardcoding: Token Plan API does not expose /models endpoint - Fixes: https://github.com/AstrBotDevs/AstrBot/issues/7585 * fix: remove api_base from config template and add model validation - Remove api_base from default_config_tmpl (always overridden, misleading) - Add model validation against MINIMAX_TOKEN_PLAN_MODELS - Raise clear ValueError if user configures an unsupported model Addressed Sourcery AI review comments. * fix: use custom_headers for Bearer token auth instead of auth_header MiniMax Token Plan requires Authorization: Bearer <token> header. Use custom_headers to inject the correct auth header instead of the non-functional auth_header key. Addressed Gemini Code Assist review comment. * fix: update MiniMax Token Plan provider adapter and documentation to English * feat: add MiniMax Token Plan configuration and icon support * feat: remove default configuration template from MiniMax Token Plan provider adapter --------- Co-authored-by: Soulter <905617992@qq.com>
This commit is contained in:
@@ -1206,7 +1206,7 @@ CONFIG_METADATA_2 = {
|
||||
"provider_type": "chat_completion",
|
||||
"enable": True,
|
||||
"key": [],
|
||||
"api_base": "https://api.kimi.com/coding/",
|
||||
"api_base": "https://api.kimi.com/coding",
|
||||
"timeout": 120,
|
||||
"proxy": "",
|
||||
"custom_headers": {"User-Agent": "claude-code/0.1.0"},
|
||||
@@ -1236,6 +1236,19 @@ CONFIG_METADATA_2 = {
|
||||
"proxy": "",
|
||||
"custom_headers": {},
|
||||
},
|
||||
"MiniMax Token Plan": {
|
||||
"id": "minimax-token-plan",
|
||||
"provider": "minimax-token-plan",
|
||||
"type": "minimax_token_plan",
|
||||
"provider_type": "chat_completion",
|
||||
"enable": True,
|
||||
"key": [],
|
||||
"api_base": "https://api.minimaxi.com/anthropic",
|
||||
"timeout": 120,
|
||||
"proxy": "",
|
||||
"custom_headers": {"User-Agent": "claude-code/0.1.0"},
|
||||
"anth_thinking_config": {"type": "", "budget": 0, "effort": ""},
|
||||
},
|
||||
"xAI": {
|
||||
"id": "xai",
|
||||
"provider": "xai",
|
||||
|
||||
@@ -363,6 +363,10 @@ class ProviderManager:
|
||||
)
|
||||
case "longcat_chat_completion":
|
||||
from .sources.longcat_source import ProviderLongCat as ProviderLongCat
|
||||
case "minimax_token_plan":
|
||||
from .sources.minimax_token_plan_source import (
|
||||
ProviderMiniMaxTokenPlan as ProviderMiniMaxTokenPlan,
|
||||
)
|
||||
case "zhipu_chat_completion":
|
||||
from .sources.zhipu_source import ProviderZhipu as ProviderZhipu
|
||||
case "groq_chat_completion":
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
from astrbot.core.provider.sources.anthropic_source import ProviderAnthropic
|
||||
|
||||
from ..register import register_provider_adapter
|
||||
|
||||
MINIMAX_TOKEN_PLAN_MODELS = [
|
||||
"MiniMax-M2.7",
|
||||
"MiniMax-M2.5",
|
||||
"MiniMax-M2.1",
|
||||
"MiniMax-M2",
|
||||
]
|
||||
|
||||
|
||||
@register_provider_adapter(
|
||||
"minimax_token_plan",
|
||||
"MiniMax Token Plan Provider Adapter",
|
||||
)
|
||||
class ProviderMiniMaxTokenPlan(ProviderAnthropic):
|
||||
"""MiniMax Token Plan provider.
|
||||
|
||||
The Token Plan API does not support the /models endpoint, so get_models()
|
||||
returns a hard-coded model list. This is a Token Plan API limitation.
|
||||
See https://github.com/AstrBotDevs/AstrBot/issues/7585 for details.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
provider_config,
|
||||
provider_settings,
|
||||
) -> None:
|
||||
# Keep api_base fixed; Token Plan users do not need to configure it.
|
||||
provider_config["api_base"] = "https://api.minimaxi.com/anthropic"
|
||||
# MiniMax Token Plan requires the Authorization: Bearer <token> header.
|
||||
key = provider_config.get("key", "")
|
||||
actual_key = key[0] if isinstance(key, list) else key
|
||||
provider_config.setdefault("custom_headers", {})["Authorization"] = (
|
||||
f"Bearer {actual_key}"
|
||||
)
|
||||
|
||||
super().__init__(
|
||||
provider_config,
|
||||
provider_settings,
|
||||
)
|
||||
|
||||
configured_model = provider_config.get("model", "MiniMax-M2.7")
|
||||
if configured_model not in MINIMAX_TOKEN_PLAN_MODELS:
|
||||
raise ValueError(
|
||||
f"Unsupported model: {configured_model!r}. "
|
||||
f"Supported models: {', '.join(MINIMAX_TOKEN_PLAN_MODELS)}"
|
||||
)
|
||||
|
||||
self.set_model(configured_model)
|
||||
|
||||
async def get_models(self) -> list[str]:
|
||||
"""Return the hard-coded known model list because Token Plan cannot fetch it dynamically."""
|
||||
return MINIMAX_TOKEN_PLAN_MODELS.copy()
|
||||
@@ -23,7 +23,7 @@ export function getProviderIcon(type) {
|
||||
'moonshot': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/kimi.svg',
|
||||
'kimi': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/kimi.svg',
|
||||
'kimi-code': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/kimi.svg',
|
||||
'kimi-code': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/longcat-color.svg',
|
||||
'longcat': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/longcat-color.svg',
|
||||
'ppio': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/ppio.svg',
|
||||
'dify': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/dify-color.svg',
|
||||
"coze": "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@1.66.0/icons/coze.svg",
|
||||
@@ -33,6 +33,7 @@ export function getProviderIcon(type) {
|
||||
'lm_studio': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/lmstudio.svg',
|
||||
'fishaudio': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/fishaudio.svg',
|
||||
'minimax': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/minimax.svg',
|
||||
'minimax-token-plan': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/minimax.svg',
|
||||
'mimo': 'https://platform.xiaomimimo.com/favicon.874c9507.png',
|
||||
'302ai': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@1.53.0/icons/ai302-color.svg',
|
||||
'microsoft': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/microsoft.svg',
|
||||
|
||||
Reference in New Issue
Block a user