|
@@ -129,6 +129,30 @@ class IntentDispatcherService(IService):
|
|
|
|
|
|
|
|
# Follow-Up-Validierung: Ist eine Rueckfrage aktiv?
|
|
# Follow-Up-Validierung: Ist eine Rueckfrage aktiv?
|
|
|
followup_ctx = self._active_followups.get(event_data.satellite_id)
|
|
followup_ctx = self._active_followups.get(event_data.satellite_id)
|
|
|
|
|
+ if followup_ctx:
|
|
|
|
|
+ import time as _time
|
|
|
|
|
+
|
|
|
|
|
+ # Timeout: Follow-Up nach 60s ablaufen lassen
|
|
|
|
|
+ created_at = followup_ctx.get("created_at", 0)
|
|
|
|
|
+ if created_at and (_time.time() - created_at) > 60:
|
|
|
|
|
+ pdebug(f"[DISPATCHER] Follow-Up abgelaufen (>60s)")
|
|
|
|
|
+ del self._active_followups[event_data.satellite_id]
|
|
|
|
|
+ followup_ctx = None
|
|
|
|
|
+
|
|
|
|
|
+ # Wenn der Classifier einen klaren anderen Intent erkannt hat
|
|
|
|
|
+ # (nicht "unknown" und hohe Confidence), Follow-Up ignorieren
|
|
|
|
|
+ elif (event_data.intent != "unknown"
|
|
|
|
|
+ and event_data.confidence >= 0.8
|
|
|
|
|
+ and event_data.intent != followup_ctx.get("follow_up_intent")
|
|
|
|
|
+ and event_data.intent != followup_ctx.get("original_intent")):
|
|
|
|
|
+ pinfo(
|
|
|
|
|
+ f"[DISPATCHER] Follow-Up uebersprungen — "
|
|
|
|
|
+ f"neuer Intent '{event_data.intent}' (conf={event_data.confidence:.2f}) "
|
|
|
|
|
+ f"hat Vorrang vor Follow-Up '{followup_ctx.get('follow_up_intent')}'"
|
|
|
|
|
+ )
|
|
|
|
|
+ del self._active_followups[event_data.satellite_id]
|
|
|
|
|
+ followup_ctx = None
|
|
|
|
|
+
|
|
|
if followup_ctx:
|
|
if followup_ctx:
|
|
|
validated = self._validate_followup_response(
|
|
validated = self._validate_followup_response(
|
|
|
event_data, followup_ctx,
|
|
event_data, followup_ctx,
|
|
@@ -257,12 +281,14 @@ class IntentDispatcherService(IService):
|
|
|
followup_prompt = result.follow_up_intent
|
|
followup_prompt = result.follow_up_intent
|
|
|
|
|
|
|
|
# Follow-Up-Kontext mit Validierung speichern
|
|
# Follow-Up-Kontext mit Validierung speichern
|
|
|
|
|
+ import time as _time
|
|
|
self._active_followups[event_data.satellite_id] = {
|
|
self._active_followups[event_data.satellite_id] = {
|
|
|
"follow_up_intent": result.follow_up_intent,
|
|
"follow_up_intent": result.follow_up_intent,
|
|
|
"valid_responses": result.follow_up_valid_responses,
|
|
"valid_responses": result.follow_up_valid_responses,
|
|
|
"retry_text": result.follow_up_retry_text,
|
|
"retry_text": result.follow_up_retry_text,
|
|
|
"data": result.data or {},
|
|
"data": result.data or {},
|
|
|
"original_intent": event_data.intent,
|
|
"original_intent": event_data.intent,
|
|
|
|
|
+ "created_at": _time.time(),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|