Skip to content

Commit

Permalink
Merge pull request #1 from tcgumus/dev-fix-unsupported-json-error
Browse files Browse the repository at this point in the history
fix: Unsupported JSON schema type {type_}
  • Loading branch information
tcgumus authored Oct 2, 2024
2 parents d353ea4 + bdb2ce9 commit b2f09e4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/open_webui/utils/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_}")

0 comments on commit b2f09e4

Please sign in to comment.