ai: return mode-specific timeout guidance when atlasbot misses SLA

This commit is contained in:
Brad Stein 2026-03-30 03:53:42 -03:00
parent 89ac893a76
commit 94310ccc2f

View File

@ -36,9 +36,23 @@ def register(app) -> None:
elapsed_ms = int((time.time() - started) * 1000)
return jsonify({"reply": reply, "latency_ms": elapsed_ms, "source": source})
elapsed_ms = int((time.time() - started) * 1000)
if mode == "quick":
budget = max(1, int(round(settings.AI_ATLASBOT_TIMEOUT_QUICK_SEC)))
fallback = (
f"Quick mode hit {budget}s response budget before finishing. "
"Try atlas-smart for a deeper answer."
)
elif mode == "smart":
budget = max(1, int(round(settings.AI_ATLASBOT_TIMEOUT_SMART_SEC)))
fallback = (
f"Smart mode hit {budget}s response budget before finishing. "
"Try atlas-genius or ask a narrower follow-up."
)
else:
fallback = "Atlas genius mode timed out before it could finish. Please retry with a narrower prompt."
return jsonify(
{
"reply": "Atlasbot is busy. Please try again in a moment.",
"reply": fallback,
"latency_ms": elapsed_ms,
"source": source,
}