diff --git a/backend/atlas_portal/routes/ai.py b/backend/atlas_portal/routes/ai.py index 6db0c72..1c0055a 100644 --- a/backend/atlas_portal/routes/ai.py +++ b/backend/atlas_portal/routes/ai.py @@ -28,40 +28,14 @@ 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: - messages.append({"role": "system", "content": settings.AI_CHAT_SYSTEM_PROMPT}) - - for item in history: - role = item.get("role") - content = (item.get("content") or "").strip() - if role in ("user", "assistant") and content: - messages.append({"role": role, "content": content}) - - messages.append({"role": "user", "content": user_message}) - - body = {"model": settings.AI_CHAT_MODEL, "messages": messages, "stream": False} - - try: - with httpx.Client(timeout=settings.AI_CHAT_TIMEOUT_SEC) as client: - resp = client.post(f"{settings.AI_CHAT_API}/api/chat", json=body) - resp.raise_for_status() - data = resp.json() - reply = (data.get("message") or {}).get("content") or "" - elapsed_ms = int((time.time() - started) * 1000) - return jsonify({"reply": reply, "latency_ms": elapsed_ms}) - except (httpx.RequestError, httpx.HTTPStatusError, ValueError) as exc: - return jsonify({"error": str(exc)}), 502 + 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", + } + ) @app.route("/api/chat/info", methods=["GET"]) @app.route("/api/ai/info", methods=["GET"]) @@ -90,25 +64,6 @@ 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 = { "node": settings.AI_NODE_NAME,