(function () { "use strict"; var SUPABASE_URL = window.OPENJARVIS_SUPABASE_URL || "https://mtbtgpwzrbostweaanpr.supabase.co"; var SUPABASE_ANON_KEY = window.OPENJARVIS_SUPABASE_ANON_KEY || ""; var PAGE_SIZE = 50; var allRows = []; var currentPage = 0; // Outlier detection — hide entries with values that are physically // implausible relative to their token count. Thresholds are ~1000x // above legitimate per-token values to avoid false positives. // Outlier bounds. Set well above realistic upper limits but tight // enough to drop the pre-fix bimodal Group B (1-5 Wh/token, ~3e16 // FLOPs/token) — see the leaderboard PR for the full diagnosis. // Realistic per-token rates on a consumer GPU + 10–30B local model: // ~0.001 Wh/token, ~1e10–1e11 FLOPs/token. We allow 500× and 10,000× // headroom respectively for inefficient hardware / larger models. var MAX_ENERGY_WH_PER_TOKEN = 0.5; // legit ≈ 0.001 Wh/tok var MAX_FLOPS_PER_TOKEN = 1e15; // legit ≈ 1e11 /tok var MAX_DOLLAR_PER_TOKEN = 25.0 / 1e6; // hard ceiling: $25/1M output function isOutlier(row) { var tokens = Number(row.total_tokens) || 0; if (tokens <= 0) return false; var energy = Number(row.energy_wh_saved) || 0; var flops = Number(row.flops_saved) || 0; var dollars = Number(row.dollar_savings) || 0; return ( energy / tokens > MAX_ENERGY_WH_PER_TOKEN || flops / tokens > MAX_FLOPS_PER_TOKEN || dollars / tokens > MAX_DOLLAR_PER_TOKEN ); } // Distinguish "user actually has zero work done" from "user's energy / // FLOPs telemetry never landed". The latter happens when the server // submits with valid dollar savings + token counts but the per-record // energy stamp was missing (pre-fix builds, GPU energy meter // unavailable, etc.). Without this check those rows show as "0.00 Wh" // and skew the rankings + headline totals. // // Threshold: 1000 tokens is well above any single chat-turn — if a // user has that many tokens recorded but no measured energy, the // telemetry is incomplete, not legitimately zero. var MIN_TOKENS_FOR_TELEMETRY = 1000; function isMissingTelemetry(row) { var tokens = Number(row.total_tokens) || 0; var energy = Number(row.energy_wh_saved) || 0; var flops = Number(row.flops_saved) || 0; return tokens > MIN_TOKENS_FOR_TELEMETRY && energy === 0 && flops === 0; } function escapeHtml(s) { var el = document.createElement("span"); el.textContent = s; return el.innerHTML; } function fmtLarge(n) { if (n >= 1e12) return (n / 1e12).toFixed(1) + "T"; if (n >= 1e9) return (n / 1e9).toFixed(1) + "B"; if (n >= 1e6) return (n / 1e6).toFixed(1) + "M"; if (n >= 1e3) return (n / 1e3).toFixed(1) + "K"; return n.toLocaleString(); } function totalPages() { return Math.max(1, Math.ceil(allRows.length / PAGE_SIZE)); } function renderPage() { var tbody = document.getElementById("leaderboard-body"); if (!tbody) return; var start = currentPage * PAGE_SIZE; var end = Math.min(start + PAGE_SIZE, allRows.length); var pageRows = allRows.slice(start, end); var html = ""; for (var j = 0; j < pageRows.length; j++) { var rank = start + j + 1; var rankClass = rank <= 3 ? " lb-rank-" + rank : ""; var medal = rank === 1 ? "\uD83E\uDD47" : rank === 2 ? "\uD83E\uDD48" : rank === 3 ? "\uD83E\uDD49" : ""; var row = pageRows[j]; // Render "—" for energy / FLOPs columns when telemetry didn't // land (vs the user genuinely having 0). The dollar / request / // token columns are unaffected because those measurements landed // even when energy didn't. var missing = isMissingTelemetry(row); var energyCell = missing ? '