Download ui-base.js from agent-memory-leaderboard/leaderboard: direct link, hf CLI and curl.
- Browser
- Download file 8.67 kB
-
https://huggingface.co/spaces/agent-memory-leaderboard/leaderboard/resolve/main/ui-base.js
- Command line
-
hf download hf://spaces/agent-memory-leaderboard/leaderboard/ui-base.js
-
curl -L -o ui-base.js https://huggingface.co/spaces/agent-memory-leaderboard/leaderboard/resolve/main/ui-base.js
8.67 kB
| function formatScore(value) { | |
| return Number.isFinite(value) ? value.toFixed(2) : "--"; | |
| } | |
| function renderLeaderboard() {} | |
| const leaderboardConfig = { | |
| textual: { | |
| categories: [ | |
| null, | |
| ["Explicit Fact Recall", "Facts, attributes, sources, and entities recalled from long histories."], | |
| ["Compositional Inference", "Relations and multi-hop evidence combined across memory fragments."], | |
| ["Temporal & Event Reasoning", "Dates, ordering, intervals, and evolving states over time."], | |
| ["Memory Governance", "Updates, conflict resolution, deletion, and forgetting."], | |
| ["Personalization & Care", "Preferences, background, wellbeing context, and appropriate adaptation."], | |
| ["Context Learning & Execution", "Rules, procedures, domain constraints, and format execution."], | |
| ["Safety & Privacy", "Evidence boundaries, robust abstention, and minimal disclosure."], | |
| ], | |
| }, | |
| coding: { | |
| categories: [ | |
| null, | |
| ["New Feature", "Performance across 51 new-feature implementation tasks."], | |
| ["Bug Fix", "Performance across 99 bug-fixing tasks."], | |
| ], | |
| }, | |
| }; | |
| function renderGithubIconLink(url, systemName) { | |
| const link = document.createElement("a"); | |
| link.href = url; | |
| link.target = "_blank"; | |
| link.rel = "noreferrer"; | |
| link.className = "github-icon-link"; | |
| link.setAttribute("aria-label", `Open ${systemName} GitHub repository`); | |
| link.title = "GitHub"; | |
| link.innerHTML = ` | |
| <svg viewBox="0 0 16 16" aria-hidden="true" focusable="false"> | |
| <path d="M8 0.2A8 8 0 0 0 5.47 15.8c0.4 0.07 0.55-0.17 0.55-0.38v-1.36c-2.22 0.48-2.69-1.07-2.69-1.07-0.36-0.92-0.88-1.17-0.88-1.17-0.72-0.49 0.05-0.48 0.05-0.48 0.8 0.06 1.22 0.82 1.22 0.82 0.71 1.22 1.87 0.87 2.32 0.66 0.07-0.52 0.28-0.87 0.51-1.07-1.77-0.2-3.64-0.89-3.64-3.95 0-0.87 0.31-1.58 0.82-2.14-0.08-0.2-0.36-1.01 0.08-2.11 0 0 0.67-0.21 2.2 0.82A7.5 7.5 0 0 1 8 4.1c0.68 0 1.36 0.09 2 0.27 1.52-1.03 2.19-0.82 2.19-0.82 0.44 1.1 0.16 1.91 0.08 2.11 0.51 0.56 0.82 1.27 0.82 2.14 0 3.07-1.87 3.75-3.65 3.95 0.29 0.25 0.54 0.73 0.54 1.48v2.19c0 0.21 0.15 0.46 0.55 0.38A8 8 0 0 0 8 0.2Z" /> | |
| </svg>`; | |
| return link; | |
| } | |
| let activeBadgeTooltip = null; | |
| function hideBadgeTooltip() { | |
| if (activeBadgeTooltip) { | |
| activeBadgeTooltip.remove(); | |
| activeBadgeTooltip = null; | |
| } | |
| } | |
| function showBadgeTooltip(target) { | |
| const text = target.dataset.tooltip; | |
| if (!text) return; | |
| hideBadgeTooltip(); | |
| const tooltip = document.createElement("span"); | |
| tooltip.className = "badge-floating-tooltip"; | |
| tooltip.textContent = text; | |
| document.body.append(tooltip); | |
| const rect = target.getBoundingClientRect(); | |
| const margin = 10; | |
| const tooltipRect = tooltip.getBoundingClientRect(); | |
| const left = Math.min( | |
| Math.max(rect.left, margin), | |
| window.innerWidth - tooltipRect.width - margin, | |
| ); | |
| const top = Math.max(rect.top - tooltipRect.height - 10, margin); | |
| tooltip.style.left = `${left}px`; | |
| tooltip.style.top = `${top}px`; | |
| activeBadgeTooltip = tooltip; | |
| } | |
| function attachBadgeTooltip(target) { | |
| target.addEventListener("mouseenter", () => showBadgeTooltip(target)); | |
| target.addEventListener("mouseleave", hideBadgeTooltip); | |
| target.addEventListener("focus", () => showBadgeTooltip(target)); | |
| target.addEventListener("blur", hideBadgeTooltip); | |
| } | |
| function getScoreTier(value, tiers) { | |
| return tiers.findIndex((score) => score === value) + 1; | |
| } | |
| function getColumnTiers(rows, field) { | |
| return [...new Set(rows.map((entry) => entry[field]).filter(Number.isFinite))] | |
| .sort((a, b) => b - a) | |
| .slice(0, 3); | |
| } | |
| function getCompetitionRanks(rows, field) { | |
| const ranks = []; | |
| let lastScore = null; | |
| let lastRank = 0; | |
| rows.forEach((entry, index) => { | |
| const score = entry[field]; | |
| if (!Number.isFinite(score)) { | |
| ranks.push(index + 1); | |
| lastScore = score; | |
| lastRank = index + 1; | |
| return; | |
| } | |
| if (index === 0 || score !== lastScore) { | |
| lastRank = index + 1; | |
| } | |
| ranks.push(lastRank); | |
| lastScore = score; | |
| }); | |
| return ranks; | |
| } | |
| function renderScoreCell(value, tier) { | |
| const cell = document.createElement("span"); | |
| cell.className = "score-cell"; | |
| const score = document.createElement("b"); | |
| score.className = tier > 0 ? `score-value score-rank-${tier}` : "score-value"; | |
| score.textContent = formatScore(value); | |
| cell.append(score); | |
| return cell; | |
| } | |
| function renderStatusCell(value, type) { | |
| const cell = document.createElement("span"); | |
| cell.className = `score-cell ${type === "volume" ? "volume-cell" : "speed-cell"}`; | |
| const status = document.createElement("b"); | |
| const normalized = typeof value === "string" ? value : "--"; | |
| const statusMap = { | |
| "快速": { className: "speed-fast", label: "Fast" }, | |
| Fast: { className: "speed-fast", label: "Fast" }, | |
| "中速": { className: "speed-medium", label: "Medium" }, | |
| Medium: { className: "speed-medium", label: "Medium" }, | |
| "慢速": { className: "speed-slow", label: "Slow" }, | |
| Slow: { className: "speed-slow", label: "Slow" }, | |
| Compact: { className: "volume-compact", label: "Compact" }, | |
| Balanced: { className: "volume-balanced", label: "Balanced" }, | |
| Verbose: { className: "volume-verbose", label: "Verbose" }, | |
| }; | |
| const state = statusMap[normalized] || { className: "speed-unknown", label: "--" }; | |
| if (type === "volume") { | |
| status.className = `speed-value volume-value ${state.className}`; | |
| status.textContent = state.label; | |
| } else { | |
| status.className = `speed-inline ${state.className}`; | |
| status.innerHTML = `<span class="speed-divider" aria-hidden="true">|</span><span>${state.label}</span>`; | |
| } | |
| cell.append(status); | |
| return cell; | |
| } | |
| function renderTextCell(value) { | |
| const cell = document.createElement("span"); | |
| cell.className = "text-cell"; | |
| cell.textContent = value || "--"; | |
| return cell; | |
| } | |
| function renderMetricCell(entry, metric, tiers) { | |
| if (metric.type === "text") { | |
| return renderTextCell(entry[metric.field]); | |
| } | |
| if (metric.type === "speed" || metric.type === "volume") { | |
| return renderStatusCell(entry[metric.field], metric.type); | |
| } | |
| return renderScoreCell(entry[metric.field], getScoreTier(entry[metric.field], tiers)); | |
| } | |
| const state = { | |
| view: window.location.hash === "#leaderboard" ? "leaderboard" : "home", | |
| track: "textual", | |
| division: "academic", | |
| category: 0, | |
| }; | |
| function setView(view, updateHash = true) { | |
| state.view = view; | |
| document.querySelectorAll("[data-view]").forEach((element) => { | |
| const active = element.dataset.view === view; | |
| element.hidden = !active; | |
| element.classList.toggle("is-active", active); | |
| }); | |
| document.querySelectorAll(".nav-link[data-view-link]").forEach((button) => { | |
| button.classList.toggle("is-active", button.dataset.viewLink === view); | |
| }); | |
| if (updateHash) { | |
| history.pushState(null, "", view === "leaderboard" ? "#leaderboard" : "#home"); | |
| } | |
| window.scrollTo({ top: 0, behavior: "smooth" }); | |
| } | |
| document.querySelectorAll("[data-view-link]").forEach((element) => { | |
| element.addEventListener("click", (event) => { | |
| event.preventDefault(); | |
| setView(element.dataset.viewLink); | |
| }); | |
| }); | |
| document.querySelectorAll("[data-open-track]").forEach((button) => { | |
| button.addEventListener("click", () => { | |
| state.track = button.dataset.openTrack; | |
| state.category = 0; | |
| document.querySelectorAll("[data-track]").forEach((trackButton) => { | |
| const active = trackButton.dataset.track === state.track; | |
| trackButton.classList.toggle("is-active", active); | |
| trackButton.setAttribute("aria-selected", String(active)); | |
| }); | |
| renderLeaderboard(); | |
| setView("leaderboard"); | |
| }); | |
| }); | |
| document.querySelectorAll("[data-track]").forEach((button) => { | |
| button.addEventListener("click", () => { | |
| state.track = button.dataset.track; | |
| state.category = 0; | |
| document.querySelectorAll("[data-track]").forEach((trackButton) => { | |
| const active = trackButton === button; | |
| trackButton.classList.toggle("is-active", active); | |
| trackButton.setAttribute("aria-selected", String(active)); | |
| }); | |
| renderLeaderboard(); | |
| }); | |
| }); | |
| document.querySelectorAll("[data-division]").forEach((button) => { | |
| button.addEventListener("click", () => { | |
| state.division = button.dataset.division; | |
| document.querySelectorAll("[data-division]").forEach((divisionButton) => { | |
| const active = divisionButton === button; | |
| divisionButton.classList.toggle("is-active", active); | |
| divisionButton.setAttribute("aria-selected", String(active)); | |
| }); | |
| renderLeaderboard(); | |
| }); | |
| }); | |
| window.addEventListener("popstate", () => { | |
| setView(window.location.hash === "#leaderboard" ? "leaderboard" : "home", false); | |
| }); | |