mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 17:22:38 +02:00
Attach active span metadata to thinking-step SSE and completion.
This commit is contained in:
parent
3ed09bdd90
commit
1dcb08e925
3 changed files with 9 additions and 1 deletions
|
|
@ -115,6 +115,7 @@ class EventRelay:
|
||||||
state.current_text_id = None
|
state.current_text_id = None
|
||||||
|
|
||||||
completion_event, new_active = complete_active_thinking_step(
|
completion_event, new_active = complete_active_thinking_step(
|
||||||
|
state=state,
|
||||||
streaming_service=self.streaming_service,
|
streaming_service=self.streaming_service,
|
||||||
content_builder=content_builder,
|
content_builder=content_builder,
|
||||||
last_active_step_id=state.last_active_step_id,
|
last_active_step_id=state.last_active_step_id,
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,13 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from .state import AgentEventRelayState
|
||||||
from .thinking_step_sse import emit_thinking_step_frame
|
from .thinking_step_sse import emit_thinking_step_frame
|
||||||
|
|
||||||
|
|
||||||
def complete_active_thinking_step(
|
def complete_active_thinking_step(
|
||||||
*,
|
*,
|
||||||
|
state: AgentEventRelayState,
|
||||||
streaming_service: Any,
|
streaming_service: Any,
|
||||||
content_builder: Any | None,
|
content_builder: Any | None,
|
||||||
last_active_step_id: str | None,
|
last_active_step_id: str | None,
|
||||||
|
|
@ -26,6 +28,7 @@ def complete_active_thinking_step(
|
||||||
title=last_active_step_title,
|
title=last_active_step_title,
|
||||||
status="completed",
|
status="completed",
|
||||||
items=last_active_step_items if last_active_step_items else None,
|
items=last_active_step_items if last_active_step_items else None,
|
||||||
|
metadata=state.span_metadata_if_active(),
|
||||||
)
|
)
|
||||||
return event, None
|
return event, None
|
||||||
return None, last_active_step_id
|
return None, last_active_step_id
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,16 @@ def emit_thinking_step_frame(
|
||||||
title: str,
|
title: str,
|
||||||
status: str = "in_progress",
|
status: str = "in_progress",
|
||||||
items: list[str] | None = None,
|
items: list[str] | None = None,
|
||||||
|
metadata: dict[str, Any] | None = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
if content_builder is not None:
|
if content_builder is not None:
|
||||||
content_builder.on_thinking_step(step_id, title, status, items)
|
content_builder.on_thinking_step(
|
||||||
|
step_id, title, status, items, metadata=metadata
|
||||||
|
)
|
||||||
return streaming_service.format_thinking_step(
|
return streaming_service.format_thinking_step(
|
||||||
step_id=step_id,
|
step_id=step_id,
|
||||||
title=title,
|
title=title,
|
||||||
status=status,
|
status=status,
|
||||||
items=items,
|
items=items,
|
||||||
|
metadata=metadata,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue