Merge pull request #5871 from tcgumus/dev

fix: Unsupported JSON schema type {type_}
This commit is contained in:
Timothy Jaeryang Baek 2024-10-03 05:07:30 +02:00 committed by GitHub
commit 2e7e346e19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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_}")