add: 增加切换ai平台命令
This commit is contained in:
@@ -150,6 +150,11 @@ class AiBotPlugin(AbsExtraConfigPlugin):
|
|||||||
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)
|
||||||
|
pass
|
||||||
|
# 如果是current,显示出当前的使用模型
|
||||||
|
if argus == 'current':
|
||||||
|
await event.reply(f"current use model is {self.config.cur_model}")
|
||||||
|
pass
|
||||||
|
|
||||||
@ai_command.subcommand(help="")
|
@ai_command.subcommand(help="")
|
||||||
@command.argument("argus")
|
@command.argument("argus")
|
||||||
@@ -159,7 +164,7 @@ class AiBotPlugin(AbsExtraConfigPlugin):
|
|||||||
models = await 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
|
||||||
await event.react("✅")
|
await event.react("✅")
|
||||||
else:
|
else:
|
||||||
await event.reply("not found valid model")
|
await event.reply("not found valid model")
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class Platform:
|
|||||||
self.http = http
|
self.http = http
|
||||||
self.config = config['platforms'][self.get_type()]
|
self.config = config['platforms'][self.get_type()]
|
||||||
self.url = self.config['url']
|
self.url = self.config['url']
|
||||||
|
# 设置当前的使用模型,这里不直接使用config对象下的配置值,而是加入了与命令决定后的使用模型名称
|
||||||
self.model = config.cur_model
|
self.model = config.cur_model
|
||||||
self.max_words = self.config['max_words']
|
self.max_words = self.config['max_words']
|
||||||
self.api_key = self.config['api_key']
|
self.api_key = self.config['api_key']
|
||||||
|
|||||||
Reference in New Issue
Block a user