feat: ai-first intent detection with keyword fallback
This commit is contained in:
@@ -210,15 +210,16 @@ def get_conversation_context(customer_id: str, acc_id: str = "", limit: int = 12
|
||||
def get_intent_emotion_hint(msg: str) -> str:
|
||||
"""语义匹配:意图/情绪识别,注入提示。EMBEDDING_MODEL 未配置时用关键词。"""
|
||||
try:
|
||||
from utils.intent_analyzer import detect_emotion_embedding, detect_intent_embedding, detect_intent_keywords
|
||||
from utils.intent_analyzer import detect_emotion_embedding, detect_intent
|
||||
|
||||
intent = detect_intent_embedding(msg)
|
||||
if not intent:
|
||||
intent = detect_intent_keywords(msg)
|
||||
decision = detect_intent(msg)
|
||||
intent = decision.intent
|
||||
emotion = detect_emotion_embedding(msg) if os.getenv("EMBEDDING_MODEL") else None
|
||||
parts = []
|
||||
if intent:
|
||||
parts.append(f"意图:{intent}")
|
||||
if decision.source:
|
||||
parts.append(f"意图来源:{decision.source}")
|
||||
if emotion:
|
||||
parts.append(f"情绪:{emotion}")
|
||||
if parts:
|
||||
|
||||
Reference in New Issue
Block a user