From d087558c224117ce68a0d0e12ccdd9974bc82a52 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Tue, 27 Jan 2026 14:09:01 -0300 Subject: [PATCH] ai: avoid fallback for atlasbot queries --- backend/atlas_portal/routes/ai.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/backend/atlas_portal/routes/ai.py b/backend/atlas_portal/routes/ai.py index 86ad945..6db0c72 100644 --- a/backend/atlas_portal/routes/ai.py +++ b/backend/atlas_portal/routes/ai.py @@ -28,6 +28,15 @@ def register(app) -> None: if atlasbot_reply: elapsed_ms = int((time.time() - started) * 1000) return jsonify({"reply": atlasbot_reply, "latency_ms": elapsed_ms, "source": "atlasbot"}) + if _requires_atlasbot(user_message): + elapsed_ms = int((time.time() - started) * 1000) + return jsonify( + { + "reply": "Atlasbot is busy. Please try again in a moment.", + "latency_ms": elapsed_ms, + "source": "atlasbot", + } + ) messages: list[dict[str, str]] = [] if settings.AI_CHAT_SYSTEM_PROMPT: @@ -81,6 +90,24 @@ def _atlasbot_answer(message: str) -> str: except (httpx.RequestError, ValueError): return "" +def _requires_atlasbot(message: str) -> bool: + text = (message or "").lower() + hints = ( + "atlas", + "titan", + "cluster", + "node", + "nodes", + "pod", + "pods", + "postgres", + "database", + "grafana", + "victoria", + "metrics", + ) + return any(hint in text for hint in hints) + def _discover_ai_meta() -> dict[str, str]: meta = {