add: 增加切换ai平台命令

This commit is contained in:
taylor
2024-10-14 13:58:36 +08:00
parent 584ffcc9c4
commit 1b8e028b83

View File

@@ -146,18 +146,17 @@ class AiBotPlugin(AbsExtraConfigPlugin):
@command.argument("argus") @command.argument("argus")
async def model(self, event: MessageEvent, argus: str): async def model(self, event: MessageEvent, argus: str):
# 如果是list表示查看当前可以使用的模型列表 # 如果是list表示查看当前可以使用的模型列表
if argus == '#list': if argus == 'list':
platform = self.get_ai_platform() platform = self.get_ai_platform()
models = await platform.list_models() models = await platform.list_models()
await event.reply("\n".join(models), markdown=True) await event.reply("\n".join(models), markdown=True)
@ai_command.subcommand(help="") @ai_command.subcommand(help="")
@command.argument("argus") @command.argument("argus")
async def use(self, event: MessageEvent, argus: str): async def use(self, event: MessageEvent, argus: str):
platform = self.get_ai_platform() platform = self.get_ai_platform()
# 获取模型列表,判断使用的模型是否存在于列表中 # 获取模型列表,判断使用的模型是否存在于列表中
models = platform.list_models() models = await platform.list_models()
if f"- {argus}" in models: if f"- {argus}" in models:
self.log.debug(f"switch model: {argus}") self.log.debug(f"switch model: {argus}")
self.config._cur_model = argus self.config._cur_model = argus