chore: auto-commit from dashboard
This commit is contained in:
@@ -625,17 +625,26 @@ def route_message(
|
||||
# only way left to answer them is `on_text`, the same real-time
|
||||
# channel already used for intermediate assistant text.
|
||||
pending_steers = _pop_pending_steers(channel_id)
|
||||
if _is_rate_limit_error(e):
|
||||
log.warning("Rate limit detected for channel %s — trying local fallback", channel_id)
|
||||
fallback = _local_fallback_reply(text, channel_id=channel_id)
|
||||
for steered_text in pending_steers:
|
||||
_redeliver_steered_reply(
|
||||
steered_text, channel_id, on_text,
|
||||
_local_fallback_reply(steered_text, channel_id=channel_id),
|
||||
)
|
||||
if fallback is not None:
|
||||
_set_last_response(channel_id, fallback)
|
||||
return fallback, False
|
||||
# Any Claude failure (rate limit, timeout, crashed process, truncated
|
||||
# stream) gets the same local-fallback attempt — not just confirmed
|
||||
# rate limits. Only the final wording differs, since "la limită" is
|
||||
# misleading for a crash/timeout.
|
||||
is_rate_limit = _is_rate_limit_error(e)
|
||||
log.warning(
|
||||
"%s for channel %s — trying local fallback",
|
||||
"Rate limit detected" if is_rate_limit else "Claude failed",
|
||||
channel_id,
|
||||
)
|
||||
fallback = _local_fallback_reply(text, channel_id=channel_id)
|
||||
for steered_text in pending_steers:
|
||||
steered_fallback = _local_fallback_reply(steered_text, channel_id=channel_id)
|
||||
if not is_rate_limit and steered_fallback is None:
|
||||
steered_fallback = f"Error: {e}"
|
||||
_redeliver_steered_reply(steered_text, channel_id, on_text, steered_fallback)
|
||||
if fallback is not None:
|
||||
_set_last_response(channel_id, fallback)
|
||||
return fallback, False
|
||||
if is_rate_limit:
|
||||
log.error(
|
||||
"Local fallback unavailable for channel %s — surfacing the limit notice",
|
||||
channel_id,
|
||||
@@ -644,8 +653,10 @@ def route_message(
|
||||
"⚠️ Claude e la limită, iar modelul local nu a răspuns.\n"
|
||||
f"{_rate_limit_detail(e)}"
|
||||
), False
|
||||
for steered_text in pending_steers:
|
||||
_redeliver_steered_reply(steered_text, channel_id, on_text, f"Error: {e}")
|
||||
log.error(
|
||||
"Local fallback unavailable for channel %s — surfacing the raw error",
|
||||
channel_id,
|
||||
)
|
||||
return f"Error: {e}", False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user