Spaces:
Sleeping

Amogh1221 commited on
Commit
122c982
·
verified ·
1 Parent(s): 8baa2bd

Update api/routes.py

Browse files
Files changed (1) hide show
  1. 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 "rate limit" in error_str or "ratelimit" in error_str or "429" in error_str 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.")
 
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.")