fix(ai): recognize conversational document filters
This commit is contained in:
@@ -83,6 +83,13 @@ ENGLISH_FINANCE_BUSINESS_KEYWORDS = (
|
||||
|
||||
|
||||
class OntologyDetectionMixin:
|
||||
@staticmethod
|
||||
def _has_document_query_signal(compact_query: str) -> bool:
|
||||
return "单据" in compact_query and (
|
||||
any(keyword in compact_query for keyword in QUERY_KEYWORDS)
|
||||
or any(keyword in compact_query for keyword in STATUS_KEYWORDS)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _is_expense_application_context(context_json: dict[str, Any]) -> bool:
|
||||
document_type = str(context_json.get("document_type") or "").strip()
|
||||
@@ -141,9 +148,7 @@ class OntologyDetectionMixin:
|
||||
)
|
||||
):
|
||||
return True
|
||||
if "单据" in compact_query and (
|
||||
"状态" in compact_query or any(keyword in compact_query for keyword in STATUS_KEYWORDS)
|
||||
):
|
||||
if self._has_document_query_signal(compact_query):
|
||||
return True
|
||||
if any(keyword in compact_query for keyword in EXPENSE_NARRATIVE_KEYWORDS):
|
||||
return True
|
||||
@@ -224,9 +229,7 @@ class OntologyDetectionMixin:
|
||||
best_scenario = "budget"
|
||||
best_score = scores["budget"]
|
||||
if best_score <= 0:
|
||||
if "单据" in compact_query and any(
|
||||
keyword in compact_query for keyword in STATUS_KEYWORDS
|
||||
):
|
||||
if self._has_document_query_signal(compact_query):
|
||||
return "expense", 0.14
|
||||
return "unknown", 0.0
|
||||
|
||||
@@ -539,7 +542,7 @@ class OntologyDetectionMixin:
|
||||
"出现“客户”不等于应收,出现“供应商”不等于应付,必须结合动作词和业务目标判断。"
|
||||
"预算编制、预算金额、成本中心、预算科目、预算预警、预算占用、"
|
||||
"剩余预算、可用预算、超预算、预算不足等问题必须使用 budget 场景。"
|
||||
"只有明确查询、统计、列出、多少、明细、对比时才优先使用 query 或 compare。"
|
||||
"只有明确查询、筛选、过滤、统计、列出、多少、明细、对比时才优先使用 query 或 compare。"
|
||||
"附件名称和 OCR 摘要只作为辅助证据,不能编造未出现的事实。"
|
||||
"如果用户明确提到打车、的士票、出租车票、网约车、乘车费、车费等交通票据,"
|
||||
"即使句子里出现“客户”,也必须优先识别为 transport,不要推断为 entertainment。"
|
||||
|
||||
@@ -36,6 +36,7 @@ SCENARIO_KEYWORDS = {
|
||||
("单据报销", 0.18),
|
||||
("报账", 0.20),
|
||||
("差旅", 0.20),
|
||||
("出差", 0.20),
|
||||
("费用", 0.14),
|
||||
("发票", 0.14),
|
||||
("票据", 0.12),
|
||||
@@ -99,6 +100,8 @@ QUERY_KEYWORDS = (
|
||||
"查",
|
||||
"查询",
|
||||
"查看",
|
||||
"筛选",
|
||||
"过滤",
|
||||
"列出",
|
||||
"统计",
|
||||
"汇总",
|
||||
@@ -158,6 +161,7 @@ EXPENSE_TYPE_KEYWORDS = build_expense_type_keyword_map()
|
||||
EXPENSE_NARRATIVE_KEYWORDS = (
|
||||
"报销",
|
||||
"报账",
|
||||
"出差",
|
||||
"招待",
|
||||
"招待费",
|
||||
"花销",
|
||||
|
||||
Reference in New Issue
Block a user