shariq-pi-extensions 0.2.21 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -133,9 +133,19 @@ function activeKeyEntries(modelId?: string) {
|
|
|
133
133
|
|
|
134
134
|
export function classifyFactoryKeyCooldown(message: string): { ms: number; kind: "auth" | "rate" | "quota" } | null {
|
|
135
135
|
const lower = message.toLowerCase();
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
if (
|
|
137
|
+
lower.includes("invalid api key") ||
|
|
138
|
+
lower.includes("api key revoked") ||
|
|
139
|
+
lower.includes("api key expired") ||
|
|
140
|
+
lower.includes("forbidden") ||
|
|
141
|
+
lower.includes("unauthorized") ||
|
|
142
|
+
lower.includes("permission") ||
|
|
143
|
+
lower.includes("access denied") ||
|
|
144
|
+
/\b401\b/.test(lower) ||
|
|
145
|
+
/\b403\b/.test(lower)
|
|
146
|
+
) {
|
|
147
|
+
return { ms: AUTH_COOLDOWN_MS, kind: "auth" };
|
|
148
|
+
}
|
|
139
149
|
if (/\b429\b/.test(lower) || lower.includes("rate limit")) return { ms: RATE_COOLDOWN_MS, kind: "rate" };
|
|
140
150
|
if (lower.includes("quota") || lower.includes("billing") || lower.includes("credit") || lower.includes("usage limit") || lower.includes("exhaust")) return { ms: DEFAULT_COOLDOWN_MS, kind: "quota" };
|
|
141
151
|
return null;
|
|
@@ -325,8 +335,8 @@ export function streamSimpleFactoryApiKeyResponses(model: any, context: any, opt
|
|
|
325
335
|
const error = errorText(event);
|
|
326
336
|
if (error) {
|
|
327
337
|
lastError = error;
|
|
328
|
-
|
|
329
|
-
if (
|
|
338
|
+
markKeyFailure(key, error, model.id);
|
|
339
|
+
if (!hasStarted) {
|
|
330
340
|
retriedBeforeStart = true;
|
|
331
341
|
break;
|
|
332
342
|
}
|