feat: 增强审核智能体页顶部上下文与提问模板

This commit is contained in:
2026-06-04 02:59:17 +08:00
parent 5fdcc31c74
commit a7cee4aa27
3 changed files with 85 additions and 0 deletions

View File

@@ -85,6 +85,8 @@ def detail(request, conversation_id: str):
active_node = "risk"
conversation.refresh_from_db()
workspace_summary = _build_workspace_summary(conversation, batch)
conversation_context = _build_conversation_context(conversation, batch, workspace_summary)
prompt_templates = _build_prompt_templates()
export_card = _build_export_card(result, conversation)
risk_card = _build_risk_card(result, conversation)
notify_card = _build_notify_card(result, conversation)
@@ -105,6 +107,8 @@ def detail(request, conversation_id: str):
"node_results": conversation.node_results,
"active_node": active_node,
"workspace_summary": workspace_summary,
"conversation_context": conversation_context,
"prompt_templates": prompt_templates,
"upload_form": upload_form,
"export_card": export_card,
"risk_card": risk_card,
@@ -246,6 +250,30 @@ def _build_workspace_summary(conversation: Conversation, batch: SubmissionBatch
}
def _build_conversation_context(
conversation: Conversation,
batch: SubmissionBatch | None,
workspace_summary: dict,
) -> dict:
return {
"batch_id": conversation.batch_id,
"product_name": conversation.product_name,
"workflow_type": batch.workflow_type if batch else "registration",
"task_status": conversation.task_status,
"highest_risk_level": workspace_summary.get("highest_risk_level", "-"),
"export_allowed": workspace_summary.get("export_allowed", "-"),
}
def _build_prompt_templates() -> list[str]:
return [
"请汇总当前资料包的章节点、页数和目录覆盖情况",
"请检查当前资料包缺失了哪些必交项和错放项",
"请抽取当前资料包的核心字段并标记低置信度项",
"请给出当前资料包的高风险项、责任人和整改建议",
]
def _build_export_card(result: AgentResult | None, conversation: Conversation) -> dict:
"""
统一组装 Word 导出能力卡上下文。

View File

@@ -16,6 +16,33 @@
{% endif %}
</section>
{% if conversation %}
<section class="grid-2">
<article class="panel">
<h2 class="section-title">顶部对话上下文</h2>
<p class="section-copy">进入会话后,先用当前批次、产品和风险状态快速建立审核上下文。</p>
<ul class="detail-list">
<li class="detail-item"><strong>批次编号</strong><div>{{ conversation_context.batch_id }}</div></li>
<li class="detail-item"><strong>产品名称</strong><div>{{ conversation_context.product_name|default:"未识别产品名称" }}</div></li>
<li class="detail-item"><strong>当前流程类型</strong><div>{{ conversation_context.workflow_type }}</div></li>
<li class="detail-item"><strong>当前审核阶段</strong><div>{{ conversation_context.task_status }}</div></li>
<li class="detail-item"><strong>当前最高风险等级</strong><div>{{ conversation_context.highest_risk_level }}</div></li>
<li class="detail-item"><strong>是否允许正式导出</strong><div>{{ conversation_context.export_allowed }}</div></li>
</ul>
</article>
<article class="panel">
<h2 class="section-title">推荐提问模板</h2>
<p class="section-copy">用这些提问模板快速进入目录汇总、完整性检查、字段抽取和风险分析。</p>
<div class="button-row">
{% for item in prompt_templates %}
<span class="pill pill-accent">{{ item }}</span>
{% endfor %}
</div>
</article>
</section>
{% endif %}
<section class="workspace-grid" style="grid-template-columns: 320px minmax(0, 1fr) 360px;">
<div class="stack">
<article class="panel">

View File

@@ -376,6 +376,36 @@ def test_chat_page_shows_upload_entry_and_dynamic_context_cards(client, db):
assert "飞书通知 / 待处理" in content
def test_chat_page_shows_top_context_and_recommended_prompts(client, db):
batch, conversation = _create_conversation_with_batch()
conversation.task_status = "processing"
conversation.node_results = [
{"label": "资料包导入", "status": "已完成"},
{"label": "目录汇总", "status": "已完成"},
{"label": "法规完整性检查", "status": "已完成"},
{"label": "字段抽取", "status": "已完成"},
{"label": "一致性核查", "status": "待复核"},
{"label": "风险预警", "status": "已阻断"},
{"label": "Word 回填导出", "status": "待复核"},
{"label": "飞书通知", "status": "待处理"},
]
conversation.save(update_fields=["task_status", "node_results", "updated_at"])
response = client.get(reverse("chat:detail", args=[conversation.conversation_id]))
content = response.content.decode("utf-8")
assert response.status_code == 200
assert "顶部对话上下文" in content
assert "当前流程类型" in content
assert "registration" in content
assert "当前审核阶段" in content
assert "processing" in content
assert "当前最高风险等级" in content
assert "推荐提问模板" in content
assert "请汇总当前资料包的章节点、页数和目录覆盖情况" in content
assert "请给出当前资料包的高风险项、责任人和整改建议" in content
def test_chat_page_blocks_formal_export_when_word_export_node_is_blocked(client, db):
batch, conversation = _create_conversation_with_batch()
conversation.node_results = [