Fixes #20534: Allow $ref in parameter for custom tools (#20535)

Co-authored-by: Peter Xin <iami@Artemis.local>
This commit is contained in:
不如归去 2025-06-02 18:08:53 +08:00 committed by GitHub
parent b4b59148dc
commit 8025ad0661
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -55,6 +55,13 @@ class ApiBasedToolSchemaParser:
# convert parameters
parameters = []
if "parameters" in interface["operation"]:
for i, parameter in enumerate(interface["operation"]["parameters"]):
if "$ref" in parameter:
root = openapi
reference = parameter["$ref"].split("/")[1:]
for ref in reference:
root = root[ref]
interface["operation"]["parameters"][i] = root
for parameter in interface["operation"]["parameters"]:
tool_parameter = ToolParameter(
name=parameter["name"],