62 lines
1.8 KiB
Python
Executable File
62 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""测试 RouterAgent 意图识别"""
|
|
import sys
|
|
sys.path.insert(0, '/home/xia-lab/wutx/00test/bbav5')
|
|
|
|
from gfa_core.mas.agents.router import RouterAgent, QueryMode
|
|
|
|
# 模拟 RouterAgent 的分类逻辑
|
|
def classify(text):
|
|
has_data = any(kw in text for kw in ["文件", "数据", ".fasta", ".gff"])
|
|
|
|
# 优先检查 FAQ 关键词
|
|
if any(kw in text for kw in RouterAgent.FAQ_KEYWORDS):
|
|
if has_data and any(kw in text for kw in ["鉴定", "分析", "构建"]):
|
|
return "ANALYSIS"
|
|
return "FAQ"
|
|
|
|
# 检查解释/解读类
|
|
if any(kw in text for kw in RouterAgent.INTERPRETATION_KEYWORDS):
|
|
return "INTERPRETATION"
|
|
|
|
# 检查咨询类
|
|
if any(kw in text for kw in RouterAgent.CONSULTATION_KEYWORDS):
|
|
return "CONSULTATION"
|
|
|
|
# 检查分析类
|
|
if has_data or any(kw in text for kw in RouterAgent.ANALYSIS_KEYWORDS):
|
|
return "ANALYSIS"
|
|
|
|
return "FAQ"
|
|
|
|
# 测试用例
|
|
test_cases = [
|
|
("什么是SPL基因家族", "FAQ"),
|
|
("帮我解释下什么是SPL", "FAQ"),
|
|
("解释SPL基因家族的功能", "FAQ"),
|
|
("SPL基因家族有什么作用", "FAQ"),
|
|
("帮我鉴定 Ft.SPL 基因家族", "ANALYSIS"),
|
|
("分析SPL基因家族", "ANALYSIS"),
|
|
]
|
|
|
|
print("RouterAgent 意图识别测试")
|
|
print("=" * 50)
|
|
print(f"FAQ_KEYWORDS: {RouterAgent.FAQ_KEYWORDS}")
|
|
print(f"INTERPRETATION_KEYWORDS: {RouterAgent.INTERPRETATION_KEYWORDS}")
|
|
print(f"ANALYSIS_KEYWORDS: {RouterAgent.ANALYSIS_KEYWORDS}")
|
|
print("=" * 50)
|
|
|
|
all_pass = True
|
|
for text, expected in test_cases:
|
|
result = classify(text)
|
|
status = "✅" if result == expected else "❌"
|
|
if result != expected:
|
|
all_pass = False
|
|
print(f"{status} '{text}' -> {result} (期望: {expected})")
|
|
|
|
print("=" * 50)
|
|
if all_pass:
|
|
print("✅ 所有测试通过!")
|
|
else:
|
|
print("❌ 有测试失败")
|