Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions astrbot/core/provider/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ def dynamic_import_provider(self, type: str) -> None:
)
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":
Expand Down
48 changes: 48 additions & 0 deletions astrbot/core/provider/sources/minimax_token_plan_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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 提供商适配器",
default_config_tmpl={
"key": "",
"api_base": "https://api.minimaxi.com/anthropic",
},
provider_display_name="MiniMax Token Plan",
)
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
class ProviderMiniMaxTokenPlan(ProviderAnthropic):
"""MiniMax Token Plan provider.

Token Plan API 不支持 /models 接口,因此 get_models() 返回硬编码的模型列表。
这是 Token Plan API 本身的限制,详见 https://github.com/AstrBotDevs/AstrBot/issues/7585
"""

def __init__(
self,
provider_config,
provider_settings,
) -> None:
# 使用固定的 api_base,不允许用户自定义
provider_config["api_base"] = "https://api.minimaxi.com/anthropic"
# 强制使用 auth header(Token Plan 要求)
provider_config["auth_header"] = True

Comment thread
Soulter marked this conversation as resolved.
Outdated
super().__init__(
provider_config,
provider_settings,
)

self.set_model(provider_config.get("model", "MiniMax-M2.7"))
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated

async def get_models(self) -> list[str]:
"""Token Plan 不支持动态获取模型列表,返回硬编码的已知模型列表。"""
return MINIMAX_TOKEN_PLAN_MODELS.copy()