代码合并
This commit is contained in:
1 parent
b0970de677
commit
8859c13cfb
26 files changed
+1707
-334
No files matched your search
@@ -25,6 +25,40 @@ class _DisabledCfg:
|
||||
report_collaboration = ReportCollaborationConfig(enabled=False)
|
||||
|
||||
|
||||
class _PlannerFakeLLM:
|
||||
"""规划师假模型:需求确认回「读者」追问;工作流设计回单份定制方案。"""
|
||||
|
||||
_converse = (
|
||||
'{"reply": "好的。先确认:这份报告的主要读者是谁?", "action": "clarify",'
|
||||
'"questions": ["这份报告的主要读者是谁?"], "impact": ["读者影响研究线划分"],'
|
||||
'"requirement": {"topic": "新能源汽车趋势报告"}}'
|
||||
)
|
||||
_ready = (
|
||||
'{"reply": "明白了,读者为企业战略决策人员。我来设计工作流。", "action": "ready",'
|
||||
'"assumptions": [], "requirement": {"topic": "新能源汽车趋势报告", "audience": "企业战略决策人员"}}'
|
||||
)
|
||||
_design = (
|
||||
'{"reply": "已按需求设计定制工作流。", "strategy": "custom", "title": "定制方案",'
|
||||
'"summary": "研究后写作", "rationale": "贴合需求", "estimated_duration_seconds": 900,'
|
||||
'"estimated_cost_level": "low", "quality_gate_ids": ["cite_required"],'
|
||||
'"nodes": ['
|
||||
'{"slot_id": "research-1", "role_key": "researcher", "display_name": "研究员", "mission": "检索证据", "depends_on": [], "output_artifact_type": "EvidenceBundle"},'
|
||||
'{"slot_id": "write-1", "role_key": "writer", "display_name": "撰写员", "mission": "成稿", "depends_on": ["research-1"], "output_artifact_type": "ReportSectionDraft"}]}'
|
||||
)
|
||||
|
||||
async def ainvoke(self, messages):
|
||||
from types import SimpleNamespace
|
||||
|
||||
prompt = str(messages[-1][1]) if messages else ""
|
||||
if "请设计工作流" in prompt:
|
||||
payload = self._design
|
||||
elif "企业战略决策人员" in prompt or "读者" in prompt and "用户最新消息" in prompt:
|
||||
payload = self._ready
|
||||
else:
|
||||
payload = self._converse
|
||||
return SimpleNamespace(content=payload)
|
||||
|
||||
|
||||
def _client(monkeypatch: pytest.MonkeyPatch, *, enabled: bool = True, user: str | None = "user_a") -> tuple[TestClient, MemoryReportCollaborationStore]:
|
||||
monkeypatch.setattr(report_collaboration, "get_app_config", lambda: _Cfg() if enabled else _DisabledCfg())
|
||||
app = FastAPI()
|
||||
@@ -32,6 +66,7 @@ def _client(monkeypatch: pytest.MonkeyPatch, *, enabled: bool = True, user: str
|
||||
inner = MemoryReportCollaborationStore()
|
||||
store = PublishingReportCollaborationStore(inner, hub)
|
||||
app.state.report_collaboration_store = store
|
||||
app.state.report_collaboration_planner_llm = _PlannerFakeLLM
|
||||
app.state.report_collaboration_live_hub = hub
|
||||
app.state.report_collaboration_sse_settings = SseStreamSettings(
|
||||
deadline_seconds=0.6,
|
||||
@@ -126,14 +161,14 @@ def test_session_message_plan_run_http(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
proposed_body = proposed.json()
|
||||
assert proposed_body["session"]["status"] == "proposal_ready"
|
||||
plans = proposed_body["plans"]
|
||||
assert {item["strategy"] for item in plans} == {"balanced_review", "parallel_depth", "focused_fast"}
|
||||
assert {item["strategy"] for item in plans} == {"custom"}
|
||||
plan = next(item for item in plans if item.get("recommended"))
|
||||
assert plan["validation"]["ok"] is True
|
||||
assert all(node.get("output_artifact_type") and node.get("acceptance_criteria") for node in plan["nodes"])
|
||||
|
||||
listed = client.get(f"/api/report-collaboration/sessions/{session_id}/plans")
|
||||
assert listed.status_code == 200
|
||||
assert len(listed.json()["plans"]) == 3
|
||||
assert len(listed.json()["plans"]) == 1
|
||||
|
||||
selected = client.post(
|
||||
f"/api/report-collaboration/sessions/{session_id}/plans/{plan['id']}/select",
|
||||
|
||||
Reference in new issue
Block a user