From 98518727240f69f4d1a8ae7f8b1daf0cb86b039c Mon Sep 17 00:00:00 2001 From: Asankilp Date: Mon, 30 Dec 2024 13:16:09 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BC=98=E5=8C=96Caller?= =?UTF-8?q?=E7=B1=BB=E4=B8=AD=E7=9A=84=E5=8F=82=E6=95=B0=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E7=AE=80=E5=8C=96properties?= =?UTF-8?q?=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/func_call/caller.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/nonebot_plugin_marshoai/plugin/func_call/caller.py b/nonebot_plugin_marshoai/plugin/func_call/caller.py index 1a05971e..b04ba987 100644 --- a/nonebot_plugin_marshoai/plugin/func_call/caller.py +++ b/nonebot_plugin_marshoai/plugin/func_call/caller.py @@ -155,6 +155,12 @@ class Caller: Returns: dict[str, Any]: 函数的json数据 """ + properties = {key: value.data() for key, value in self._parameters.items()} + if not properties: + properties["placeholder"] = { + "type": "string", + "description": "占位符,用于显示在对话框中", # 为保证兼容性而设置的无用参数 + } return { "type": "function", "function": { @@ -162,15 +168,7 @@ class Caller: "description": self._description, "parameters": { "type": "object", - "properties": { - **{ - key: value.data() for key, value in self._parameters.items() - }, - "placeholder": { - "type": "string", - "description": "占位符,用于显示在对话框中", # 为保证兼容性而设置的无用参数 - }, - }, + "properties": properties, }, "required": [ key