feat: 增强规则资产管理与审计页面运行时调试
后端新增规则资产版本管理和规则文件 CRUD 接口,优化风险 规则生成模板执行和员工数据模型字段,知识库 RAG 增强本 地回退和文档提取能力,清理旧风险规则文件统一由生成引擎 管理,前端审计页面增加运行时调试面板和规则资产编辑交互, 补充单元测试覆盖。
This commit is contained in:
@@ -589,6 +589,66 @@ def test_semantic_ontology_service_covers_common_expense_scene_keywords(
|
||||
)
|
||||
|
||||
|
||||
def test_semantic_ontology_service_connects_expense_application_to_ontology() -> None:
|
||||
session_factory = build_session_factory()
|
||||
with session_factory() as db:
|
||||
result = SemanticOntologyService(db).parse(
|
||||
OntologyParseRequest(
|
||||
query="申请2026-06-01 ~ 2026-06-03去北京做客户现场验收,差旅预算18000元",
|
||||
user_id="pytest",
|
||||
context_json={
|
||||
"document_type": "expense_application",
|
||||
"application_stage": "pre_approval",
|
||||
"entry_source": "documents_application",
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
assert result.scenario == "expense"
|
||||
assert result.intent == "draft"
|
||||
assert any(
|
||||
item.type == "document_type" and item.normalized_value == "expense_application"
|
||||
for item in result.entities
|
||||
)
|
||||
assert any(
|
||||
item.type == "workflow_stage" and item.normalized_value == "pre_approval"
|
||||
for item in result.entities
|
||||
)
|
||||
assert any(
|
||||
item.field == "document_type" and item.value == "expense_application"
|
||||
for item in result.constraints
|
||||
)
|
||||
assert any(
|
||||
item.type == "expense_type" and item.normalized_value == "travel"
|
||||
for item in result.entities
|
||||
)
|
||||
|
||||
|
||||
def test_semantic_ontology_service_requires_attachment_for_meeting_application() -> None:
|
||||
session_factory = build_session_factory()
|
||||
with session_factory() as db:
|
||||
result = SemanticOntologyService(db).parse(
|
||||
OntologyParseRequest(
|
||||
query="发起会务申请,2026-06-01 ~ 2026-06-02上海产品发布会,预算32000元",
|
||||
user_id="pytest",
|
||||
context_json={
|
||||
"document_type": "expense_application",
|
||||
"application_stage": "pre_approval",
|
||||
"entry_source": "documents_application",
|
||||
"attachment_count": 0,
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
assert result.scenario == "expense"
|
||||
assert result.intent == "draft"
|
||||
assert any(
|
||||
item.type == "expense_type" and item.normalized_value == "meeting"
|
||||
for item in result.entities
|
||||
)
|
||||
assert "attachments" in result.missing_slots
|
||||
|
||||
|
||||
def test_semantic_ontology_service_uses_model_parse_when_available(monkeypatch) -> None:
|
||||
session_factory = build_session_factory()
|
||||
with session_factory() as db:
|
||||
|
||||
Reference in New Issue
Block a user