add: 添加切换模型命令

This commit is contained in:
taylor
2024-10-14 00:49:42 +08:00
parent e2d6acb92f
commit 2d04636cfd
2 changed files with 21 additions and 1 deletions

View File

@@ -172,6 +172,20 @@ class AiBotPlugin(AbsExtraConfigPlugin):
await event.reply("\n".join(models), markdown=True)
# 如果不是,如果是其他的名称,表示这是一个模型名
# 如果是use为第二命令,则表示要切换模型
if argus.startswith('use'):
arg_elements = argus.strip().split(" ", 2)
# 如果命令小于2的个数就没有写模型名无法切换
if len(arg_elements) < 2:
await event.reply("give me a model name after 'use' command", markdown=True)
platform = self.get_ai_platform()
models = platform.list_models()
if f"- {arg_elements[1]}" in models:
self.log.debug(f"switch model: {arg_elements[1]}")
self.model = arg_elements[1]
await event.react("")
else:
await event.reply("not found valid model")
@classmethod
def get_config_class(cls) -> Type[BaseProxyConfig]: