feat: complete production hardening implementation, specialty canonicalization, google-genai migration, voice reliability, sqlite concurrency, and test suite consolidation
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
"""
|
||||
Question intent tracker for semantic question deduplication.
|
||||
"""
|
||||
|
||||
from typing import Optional, List, Dict, Any
|
||||
|
||||
from app.services.contextual_normalizer import detect_previous_question_intent
|
||||
|
||||
|
||||
def get_last_ai_intent(conversation_history: List[Dict[str, Any]]) -> Optional[str]:
|
||||
"""
|
||||
Returns the intent code of the last AI message in conversation history.
|
||||
"""
|
||||
if not conversation_history:
|
||||
return None
|
||||
|
||||
last_ai_msg = None
|
||||
for turn in reversed(conversation_history):
|
||||
if turn.get("role") in ["assistant", "ai"]:
|
||||
last_ai_msg = turn.get("message") or turn.get("content")
|
||||
break
|
||||
|
||||
if last_ai_msg:
|
||||
return detect_previous_question_intent(last_ai_msg)
|
||||
|
||||
return None
|
||||
Reference in New Issue
Block a user