feat: 多专业小模型+路由模型系统 MVP(mock 全链路 + FastAPI 网关 + 论文调研)

This commit is contained in:
tzt
2026-08-12 10:40:04 +08:00
commit 1e51167ea5
50 changed files with 49382 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
"""分类器单元测试。"""
from router_system.classifier import RuleClassifier
def test_code_classification():
clf = RuleClassifier()
r = clf.classify("用 Python 写一个快速排序函数")
assert r.domain == "code"
assert r.confidence > 0.7
def test_math_classification():
clf = RuleClassifier()
r = clf.classify("求解方程 x^2 - 5x + 6 = 0")
assert r.domain == "math"
assert r.confidence > 0.7
def test_legal_classification():
clf = RuleClassifier()
r = clf.classify("劳动合同到期不续签需要支付经济补偿吗")
assert r.domain == "legal"
def test_medical_classification():
clf = RuleClassifier()
r = clf.classify("高血压患者日常饮食需要注意什么")
assert r.domain == "medical"
def test_general_low_confidence():
clf = RuleClassifier()
r = clf.classify("今天天气怎么样")
# 未命中任何领域 -> 低置信度,触发 should_fallback
assert r.domain == "general"
assert clf.should_fallback(r, 0.6) is True
def test_difficulty_estimation():
clf = RuleClassifier()
easy = clf.classify("1 + 1 = ?")
hard = clf.classify("证明费马大定理并推导其推论,给出详细步骤")
assert hard.difficulty in ("medium", "hard")
assert easy.difficulty == "easy"