From becf76ecd9e118bf129309e4892569d6336b0acd Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 16 Sep 2026 16:15:17 +0800 Subject: [PATCH] =?UTF-8?q?feat(bioflow):=20=E5=88=86=E6=9E=90=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E8=A7=84=E5=88=92=E4=B8=AD=E6=8F=90=E7=A4=BA=E2=80=94?= =?UTF-8?q?=E2=80=94planning=20=E5=B8=A7+=E5=89=8D=E7=AB=AF=E6=80=9D?= =?UTF-8?q?=E8=80=83=E4=B8=AD=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 后端 chat 流在规划开始前发 planning 帧(seq=-2,与 plan_ready 同机制) - 前端收到 planning 帧立即创建 bioflow_path 块(status=running, 脉动圆点+「正在分析需求并规划分析路径…」),plan_ready 填入候选并关闭 - bioflow store 增加 planning/planningText 状态 - 339 后端用例 + 121 r3debug + 373 主套件全绿;已部署 176 Co-Authored-By: Claude Fable 5 --- bioflow_service/app/routers/bioflow.py | 4 ++++ bioflow_service/tests/test_api.py | 6 +++--- ui/src/components/chat/FlowPathCard.vue | 26 ++++++++++++++++++++++++- ui/src/i18n/bioflow.js | 1 + ui/src/stores/bioflow.js | 10 ++++++++++ ui/src/stores/chat.js | 15 ++++++++++++++ 6 files changed, 58 insertions(+), 4 deletions(-) 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 });