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: