Show a friendly message on 429 instead of raw JSON
Map HTTP 429 in _friendly_http_error: OpenRouter's free-models-per-day cap gets a "daily limit, resets 00:00 UTC" message; other rate limits get a generic "too many requests, try again" note. Avoids leaking the raw error JSON (incl. user_id) to players. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TEpWMjnfPqzZ13nPMoGhs5
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
328ae8942d
commit
2953cd70ed
@@ -267,4 +267,13 @@ class OpenAICompatibleProvider(Provider):
|
|||||||
f"Endpoint or model not found (HTTP 404). Check the endpoint URL and that "
|
f"Endpoint or model not found (HTTP 404). Check the endpoint URL and that "
|
||||||
f"model '{self.model}' exists. {detail}"
|
f"model '{self.model}' exists. {detail}"
|
||||||
)
|
)
|
||||||
|
if status == 429:
|
||||||
|
# OpenRouter's shared free tier has a per-day cap; distinguish it
|
||||||
|
# from a short-term burst limit so the message is actionable.
|
||||||
|
if "free-models-per-day" in detail:
|
||||||
|
return (
|
||||||
|
"The free demo has hit its daily request limit (resets at "
|
||||||
|
"00:00 UTC). Please try again later."
|
||||||
|
)
|
||||||
|
return "The AI is getting too many requests right now — wait a moment and try again."
|
||||||
return f"AI endpoint returned HTTP {status}: {detail}"
|
return f"AI endpoint returned HTTP {status}: {detail}"
|
||||||
|
|||||||
Reference in New Issue
Block a user