fix: Refactor JSON serialization in build_flow and log_vertex_build (#5189)

* refactor(langflow): Update JSON serialization in build_flow and log_vertex_build

* Refactor JSON serialization in build_flow and log_vertex_build functions

* Refactor JSON serialization in build_flow and log_vertex_build functions
This commit is contained in:
anovazzi1 2024-12-12 15:51:24 -03:00 committed by GitHub
commit 0531084e35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View file

@ -176,6 +176,7 @@ async def log_vertex_build(
try:
if not get_settings_service().settings.vertex_builds_storage_enabled:
return
vertex_build = VertexBuildBase(
flow_id=flow_id,
id=vertex_id,

View file

@ -1,5 +1,7 @@
from fastapi.encoders import jsonable_encoder
from pydantic import BaseModel, field_serializer
from pydantic.v1 import BaseModel as V1BaseModel
from pydantic_core import PydanticSerializationError
from langflow.schema.log import LoggableType
@ -24,4 +26,8 @@ class Log(BaseModel):
return value.to_json()
if isinstance(value, BaseModel):
return value.model_dump(exclude_none=True)
try:
value = jsonable_encoder(value)
except PydanticSerializationError:
return str(value)
return value