From b3c63f0ae4769446266d1f3f958c93249e113d59 Mon Sep 17 00:00:00 2001 From: Asankilp Date: Mon, 16 Dec 2024 01:57:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtools=E7=A6=81=E7=94=A8plugin?= =?UTF-8?q?s=E5=90=AF=E7=94=A8=E6=97=B6=E6=97=A0=E6=B3=95=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_marshoai/azure.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/nonebot_plugin_marshoai/azure.py b/nonebot_plugin_marshoai/azure.py index 6c397198..d228f725 100644 --- a/nonebot_plugin_marshoai/azure.py +++ b/nonebot_plugin_marshoai/azure.py @@ -108,11 +108,13 @@ async def _preload_plugins(): """启动钩子加载插件""" if config.marshoai_enable_plugins: marshoai_plugin_dirs = config.marshoai_plugin_dirs # 外部插件目录列表 - marshoai_plugin_dirs.insert(0, Path(__file__).parent / "plugins") # 预置插件目录 + marshoai_plugin_dirs.insert( + 0, Path(__file__).parent / "plugins" + ) # 预置插件目录 load_plugins(*marshoai_plugin_dirs) logger.info( "如果启用小棉插件后使用的模型出现报错,请尝试将 MARSHOAI_ENABLE_PLUGINS 设为 false。" - ) + ) @add_usermsg_cmd.handle() @@ -274,14 +276,14 @@ async def marsho( if not is_reasoning_model: context_msg = [get_prompt()] + context_msg # o1等推理模型不支持系统提示词, 故不添加 + tools_lists = tools.tools_list + list( + map(lambda v: v.data(), get_function_calls().values()) + ) response = await make_chat( client=client, model_name=model_name, msg=context_msg + [UserMessage(content=usermsg)], # type: ignore - tools=tools.get_tools_list() - + list( - map(lambda v: v.data(), get_function_calls().values()) - ), # TODO 临时追加函数,后期优化 + tools=tools_lists if tools_lists else None, # TODO 临时追加函数,后期优化 ) # await UniMessage(str(response)).send() choice = response.choices[0]