style: 统一审核智能体状态展示口径
This commit is contained in:
@@ -32,3 +32,15 @@ class Conversation(models.Model):
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.title
|
||||
|
||||
def get_task_status_display_text(self) -> str:
|
||||
"""返回会话阶段的中文展示文案。"""
|
||||
return {
|
||||
self.STATUS_PENDING: "处理中",
|
||||
self.STATUS_PROCESSING: "处理中",
|
||||
self.STATUS_COMPLETED: "已完成",
|
||||
self.STATUS_REVIEW_REQUIRED: "待复核",
|
||||
self.STATUS_BLOCKED: "已阻断",
|
||||
self.STATUS_FAILED: "失败",
|
||||
"success": "已完成",
|
||||
}.get(self.task_status, self.task_status)
|
||||
|
||||
@@ -15,6 +15,38 @@ from .export_service import generate_registration_export, update_conversation_wi
|
||||
from .forms import ChatForm, ConversationUploadForm
|
||||
from .models import Conversation
|
||||
|
||||
RISK_LEVEL_DISPLAY = {
|
||||
"high": "高",
|
||||
"medium": "中",
|
||||
"low": "低",
|
||||
}
|
||||
|
||||
PASS_STATUS_DISPLAY = {
|
||||
"blocked": "已阻断",
|
||||
"failed": "失败",
|
||||
"review_required": "待复核",
|
||||
"manual_review": "待复核",
|
||||
"completed": "已完成",
|
||||
"passed": "已完成",
|
||||
}
|
||||
|
||||
EXPORT_STATUS_DISPLAY = {
|
||||
"completed": "已完成",
|
||||
"draft_only": "待复核",
|
||||
"review_required": "待复核",
|
||||
"manual_review": "待复核",
|
||||
"blocked": "已阻断",
|
||||
"failed": "失败",
|
||||
"processing": "处理中",
|
||||
"pending": "处理中",
|
||||
}
|
||||
|
||||
NOTIFY_MESSAGE_STATUS_DISPLAY = {
|
||||
"sent": "已发送",
|
||||
"failed": "失败",
|
||||
"pending": "处理中",
|
||||
}
|
||||
|
||||
|
||||
def index(request):
|
||||
conversations = Conversation.objects.all()
|
||||
@@ -264,7 +296,7 @@ def _build_conversation_context(
|
||||
"batch_id": conversation.batch_id,
|
||||
"product_name": conversation.product_name,
|
||||
"workflow_type": batch.workflow_type if batch else "registration",
|
||||
"task_status": conversation.task_status,
|
||||
"task_status": conversation.get_task_status_display_text(),
|
||||
"highest_risk_level": workspace_summary.get("highest_risk_level", "-"),
|
||||
"export_allowed": workspace_summary.get("export_allowed", "-"),
|
||||
}
|
||||
@@ -327,7 +359,7 @@ def _build_analysis_card(result: AgentResult | None, conversation: Conversation)
|
||||
"kind": "completeness",
|
||||
"title": "完整性检查能力卡",
|
||||
"summary": structured_output.get("summary", ""),
|
||||
"stats": [{"label": "风险等级", "value": structured_output.get("risk_level", "-")}],
|
||||
"stats": [{"label": "风险等级", "value": _get_risk_level_display_text(structured_output.get("risk_level", "-"))}],
|
||||
"items": structured_output.get("missing_items") or [],
|
||||
"warnings": structured_output.get("misplaced_items") or [],
|
||||
}
|
||||
@@ -345,7 +377,7 @@ def _build_analysis_card(result: AgentResult | None, conversation: Conversation)
|
||||
"kind": "consistency",
|
||||
"title": "一致性核查能力卡",
|
||||
"summary": structured_output.get("summary", ""),
|
||||
"stats": [{"label": "风险等级", "value": structured_output.get("risk_level", "-")}],
|
||||
"stats": [{"label": "风险等级", "value": _get_risk_level_display_text(structured_output.get("risk_level", "-"))}],
|
||||
"items": structured_output.get("conflict_items") or [],
|
||||
"warnings": structured_output.get("mixed_document_risks") or [],
|
||||
}
|
||||
@@ -368,7 +400,7 @@ def _build_export_card(result: AgentResult | None, conversation: Conversation) -
|
||||
return {
|
||||
"template_name": structured_output.get("template_name", ""),
|
||||
"template_version": structured_output.get("template_version", ""),
|
||||
"export_status": structured_output.get("export_status", ""),
|
||||
"export_status": _get_export_status_display_text(structured_output.get("export_status", "")),
|
||||
"filled_fields": structured_output.get("filled_fields") or [],
|
||||
"blocked_fields": structured_output.get("blocked_fields") or [],
|
||||
"download_url": structured_output.get("download_url", ""),
|
||||
@@ -385,8 +417,10 @@ def _build_risk_card(result: AgentResult | None, conversation: Conversation) ->
|
||||
return {}
|
||||
return {
|
||||
"summary": structured_output.get("summary", ""),
|
||||
"highest_risk_level": structured_output.get("highest_risk_level", ""),
|
||||
"pass_status": structured_output.get("pass_status", ""),
|
||||
"highest_risk_level": _get_risk_level_display_text(
|
||||
structured_output.get("highest_risk_level", "")
|
||||
),
|
||||
"pass_status": _get_pass_status_display_text(structured_output.get("pass_status", "")),
|
||||
"manual_review_items": structured_output.get("manual_review_items") or [],
|
||||
"risk_items": structured_output.get("risk_items") or [],
|
||||
"owner_roles": structured_output.get("owner_roles") or [],
|
||||
@@ -418,12 +452,28 @@ def _build_notify_card(result: AgentResult | None, conversation: Conversation) -
|
||||
return {
|
||||
"notify_reason": notify_reason,
|
||||
"mentioned_users": mentioned_users,
|
||||
"message_status": message_status,
|
||||
"message_status": _get_notify_message_status_display_text(message_status),
|
||||
"web_detail_url": web_detail_url,
|
||||
"owners": owners,
|
||||
}
|
||||
|
||||
|
||||
def _get_risk_level_display_text(level: str) -> str:
|
||||
return RISK_LEVEL_DISPLAY.get(level, level)
|
||||
|
||||
|
||||
def _get_pass_status_display_text(status: str) -> str:
|
||||
return PASS_STATUS_DISPLAY.get(status, status)
|
||||
|
||||
|
||||
def _get_export_status_display_text(status: str) -> str:
|
||||
return EXPORT_STATUS_DISPLAY.get(status, status)
|
||||
|
||||
|
||||
def _get_notify_message_status_display_text(status: str) -> str:
|
||||
return NOTIFY_MESSAGE_STATUS_DISPLAY.get(status, status)
|
||||
|
||||
|
||||
def _apply_agent_result_to_conversation(conversation: Conversation, result: AgentResult) -> None:
|
||||
conversation.task_status = result.status
|
||||
if result.node_results:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<div class="badge-row">
|
||||
<span class="pill pill-accent">批次:{{ conversation.batch_id }}</span>
|
||||
<span class="pill">产品:{{ conversation.product_name|default:"未识别产品名称" }}</span>
|
||||
<span class="pill">阶段:{{ conversation.task_status }}</span>
|
||||
<span class="pill">阶段:{{ conversation_context.task_status }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
@@ -422,7 +422,7 @@ def test_chat_page_shows_top_context_and_recommended_prompts(client, db):
|
||||
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
|
||||
@@ -486,7 +486,7 @@ def test_chat_page_shows_consistency_card_from_conversation_summary(client, db):
|
||||
assert "一致性核查能力卡" in content
|
||||
assert "申请表与说明书不一致" in content
|
||||
assert "疑似混入其他产品资料" in content
|
||||
assert "high" in content
|
||||
assert "高" in content
|
||||
|
||||
|
||||
def test_chat_page_shows_completeness_card_from_conversation_summary(client, db):
|
||||
@@ -727,7 +727,9 @@ def test_chat_page_shows_risk_and_notification_cards_from_conversation_summary(c
|
||||
assert response.status_code == 200
|
||||
assert "风险预警能力卡" in content
|
||||
assert "总风险等级" in content
|
||||
assert "high" in content
|
||||
assert "高" in content
|
||||
assert "是否通过" in content
|
||||
assert "已阻断" in content
|
||||
assert "注册资料负责人" in content
|
||||
assert "注册事务部" in content
|
||||
assert "字段冲突" in content
|
||||
@@ -738,7 +740,7 @@ def test_chat_page_shows_risk_and_notification_cards_from_conversation_summary(c
|
||||
assert "CH1.11.5 沟通记录缺失" in content
|
||||
assert "飞书通知能力卡" in content
|
||||
assert "task_completed" in content
|
||||
assert "sent" in content
|
||||
assert "已发送" in content
|
||||
|
||||
|
||||
def test_chat_upload_keeps_existing_conversation_binding_and_adds_documents(client, db):
|
||||
|
||||
Reference in New Issue
Block a user