feat(archivar): Lernsystem-Verdrahtung — Move-Request + Clarify lernen Keyword-Gewichte
- RoutingDecision um matched_keywords-Feld erweitert (router.py) - _extract_routing_keywords-Stub entfernt, Keywords aus Decision durchreichen (adapter_integration.py) - _routed_messages nach classify_and_route() befüllen (adapter.py) - move_req-Dict um message_id erweitert (adapter.py) - Move-Request-Handler: handle_feedback_response mit confirm/stay/never aufrufen (adapter.py) - handle_clarification_response: update_keyword_weight für ambige Keywords lernen (adapter_integration.py) - Clarify-Frage-Text: "Ich möchte mir das für die Zukunft richtig merken..." (config.py) Feedback-Mapping: 1️⃣ Rüber=confirm, 2️⃣ Hier=stay, 3️⃣ Nein=never, 📝/💬=stay, 📋=confirm
This commit is contained in:
@@ -107,6 +107,9 @@ class RoutingDecision:
|
||||
return_summary_to_source: Optional[str] = None
|
||||
"""Zusammenfassungstext, der nach Abschluss an den Ursprungsraum gesendet wird."""
|
||||
|
||||
matched_keywords: List[str] = field(default_factory=list)
|
||||
"""Liste der Keywords, die zum Routing-Vorschlag führten."""
|
||||
|
||||
def should_route(self) -> bool:
|
||||
"""True wenn die Nachricht geroutet werden sollte."""
|
||||
return (
|
||||
@@ -246,12 +249,16 @@ class BidirectionalRouter:
|
||||
room_name = matched_room.name.replace("#", "") if matched_room.name.startswith("#") else matched_room.name
|
||||
notification = f"📋 Bearbeite ich in #{room_name} — [Link]"
|
||||
|
||||
# Extrahiere die gematchten Keywords
|
||||
matched_keywords = self._extract_matched_keywords(text, matched_room)
|
||||
|
||||
return RoutingDecision(
|
||||
category="work_order", # Keyword-Matches sind typischerweise Work Orders
|
||||
target_room=matched_room.room_id,
|
||||
confidence=0.95,
|
||||
matched_room_name=matched_room.name,
|
||||
source_room_notification=notification,
|
||||
matched_keywords=matched_keywords,
|
||||
)
|
||||
|
||||
# ── Schritt 4: Embedding-basierte Klassifikation ───────────────
|
||||
@@ -507,6 +514,31 @@ class BidirectionalRouter:
|
||||
|
||||
return ""
|
||||
|
||||
def _extract_matched_keywords(self, text: str, room: RoomEntry) -> List[str]:
|
||||
"""Extrahiere die Keywords, die zum Match führten.
|
||||
|
||||
Args:
|
||||
text: Der Nachrichtentext
|
||||
room: Der gematchte Raum
|
||||
|
||||
Returns:
|
||||
Liste der gematchten Keywords
|
||||
"""
|
||||
text_lower = text.lower()
|
||||
matched_keywords = []
|
||||
|
||||
# Prüfe 100% Evidenz Keywords
|
||||
for kw in room.keywords_100:
|
||||
if kw.lower() in text_lower and kw not in matched_keywords:
|
||||
matched_keywords.append(kw)
|
||||
|
||||
# Prüfe kontextabhängige Keywords
|
||||
for kw in room.keywords_context:
|
||||
if kw.lower() in text_lower and kw not in matched_keywords:
|
||||
matched_keywords.append(kw)
|
||||
|
||||
return matched_keywords
|
||||
|
||||
# ── Bidirektionales Routing ────────────────────────────────────────
|
||||
|
||||
async def move_message(self, source_room: str, target_room: str, message: str, message_id: str) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user