From a040b9428d1df1ed78c7d21ab24658436fdec442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E4=BA=86=E7=9D=A1=E5=A4=A7=E8=A7=89?= <64798754+stakeswky@users.noreply.github.com> Date: Tue, 24 Feb 2026 15:31:12 +0800 Subject: [PATCH] fix: correct type annotations in Langfuse trace entities to match SDK (#32498) Co-authored-by: User --- .../langfuse_trace/entities/langfuse_trace_entity.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/core/ops/langfuse_trace/entities/langfuse_trace_entity.py b/api/core/ops/langfuse_trace/entities/langfuse_trace_entity.py index 312c7d3676..76755bf769 100644 --- a/api/core/ops/langfuse_trace/entities/langfuse_trace_entity.py +++ b/api/core/ops/langfuse_trace/entities/langfuse_trace_entity.py @@ -129,11 +129,11 @@ class LangfuseSpan(BaseModel): default=None, description="The id of the user that triggered the execution. Used to provide user-level analytics.", ) - start_time: datetime | str | None = Field( + start_time: datetime | None = Field( default_factory=datetime.now, description="The time at which the span started, defaults to the current time.", ) - end_time: datetime | str | None = Field( + end_time: datetime | None = Field( default=None, description="The time at which the span ended. Automatically set by span.end().", ) @@ -146,7 +146,7 @@ class LangfuseSpan(BaseModel): description="Additional metadata of the span. Can be any JSON object. Metadata is merged when being updated " "via the API.", ) - level: str | None = Field( + level: LevelEnum | None = Field( default=None, description="The level of the span. Can be DEBUG, DEFAULT, WARNING or ERROR. Used for sorting/filtering of " "traces with elevated error levels and for highlighting in the UI.", @@ -222,16 +222,16 @@ class LangfuseGeneration(BaseModel): default=None, description="Identifier of the generation. Useful for sorting/filtering in the UI.", ) - start_time: datetime | str | None = Field( + start_time: datetime | None = Field( default_factory=datetime.now, description="The time at which the generation started, defaults to the current time.", ) - completion_start_time: datetime | str | None = Field( + completion_start_time: datetime | None = Field( default=None, description="The time at which the completion started (streaming). Set it to get latency analytics broken " "down into time until completion started and completion duration.", ) - end_time: datetime | str | None = Field( + end_time: datetime | None = Field( default=None, description="The time at which the generation ended. Automatically set by generation.end().", )