mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 09:12:40 +02:00
wire orchestrator streaming context path and align event relay outputs
This commit is contained in:
parent
0f40279d95
commit
a04b2e88bd
8 changed files with 94 additions and 109 deletions
|
|
@ -7,8 +7,8 @@ from typing import Any
|
|||
|
||||
import pytest
|
||||
|
||||
from app.tasks.chat.streaming.orchestration import stream_agent_events
|
||||
from app.tasks.chat.streaming.orchestration.output import StreamOutput
|
||||
from app.tasks.chat.streaming.orchestration import stream_output
|
||||
from app.tasks.chat.streaming.orchestration.output import StreamingResult
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ async def _collect(stream: Any) -> list[str]:
|
|||
return out
|
||||
|
||||
|
||||
async def test_stream_agent_events_emits_text_lifecycle_and_updates_result() -> None:
|
||||
async def test_stream_output_emits_text_lifecycle_and_updates_result() -> None:
|
||||
service = _StreamingService()
|
||||
agent = _Agent(
|
||||
[
|
||||
|
|
@ -64,10 +64,10 @@ async def test_stream_agent_events_emits_text_lifecycle_and_updates_result() ->
|
|||
{"event": "on_chat_model_stream", "data": {"chunk": _Chunk(content=" world")}},
|
||||
]
|
||||
)
|
||||
result = StreamOutput()
|
||||
result = StreamingResult()
|
||||
|
||||
frames = await _collect(
|
||||
stream_agent_events(
|
||||
stream_output(
|
||||
agent=agent,
|
||||
config={"configurable": {"thread_id": "t-1"}},
|
||||
input_data={"messages": []},
|
||||
|
|
@ -86,7 +86,7 @@ async def test_stream_agent_events_emits_text_lifecycle_and_updates_result() ->
|
|||
assert result.agent_called_update_memory is False
|
||||
|
||||
|
||||
async def test_stream_agent_events_passes_runtime_context_to_agent() -> None:
|
||||
async def test_stream_output_passes_runtime_context_to_agent() -> None:
|
||||
service = _StreamingService()
|
||||
class _ContextAwareAgent:
|
||||
async def astream_events(self, input_data: Any, **kwargs: Any):
|
||||
|
|
@ -95,10 +95,10 @@ async def test_stream_agent_events_passes_runtime_context_to_agent() -> None:
|
|||
yield {"event": "on_chat_model_stream", "data": {"chunk": _Chunk(text)}}
|
||||
|
||||
agent = _ContextAwareAgent()
|
||||
result = StreamOutput()
|
||||
result = StreamingResult()
|
||||
|
||||
frames = await _collect(
|
||||
stream_agent_events(
|
||||
stream_output(
|
||||
agent=agent,
|
||||
config={"configurable": {"thread_id": "t-2"}},
|
||||
input_data={"messages": []},
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from typing import Any
|
|||
|
||||
import pytest
|
||||
|
||||
from app.tasks.chat.streaming.orchestration import StreamExecutionInput
|
||||
from app.tasks.chat.streaming.orchestration import StreamingContext
|
||||
from app.tasks.chat.streaming.orchestration.orchestrator import (
|
||||
stream_chat,
|
||||
stream_regenerate,
|
||||
|
|
@ -60,7 +60,7 @@ async def _collect(stream: Any) -> list[str]:
|
|||
return out
|
||||
|
||||
|
||||
async def test_stream_chat_uses_orchestration_input_path() -> None:
|
||||
async def test_stream_chat_uses_streaming_context_path() -> None:
|
||||
service = _StreamingService()
|
||||
agent = _Agent(
|
||||
[
|
||||
|
|
@ -73,7 +73,7 @@ async def test_stream_chat_uses_orchestration_input_path() -> None:
|
|||
user_query="ignored-here",
|
||||
search_space_id=1,
|
||||
chat_id=77,
|
||||
orchestration_input=StreamExecutionInput(
|
||||
streaming_context=StreamingContext(
|
||||
agent=agent,
|
||||
config={"configurable": {"thread_id": "thread-1"}},
|
||||
input_data={"messages": []},
|
||||
|
|
@ -90,7 +90,7 @@ async def test_stream_chat_uses_orchestration_input_path() -> None:
|
|||
]
|
||||
|
||||
|
||||
async def test_stream_resume_uses_orchestration_input_path() -> None:
|
||||
async def test_stream_resume_uses_streaming_context_path() -> None:
|
||||
service = _StreamingService()
|
||||
agent = _Agent([{"event": "on_chat_model_stream", "data": {"chunk": _Chunk("r")}}])
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ async def test_stream_resume_uses_orchestration_input_path() -> None:
|
|||
chat_id=9,
|
||||
search_space_id=1,
|
||||
decisions=[],
|
||||
orchestration_input=StreamExecutionInput(
|
||||
streaming_context=StreamingContext(
|
||||
agent=agent,
|
||||
config={"configurable": {"thread_id": "thread-r"}},
|
||||
input_data={"messages": []},
|
||||
|
|
@ -115,7 +115,7 @@ async def test_stream_resume_uses_orchestration_input_path() -> None:
|
|||
]
|
||||
|
||||
|
||||
async def test_stream_regenerate_uses_orchestration_input_path() -> None:
|
||||
async def test_stream_regenerate_uses_streaming_context_path() -> None:
|
||||
service = _StreamingService()
|
||||
agent = _Agent([{"event": "on_chat_model_stream", "data": {"chunk": _Chunk("g")}}])
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ async def test_stream_regenerate_uses_orchestration_input_path() -> None:
|
|||
user_query="q",
|
||||
search_space_id=1,
|
||||
chat_id=2,
|
||||
orchestration_input=StreamExecutionInput(
|
||||
streaming_context=StreamingContext(
|
||||
agent=agent,
|
||||
config={"configurable": {"thread_id": "thread-g"}},
|
||||
input_data={"messages": []},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue