From bdb2ce944856f7dbf169a16326f1815b56f3e245 Mon Sep 17 00:00:00 2001 From: t Date: Wed, 2 Oct 2024 15:34:48 +0300 Subject: [PATCH] fix: Unsupported JSON schema type {type_} --- backend/open_webui/utils/schemas.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/open_webui/utils/schemas.py b/backend/open_webui/utils/schemas.py index 958e57318..4d1d448cd 100644 --- a/backend/open_webui/utils/schemas.py +++ b/backend/open_webui/utils/schemas.py @@ -104,5 +104,9 @@ def json_schema_to_pydantic_type(json_schema: dict[str, Any]) -> Any: return Optional[Any] # Use Optional[Any] for nullable fields elif type_ == "literal": return Literal[literal_eval(json_schema.get("enum"))] + elif type_ == "optional": + inner_schema = json_schema.get("items", {"type": "string"}) + inner_type = json_schema_to_pydantic_type(inner_schema) + return Optional[inner_type] else: raise ValueError(f"Unsupported JSON schema type: {type_}")