opencode-pollinations-plugin 5.2.2 → 5.2.3
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.
- package/dist/server/proxy.js +10 -3
- package/package.json +1 -1
package/dist/server/proxy.js
CHANGED
|
@@ -446,14 +446,21 @@ export async function handleChatCompletion(req, res, bodyRaw) {
|
|
|
446
446
|
});
|
|
447
447
|
if (!fetchRes.ok) {
|
|
448
448
|
log(`Upstream Error: ${fetchRes.status} ${fetchRes.statusText}`);
|
|
449
|
-
// TRANSPARENT FALLBACK ON
|
|
450
|
-
if ((fetchRes.status === 402 || fetchRes.status === 429) && isEnterprise) {
|
|
449
|
+
// TRANSPARENT FALLBACK ON 4xx Errors (Payment, Rate Limit, Auth) IF Enterprise
|
|
450
|
+
if ((fetchRes.status === 402 || fetchRes.status === 429 || fetchRes.status === 401 || fetchRes.status === 403) && isEnterprise) {
|
|
451
451
|
log(`[SafetyNet] Upstream Rejection (${fetchRes.status}). Triggering Transparent Fallback.`);
|
|
452
452
|
// 1. Switch Config
|
|
453
453
|
actualModel = config.fallbacks.free.main.replace('free/', '');
|
|
454
454
|
isEnterprise = false;
|
|
455
455
|
isFallbackActive = true;
|
|
456
|
-
|
|
456
|
+
if (fetchRes.status === 402)
|
|
457
|
+
fallbackReason = "Insufficient Funds (Upstream 402)";
|
|
458
|
+
else if (fetchRes.status === 429)
|
|
459
|
+
fallbackReason = "Rate Limit (Upstream 429)";
|
|
460
|
+
else if (fetchRes.status === 401)
|
|
461
|
+
fallbackReason = "Invalid API Key (Upstream 401)";
|
|
462
|
+
else
|
|
463
|
+
fallbackReason = `Access Denied (${fetchRes.status})`;
|
|
457
464
|
// 2. Notify
|
|
458
465
|
emitStatusToast('warning', `⚠️ Safety Net: ${actualModel} (${fallbackReason})`, 'Pollinations Safety');
|
|
459
466
|
emitLogToast('warning', `Recovering from ${fetchRes.status} -> Switching to ${actualModel}`, 'Safety Net');
|
package/package.json
CHANGED