ai: avoid fallback for atlasbot queries
This commit is contained in:
parent
ecdb87d9a8
commit
d087558c22
@ -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 = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user