feat: 新增风险图谱算法与系统仪表盘及操作反馈体系
后端新增风险图谱算法模块、风险观察与反馈服务、规则 DSL 校验器和可解释性引擎,完善系统仪表盘和财务仪表盘统计, 优化 agent 运行和编排执行链路,清理旧开发文档,前端新增 系统趋势、负载热力图等多种仪表盘图表组件,完善操作反馈 对话框和工作台日期选择器,优化报销创建和审批详情交互, 补充单元测试覆盖。
This commit is contained in:
@@ -44,8 +44,10 @@ class AccountBehaviorProfileService(EmployeeBehaviorProfileMetricHelpers):
|
||||
empty_reason="当前账号未匹配员工目录,无法形成审批场景员工画像。",
|
||||
)
|
||||
|
||||
runs = self._fetch_account_runs(identifiers, datetime.now(UTC) - timedelta(days=window_days))
|
||||
if not runs:
|
||||
cutoff = datetime.now(UTC) - timedelta(days=window_days)
|
||||
runs = self._fetch_account_runs(identifiers, cutoff)
|
||||
usage_duration_metrics = self._resolve_usage_duration_metrics(identifiers, cutoff, runs)
|
||||
if not runs and not usage_duration_metrics["online_duration_ms"]:
|
||||
return EmployeeProfileLatestRead(
|
||||
employee_id=account_id,
|
||||
employee_name=account_name,
|
||||
@@ -57,6 +59,7 @@ class AccountBehaviorProfileService(EmployeeBehaviorProfileMetricHelpers):
|
||||
|
||||
result = self._calculate_account_ai_usage_profile(
|
||||
runs=runs,
|
||||
usage_duration_metrics=usage_duration_metrics,
|
||||
window_days=window_days,
|
||||
expense_type_scope=expense_type_scope,
|
||||
)
|
||||
@@ -100,6 +103,7 @@ class AccountBehaviorProfileService(EmployeeBehaviorProfileMetricHelpers):
|
||||
self,
|
||||
*,
|
||||
runs: list[AgentRun],
|
||||
usage_duration_metrics: dict[str, Any],
|
||||
window_days: int,
|
||||
expense_type_scope: str,
|
||||
):
|
||||
@@ -108,7 +112,6 @@ class AccountBehaviorProfileService(EmployeeBehaviorProfileMetricHelpers):
|
||||
tool for tool in tool_calls if str(tool.status or "").lower() not in {"success", "ok"}
|
||||
]
|
||||
estimated_tokens = self._estimate_tokens(runs)
|
||||
duration_ms = self._sum_agent_run_duration_ms(runs)
|
||||
token_mode = "estimated_token_count" if estimated_tokens else "unavailable"
|
||||
|
||||
return evaluate_weighted_profile(
|
||||
@@ -159,8 +162,7 @@ class AccountBehaviorProfileService(EmployeeBehaviorProfileMetricHelpers):
|
||||
"token_count_mode": token_mode,
|
||||
"estimated_token_count": estimated_tokens,
|
||||
"exact_token_count": None,
|
||||
"ai_run_duration_ms": duration_ms,
|
||||
"ai_run_duration_mode": "elapsed_or_tool_call_fallback",
|
||||
**usage_duration_metrics,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user