feat: 新增风险规则生成引擎与知识图谱可视化

后端新增风险规则自动生成和模板执行服务,支持从规则资产
批量生成并持久化风险规则文件;知识库入库日志增强图谱
查询和本地 RAG 回退,前端审计页面增加风险规则模型和流
程图组件,知识入库面板拆分为图谱可视化子组件,报销创
建页面增加引导式流程模型,更新知识库索引数据。
This commit is contained in:
caoxiaozhu
2026-05-23 19:54:42 +08:00
parent 5b388d08c0
commit 575f093c74
63 changed files with 35497 additions and 1517 deletions

View File

@@ -6,12 +6,14 @@ from typing import Any
from sqlalchemy.orm import Session
from app.core.config import get_settings
from app.core.agent_enums import AgentName, AgentPermissionLevel, AgentRunStatus
from app.core.logging import get_logger
from app.models.agent_run import AgentRun, AgentToolCall, SemanticParseLog
from app.repositories.agent_run import AgentRunRepository
from app.schemas.agent_run import AgentRunRead, AgentToolCallRead, SemanticParseRead
from app.services.agent_foundation import AgentFoundationService
from app.services.knowledge_ingest_log import enrich_knowledge_ingest_route_json
logger = get_logger("app.services.agent_runs")
@@ -42,7 +44,7 @@ class AgentRunService:
run = self.repository.get_by_run_id(run_id)
if run is None:
return None
return self._serialize_run(run)
return self._serialize_run(run, enrich_knowledge_ingest=True)
def create_run(
self,
@@ -314,9 +316,19 @@ class AgentRunService:
except ValueError:
return None
@staticmethod
def _serialize_run(run: AgentRun) -> AgentRunRead:
def _serialize_run(
self,
run: AgentRun,
*,
enrich_knowledge_ingest: bool = False,
) -> AgentRunRead:
semantic_parse = run.semantic_parse_logs[0] if run.semantic_parse_logs else None
route_json = run.route_json
if enrich_knowledge_ingest:
route_json = enrich_knowledge_ingest_route_json(
dict(run.route_json or {}),
storage_root=get_settings().resolved_storage_root_dir,
)
return AgentRunRead(
id=run.id,
run_id=run.run_id,
@@ -325,7 +337,7 @@ class AgentRunService:
user_id=run.user_id,
task_id=run.task_id,
ontology_json=run.ontology_json,
route_json=run.route_json,
route_json=route_json,
permission_level=run.permission_level,
status=run.status,
result_summary=run.result_summary,