refactor: Update timestamp handling in Message schema

Refactor the `timestamp` field in the `Message` schema to use the `datetime.now(timezone.utc)` function instead of the `utc_now` utility. This change ensures consistency with other modules and reduces redundancy.

No behavioral changes are intended; only the implementation detail is modified to leverage the built-in function for getting the current UTC datetime.
This commit is contained in:
Rodrigo 2024-06-16 17:29:36 -03:00
commit 2cc23b8399

View file

@ -8,7 +8,6 @@ from pydantic import BeforeValidator, ConfigDict, Field, field_serializer
from langflow.schema.data import Data
from langflow.schema.image import Image, get_file_paths, is_image_file
from langflow.utils.util import utc_now
def _timestamp_to_str(timestamp: datetime) -> str:
return timestamp.strftime("%Y-%m-%d %H:%M:%S")
@ -24,7 +23,7 @@ class Message(Data):
files: Optional[list[str | Image]] = Field(default=[])
session_id: Optional[str] = Field(default="")
timestamp: Annotated[str, BeforeValidator(_timestamp_to_str)] = Field(
default=utc_now(stringify=True)
default=datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
)
flow_id: Optional[str] = None