opencode-pollinations-plugin 5.4.3 → 5.4.5
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/generate-config.js +2 -0
- package/dist/server/proxy.js +27 -14
- package/package.json +1 -1
|
@@ -79,6 +79,8 @@ export async function generatePollinationsConfig(forceApiKey) {
|
|
|
79
79
|
if (!hasGemini) {
|
|
80
80
|
log(`[ConfigGen] Force-injecting free/gemini.`);
|
|
81
81
|
modelsOutput.push({ id: "free/gemini", name: "[Free] Gemini Flash (Force)", object: "model", variants: {} });
|
|
82
|
+
// ALIAS for Full ID matching (Fix ProviderModelNotFoundError)
|
|
83
|
+
modelsOutput.push({ id: "pollinations/free/gemini", name: "[Free] Gemini Flash (Alias)", object: "model", variants: {} });
|
|
82
84
|
}
|
|
83
85
|
// 2. ENTERPRISE UNIVERSE
|
|
84
86
|
if (effectiveKey && effectiveKey.length > 5 && effectiveKey !== 'dummy') {
|
package/dist/server/proxy.js
CHANGED
|
@@ -461,21 +461,34 @@ export async function handleChatCompletion(req, res, bodyRaw) {
|
|
|
461
461
|
});
|
|
462
462
|
if (!fetchRes.ok) {
|
|
463
463
|
log(`Upstream Error: ${fetchRes.status} ${fetchRes.statusText}`);
|
|
464
|
-
// TRANSPARENT FALLBACK
|
|
465
|
-
|
|
464
|
+
// TRANSPARENT FALLBACK LOGIC
|
|
465
|
+
// 1. Enterprise Safety Net (Quota/Auth/RateLimit)
|
|
466
|
+
// 2. Gemini Tools Fix (Gemini + Tools -> 401 -> Fallback to OpenAI)
|
|
467
|
+
const isEnterpriseFallback = (fetchRes.status === 402 || fetchRes.status === 429 || fetchRes.status === 401 || fetchRes.status === 403) && isEnterprise;
|
|
468
|
+
const isGeminiToolsFallback = fetchRes.status === 401 && actualModel.includes('gemini') && !isEnterprise && proxyBody.tools && proxyBody.tools.length > 0;
|
|
469
|
+
if (isEnterpriseFallback || isGeminiToolsFallback) {
|
|
466
470
|
log(`[SafetyNet] Upstream Rejection (${fetchRes.status}). Triggering Transparent Fallback.`);
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
471
|
+
if (isEnterpriseFallback) {
|
|
472
|
+
// 1a. Enterprise -> Free Fallback
|
|
473
|
+
actualModel = config.fallbacks.free.main.replace('free/', '');
|
|
474
|
+
isEnterprise = false;
|
|
475
|
+
isFallbackActive = true;
|
|
476
|
+
if (fetchRes.status === 402)
|
|
477
|
+
fallbackReason = "Insufficient Funds (Upstream 402)";
|
|
478
|
+
else if (fetchRes.status === 429)
|
|
479
|
+
fallbackReason = "Rate Limit (Upstream 429)";
|
|
480
|
+
else if (fetchRes.status === 401)
|
|
481
|
+
fallbackReason = "Invalid API Key (Upstream 401)";
|
|
482
|
+
else
|
|
483
|
+
fallbackReason = `Access Denied (${fetchRes.status})`;
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
// 1b. Gemini Tools -> OpenAI Fallback
|
|
487
|
+
log(`[Fix] Gemini Tools 401 detected. Falling back to 'openai' model.`);
|
|
488
|
+
actualModel = 'openai'; // Assume gpt-4o-mini or similar capable of tools
|
|
489
|
+
isFallbackActive = true;
|
|
490
|
+
fallbackReason = "Gemini Tools Auth Failed (Fallback to OpenAI)";
|
|
491
|
+
}
|
|
479
492
|
// 2. Notify
|
|
480
493
|
emitStatusToast('warning', `⚠️ Safety Net: ${actualModel} (${fallbackReason})`, 'Pollinations Safety');
|
|
481
494
|
emitLogToast('warning', `Recovering from ${fetchRes.status} -> Switching to ${actualModel}`, 'Safety Net');
|
package/package.json
CHANGED