🐛 优化Caller类中的参数处理逻辑,简化properties构建

This commit is contained in:
Asankilp 2024-12-30 13:16:09 +08:00
parent aad0ec7b60
commit 9851872724

View File

@ -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