add: 增加查看当前使用的ai平台命令

add: 增加查看info命令
This commit is contained in:
taylor
2024-10-14 21:28:18 +08:00
parent 31624b3059
commit 8874bef006
3 changed files with 31 additions and 3 deletions

View File

@@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" /> <excludeFolder url="file://$MODULE_DIR$/venv" />
</content> </content>
<orderEntry type="jdk" jdkName="maubot-llm-conda" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.11 (maubot-llmplus)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

2
.idea/misc.xml generated
View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="maubot-llm-conda" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (maubot-llmplus)" project-jdk-type="Python SDK" />
</project> </project>

View File

@@ -140,10 +140,38 @@ class AiBotPlugin(AbsExtraConfigPlugin):
""" """
@ai_command.subcommand(help="") @ai_command.subcommand(help="")
async def info(self, event: MessageEvent) -> None: async def info(self, event: MessageEvent) -> None:
show_infos = []
# 当前机器人名称
show_infos.append(f"bot name: {self.get_bot_name()}\n")
# 查询当前使用的ai平台 # 查询当前使用的ai平台
show_infos.append(f"platform: {self.get_cur_platform()}\n")
show_infos.append("platform detail: \n")
# 查询当前ai平台的配置信息 # 查询当前ai平台的配置信息
p_m_dict = dict(self.config['platforms'][self.get_cur_platform()])
for k, v in p_m_dict:
show_infos.append(f"- {k}: {v}\n")
# 当前使用的model # 当前使用的model
# 列出model信息 show_infos.append(f"model: {self.config.cur_model}\n")
# TODO 列出model信息
pass
"""
获取实际平台名称
"""
def get_cur_platform(self) -> str:
platform_model = self.config.cur_platform
return platform_model.split('#')[0]
@ai_command.subcommand(help="")
@command.argument("argus")
async def platform(self, event: MessageEvent, argus: str):
if argus == 'list':
p_dict = dict(self.config['platforms'])
platforms = [f"- {platform}" for platform in set(p_dict.keys())]
await event.reply("\n".join(platforms))
pass
if argus == 'current':
await event.reply(f"current use platform is {self.config.cur_platform}")
pass pass
@ai_command.subcommand(help="") @ai_command.subcommand(help="")