Update api/routes.py
Browse files- api/routes.py +1 -1
api/routes.py
CHANGED
|
@@ -172,7 +172,7 @@ def chat_text(
|
|
| 172 |
except Exception as e:
|
| 173 |
error_str = str(e).lower()
|
| 174 |
error_type = type(e).__name__.lower()
|
| 175 |
-
if
|
| 176 |
raise HTTPException(status_code=429, detail="Tokens Exhausted")
|
| 177 |
if "connection error" in error_str or "all providers failed" in error_str or "unavailable" in error_str:
|
| 178 |
raise HTTPException(status_code=503, detail="LLMs are currently unavailable. Please try again later.")
|
|
|
|
| 172 |
except Exception as e:
|
| 173 |
error_str = str(e).lower()
|
| 174 |
error_type = type(e).__name__.lower()
|
| 175 |
+
if any(k in error_str for k in ("rate limit", "ratelimit", "429", "402", "tokens exhausted", "quota")) or "ratelimit" in error_type:
|
| 176 |
raise HTTPException(status_code=429, detail="Tokens Exhausted")
|
| 177 |
if "connection error" in error_str or "all providers failed" in error_str or "unavailable" in error_str:
|
| 178 |
raise HTTPException(status_code=503, detail="LLMs are currently unavailable. Please try again later.")
|