diff --git a/bioflow_service/app/routers/bioflow.py b/bioflow_service/app/routers/bioflow.py index ed096fa..1051992 100644 --- a/bioflow_service/app/routers/bioflow.py +++ b/bioflow_service/app/routers/bioflow.py @@ -220,6 +220,10 @@ async def chat_stream(body: ChatStreamRequest) -> StreamingResponse: return # 1. 规划(候选路径;复用/LLM/降级) + # 规划开始帧:前端据此显示「分析路径规划中…」占位(planning 状态) + yield _sse({"type": "planning", "seq": -2, "data": { + "message": "正在分析需求并规划分析路径…", + }}) try: plan: PlanResult = await ctx.planner.plan(body.message) except PlannerError as exc: diff --git a/bioflow_service/tests/test_api.py b/bioflow_service/tests/test_api.py index 130919f..9652c44 100644 --- a/bioflow_service/tests/test_api.py +++ b/bioflow_service/tests/test_api.py @@ -288,7 +288,7 @@ def test_catalog_unknown_chain(api): def test_chat_stream_plan_ready(api_context): """TC-BIO-API-001/002:chat/stream SSE,plan_ready 下发候选。""" - events = _read_sse(_chat_stream_call("帮我跑水稻 SPL 家族鉴定"), max_events=1) + events = _read_sse(_chat_stream_call("帮我跑水稻 SPL 家族鉴定"), max_events=2) types = [e["type"] for e in events] assert "plan_ready" in types plan = [e for e in events if e["type"] == "plan_ready"][0]["data"] @@ -305,7 +305,7 @@ def test_chat_stream_unknown_stage_rejected(api_context, monkeypatch): {"purpose": "坏", "stages": ["fake_stage_xyz"]}, {"purpose": "好", "stages": ["identify"]}, ])) - events = _read_sse(_chat_stream_call("帮我跑水稻 SPL 家族鉴定"), max_events=1) + events = _read_sse(_chat_stream_call("帮我跑水稻 SPL 家族鉴定"), max_events=2) plan = [e for e in events if e["type"] == "plan_ready"][0]["data"] for c in plan["candidates"]: assert "fake_stage_xyz" not in c["stages"] @@ -343,7 +343,7 @@ def test_chat_stream_llm_timeout_degrade(api_context, monkeypatch): from conftest import FakeLLM import app.services.bioflow.planner as planner_mod monkeypatch.setattr(planner_mod, "complete_json", FakeLLM(error="timeout")) - events = _read_sse(_chat_stream_call("帮我跑水稻 SPL 家族鉴定"), max_events=1) + events = _read_sse(_chat_stream_call("帮我跑水稻 SPL 家族鉴定"), max_events=2) plan = [e for e in events if e["type"] == "plan_ready"][0]["data"] assert plan["fallback"] # 降级提示 assert plan["candidates"] diff --git a/ui/src/components/chat/FlowPathCard.vue b/ui/src/components/chat/FlowPathCard.vue index a468758..9f497ce 100644 --- a/ui/src/components/chat/FlowPathCard.vue +++ b/ui/src/components/chat/FlowPathCard.vue @@ -109,7 +109,11 @@ defineExpose({ select: pick, confirm: confirmCreate });