feat: 集成Hermes智能体系统,增强聊天和差旅报销功能
This commit is contained in:
@@ -258,19 +258,57 @@ def test_semantic_ontology_service_extracts_entities_time_and_constraints() -> N
|
||||
assert result.intent == "query"
|
||||
assert result.time_range.start_date == "2026-04-01"
|
||||
assert result.time_range.end_date == "2026-04-30"
|
||||
assert any(
|
||||
item.type == "employee" and item.normalized_value == "张三"
|
||||
for item in result.entities
|
||||
|
||||
|
||||
def test_semantic_ontology_service_treats_travel_amount_question_as_knowledge_query() -> None:
|
||||
session_factory = build_session_factory()
|
||||
with session_factory() as db:
|
||||
result = SemanticOntologyService(db).parse(
|
||||
OntologyParseRequest(
|
||||
query="我要去武汉出差3天,请问我一共可以报销多少费用?",
|
||||
user_id="pytest",
|
||||
context_json={
|
||||
"role_codes": ["employee"],
|
||||
"name": "曹笑竹",
|
||||
"grade": "P3",
|
||||
"session_type": "knowledge",
|
||||
},
|
||||
)
|
||||
)
|
||||
assert any(
|
||||
item.type == "expense_type" and item.normalized_value == "travel"
|
||||
for item in result.entities
|
||||
)
|
||||
assert any(
|
||||
item.field == "amount" and item.operator == ">" and item.value == 5000
|
||||
for item in result.constraints
|
||||
|
||||
assert result.scenario == "knowledge"
|
||||
assert result.intent == "query"
|
||||
assert result.clarification_required is False
|
||||
assert result.clarification_question is None
|
||||
assert result.missing_slots == []
|
||||
|
||||
|
||||
def test_semantic_ontology_service_keeps_travel_amount_follow_up_in_knowledge_query() -> None:
|
||||
session_factory = build_session_factory()
|
||||
with session_factory() as db:
|
||||
result = SemanticOntologyService(db).parse(
|
||||
OntologyParseRequest(
|
||||
query="那P4员工可以报销多少钱?",
|
||||
user_id="pytest",
|
||||
context_json={
|
||||
"role_codes": ["employee"],
|
||||
"name": "曹笑竹",
|
||||
"grade": "P3",
|
||||
"session_type": "knowledge",
|
||||
"conversation_history": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "我要去武汉出差3天,请问我一共可以报销多少费用?",
|
||||
}
|
||||
],
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
assert result.scenario == "knowledge"
|
||||
assert result.intent == "query"
|
||||
assert result.clarification_required is False
|
||||
|
||||
|
||||
def test_semantic_ontology_service_prefers_expense_for_customer_entertainment_narrative() -> None:
|
||||
session_factory = build_session_factory()
|
||||
|
||||
Reference in New Issue
Block a user