Spaces:
Runtime error
Runtime error
| custom_css = """ | |
| /* Sort arrow/button styles */ | |
| .sort-arrow, .sort-btn { | |
| display: inline-flex; | |
| align-items: center; | |
| justify-content: center; | |
| background: #23244a; | |
| color: #ffd700 !important; /* ํญ์ ๋ ธ๋์ */ | |
| border: 1.5px solid #ffd700; /* ๊ธ์ ํ ๋๋ฆฌ */ | |
| border-radius: 6px; | |
| font-size: 15px; | |
| font-weight: 700; | |
| margin-left: 6px; | |
| margin-right: 2px; | |
| padding: 2px 8px 2px 6px; | |
| cursor: pointer; | |
| transition: background 0.2s, color 0.2s, border 0.2s; | |
| min-width: 28px; | |
| min-height: 28px; | |
| outline: none; | |
| } | |
| .sort-arrow.active, .sort-btn.active { | |
| color: #ffd700 !important; /* ๊ธ์ */ | |
| border-color: #ffd700; | |
| background: #1a237e; | |
| } | |
| .sort-arrow:hover, .sort-btn:hover { | |
| background: #ffd700; | |
| color: #23244a !important; | |
| border-color: #ffd700; | |
| } | |
| .sort-arrow svg, .sort-btn svg { | |
| margin-left: 2px; | |
| margin-right: 0; | |
| width: 1em; | |
| height: 1em; | |
| vertical-align: middle; | |
| } | |
| /* Enhanced leaderboard table styles */ | |
| .pretty-leaderboard-table { | |
| width: 100%; | |
| border-collapse: separate; | |
| border-spacing: 0; | |
| background: rgba(30, 34, 54, 0.98); | |
| border-radius: 16px; | |
| box-shadow: 0 4px 24px 0 rgba(16, 152, 247, 0.10), 0 1.5px 6px 0 rgba(227, 84, 84, 0.08); | |
| overflow: hidden; | |
| margin-bottom: 24px; | |
| } | |
| .pretty-leaderboard-table th, .pretty-leaderboard-table td { | |
| padding: 12px 16px; | |
| text-align: left; | |
| border-bottom: 1px solid #23244a; | |
| font-size: 15px; | |
| } | |
| .pretty-leaderboard-table th { | |
| background: linear-gradient(90deg, #23244a 0%, #1a237e 100%); | |
| color: #F5F6F7; | |
| font-weight: 700; | |
| letter-spacing: 0.5px; | |
| border-bottom: 2px solid #1098F7; | |
| } | |
| .pretty-leaderboard-table tr:nth-child(even) { | |
| background: rgba(245, 246, 247, 0.03); | |
| } | |
| .pretty-leaderboard-table tr:hover { | |
| background: rgba(16, 152, 247, 0.08); | |
| transition: background 0.2s; | |
| } | |
| .pretty-leaderboard-table td { | |
| color: #F5F6F7; | |
| vertical-align: middle; | |
| } | |
| .pretty-leaderboard-table tr:last-child td { | |
| border-bottom: none; | |
| } | |
| .pretty-leaderboard-table th:first-child, .pretty-leaderboard-table td:first-child { | |
| border-top-left-radius: 16px; | |
| } | |
| .pretty-leaderboard-table th:last-child, .pretty-leaderboard-table td:last-child { | |
| border-top-right-radius: 16px; | |
| } | |
| /* Enhanced score bar styles */ | |
| .score-bar { | |
| display: flex; | |
| align-items: center; | |
| gap: 12px; | |
| width: 100%; | |
| } | |
| .score-bar-track { | |
| flex-grow: 1; | |
| height: 10px; | |
| background: rgba(245, 246, 247, 0.12); | |
| border-radius: 5px; | |
| overflow: hidden; | |
| max-width: 220px; | |
| box-shadow: 0 1px 4px 0 rgba(16, 152, 247, 0.10); | |
| } | |
| .score-bar-fill { | |
| height: 100%; | |
| background: linear-gradient(90deg, #E35454, #1098F7); | |
| border-radius: 5px; | |
| transition: width 0.3s cubic-bezier(0.4,0,0.2,1); | |
| } | |
| .score-bar-value { | |
| font-family: 'SF Mono', monospace; | |
| font-weight: 600; | |
| color: #F5F6F7; | |
| min-width: 60px; | |
| font-size: 14px; | |
| } | |
| body { | |
| min-height: 100vh; | |
| background: linear-gradient(135deg, #1a237e 0%, #311b92 100%); | |
| background-image: | |
| radial-gradient(rgba(255,255,255,0.12) 1.2px, transparent 1.2px), | |
| radial-gradient(rgba(255,255,255,0.08) 1px, transparent 1px); | |
| background-size: 40px 40px, 80px 80px; | |
| background-position: 0 0, 20px 20px; | |
| } | |
| .markdown-text { | |
| font-size: 16px !important; | |
| } | |
| #models-to-add-text { | |
| font-size: 18px !important; | |
| } | |
| #citation-button span { | |
| font-size: 16px !important; | |
| } | |
| #citation-button textarea { | |
| font-size: 16px !important; | |
| } | |
| #citation-button > label > button { | |
| margin: 6px; | |
| transform: scale(1.3); | |
| } | |
| #leaderboard-table { | |
| margin-top: 15px; | |
| /* Space-themed background */ | |
| background: linear-gradient(135deg, #1a237e 0%, #311b92 100%); | |
| position: relative; | |
| background-image: | |
| radial-gradient(rgba(255,255,255,0.15) 1.2px, transparent 1.2px), | |
| radial-gradient(rgba(255,255,255,0.10) 1px, transparent 1px); | |
| background-size: 40px 40px, 80px 80px; | |
| background-position: 0 0, 20px 20px; | |
| } | |
| #leaderboard-table-lite { | |
| margin-top: 15px | |
| } | |
| #search-bar-table-box > div:first-child { | |
| background: none; | |
| border: none; | |
| } | |
| #search-bar { | |
| padding: 0px; | |
| } | |
| /* Limit the width of the first AutoEvalColumn so that names don't expand too much */ | |
| #leaderboard-table td:nth-child(2), | |
| #leaderboard-table th:nth-child(2) { | |
| max-width: 400px; | |
| overflow: auto; | |
| white-space: nowrap; | |
| } | |
| .tab-buttons button { | |
| font-size: 20px; | |
| } | |
| #scale-logo { | |
| border-style: none !important; | |
| box-shadow: none; | |
| display: block; | |
| margin-left: auto; | |
| margin-right: auto; | |
| max-width: 600px; | |
| } | |
| #scale-logo .download { | |
| display: none; | |
| } | |
| #filter_type{ | |
| border: 0; | |
| padding-left: 0; | |
| padding-top: 0; | |
| } | |
| #filter_type label { | |
| display: flex; | |
| } | |
| #filter_type label > span{ | |
| margin-top: var(--spacing-lg); | |
| margin-right: 0.5em; | |
| } | |
| #filter_type label > .wrap{ | |
| width: 103px; | |
| } | |
| #filter_type label > .wrap .wrap-inner{ | |
| padding: 2px; | |
| } | |
| #filter_type label > .wrap .wrap-inner input{ | |
| width: 1px | |
| } | |
| #filter-columns-type{ | |
| border:0; | |
| padding:0.5; | |
| } | |
| #filter-columns-size{ | |
| border:0; | |
| padding:0.5; | |
| } | |
| #box-filter > .form{ | |
| border: 0 | |
| } | |
| /* Model type and output form badge styles */ | |
| .badge { | |
| display: inline-block; | |
| border-radius: 12px; | |
| padding: 2px 10px; | |
| font-size: 0.85em; | |
| font-weight: 700; | |
| margin-left: 6px; | |
| box-shadow: 0 1px 4px rgba(0,0,0,0.10); | |
| vertical-align: middle; | |
| } | |
| .badge-open { | |
| background: linear-gradient(90deg, #2196f3, #21cbf3); | |
| color: #fff; | |
| } | |
| .badge-closed { | |
| background: linear-gradient(90deg, #757575, #bdbdbd); | |
| color: #fff; | |
| } | |
| .badge-normal { | |
| background: linear-gradient(90deg, #43a047, #66bb6a); | |
| color: #fff; | |
| } | |
| .badge-reasoning { | |
| background: linear-gradient(90deg, #8e24aa, #d500f9); | |
| color: #fff; | |
| } | |
| /* Sort button styles */ | |
| .sort-btn { | |
| background: #23244a; | |
| color: #F5F6F7; | |
| border: 1px solid #1098F7; | |
| border-radius: 6px; | |
| font-size: 13px; | |
| font-weight: 700; | |
| margin-left: 4px; | |
| margin-right: 2px; | |
| padding: 2px 7px; | |
| cursor: pointer; | |
| transition: background 0.2s, color 0.2s; | |
| } | |
| .sort-btn:hover { | |
| background: #1098F7; | |
| color: #fff; | |
| } | |
| """ | |
| get_window_url_params = """ | |
| function(url_params) { | |
| const params = new URLSearchParams(window.location.search); | |
| url_params = Object.fromEntries(params); | |
| return url_params; | |
| } | |
| """ | |
| def get_rank_badge(rank: int) -> str: | |
| """ | |
| Returns HTML for a rank badge (1st, 2nd, 3rd) with appropriate styling. | |
| """ | |
| badge_styles = { | |
| 1: ("1st", "linear-gradient(145deg, #ffd700, #ffc400)", "#000"), | |
| 2: ("2nd", "linear-gradient(145deg, #9ca3af, #787C7E)", "#fff"), | |
| 3: ("3rd", "linear-gradient(145deg, #CD7F32, #b36a1d)", "#fff"), | |
| } | |
| if rank in badge_styles: | |
| label, gradient, text_color = badge_styles[rank] | |
| return f''' | |
| <div style=" | |
| display: inline-flex; | |
| align-items: center; | |
| justify-content: center; | |
| min-width: 48px; | |
| padding: 4px 12px; | |
| background: {gradient}; | |
| color: {text_color}; | |
| border-radius: 6px; | |
| font-weight: 700; | |
| font-size: 1em; | |
| box-shadow: 0 2px 4px rgba(0,0,0,0.18); | |
| border: 1.5px solid #fff2; | |
| "> | |
| {label} | |
| </div> | |
| ''' | |
| return f''' | |
| <div style=" | |
| display: inline-flex; | |
| align-items: center; | |
| justify-content: center; | |
| min-width: 28px; | |
| color: #a1a1aa; | |
| font-weight: 500; | |
| "> | |
| {rank} | |
| </div> | |
| ''' | |
| def get_score_gauge(score: float, max_score: float = 1.0) -> str: | |
| """ | |
| Returns HTML for an overall score gauge (progress bar style). | |
| """ | |
| percent = min(max(score / max_score, 0), 1) * 100 | |
| return f''' | |
| <div class="score-bar" style="margin: 0.5em 0;"> | |
| <div class="score-bar-track"> | |
| <div class="score-bar-fill" style="width: {percent}%;"></div> | |
| </div> | |
| <span class="score-bar-value">{score:.3f}</span> | |
| </div> | |
| ''' | |
| def get_leaderboard_table_html(df) -> str: | |
| """ | |
| Returns HTML for a pretty leaderboard table using badge and gauge. | |
| Expects df to have columns: 'Model', 'Score', 'Model Type', 'Output Form'. | |
| """ | |
| def get_type_badge(model_type): | |
| if model_type == "open": | |
| return '<span class="badge badge-open">open</span>' | |
| else: | |
| return '<span class="badge badge-closed">closed</span>' | |
| def get_output_badge(output_form): | |
| if output_form == "reasoning": | |
| return '<span class="badge badge-reasoning">reasoning</span>' | |
| else: | |
| return '<span class="badge badge-normal">normal</span>' | |
| html = ['<table class="pretty-leaderboard-table">'] | |
| # Header | |
| html.append( | |
| "<thead><tr>" | |
| "<th>Rank</th>" | |
| "<th>Model</th>" | |
| "<th>Overall Score</th>" | |
| "</tr></thead>" | |
| ) | |
| html.append("<tbody>") | |
| for idx, row in enumerate(df.itertuples(index=False), 1): | |
| model = getattr(row, "Model", "") | |
| score = getattr(row, "Score", 0.0) | |
| model_type = getattr(row, "Model_Type", getattr(row, "Model Type", "open")) | |
| output_form = getattr(row, "Output_Form", getattr(row, "Output Form", "normal")) | |
| badge = get_rank_badge(idx) | |
| gauge = get_score_gauge(score) | |
| type_badge = get_type_badge(model_type) | |
| output_badge = get_output_badge(output_form) | |
| html.append( | |
| f"<tr>" | |
| f"<td>{badge}</td>" | |
| f"<td>{model} {type_badge} {output_badge}</td>" | |
| f"<td>{gauge}</td>" | |
| f"</tr>" | |
| ) | |
| html.append("</tbody></table>") | |
| return "\n".join(html) | |