feat: ai-first intent detection with keyword fallback

This commit is contained in:
2026-03-01 17:09:05 +08:00
parent 4a07f9c726
commit 00c80c3bec
5 changed files with 117 additions and 24 deletions

View File

@@ -0,0 +1,24 @@
import unittest
from utils.intent_analyzer import detect_intent
class IntentAnalyzerTests(unittest.TestCase):
def test_keyword_fallback_for_price(self):
d = detect_intent("这个怎么收费")
self.assertEqual(d.intent, "询价")
self.assertEqual(d.source, "keyword")
def test_keyword_fallback_for_greeting(self):
d = detect_intent("你好 在吗")
self.assertEqual(d.intent, "打招呼")
self.assertEqual(d.source, "keyword")
def test_unknown_intent(self):
d = detect_intent("abc123")
self.assertEqual(d.intent, "")
self.assertIn(d.source, ("none", ""))
if __name__ == "__main__":
unittest.main()