fix: get_tools_description to use inputSchema.properties
This commit is contained in:
@@ -1131,8 +1131,15 @@ def get_tools_description() -> str:
|
||||
\"\"\"生成工具描述供 LLM 使用\"\"\"
|
||||
tools_desc = []
|
||||
for t in TOOL_LIST:
|
||||
params = t.get("parameters", {{}})
|
||||
param_desc = ", ".join([f"{{k}}: {{v.get('type', 'string')}}" for k, v in params.items()])
|
||||
# 支持 inputSchema.properties 或 parameters 格式
|
||||
schema = t.get("inputSchema", {{}})
|
||||
params = schema.get("properties", t.get("parameters", {{}}))
|
||||
required = schema.get("required", [])
|
||||
param_parts = []
|
||||
for k, v in params.items():
|
||||
req_mark = "*" if k in required else ""
|
||||
param_parts.append(f"{{k}}{{req_mark}}: {{v.get('type', 'string')}} ({{v.get('description', '')}})")
|
||||
param_desc = ", ".join(param_parts)
|
||||
tools_desc.append(f"- {{t['name']}}: {{t['description']}}\\n 参数: {{param_desc or '无'}}")
|
||||
return "\\n".join(tools_desc)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user