feat: 增强规则资产管理与审计页面运行时调试
后端新增规则资产版本管理和规则文件 CRUD 接口,优化风险 规则生成模板执行和员工数据模型字段,知识库 RAG 增强本 地回退和文档提取能力,清理旧风险规则文件统一由生成引擎 管理,前端审计页面增加运行时调试面板和规则资产编辑交互, 补充单元测试覆盖。
This commit is contained in:
@@ -20,6 +20,8 @@ from app.services.ontology_rules import (
|
||||
COMPARE_KEYWORDS,
|
||||
DRAFT_FOLLOW_UP_KEYWORDS,
|
||||
DRAFT_KEYWORDS,
|
||||
EXPENSE_APPLICATION_CONTEXT_TYPES,
|
||||
EXPENSE_APPLICATION_KEYWORDS,
|
||||
EXPENSE_NARRATIVE_KEYWORDS,
|
||||
EXPENSE_REVIEW_ACTIONS,
|
||||
EXPLAIN_KEYWORDS,
|
||||
@@ -71,6 +73,21 @@ EXPLICIT_ENTERTAINMENT_KEYWORDS = (
|
||||
|
||||
|
||||
class OntologyDetectionMixin:
|
||||
@staticmethod
|
||||
def _is_expense_application_context(context_json: dict[str, Any]) -> bool:
|
||||
document_type = str(context_json.get("document_type") or "").strip()
|
||||
application_stage = str(context_json.get("application_stage") or "").strip()
|
||||
entry_source = str(context_json.get("entry_source") or "").strip()
|
||||
return (
|
||||
document_type in EXPENSE_APPLICATION_CONTEXT_TYPES
|
||||
or application_stage in EXPENSE_APPLICATION_CONTEXT_TYPES
|
||||
or entry_source in {"documents_application", "expense_application"}
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _looks_like_expense_application(compact_query: str) -> bool:
|
||||
return any(keyword in compact_query for keyword in EXPENSE_APPLICATION_KEYWORDS)
|
||||
|
||||
def _detect_scenario(self, compact_query: str) -> tuple[str, float]:
|
||||
scores = {key: 0.0 for key in SCENARIO_KEYWORDS}
|
||||
for scenario, keywords in SCENARIO_KEYWORDS.items():
|
||||
@@ -341,6 +358,9 @@ class OntologyDetectionMixin:
|
||||
"conversation_id": payload.context_json.get("conversation_id"),
|
||||
"conversation_scenario": payload.context_json.get("conversation_scenario"),
|
||||
"conversation_intent": payload.context_json.get("conversation_intent"),
|
||||
"document_type": payload.context_json.get("document_type"),
|
||||
"application_stage": payload.context_json.get("application_stage"),
|
||||
"application_fields": payload.context_json.get("application_fields"),
|
||||
"draft_claim_id": payload.context_json.get("draft_claim_id"),
|
||||
"review_action": payload.context_json.get("review_action"),
|
||||
"review_form_values": payload.context_json.get("review_form_values"),
|
||||
|
||||
Reference in New Issue
Block a user