后端新增风险图谱算法模块、风险观察与反馈服务、规则 DSL 校验器和可解释性引擎,完善系统仪表盘和财务仪表盘统计, 优化 agent 运行和编排执行链路,清理旧开发文档,前端新增 系统趋势、负载热力图等多种仪表盘图表组件,完善操作反馈 对话框和工作台日期选择器,优化报销创建和审批详情交互, 补充单元测试覆盖。
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from copy import deepcopy
|
|
from typing import Any
|
|
|
|
from app.services.risk_rule_generation_interpreter import build_dsl_from_semantic_plan
|
|
|
|
|
|
DSL_PAYLOAD_KEYS = ("dsl", "json_dsl", "rule_dsl", "rule")
|
|
|
|
|
|
def unwrap_semantic_plan_payload(payload: dict[str, Any]) -> dict[str, Any]:
|
|
"""兼容旧版扁平 JSON 与新版 semantic_plan + DSL 包装结构。"""
|
|
|
|
if not isinstance(payload, dict):
|
|
return {}
|
|
semantic_plan = payload.get("semantic_plan")
|
|
semantic_plan = semantic_plan if isinstance(semantic_plan, dict) else {}
|
|
dsl = next((payload.get(key) for key in DSL_PAYLOAD_KEYS if isinstance(payload.get(key), dict)), None)
|
|
if not isinstance(dsl, dict):
|
|
result = build_dsl_from_semantic_plan(semantic_plan) or deepcopy(payload)
|
|
if semantic_plan:
|
|
result["model_semantic_plan"] = semantic_plan
|
|
return result
|
|
|
|
result = deepcopy(dsl)
|
|
if semantic_plan:
|
|
result["model_semantic_plan"] = semantic_plan
|
|
for key in ("name", "description", "flow", "risk_scoring_evidence", "unsupported_fields"):
|
|
if key not in result and key in payload:
|
|
result[key] = deepcopy(payload[key])
|
|
return result
|