fix: Agent execution time duration display in streaming mode (#7852)

* Update events.py

* timer compotation update

* clean up

* add time elapsed for streaming

* [autofix.ci] apply automated fixes

* Update events.py

* preliminary fix

* Update src/backend/base/langflow/schema/message.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* Update src/backend/base/langflow/schema/message.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
Edwin Jose 2025-05-02 13:23:07 -04:00 committed by GitHub
commit a904db6220
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 2 deletions

View file

@ -231,7 +231,8 @@ async def handle_on_chain_stream(
agent_message.text += output_text
agent_message.properties.state = "partial"
agent_message = await send_message_method(message=agent_message)
start_time = perf_counter()
if not agent_message.text:
start_time = perf_counter()
return agent_message, start_time

View file

@ -51,6 +51,7 @@ class Message(Data):
properties: Properties = Field(default_factory=Properties)
category: Literal["message", "error", "warning", "info"] | None = "message"
content_blocks: list[ContentBlock] = Field(default_factory=list)
duration: int | None = None
@field_validator("flow_id", mode="before")
@classmethod
@ -306,6 +307,7 @@ class MessageResponse(DefaultModel):
text: str
files: list[str] = []
edit: bool
duration: float | None = None
properties: Properties | None = None
category: str | None = None

View file

@ -327,7 +327,6 @@ export default function ChatMessage({
playgroundPage={playgroundPage}
contentBlocks={chat.content_blocks}
isLoading={
chatMessage === "" &&
chat.properties?.state === "partial" &&
isBuilding &&
lastMessage