fix serialization pydantic

This commit is contained in:
Xi Yan 2024-12-30 13:12:51 -08:00
parent 48df492a44
commit ca6f204f4d

View file

@ -4,6 +4,7 @@
# This source code is licensed under the terms described in the LICENSE file in # This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree. # the root directory of this source tree.
import base64
from typing import Annotated, List, Literal, Optional, Union from typing import Annotated, List, Literal, Optional, Union
from llama_models.schema_utils import json_schema_type, register_schema from llama_models.schema_utils import json_schema_type, register_schema
@ -28,7 +29,7 @@ class _URLOrData(BaseModel):
return {"url": values} return {"url": values}
class Config: class Config:
json_encoders = {bytes: lambda v: str("binary data")} json_encoders = {bytes: lambda v: base64.b64encode(v).decode("utf-8")}
@json_schema_type @json_schema_type