feat: ai-first intent detection with keyword fallback
This commit is contained in:
24
tests/test_intent_analyzer.py
Normal file
24
tests/test_intent_analyzer.py
Normal 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()
|
||||
Reference in New Issue
Block a user