Spaces:
Running
Running
Update leaderboard.py
Browse files- leaderboard.py +212 -212
leaderboard.py
CHANGED
|
@@ -1,212 +1,212 @@
|
|
| 1 |
-
import pandas as pd
|
| 2 |
-
from typing import Optional
|
| 3 |
-
|
| 4 |
-
# Mock Helper Functions
|
| 5 |
-
def get_rank_badge(rank):
|
| 6 |
-
colors = {1: "#FFD700", 2: "#C0C0C0", 3: "#CD7F32"}
|
| 7 |
-
color = colors.get(rank, "#64748B")
|
| 8 |
-
return f'<span style="display: inline-block; width: 28px; height: 28px; line-height: 28px; text-align: center; border-radius: 50%; background-color: {color}; color: white; font-weight: bold;">{rank}</span>'
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
def get_success_rate_bar(rate):
|
| 12 |
-
if pd.isna(rate):
|
| 13 |
-
return "N/A"
|
| 14 |
-
color = "#10B981" if rate >= 75 else "#F59E0B" if rate >= 50 else "#EF4444"
|
| 15 |
-
return f"""
|
| 16 |
-
<div style="background-color: #E2E8F0; border-radius: 6px; overflow: hidden; height: 20px; position: relative;">
|
| 17 |
-
<div style="width: {rate}%; background-color: {color}; height: 100%;"></div>
|
| 18 |
-
<span style="position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #0F172A; font-weight: 600; font-size: 12px;">{rate:.1f}%</span>
|
| 19 |
-
</div>
|
| 20 |
-
"""
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
def get_gpu_utilization_bar(util):
|
| 24 |
-
return get_success_rate_bar(util)
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
def get_provider_badge(provider):
|
| 28 |
-
color = "#4F46E5" if provider == "litellm" else "#14B8A6"
|
| 29 |
-
return f'<span style="background-color: {color}; color: white; padding: 4px 8px; border-radius: 12px; font-size: 12px; font-weight: 500;">{provider}</span>'
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
def get_agent_type_badge(agent_type):
|
| 33 |
-
color = "#0EA5E9"
|
| 34 |
-
return f'<span style="background-color: {color}; color: white; padding: 4px 8px; border-radius: 12px; font-size: 12px; font-weight: 500;">{agent_type}</span>'
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
def get_hardware_badge(has_gpu):
|
| 38 |
-
label = "GPU" if has_gpu else "CPU"
|
| 39 |
-
color = "#10B981" if has_gpu else "#F59E0B"
|
| 40 |
-
return f'<span style="background-color: {color}; color: white; padding: 4px 8px; border-radius: 12px; font-size: 12px; font-weight: 500;">{label}</span>'
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
def format_cost(cost):
|
| 44 |
-
if pd.isna(cost):
|
| 45 |
-
return "N/A"
|
| 46 |
-
return f"${cost:.4f}"
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
def format_duration(ms):
|
| 50 |
-
if pd.isna(ms):
|
| 51 |
-
return "N/A"
|
| 52 |
-
return f"{ms / 1000:.2f}s"
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
def generate_leaderboard_html(
|
| 56 |
-
df: pd.DataFrame, sort_by: str = "success_rate", ascending: bool = False
|
| 57 |
-
) -> str:
|
| 58 |
-
"""
|
| 59 |
-
Generates a styled HTML table for the leaderboard.
|
| 60 |
-
|
| 61 |
-
Args:
|
| 62 |
-
df: The leaderboard DataFrame.
|
| 63 |
-
sort_by: The column to sort the DataFrame by.
|
| 64 |
-
ascending: The sort order.
|
| 65 |
-
|
| 66 |
-
Returns:
|
| 67 |
-
A string containing the complete HTML for the table.
|
| 68 |
-
"""
|
| 69 |
-
df_sorted = df.sort_values(by=sort_by, ascending=ascending).reset_index(drop=True)
|
| 70 |
-
|
| 71 |
-
html = """
|
| 72 |
-
<style>
|
| 73 |
-
/* Leaderboard Table Styles */
|
| 74 |
-
.tm-action-button {
|
| 75 |
-
background-color: #EF4444;
|
| 76 |
-
color: white;
|
| 77 |
-
border: none;
|
| 78 |
-
padding: 6px 12px;
|
| 79 |
-
border-radius: 6px;
|
| 80 |
-
font-size: 12px;
|
| 81 |
-
font-weight: 500;
|
| 82 |
-
cursor: pointer;
|
| 83 |
-
transition: background-color 0.2s ease;
|
| 84 |
-
}
|
| 85 |
-
.tm-action-button:hover {
|
| 86 |
-
background-color: #DC2626; /* Darker red on hover */
|
| 87 |
-
}
|
| 88 |
-
.tm-leaderboard-container { background: #F8FAFC; border-radius: 16px; overflow-x: auto; overflow-y: visible; border: 1px solid rgba(203, 213, 225, 0.8); margin: 20px 0; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); max-width: 100%; }
|
| 89 |
-
.tm-leaderboard-container::-webkit-scrollbar { height: 8px; }
|
| 90 |
-
.tm-leaderboard-container::-webkit-scrollbar-track { background: #E2E8F0; border-radius: 4px; }
|
| 91 |
-
.tm-leaderboard-container::-webkit-scrollbar-thumb { background: #94A3B8; border-radius: 4px; }
|
| 92 |
-
.tm-leaderboard-container::-webkit-scrollbar-thumb:hover { background: #64748B; }
|
| 93 |
-
.tm-leaderboard-table { width: 100%; min-width: 1650px; border-collapse: collapse; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #FFFFFF; color: #0F172A; }
|
| 94 |
-
.tm-leaderboard-table thead { background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(10px); }
|
| 95 |
-
.tm-leaderboard-table th { padding: 16px 12px; text-align: left; font-weight: 600; color: #FFFFFF; border-bottom: 2px solid #4338CA; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
|
| 96 |
-
.tm-leaderboard-table td { padding: 14px 12px; border-bottom: 1px solid rgba(226, 232, 240, 0.8); color: #1E293B; font-size: 14px; vertical-align: middle; }
|
| 97 |
-
.tm-leaderboard-table tbody tr { transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); cursor: pointer; }
|
| 98 |
-
.tm-leaderboard-table tbody tr:hover { background: rgba(99, 102, 241, 0.08) !important; box-shadow: 0 0 15px rgba(99, 102, 241, 0.15), inset 0 0 15px rgba(99, 102, 241, 0.05); transform: scale(1.002); }
|
| 99 |
-
.tm-leaderboard-table tbody tr:nth-child(even) { background: rgba(241, 245, 249, 0.6); }
|
| 100 |
-
.tm-model-name { font-weight: 600; color: #000000 !important; font-size: 15px; transition: color 0.2s ease; }
|
| 101 |
-
.tm-leaderboard-table tr:hover .tm-model-name { color: #4F46E5 !important; }
|
| 102 |
-
.tm-numeric-cell { font-family: 'Monaco', 'Menlo', monospace; font-size: 13px; text-align: center; color: #000000 !important; }
|
| 103 |
-
.tm-badge-cell { text-align: center; }
|
| 104 |
-
.tm-run-id { font-family: 'Monaco', 'Menlo', monospace; font-size: 12px; color: #000000 !important; cursor: pointer; text-decoration: none; font-weight: 500; transition: all 0.2s ease; }
|
| 105 |
-
.tm-run-id:hover { color: #4F46E5 !important; text-decoration: underline; }
|
| 106 |
-
.tm-text-cell { color: #000000 !important; font-size: 0.9em; }
|
| 107 |
-
@media (max-width: 1024px) { .tm-leaderboard-table th, .tm-leaderboard-table td { padding: 10px 8px; font-size: 12px; } .tm-hide-mobile { display: none !important; } }
|
| 108 |
-
@media (max-width: 768px) { .tm-leaderboard-table th:nth-child(n+7), .tm-leaderboard-table td:nth-child(n+7) { display: none !important; } .tm-model-name { font-size: 13px; } }
|
| 109 |
-
@media (max-width: 480px) { .tm-leaderboard-table th:nth-child(n+4), .tm-leaderboard-table td:nth-child(n+4) { display: none !important; } .tm-leaderboard-table th:nth-child(3), .tm-leaderboard-table td:nth-child(3) { display: table-cell !important; } }
|
| 110 |
-
</style>
|
| 111 |
-
|
| 112 |
-
<div class="tm-leaderboard-container">
|
| 113 |
-
<table class="tm-leaderboard-table">
|
| 114 |
-
<thead>
|
| 115 |
-
<tr>
|
| 116 |
-
<th style="width: 60px;">Rank</th>
|
| 117 |
-
<th style="width: 110px;" title="Run ID">Run ID</th>
|
| 118 |
-
<th style="min-width: 160px;">Model</th>
|
| 119 |
-
<th style="width: 80px;">Type</th>
|
| 120 |
-
<th style="width: 90px;">Provider</th>
|
| 121 |
-
<th style="width: 85px;" title="Hardware used for evaluation: GPU or CPU">Hardware</th>
|
| 122 |
-
<th style="width: 150px;" title="Percentage of test cases that passed (0-100%). Higher is better.">Success Rate</th>
|
| 123 |
-
<th style="width: 140px;" class="tm-numeric-cell" title="Tests: Total / Pass / Fail">Tests (P/F)</th>
|
| 124 |
-
<th style="width: 70px;" class="tm-numeric-cell" title="Average number of steps per test case.">Steps</th>
|
| 125 |
-
<th style="width: 100px;" class="tm-numeric-cell" title="Average time per test case. Lower is better.">Duration</th>
|
| 126 |
-
<th style="width: 90px;" class="tm-numeric-cell" title="Total tokens used across all tests.">Tokens</th>
|
| 127 |
-
<th style="width: 90px;" class="tm-numeric-cell" title="Total API + power costs in USD. Lower is better.">Cost</th>
|
| 128 |
-
<th style="width: 80px;" class="tm-numeric-cell tm-hide-mobile" title="Carbon footprint in grams of CO2 equivalent.">CO2</th>
|
| 129 |
-
<th style="width: 100px;" class="tm-hide-mobile" title="Average GPU usage during evaluation (0-100%).">GPU Util</th>
|
| 130 |
-
<th style="width: 140px;" class="tm-hide-mobile">Timestamp</th>
|
| 131 |
-
<th style="width: 110px;" class="tm-hide-mobile">Submitted By</th>
|
| 132 |
-
<th style="width: 100px;">Actions</th>
|
| 133 |
-
</tr>
|
| 134 |
-
</thead>
|
| 135 |
-
<tbody>
|
| 136 |
-
"""
|
| 137 |
-
|
| 138 |
-
for idx, row in df_sorted.iterrows():
|
| 139 |
-
rank = idx + 1
|
| 140 |
-
model = row.get("model", "Unknown")
|
| 141 |
-
agent_type = row.get("agent_type", "unknown")
|
| 142 |
-
provider = row.get("provider", "unknown")
|
| 143 |
-
success_rate = row.get("success_rate", 0.0)
|
| 144 |
-
total_tests = row.get("total_tests", 0)
|
| 145 |
-
successful_tests = row.get("successful_tests", 0)
|
| 146 |
-
failed_tests = row.get("failed_tests", 0)
|
| 147 |
-
avg_steps = row.get("avg_steps", 0.0)
|
| 148 |
-
avg_duration_ms = row.get("avg_duration_ms", 0.0)
|
| 149 |
-
total_tokens = row.get("total_tokens", 0)
|
| 150 |
-
total_cost_usd = row.get("total_cost_usd", 0.0)
|
| 151 |
-
co2_emissions_g = row.get("co2_emissions_g", 0.0)
|
| 152 |
-
gpu_utilization_avg = row.get("gpu_utilization_avg", None)
|
| 153 |
-
timestamp = row.get("timestamp", "")
|
| 154 |
-
submitted_by = row.get("submitted_by", "Unknown")
|
| 155 |
-
run_id = row.get("run_id", "N/A")
|
| 156 |
-
|
| 157 |
-
has_gpu = pd.notna(gpu_utilization_avg) and gpu_utilization_avg > 0
|
| 158 |
-
gpu_display = (
|
| 159 |
-
get_gpu_utilization_bar(gpu_utilization_avg)
|
| 160 |
-
if has_gpu
|
| 161 |
-
else '<span style="color: #94A3B8; font-size: 0.85em;">N/A</span>'
|
| 162 |
-
)
|
| 163 |
-
co2_display = (
|
| 164 |
-
f"{co2_emissions_g:.2f}g"
|
| 165 |
-
if pd.notna(co2_emissions_g) and co2_emissions_g > 0
|
| 166 |
-
else '<span style="color: #94A3B8; font-size: 0.85em;">N/A</span>'
|
| 167 |
-
)
|
| 168 |
-
timestamp_display = str(timestamp)[:16] if pd.notna(timestamp) else "N/A"
|
| 169 |
-
run_id_short = run_id[:8] + "..." if len(run_id) > 8 else run_id
|
| 170 |
-
|
| 171 |
-
data_attrs_dict = {
|
| 172 |
-
f"data-{key.replace('_', '-')}": value
|
| 173 |
-
for key, value in row.to_dict().items()
|
| 174 |
-
}
|
| 175 |
-
data_attrs = " ".join(
|
| 176 |
-
[f'{key}="{value}"' for key, value in data_attrs_dict.items()]
|
| 177 |
-
)
|
| 178 |
-
|
| 179 |
-
html += f"""
|
| 180 |
-
<tr {data_attrs}>
|
| 181 |
-
<td>{get_rank_badge(rank)}</td>
|
| 182 |
-
<td class="tm-run-id" title="{run_id}">{run_id_short}</td>
|
| 183 |
-
<td class="tm-model-name">{model}</td>
|
| 184 |
-
<td class="tm-badge-cell">{get_agent_type_badge(agent_type)}</td>
|
| 185 |
-
<td class="tm-badge-cell">{get_provider_badge(provider)}</td>
|
| 186 |
-
<td class="tm-badge-cell">{get_hardware_badge(has_gpu)}</td>
|
| 187 |
-
<td>{get_success_rate_bar(success_rate)}</td>
|
| 188 |
-
<td class="tm-numeric-cell">
|
| 189 |
-
<strong>{total_tests}</strong> / <span style="color: #10B981;">{successful_tests}</span> / <span style="color: #EF4444;">{failed_tests}</span>
|
| 190 |
-
</td>
|
| 191 |
-
<td class="tm-numeric-cell">{avg_steps:.1f}</td>
|
| 192 |
-
<td class="tm-numeric-cell">{format_duration(avg_duration_ms)}</td>
|
| 193 |
-
<td class="tm-numeric-cell">{total_tokens:,}</td>
|
| 194 |
-
<td class="tm-numeric-cell">{format_cost(total_cost_usd)}</td>
|
| 195 |
-
<td class="tm-numeric-cell tm-hide-mobile">{co2_display}</td>
|
| 196 |
-
<td class="tm-hide-mobile">{gpu_display}</td>
|
| 197 |
-
<td class="tm-hide-mobile tm-text-cell">{timestamp_display}</td>
|
| 198 |
-
<td class="tm-hide-mobile tm-text-cell">{submitted_by}</td>
|
| 199 |
-
<td>
|
| 200 |
-
<button class="tm-action-button" data-action="delete" data-run-id="{run_id}">
|
| 201 |
-
Delete
|
| 202 |
-
</button>
|
| 203 |
-
</td>
|
| 204 |
-
</tr>
|
| 205 |
-
"""
|
| 206 |
-
|
| 207 |
-
html += """
|
| 208 |
-
</tbody>
|
| 209 |
-
</table>
|
| 210 |
-
</div>
|
| 211 |
-
"""
|
| 212 |
-
return html
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
from typing import Optional
|
| 3 |
+
|
| 4 |
+
# Mock Helper Functions
|
| 5 |
+
def get_rank_badge(rank):
|
| 6 |
+
colors = {1: "#FFD700", 2: "#C0C0C0", 3: "#CD7F32"}
|
| 7 |
+
color = colors.get(rank, "#64748B")
|
| 8 |
+
return f'<span style="display: inline-block; width: 28px; height: 28px; line-height: 28px; text-align: center; border-radius: 50%; background-color: {color}; color: white; font-weight: bold;">{rank}</span>'
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def get_success_rate_bar(rate):
|
| 12 |
+
if pd.isna(rate):
|
| 13 |
+
return "N/A"
|
| 14 |
+
color = "#10B981" if rate >= 75 else "#F59E0B" if rate >= 50 else "#EF4444"
|
| 15 |
+
return f"""
|
| 16 |
+
<div style="background-color: #E2E8F0; border-radius: 6px; overflow: hidden; height: 20px; position: relative;">
|
| 17 |
+
<div style="width: {rate}%; background-color: {color}; height: 100%;"></div>
|
| 18 |
+
<span style="position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #0F172A; font-weight: 600; font-size: 12px;">{rate:.1f}%</span>
|
| 19 |
+
</div>
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def get_gpu_utilization_bar(util):
|
| 24 |
+
return get_success_rate_bar(util)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def get_provider_badge(provider):
|
| 28 |
+
color = "#4F46E5" if provider == "litellm" else "#14B8A6"
|
| 29 |
+
return f'<span style="background-color: {color}; color: white; padding: 4px 8px; border-radius: 12px; font-size: 12px; font-weight: 500;">{provider}</span>'
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def get_agent_type_badge(agent_type):
|
| 33 |
+
color = "#0EA5E9"
|
| 34 |
+
return f'<span style="background-color: {color}; color: white; padding: 4px 8px; border-radius: 12px; font-size: 12px; font-weight: 500;">{agent_type}</span>'
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def get_hardware_badge(has_gpu):
|
| 38 |
+
label = "GPU" if has_gpu else "CPU"
|
| 39 |
+
color = "#10B981" if has_gpu else "#F59E0B"
|
| 40 |
+
return f'<span style="background-color: {color}; color: white; padding: 4px 8px; border-radius: 12px; font-size: 12px; font-weight: 500;">{label}</span>'
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def format_cost(cost):
|
| 44 |
+
if pd.isna(cost):
|
| 45 |
+
return "N/A"
|
| 46 |
+
return f"${cost:.4f}"
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def format_duration(ms):
|
| 50 |
+
if pd.isna(ms):
|
| 51 |
+
return "N/A"
|
| 52 |
+
return f"{ms / 1000:.2f}s"
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def generate_leaderboard_html(
|
| 56 |
+
df: pd.DataFrame, sort_by: str = "success_rate", ascending: bool = False
|
| 57 |
+
) -> str:
|
| 58 |
+
"""
|
| 59 |
+
Generates a styled HTML table for the leaderboard.
|
| 60 |
+
|
| 61 |
+
Args:
|
| 62 |
+
df: The leaderboard DataFrame.
|
| 63 |
+
sort_by: The column to sort the DataFrame by.
|
| 64 |
+
ascending: The sort order.
|
| 65 |
+
|
| 66 |
+
Returns:
|
| 67 |
+
A string containing the complete HTML for the table.
|
| 68 |
+
"""
|
| 69 |
+
df_sorted = df.sort_values(by=sort_by, ascending=ascending).reset_index(drop=True)
|
| 70 |
+
|
| 71 |
+
html = """
|
| 72 |
+
<style>
|
| 73 |
+
/* Leaderboard Table Styles */
|
| 74 |
+
.tm-action-button {
|
| 75 |
+
background-color: #EF4444 !important;
|
| 76 |
+
color: white;
|
| 77 |
+
border: none;
|
| 78 |
+
padding: 6px 12px;
|
| 79 |
+
border-radius: 6px;
|
| 80 |
+
font-size: 12px;
|
| 81 |
+
font-weight: 500;
|
| 82 |
+
cursor: pointer;
|
| 83 |
+
transition: background-color 0.2s ease;
|
| 84 |
+
}
|
| 85 |
+
.tm-action-button:hover {
|
| 86 |
+
background-color: #DC2626; /* Darker red on hover */
|
| 87 |
+
}
|
| 88 |
+
.tm-leaderboard-container { background: #F8FAFC; border-radius: 16px; overflow-x: auto; overflow-y: visible; border: 1px solid rgba(203, 213, 225, 0.8); margin: 20px 0; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); max-width: 100%; }
|
| 89 |
+
.tm-leaderboard-container::-webkit-scrollbar { height: 8px; }
|
| 90 |
+
.tm-leaderboard-container::-webkit-scrollbar-track { background: #E2E8F0; border-radius: 4px; }
|
| 91 |
+
.tm-leaderboard-container::-webkit-scrollbar-thumb { background: #94A3B8; border-radius: 4px; }
|
| 92 |
+
.tm-leaderboard-container::-webkit-scrollbar-thumb:hover { background: #64748B; }
|
| 93 |
+
.tm-leaderboard-table { width: 100%; min-width: 1650px; border-collapse: collapse; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #FFFFFF; color: #0F172A; }
|
| 94 |
+
.tm-leaderboard-table thead { background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(10px); }
|
| 95 |
+
.tm-leaderboard-table th { padding: 16px 12px; text-align: left; font-weight: 600; color: #FFFFFF; border-bottom: 2px solid #4338CA; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
|
| 96 |
+
.tm-leaderboard-table td { padding: 14px 12px; border-bottom: 1px solid rgba(226, 232, 240, 0.8); color: #1E293B; font-size: 14px; vertical-align: middle; }
|
| 97 |
+
.tm-leaderboard-table tbody tr { transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); cursor: pointer; }
|
| 98 |
+
.tm-leaderboard-table tbody tr:hover { background: rgba(99, 102, 241, 0.08) !important; box-shadow: 0 0 15px rgba(99, 102, 241, 0.15), inset 0 0 15px rgba(99, 102, 241, 0.05); transform: scale(1.002); }
|
| 99 |
+
.tm-leaderboard-table tbody tr:nth-child(even) { background: rgba(241, 245, 249, 0.6); }
|
| 100 |
+
.tm-model-name { font-weight: 600; color: #000000 !important; font-size: 15px; transition: color 0.2s ease; }
|
| 101 |
+
.tm-leaderboard-table tr:hover .tm-model-name { color: #4F46E5 !important; }
|
| 102 |
+
.tm-numeric-cell { font-family: 'Monaco', 'Menlo', monospace; font-size: 13px; text-align: center; color: #000000 !important; }
|
| 103 |
+
.tm-badge-cell { text-align: center; }
|
| 104 |
+
.tm-run-id { font-family: 'Monaco', 'Menlo', monospace; font-size: 12px; color: #000000 !important; cursor: pointer; text-decoration: none; font-weight: 500; transition: all 0.2s ease; }
|
| 105 |
+
.tm-run-id:hover { color: #4F46E5 !important; text-decoration: underline; }
|
| 106 |
+
.tm-text-cell { color: #000000 !important; font-size: 0.9em; }
|
| 107 |
+
@media (max-width: 1024px) { .tm-leaderboard-table th, .tm-leaderboard-table td { padding: 10px 8px; font-size: 12px; } .tm-hide-mobile { display: none !important; } }
|
| 108 |
+
@media (max-width: 768px) { .tm-leaderboard-table th:nth-child(n+7), .tm-leaderboard-table td:nth-child(n+7) { display: none !important; } .tm-model-name { font-size: 13px; } }
|
| 109 |
+
@media (max-width: 480px) { .tm-leaderboard-table th:nth-child(n+4), .tm-leaderboard-table td:nth-child(n+4) { display: none !important; } .tm-leaderboard-table th:nth-child(3), .tm-leaderboard-table td:nth-child(3) { display: table-cell !important; } }
|
| 110 |
+
</style>
|
| 111 |
+
|
| 112 |
+
<div class="tm-leaderboard-container">
|
| 113 |
+
<table class="tm-leaderboard-table">
|
| 114 |
+
<thead>
|
| 115 |
+
<tr>
|
| 116 |
+
<th style="width: 60px;">Rank</th>
|
| 117 |
+
<th style="width: 110px;" title="Run ID">Run ID</th>
|
| 118 |
+
<th style="min-width: 160px;">Model</th>
|
| 119 |
+
<th style="width: 80px;">Type</th>
|
| 120 |
+
<th style="width: 90px;">Provider</th>
|
| 121 |
+
<th style="width: 85px;" title="Hardware used for evaluation: GPU or CPU">Hardware</th>
|
| 122 |
+
<th style="width: 150px;" title="Percentage of test cases that passed (0-100%). Higher is better.">Success Rate</th>
|
| 123 |
+
<th style="width: 140px;" class="tm-numeric-cell" title="Tests: Total / Pass / Fail">Tests (P/F)</th>
|
| 124 |
+
<th style="width: 70px;" class="tm-numeric-cell" title="Average number of steps per test case.">Steps</th>
|
| 125 |
+
<th style="width: 100px;" class="tm-numeric-cell" title="Average time per test case. Lower is better.">Duration</th>
|
| 126 |
+
<th style="width: 90px;" class="tm-numeric-cell" title="Total tokens used across all tests.">Tokens</th>
|
| 127 |
+
<th style="width: 90px;" class="tm-numeric-cell" title="Total API + power costs in USD. Lower is better.">Cost</th>
|
| 128 |
+
<th style="width: 80px;" class="tm-numeric-cell tm-hide-mobile" title="Carbon footprint in grams of CO2 equivalent.">CO2</th>
|
| 129 |
+
<th style="width: 100px;" class="tm-hide-mobile" title="Average GPU usage during evaluation (0-100%).">GPU Util</th>
|
| 130 |
+
<th style="width: 140px;" class="tm-hide-mobile">Timestamp</th>
|
| 131 |
+
<th style="width: 110px;" class="tm-hide-mobile">Submitted By</th>
|
| 132 |
+
<th style="width: 100px;">Actions</th>
|
| 133 |
+
</tr>
|
| 134 |
+
</thead>
|
| 135 |
+
<tbody>
|
| 136 |
+
"""
|
| 137 |
+
|
| 138 |
+
for idx, row in df_sorted.iterrows():
|
| 139 |
+
rank = idx + 1
|
| 140 |
+
model = row.get("model", "Unknown")
|
| 141 |
+
agent_type = row.get("agent_type", "unknown")
|
| 142 |
+
provider = row.get("provider", "unknown")
|
| 143 |
+
success_rate = row.get("success_rate", 0.0)
|
| 144 |
+
total_tests = row.get("total_tests", 0)
|
| 145 |
+
successful_tests = row.get("successful_tests", 0)
|
| 146 |
+
failed_tests = row.get("failed_tests", 0)
|
| 147 |
+
avg_steps = row.get("avg_steps", 0.0)
|
| 148 |
+
avg_duration_ms = row.get("avg_duration_ms", 0.0)
|
| 149 |
+
total_tokens = row.get("total_tokens", 0)
|
| 150 |
+
total_cost_usd = row.get("total_cost_usd", 0.0)
|
| 151 |
+
co2_emissions_g = row.get("co2_emissions_g", 0.0)
|
| 152 |
+
gpu_utilization_avg = row.get("gpu_utilization_avg", None)
|
| 153 |
+
timestamp = row.get("timestamp", "")
|
| 154 |
+
submitted_by = row.get("submitted_by", "Unknown")
|
| 155 |
+
run_id = row.get("run_id", "N/A")
|
| 156 |
+
|
| 157 |
+
has_gpu = pd.notna(gpu_utilization_avg) and gpu_utilization_avg > 0
|
| 158 |
+
gpu_display = (
|
| 159 |
+
get_gpu_utilization_bar(gpu_utilization_avg)
|
| 160 |
+
if has_gpu
|
| 161 |
+
else '<span style="color: #94A3B8; font-size: 0.85em;">N/A</span>'
|
| 162 |
+
)
|
| 163 |
+
co2_display = (
|
| 164 |
+
f"{co2_emissions_g:.2f}g"
|
| 165 |
+
if pd.notna(co2_emissions_g) and co2_emissions_g > 0
|
| 166 |
+
else '<span style="color: #94A3B8; font-size: 0.85em;">N/A</span>'
|
| 167 |
+
)
|
| 168 |
+
timestamp_display = str(timestamp)[:16] if pd.notna(timestamp) else "N/A"
|
| 169 |
+
run_id_short = run_id[:8] + "..." if len(run_id) > 8 else run_id
|
| 170 |
+
|
| 171 |
+
data_attrs_dict = {
|
| 172 |
+
f"data-{key.replace('_', '-')}": value
|
| 173 |
+
for key, value in row.to_dict().items()
|
| 174 |
+
}
|
| 175 |
+
data_attrs = " ".join(
|
| 176 |
+
[f'{key}="{value}"' for key, value in data_attrs_dict.items()]
|
| 177 |
+
)
|
| 178 |
+
|
| 179 |
+
html += f"""
|
| 180 |
+
<tr {data_attrs}>
|
| 181 |
+
<td>{get_rank_badge(rank)}</td>
|
| 182 |
+
<td class="tm-run-id" title="{run_id}">{run_id_short}</td>
|
| 183 |
+
<td class="tm-model-name">{model}</td>
|
| 184 |
+
<td class="tm-badge-cell">{get_agent_type_badge(agent_type)}</td>
|
| 185 |
+
<td class="tm-badge-cell">{get_provider_badge(provider)}</td>
|
| 186 |
+
<td class="tm-badge-cell">{get_hardware_badge(has_gpu)}</td>
|
| 187 |
+
<td>{get_success_rate_bar(success_rate)}</td>
|
| 188 |
+
<td class="tm-numeric-cell">
|
| 189 |
+
<strong>{total_tests}</strong> / <span style="color: #10B981;">{successful_tests}</span> / <span style="color: #EF4444;">{failed_tests}</span>
|
| 190 |
+
</td>
|
| 191 |
+
<td class="tm-numeric-cell">{avg_steps:.1f}</td>
|
| 192 |
+
<td class="tm-numeric-cell">{format_duration(avg_duration_ms)}</td>
|
| 193 |
+
<td class="tm-numeric-cell">{total_tokens:,}</td>
|
| 194 |
+
<td class="tm-numeric-cell">{format_cost(total_cost_usd)}</td>
|
| 195 |
+
<td class="tm-numeric-cell tm-hide-mobile">{co2_display}</td>
|
| 196 |
+
<td class="tm-hide-mobile">{gpu_display}</td>
|
| 197 |
+
<td class="tm-hide-mobile tm-text-cell">{timestamp_display}</td>
|
| 198 |
+
<td class="tm-hide-mobile tm-text-cell">{submitted_by}</td>
|
| 199 |
+
<td>
|
| 200 |
+
<button class="tm-action-button" data-action="delete" data-run-id="{run_id}">
|
| 201 |
+
Delete
|
| 202 |
+
</button>
|
| 203 |
+
</td>
|
| 204 |
+
</tr>
|
| 205 |
+
"""
|
| 206 |
+
|
| 207 |
+
html += """
|
| 208 |
+
</tbody>
|
| 209 |
+
</table>
|
| 210 |
+
</div>
|
| 211 |
+
"""
|
| 212 |
+
return html
|