mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 11:57:51 +01:00
fix: include items property in OpenAPI array parameters for OpenAI function calling
Resolves issue where OpenAPI specs with array query parameters were generating invalid OpenAI function schemas missing the required 'items' property, causing 400 Bad Request errors from OpenAI. The fix ensures that when converting OpenAPI parameter schemas to OpenAI function schemas, array parameters properly include their 'items' property definition. Fixes open-webui/open-webui#14115
This commit is contained in:
@@ -399,10 +399,16 @@ def convert_openapi_to_tool_payload(openapi_spec):
|
|||||||
description += (
|
description += (
|
||||||
f". Possible values: {', '.join(param_schema.get('enum'))}"
|
f". Possible values: {', '.join(param_schema.get('enum'))}"
|
||||||
)
|
)
|
||||||
tool["parameters"]["properties"][param_name] = {
|
param_property = {
|
||||||
"type": param_schema.get("type"),
|
"type": param_schema.get("type"),
|
||||||
"description": description,
|
"description": description,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Include items property for array types (required by OpenAI)
|
||||||
|
if param_schema.get("type") == "array" and "items" in param_schema:
|
||||||
|
param_property["items"] = param_schema["items"]
|
||||||
|
|
||||||
|
tool["parameters"]["properties"][param_name] = param_property
|
||||||
if param.get("required"):
|
if param.get("required"):
|
||||||
tool["parameters"]["required"].append(param_name)
|
tool["parameters"]["required"].append(param_name)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user