fix: handle parameters.properties being array, not just parameters itself
This commit is contained in:
@@ -145,13 +145,26 @@ async def proxy(path: str, request: Request):
|
||||
stripped_any = True
|
||||
|
||||
# Fix tool function parameters: must be object, not array/null/missing
|
||||
# Also fix nested: parameters.properties must be object, not array
|
||||
tools = data.get("tools")
|
||||
if isinstance(tools, list):
|
||||
for tool in tools:
|
||||
func = tool.get("function") if isinstance(tool, dict) else None
|
||||
if isinstance(func, dict) and not isinstance(func.get("parameters"), dict):
|
||||
if not isinstance(func, dict):
|
||||
continue
|
||||
params = func.get("parameters")
|
||||
if not isinstance(params, dict):
|
||||
func["parameters"] = {"type": "object", "properties": {}}
|
||||
stripped_any = True
|
||||
else:
|
||||
# Fix nested: properties must be object, not array
|
||||
if not isinstance(params.get("properties"), dict):
|
||||
params["properties"] = {}
|
||||
stripped_any = True
|
||||
# required must be a list of strings if present
|
||||
if "required" in params and not isinstance(params["required"], list):
|
||||
del params["required"]
|
||||
stripped_any = True
|
||||
|
||||
if stripped_any:
|
||||
body = json.dumps(data).encode()
|
||||
|
||||
Reference in New Issue
Block a user