From 006f925afdb6ff11645457501cbf073b425b9f91 Mon Sep 17 00:00:00 2001 From: Snowykami Date: Mon, 16 Dec 2024 03:02:05 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E4=BC=98=E5=8C=96=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=8F=82=E6=95=B0=E8=A7=A3=E6=9E=90=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AF=B9JSON=E8=A7=A3=E6=9E=90=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E5=A4=84=E7=90=86=EF=BC=9B=E6=9B=B4=E6=96=B0run=5Fshe?= =?UTF-8?q?ll=5Fcommand=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_marshoai/azure.py | 9 ++++++--- .../plugins/snowykami_testplugin/__init__.py | 4 +--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/nonebot_plugin_marshoai/azure.py b/nonebot_plugin_marshoai/azure.py index d228f725..3f85d4d3 100644 --- a/nonebot_plugin_marshoai/azure.py +++ b/nonebot_plugin_marshoai/azure.py @@ -323,9 +323,12 @@ async def marsho( if isinstance( tool_call, ChatCompletionsToolCall ): # 循环调用工具直到不需要调用 - function_args = json.loads( - tool_call.function.arguments.replace("'", '"') - ) + try: + function_args = json.loads(tool_call.function.arguments) + except json.JSONDecodeError: + function_args = json.loads( + tool_call.function.arguments.replace("'", '"') + ) logger.info( f"调用函数 {tool_call.function.name} ,参数为 {function_args}" ) diff --git a/nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py b/nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py index b3083bbc..25c19862 100644 --- a/nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py +++ b/nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py @@ -97,9 +97,7 @@ async def run_python_code(code: str, b: Bot, e: MessageEvent) -> str: @on_function_call( description="在设备上运行shell命令, Run command on this device" -).params(command=String(description="shell命令内容")).permission(SUPERUSER).name( - "run_shell_command" -) +).params(command=String(description="shell命令内容")).permission(SUPERUSER) async def run_shell_command(command: str, b: Bot, e: MessageEvent) -> str: """运行shell命令""" try: