style: 统一飞书通知节点状态语义
This commit is contained in:
@@ -117,7 +117,8 @@ def detail(request, conversation_id: str):
|
||||
)
|
||||
active_node = "risk"
|
||||
conversation.refresh_from_db()
|
||||
workspace_summary = _build_workspace_summary(conversation, batch)
|
||||
display_node_results = _normalize_node_results(conversation.node_results)
|
||||
workspace_summary = _build_workspace_summary(conversation, batch, display_node_results)
|
||||
conversation_context = _build_conversation_context(conversation, batch, workspace_summary)
|
||||
prompt_templates = _build_prompt_templates()
|
||||
analysis_card = _build_analysis_card(result, conversation)
|
||||
@@ -140,7 +141,7 @@ def detail(request, conversation_id: str):
|
||||
"result": result,
|
||||
"audit_log": audit_log,
|
||||
"task_modes": task_modes,
|
||||
"node_results": conversation.node_results,
|
||||
"node_results": display_node_results,
|
||||
"active_node": active_node,
|
||||
"workspace_summary": workspace_summary,
|
||||
"conversation_context": conversation_context,
|
||||
@@ -258,8 +259,13 @@ def _persist_notification_records(result: AgentResult, *, web_detail_url: str =
|
||||
)
|
||||
|
||||
|
||||
def _build_workspace_summary(conversation: Conversation, batch: SubmissionBatch | None) -> dict:
|
||||
node_status_map = {node.get("label"): node.get("status", "") for node in conversation.node_results}
|
||||
def _build_workspace_summary(
|
||||
conversation: Conversation,
|
||||
batch: SubmissionBatch | None,
|
||||
display_node_results: list[dict] | None = None,
|
||||
) -> dict:
|
||||
normalized_nodes = display_node_results or _normalize_node_results(conversation.node_results)
|
||||
node_status_map = {node.get("label"): node.get("status", "") for node in normalized_nodes}
|
||||
risk_status = node_status_map.get("风险预警", "待处理")
|
||||
notify_status = node_status_map.get("飞书通知", "待处理")
|
||||
export_status = node_status_map.get("Word 回填导出", "待处理")
|
||||
@@ -458,6 +464,23 @@ def _build_notify_card(result: AgentResult | None, conversation: Conversation) -
|
||||
}
|
||||
|
||||
|
||||
def _normalize_node_results(node_results: list[dict]) -> list[dict]:
|
||||
normalized = []
|
||||
for node in node_results or []:
|
||||
item = dict(node)
|
||||
label = item.get("label", "")
|
||||
status = item.get("status", "")
|
||||
if label == "飞书通知":
|
||||
if status in {"已完成", "success", "sent"}:
|
||||
item["status"] = "已发送"
|
||||
elif status in {"failed", "error"}:
|
||||
item["status"] = "失败"
|
||||
elif status in {"pending", "processing"}:
|
||||
item["status"] = "待处理"
|
||||
normalized.append(item)
|
||||
return normalized
|
||||
|
||||
|
||||
def _get_risk_level_display_text(level: str) -> str:
|
||||
return RISK_LEVEL_DISPLAY.get(level, level)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user