feat: migrate chat orchestration to deep langgraph workers

This commit is contained in:
2026-03-12 22:25:36 +01:00
parent 2de67213f8
commit fe085a7951
27 changed files with 716 additions and 3590 deletions

View File

@@ -9,7 +9,6 @@ from app.schemas import (
WsFloatingDomain,
WsFloatingRequest,
WsFloatingScope,
WsStreamBlock,
WsStreamEnd,
WsStreamStart,
WsStreamText,
@@ -25,7 +24,6 @@ def test_v3_frame_types_exist():
"floating_request",
"stream_start",
"stream_text",
"stream_block",
"stream_end",
"floating_domain",
"data_request",
@@ -174,89 +172,21 @@ def test_stream_text_deserializes():
assert frame.chunk == "test"
# ── WsStreamBlock ─────────────────────────────────────────────────────
def test_stream_block_chart():
data = {
"type": "chart",
"chartType": "bar",
"title": "Tasks",
"data": [{"name": "Done", "count": 5}],
"config": {"count": {"label": "Count", "color": "#4f46e5"}},
}
frame = WsStreamBlock(request_id="r1", block_type="chart", data=data)
assert frame.type == WsFrameType.stream_block
assert frame.block_type == "chart"
assert frame.data["chartType"] == "bar"
def test_stream_block_entity_ref():
frame = WsStreamBlock(
request_id="r1",
block_type="entity_ref",
data={"type": "task", "id": "t-1", "title": "Fix bug"},
)
assert frame.block_type == "entity_ref"
def test_stream_block_table():
frame = WsStreamBlock(
request_id="r1",
block_type="table",
data={"headers": ["A", "B"], "rows": [["1", "2"]]},
)
assert frame.block_type == "table"
def test_stream_block_timeline():
frame = WsStreamBlock(
request_id="r1",
block_type="timeline",
data={"timelines": [{"id": "c1", "title": "Launch", "date": 1700000000}]},
)
assert frame.block_type == "timeline"
def test_stream_block_invalid_type():
with pytest.raises(ValidationError):
WsStreamBlock(
request_id="r1",
block_type="unknown", # type: ignore[arg-type]
data={},
)
def test_stream_block_serializes():
frame = WsStreamBlock(request_id="r1", block_type="table", data={"headers": [], "rows": []})
d = frame.model_dump()
assert d["type"] == "stream_block"
assert d["block_type"] == "table"
# ── WsStreamEnd ───────────────────────────────────────────────────────
def test_stream_end_defaults():
frame = WsStreamEnd(request_id="r1")
assert frame.type == WsFrameType.stream_end
assert frame.mutations == []
def test_stream_end_with_mutations():
mutations = [{"action": "create", "table": "tasks", "data": {"title": "New task"}}]
frame = WsStreamEnd(request_id="r1", mutations=mutations)
assert len(frame.mutations) == 1
assert frame.mutations[0]["action"] == "create"
def test_stream_end_serializes():
data = WsStreamEnd(request_id="r2").model_dump()
assert data == {"type": "stream_end", "request_id": "r2", "mutations": []}
assert data == {"type": "stream_end", "request_id": "r2"}
def test_stream_end_deserializes():
raw = {"type": "stream_end", "request_id": "r3", "mutations": []}
raw = {"type": "stream_end", "request_id": "r3"}
frame = WsStreamEnd.model_validate(raw)
assert frame.request_id == "r3"