feat: 添加线索引擎、NLQ、场景检测、前端界面等核心功能模块
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
"""NLQ 结构化检索集成测试(需 PostgreSQL)。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.engines import scan
|
||||
from app.nlq import service as nlq
|
||||
from app.scenarios.split_contract import ContractRecord
|
||||
|
||||
|
||||
def _seed(session):
|
||||
contracts = [ContractRecord(f"C{i}", f"CUST{i}", 850000) for i in range(8)]
|
||||
scan.run_split_contract_scan(
|
||||
session, contracts, approval_threshold=1_000_000, shared_controller=True
|
||||
)
|
||||
session.flush()
|
||||
|
||||
|
||||
def test_nlq_retrieves_split_clues(session):
|
||||
_seed(session)
|
||||
ans = nlq.ask("列出高置信的政企拆单线索", session=session)
|
||||
assert ans.provider == "datahub"
|
||||
assert ans.egress is False
|
||||
assert "政企拆单" in ans.answer
|
||||
assert "共检索到" in ans.answer
|
||||
|
||||
|
||||
def test_nlq_no_match(session):
|
||||
ans = nlq.ask("列出养卡骗补线索", session=session)
|
||||
assert ans.egress is False
|
||||
assert "未检索到" in ans.answer or "共检索到" in ans.answer
|
||||
|
||||
|
||||
def test_nlq_open_question_falls_back_to_llm(session):
|
||||
# 不含检索关键词 → 走 LLM(mock)
|
||||
ans = nlq.ask("你好,请介绍一下你的能力", session=session)
|
||||
assert ans.provider in ("mock", "datahub")
|
||||
assert ans.egress is False
|
||||
Reference in New Issue
Block a user