From ca6f204f4d8af6933f8bd411b9b6d27369db797b Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Mon, 30 Dec 2024 13:12:51 -0800 Subject: [PATCH] fix serialization pydantic --- llama_stack/apis/common/content_types.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llama_stack/apis/common/content_types.py b/llama_stack/apis/common/content_types.py index 054ef2e18..e198d27c7 100644 --- a/llama_stack/apis/common/content_types.py +++ b/llama_stack/apis/common/content_types.py @@ -4,6 +4,7 @@ # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. +import base64 from typing import Annotated, List, Literal, Optional, Union from llama_models.schema_utils import json_schema_type, register_schema @@ -28,7 +29,7 @@ class _URLOrData(BaseModel): return {"url": values} class Config: - json_encoders = {bytes: lambda v: str("binary data")} + json_encoders = {bytes: lambda v: base64.b64encode(v).decode("utf-8")} @json_schema_type