fix(adapter): _MULTIROOM from module-level constant to runtime function
This commit is contained in:
+10
-8
@@ -35,9 +35,11 @@ class RocketChatRateLimitError(Exception):
|
||||
_room_context: Dict[str, Dict[str, str]] = {} # chat_id → {thematic_target, origin_room}
|
||||
_room_context_lock = threading.Lock()
|
||||
|
||||
_MULTIROOM = os.getenv("MULTIROOM_AGENT", "true").strip().lower() not in ("false", "0", "no", "off")
|
||||
def _MULTIROOM() -> bool:
|
||||
"""Laufzeit-Auswertung von MULTIROOM_AGENT (nicht beim Import, da .env via systemd EnvironmentFile erst später geladen wird)."""
|
||||
return os.getenv("MULTIROOM_AGENT", "true").strip().lower() not in ("false", "0", "no", "off")
|
||||
|
||||
if _MULTIROOM:
|
||||
if _MULTIROOM():
|
||||
from archivar.adapter_integration import ArchivarMessageHandler
|
||||
|
||||
# ── Access __init__ symbols (plugin loaded as flat module, no relative imports) ──
|
||||
@@ -481,7 +483,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
self._last_ddp_ping_ok = False
|
||||
self._running = False
|
||||
# Archivar: Embedding-basierte Nachrichten-Klassifikation
|
||||
if _MULTIROOM:
|
||||
if _MULTIROOM():
|
||||
self.archivar = ArchivarMessageHandler(
|
||||
send_callback=self._send_via_archivar,
|
||||
button_send_callback=self._send_archivar_buttons,
|
||||
@@ -598,7 +600,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
len(self._user_rooms),
|
||||
{k: f"{len(v)} rooms" for k, v in self._user_rooms.items()})
|
||||
# Archivar initialisieren (Embedding-basierte Klassifikation)
|
||||
if _MULTIROOM and self.archivar is not None:
|
||||
if _MULTIROOM() and self.archivar is not None:
|
||||
try:
|
||||
await self.archivar.initialize()
|
||||
# Feed the actual subscribed room IDs to the router so it can
|
||||
@@ -797,7 +799,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
logger.debug("[rocketchat] Error processing CLARIFY response: %s", e)
|
||||
|
||||
# Auto-Onboarding: Wenn onboarding_active, fange alle relevanten Antworten ab
|
||||
if _MULTIROOM and self.archivar is not None and self.archivar._stats.get("onboarding_active", False):
|
||||
if _MULTIROOM() and self.archivar is not None and self.archivar._stats.get("onboarding_active", False):
|
||||
stripped = text.strip()
|
||||
# Nur Nachrichten aus dem Operator-DM-Raum als Onboarding behandeln
|
||||
operator_room = self._onboarding_state.get("operator_room_id", "")
|
||||
@@ -867,7 +869,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
feedback_type = "stay"
|
||||
|
||||
# Lernsystem: Keyword-Gewichte aus User-Entscheidung lernen
|
||||
if _MULTIROOM and self.archivar is not None and move_req.get("message_id"):
|
||||
if _MULTIROOM() and self.archivar is not None and move_req.get("message_id"):
|
||||
user_id = user_info.get("_id", "")
|
||||
await self.archivar.handle_feedback_response(
|
||||
message_id=move_req["message_id"],
|
||||
@@ -887,10 +889,10 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
decision = None
|
||||
is_auftrag = _is_auftrag(text)
|
||||
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Entering Archivar block — room_type=%s, is_auftrag=%s, _MULTIROOM=%s, archivar=%s", room_type, is_auftrag, _MULTIROOM, self.archivar is not None)
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Entering Archivar block — room_type=%s, is_auftrag=%s, _MULTIROOM=%s, archivar=%s", room_type, is_auftrag, _MULTIROOM(), self.archivar is not None)
|
||||
|
||||
try:
|
||||
if _MULTIROOM and self.archivar is not None:
|
||||
if _MULTIROOM() and self.archivar is not None:
|
||||
if is_button_response or room_id in self._rooms_with_pending_questions:
|
||||
if not is_button_response:
|
||||
logger.debug("[rocketchat] Room %s had pending question — Archivar bypassed", room_id)
|
||||
|
||||
Reference in New Issue
Block a user