feat(P1): Auto-Route-Widerspruch-Flow — detect_routing_contradiction + Clarify
- feedback_detector.py: HIER_HER-Muster ergänzt (positive Formulierung
'Nein, es passt hier her' → routing_rejection)
- router.py: RoutingDecision um is_contradiction/contradiction_result
erweitert; should_route() blockt bei Widerspruch
- adapter_integration.py: detect_routing_contradiction als Pre-Check in
classify_and_route() eingebunden (Clarify statt Auto-Route)
- adapter.py: _send_widerspruch_clarify() mit 2 Buttons
('generell hier her' → set_never_route, 'nur jetzt hier her' → stay_once),
WIDERSPRUCH:-Button-Handler, _widerspruch_state; alte V8.3-3
Auto-Retrieve-Routine durch Clarify-Flow ersetzt
- tests: test_auto_route_contradiction_persists.py (14 Tests, 4 Szenarien)
Pitfalls beachtet: P-028, P-040, P-056, P-057, P-066, P-067
This commit is contained in:
@@ -128,6 +128,17 @@ class RoutingWiderspruchDetector:
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
# e) Hier-her-Bestätigung: positive Formulierung „passt hier her"
|
||||
# „Nein, es passt hier her", „Das gehört hier her", „Bleib hier"
|
||||
# → routing_rejection ohne Raumnennung (User will im aktuellen Raum bleiben).
|
||||
HIER_HER: re.Pattern = re.compile(
|
||||
r"(?:passt|gehört|gehoert|bleibt|bleib|soll|landet)\s+"
|
||||
r"(?:hier\s+her|hierher|hier\s+hin|hierhin|hier)"
|
||||
r"|"
|
||||
r"(?:bleib|bleibe|lass\s+es)\s+hier",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
# ── Confidence-Werte pro Mustertyp ──────────────────────────────────
|
||||
|
||||
CONFIDENCE_MAP = {
|
||||
@@ -136,6 +147,7 @@ class RoutingWiderspruchDetector:
|
||||
"nicht_in_x_sondern_in_y": 0.92,
|
||||
"verneinung": 0.85,
|
||||
"befehle": 0.82,
|
||||
"hier_her": 0.86,
|
||||
}
|
||||
|
||||
# ── Public API ──────────────────────────────────────────────────────
|
||||
@@ -228,5 +240,19 @@ class RoutingWiderspruchDetector:
|
||||
matched_pattern="befehle",
|
||||
)
|
||||
|
||||
# ── e) Hier-her-Bestätigung ──────────────────────────────────────
|
||||
# Positive Formulierung „passt hier her" — User will im aktuellen
|
||||
# Raum bleiben. Wird NACH den spezifischeren Mustern geprüft, damit
|
||||
# „nicht in X, sondern hier" korrekt als reroute_request erkannt wird.
|
||||
m_hier = self.HIER_HER.search(text)
|
||||
if m_hier:
|
||||
logger.debug("Widerspruch (hier_her): matched")
|
||||
return ContradictionResult(
|
||||
has_contradiction=True,
|
||||
contradiction_type="routing_rejection",
|
||||
confidence=self.CONFIDENCE_MAP["hier_her"],
|
||||
matched_pattern="hier_her",
|
||||
)
|
||||
|
||||
# Kein Widerspruch erkannt
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user