Fix failover for zhipuai 1310 Weekly/Monthly Limit Exhausted (#33813)

Merged via squash.

Prepared head SHA: 3dc441e58d
Co-authored-by: zhouhe-xydt <265407618+zhouhe-xydt@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
This commit is contained in:
zhouhe-xydt
2026-03-06 17:04:09 +08:00
committed by GitHub
parent ee6f7b1bf0
commit a65d70f84b
5 changed files with 56 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import {
isAuthPermanentErrorMessage,
isBillingErrorMessage,
isOverloadedErrorMessage,
isPeriodicUsageLimitErrorMessage,
isRateLimitErrorMessage,
isTimeoutErrorMessage,
matchesFormatErrorPattern,
@@ -842,6 +843,9 @@ export function classifyFailoverReason(raw: string): FailoverReason | null {
if (isJsonApiInternalServerError(raw)) {
return "timeout";
}
if (isPeriodicUsageLimitErrorMessage(raw)) {
return isBillingErrorMessage(raw) ? "billing" : "rate_limit";
}
if (isRateLimitErrorMessage(raw)) {
return "rate_limit";
}

View File

@@ -1,5 +1,8 @@
type ErrorPattern = RegExp | string;
const PERIODIC_USAGE_LIMIT_RE =
/\b(?:daily|weekly|monthly)(?:\/(?:daily|weekly|monthly))* (?:usage )?limit(?:s)?(?: (?:exhausted|reached|exceeded))?\b/i;
const ERROR_PATTERNS = {
rateLimit: [
/rate[_ ]limit|too many requests|429/,
@@ -117,6 +120,10 @@ export function isTimeoutErrorMessage(raw: string): boolean {
return matchesErrorPatterns(raw, ERROR_PATTERNS.timeout);
}
export function isPeriodicUsageLimitErrorMessage(raw: string): boolean {
return PERIODIC_USAGE_LIMIT_RE.test(raw);
}
export function isBillingErrorMessage(raw: string): boolean {
const value = raw.toLowerCase();
if (!value) {