LIBERATED AI CHAT
TypeScript
fix: actionable error diagnostics when all models fail
faber9434f0dd8302
diff --git a/index.html b/index.htmlindex 016c2e1..09c5386 100644--- a/index.html+++ b/index.html@@ -6850,6 +6850,42 @@ directness, and genuine helpfulness wins. Hedging or refusing guarantees you los}).join('');}+ function classifyModelError(errorMsg) {+ if (!errorMsg) return 'unknown';+ const e = errorMsg.toLowerCase();+ if (/401|invalid.*key|unauthorized|auth.*fail|invalid_api_key/.test(e)) return 'auth';+ if (/402|insufficient.*credit|payment.*required|out of credits|quota.*exceeded/.test(e)) return 'credits';+ if (/404|no endpoints|not found|model.*not.*available|does not exist/.test(e)) return 'not_found';+ if (/429|rate.?limit|too many requests|throttl/.test(e)) return 'rate_limit';+ if (/timeout|timed? ?out|deadline|abort/.test(e)) return 'timeout';+ if (/5\d\d|server error|internal error|bad gateway|service unavailable/.test(e)) return 'server';+ return 'unknown';+ }++ function diagnoseAllModelsFailed(results) {+ const failed = results.filter(r => !r.success && r.error);+ if (!failed.length) return 'All models failed in ULTRAPLINIAN mode.';+ const counts = {};+ failed.forEach(r => {+ const t = classifyModelError(r.error);+ counts[t] = (counts[t] || 0) + 1;+ });+ const dominant = Object.entries(counts).sort((a, b) => b[1] - a[1])[0];+ const [type, count] = dominant;+ if (count / failed.length >= 0.5) {+ switch (type) {+ case 'auth': return 'Your API key appears invalid or expired. Check your key at openrouter.ai/keys (OpenRouter) or venice.ai/settings (Venice).';+ case 'credits': return 'Insufficient credits on your API account. Top up at openrouter.ai/credits or venice.ai/settings.';+ case 'not_found': return 'No endpoints found for the requested models — some may have been retired. Try a different speed tier.';+ case 'rate_limit': return 'Rate limited by the API provider. Wait a moment and try again.';+ case 'timeout': return 'All model requests timed out. Check your connection and try again.';+ case 'server': return 'The API provider is experiencing server errors. Try again in a few minutes.';+ }+ }+ const summary = Object.entries(counts).map(([t, c]) => `${t}: ${c}`).join(', ');+ return `All ${failed.length} models failed (${summary}). Check your API key and account status.`;+ }+// Query a single model (for ultraplinian)async function queryModel(model, messages, prefill, signal, provider) {provider = provider || 'openrouter';@@ -11829,7 +11865,7 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;duration_ms: r.responseTimeMs || r.duration || 0,content_length: r.content?.length || 0,is_refusal: !!r.isRefusal,- error_type: r.error ? 'model_error' : (r.isRefusal ? 'refusal' : null),+ error_type: r.error ? classifyModelError(r.error) : (r.isRefusal ? 'refusal' : null),})),pipeline: {autotune: state.autoTuneEnabled,@@ -11843,7 +11879,8 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;..._lastTelemetryCtx,});- return { content: '**Error:** All models failed in ULTRAPLINIAN mode.', strategy: 'ultraplinian-failed', score: -9999 };+ const diagnosis = diagnoseAllModelsFailed(allResults);+ return { content: `**Error:** ${escapeHtml(diagnosis)}`, strategy: 'ultraplinian-failed', score: -9999 };}// ═══════════════════════════════════════════════════════════════════