Spaces:
Paused
Paused
Amber Tanaka
commited on
New svgs (#42)
Browse files- assets/api-custom.svg +3 -0
- assets/api-equivalent.svg +3 -0
- assets/api-standard.svg +3 -0
- assets/api.svg +0 -3
- assets/c-custom.svg +3 -0
- assets/c-equivalent.svg +3 -0
- assets/c-standard.svg +3 -0
- assets/circle-dark.svg +0 -3
- assets/circle-light.svg +0 -3
- assets/diamond-dark.svg +0 -3
- assets/diamond-light.svg +0 -3
- assets/open-source.svg +0 -3
- assets/open-weights.svg +0 -3
- assets/os-custom.svg +3 -0
- assets/os-equivalent.svg +3 -0
- assets/os-ow-custom.svg +3 -0
- assets/os-ow-equivalent.svg +3 -0
- assets/os-ow-standard.svg +3 -0
- assets/os-standard.svg +3 -0
- assets/star-dark.svg +0 -3
- assets/star-light.svg +0 -3
- assets/ui.svg +0 -3
- content.py +0 -23
- leaderboard_transformer.py +9 -11
- ui_components.py +88 -80
assets/api-custom.svg
ADDED
|
|
assets/api-equivalent.svg
ADDED
|
|
assets/api-standard.svg
ADDED
|
|
assets/api.svg
DELETED
assets/c-custom.svg
ADDED
|
|
assets/c-equivalent.svg
ADDED
|
|
assets/c-standard.svg
ADDED
|
|
assets/circle-dark.svg
DELETED
assets/circle-light.svg
DELETED
assets/diamond-dark.svg
DELETED
assets/diamond-light.svg
DELETED
assets/open-source.svg
DELETED
assets/open-weights.svg
DELETED
assets/os-custom.svg
ADDED
|
|
assets/os-equivalent.svg
ADDED
|
|
assets/os-ow-custom.svg
ADDED
|
|
assets/os-ow-equivalent.svg
ADDED
|
|
assets/os-ow-standard.svg
ADDED
|
|
assets/os-standard.svg
ADDED
|
|
assets/star-dark.svg
DELETED
assets/star-light.svg
DELETED
assets/ui.svg
DELETED
content.py
CHANGED
|
@@ -245,34 +245,11 @@ nav.svelte-ti537g.svelte-ti537g {
|
|
| 245 |
height: 16px;
|
| 246 |
vertical-align: middle;
|
| 247 |
}
|
| 248 |
-
|
| 249 |
-
/* By default, hide BOTH theme-aware icons inside a DataFrame cell */
|
| 250 |
-
.wrap-header-df .cell-wrap .light-mode-icon,
|
| 251 |
-
.wrap-header-df .cell-wrap .dark-mode-icon {
|
| 252 |
-
display: none !important;
|
| 253 |
-
}
|
| 254 |
-
|
| 255 |
-
/* Light Theme Rule: Show the light-mode icon */
|
| 256 |
-
html:not(.dark) .wrap-header-df .cell-wrap .light-mode-icon {
|
| 257 |
-
display: inline-block !important;
|
| 258 |
-
}
|
| 259 |
-
|
| 260 |
-
/* Dark Theme Rule: Show the dark-mode icon */
|
| 261 |
-
.dark .wrap-header-df .cell-wrap .dark-mode-icon {
|
| 262 |
-
display: inline-block !important;
|
| 263 |
-
}
|
| 264 |
#legend-markdown img {
|
| 265 |
width: 16px;
|
| 266 |
height: 16px;
|
| 267 |
vertical-align: middle;
|
| 268 |
}
|
| 269 |
-
html:not(.dark) #legend-markdown .light-mode-icon,
|
| 270 |
-
.dark #legend-markdown .dark-mode-icon {
|
| 271 |
-
display: inline-block;
|
| 272 |
-
}
|
| 273 |
-
#legend-markdown .light-mode-icon, #legend-markdown .dark-mode-icon {
|
| 274 |
-
display: none;
|
| 275 |
-
}
|
| 276 |
/*------ Global tooltip styles ------*/
|
| 277 |
.tooltip-icon {
|
| 278 |
display: inline-block;
|
|
|
|
| 245 |
height: 16px;
|
| 246 |
vertical-align: middle;
|
| 247 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
#legend-markdown img {
|
| 249 |
width: 16px;
|
| 250 |
height: 16px;
|
| 251 |
vertical-align: middle;
|
| 252 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
/*------ Global tooltip styles ------*/
|
| 254 |
.tooltip-icon {
|
| 255 |
display: inline-block;
|
leaderboard_transformer.py
CHANGED
|
@@ -336,16 +336,16 @@ def _plot_scatter_plotly(
|
|
| 336 |
|
| 337 |
# --- Section 1: Define Mappings ---
|
| 338 |
color_map = {
|
| 339 |
-
"
|
| 340 |
-
"
|
| 341 |
-
"
|
| 342 |
-
"
|
| 343 |
}
|
| 344 |
category_order = list(color_map.keys())
|
| 345 |
shape_map = {
|
| 346 |
"Standard": "star",
|
| 347 |
-
"Custom with Standard Search": "diamond",
|
| 348 |
-
"Fully Custom": "
|
| 349 |
}
|
| 350 |
default_shape = 'square'
|
| 351 |
|
|
@@ -424,7 +424,7 @@ def _plot_scatter_plotly(
|
|
| 424 |
y=frontier_df['y'],
|
| 425 |
mode='lines',
|
| 426 |
name='Efficiency Frontier',
|
| 427 |
-
line=dict(color='
|
| 428 |
hoverinfo='skip'
|
| 429 |
))
|
| 430 |
|
|
@@ -492,7 +492,7 @@ def _plot_scatter_plotly(
|
|
| 492 |
symbol=group['shape_symbol'],
|
| 493 |
size=10,
|
| 494 |
opacity=0.8,
|
| 495 |
-
line=dict(width=1, color='
|
| 496 |
)
|
| 497 |
))
|
| 498 |
# ---- Add logic for making the legend -----------
|
|
@@ -522,7 +522,7 @@ def _plot_scatter_plotly(
|
|
| 522 |
marker=dict(color='black', symbol=shape_symbol, size=12)
|
| 523 |
))
|
| 524 |
|
| 525 |
-
# --- Section 8: Configure Layout
|
| 526 |
xaxis_config = dict(title=x_axis_label, rangemode="tozero")
|
| 527 |
if divider_line_x > 0:
|
| 528 |
fig.add_vline(
|
|
@@ -634,8 +634,6 @@ def format_score_column(df: pd.DataFrame, score_col_name: str) -> pd.DataFrame:
|
|
| 634 |
|
| 635 |
|
| 636 |
def get_pareto_df(data):
|
| 637 |
-
# This is a placeholder; use your actual function that handles dynamic column names
|
| 638 |
-
# A robust version might look for any column with "Cost" and "Score"
|
| 639 |
cost_cols = [c for c in data.columns if 'Cost' in c]
|
| 640 |
score_cols = [c for c in data.columns if 'Score' in c]
|
| 641 |
if not cost_cols or not score_cols:
|
|
|
|
| 336 |
|
| 337 |
# --- Section 1: Define Mappings ---
|
| 338 |
color_map = {
|
| 339 |
+
"Open Source + Open Weights": "deeppink",
|
| 340 |
+
"Open Source": "coral",
|
| 341 |
+
"API Available": "yellow",
|
| 342 |
+
"Closed": "white",
|
| 343 |
}
|
| 344 |
category_order = list(color_map.keys())
|
| 345 |
shape_map = {
|
| 346 |
"Standard": "star",
|
| 347 |
+
"Custom with Standard Search": "star-diamond",
|
| 348 |
+
"Fully Custom": "star-triangle-up"
|
| 349 |
}
|
| 350 |
default_shape = 'square'
|
| 351 |
|
|
|
|
| 424 |
y=frontier_df['y'],
|
| 425 |
mode='lines',
|
| 426 |
name='Efficiency Frontier',
|
| 427 |
+
line=dict(color='#0FCB8C', width=2, dash='dash'),
|
| 428 |
hoverinfo='skip'
|
| 429 |
))
|
| 430 |
|
|
|
|
| 492 |
symbol=group['shape_symbol'],
|
| 493 |
size=10,
|
| 494 |
opacity=0.8,
|
| 495 |
+
line=dict(width=1, color='deeppink')
|
| 496 |
)
|
| 497 |
))
|
| 498 |
# ---- Add logic for making the legend -----------
|
|
|
|
| 522 |
marker=dict(color='black', symbol=shape_symbol, size=12)
|
| 523 |
))
|
| 524 |
|
| 525 |
+
# --- Section 8: Configure Layout ---
|
| 526 |
xaxis_config = dict(title=x_axis_label, rangemode="tozero")
|
| 527 |
if divider_line_x > 0:
|
| 528 |
fig.add_vline(
|
|
|
|
| 634 |
|
| 635 |
|
| 636 |
def get_pareto_df(data):
|
|
|
|
|
|
|
| 637 |
cost_cols = [c for c in data.columns if 'Cost' in c]
|
| 638 |
score_cols = [c for c in data.columns if 'Score' in c]
|
| 639 |
if not cost_cols or not score_cols:
|
ui_components.py
CHANGED
|
@@ -51,73 +51,90 @@ api = HfApi()
|
|
| 51 |
MAX_UPLOAD_BYTES = 100 * 1024**2
|
| 52 |
AGENTEVAL_MANIFEST_NAME = "agenteval.json"
|
| 53 |
os.makedirs(EXTRACTED_DATA_DIR, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
-
#
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
def
|
| 59 |
"""
|
| 60 |
-
|
| 61 |
-
|
| 62 |
"""
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
with open(file_path, "rb") as svg_file:
|
| 70 |
-
encoded_string = base64.b64encode(svg_file.read()).decode('utf-8')
|
| 71 |
-
data_uri = f"data:image/svg+xml;base64,{encoded_string}"
|
| 72 |
-
|
| 73 |
-
# Store in cache for future use
|
| 74 |
-
SVG_DATA_URI_CACHE[file_path] = data_uri
|
| 75 |
-
return data_uri
|
| 76 |
-
except FileNotFoundError:
|
| 77 |
-
# If the file doesn't exist, print a warning and return an empty string
|
| 78 |
-
print(f"Warning: SVG file not found at '{file_path}'")
|
| 79 |
-
return ""
|
| 80 |
|
| 81 |
def create_svg_html(value, svg_map):
|
| 82 |
"""
|
| 83 |
Generates the absolute simplest HTML for an icon, without any extra text.
|
| 84 |
This version is compatible with gr.DataFrame.
|
| 85 |
"""
|
| 86 |
-
# If the value isn't in our map, return an empty string so the cell is blank.
|
| 87 |
if pd.isna(value) or value not in svg_map:
|
| 88 |
return ""
|
| 89 |
|
| 90 |
path_info = svg_map[value]
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
dark_theme_icon_uri = get_svg_as_data_uri(path_info['light'])
|
| 96 |
-
|
| 97 |
-
# Generate the HTML for the two icons side-by-side, with NO text.
|
| 98 |
-
img1 = f'<img src="{light_theme_icon_uri}" class="light-mode-icon" alt="{value}" title="{value}">'
|
| 99 |
-
img2 = f'<img src="{dark_theme_icon_uri}" class="dark-mode-icon" alt="{value}" title="{value}">'
|
| 100 |
-
return f'{img1}{img2}'
|
| 101 |
-
|
| 102 |
-
# For single icons that don't change with theme (like Openness)
|
| 103 |
-
elif isinstance(path_info, str):
|
| 104 |
-
src = get_svg_as_data_uri(path_info)
|
| 105 |
-
# Generate the HTML for the single icon, with NO text.
|
| 106 |
return f'<img src="{src}" style="width: 16px; height: 16px; vertical-align: middle;" alt="{value}" title="{value}">'
|
| 107 |
-
|
| 108 |
-
# Fallback in case of an unexpected data type
|
| 109 |
return ""
|
| 110 |
|
| 111 |
-
# Global variables
|
| 112 |
-
OPENNESS_SVG_MAP = {
|
| 113 |
-
"Open Source + Open Weights": "assets/open-weights.svg", "Open Source": "assets/open-source.svg", "API Available": "assets/api.svg", "Closed": "assets/ui.svg"
|
| 114 |
-
}
|
| 115 |
-
TOOLING_SVG_MAP = {
|
| 116 |
-
"Standard": {"light": "assets/star-light.svg", "dark": "assets/star-dark.svg"},
|
| 117 |
-
"Custom with Standard Search": {"light": "assets/diamond-light.svg", "dark": "assets/diamond-dark.svg"},
|
| 118 |
-
"Fully Custom": {"light": "assets/circle-light.svg", "dark": "assets/circle-dark.svg"},
|
| 119 |
-
}
|
| 120 |
-
|
| 121 |
# Dynamically generate the correct HTML for the legend parts
|
| 122 |
openness_html = " ".join([create_svg_html(name, OPENNESS_SVG_MAP) for name in OPENNESS_SVG_MAP])
|
| 123 |
tooling_html = " ".join([create_svg_html(name, TOOLING_SVG_MAP) for name in TOOLING_SVG_MAP])
|
|
@@ -136,22 +153,12 @@ openness_html = " ".join(openness_html_items)
|
|
| 136 |
|
| 137 |
# Create HTML for the "Tooling" legend items
|
| 138 |
tooling_html_items = []
|
| 139 |
-
for name,
|
| 140 |
-
|
| 141 |
-
dark_theme_icon_uri = get_svg_as_data_uri(paths['light'])
|
| 142 |
-
|
| 143 |
-
# The two swapping icons need to be stacked with absolute positioning
|
| 144 |
-
img1 = f'<img src="{light_theme_icon_uri}" class="light-mode-icon" alt="{name}" title="{name}" style="position: absolute; top: 0; left: 0;">'
|
| 145 |
-
img2 = f'<img src="{dark_theme_icon_uri}" class="dark-mode-icon" alt="{name}" title="{name}" style="position: absolute; top: 0; left: 0;">'
|
| 146 |
-
|
| 147 |
-
# Their container needs a defined size and relative positioning
|
| 148 |
-
icon_container = f'<div style="width: 16px; height: 16px; position: relative; flex-shrink: 0;">{img1}{img2}</div>'
|
| 149 |
-
|
| 150 |
-
# This item is also a flexbox container
|
| 151 |
tooling_html_items.append(
|
| 152 |
f'<div style="display: flex; align-items: center; white-space: nowrap;">'
|
| 153 |
-
f'{
|
| 154 |
-
f'<span
|
| 155 |
f'</div>'
|
| 156 |
)
|
| 157 |
tooling_html = " ".join(tooling_html_items)
|
|
@@ -202,7 +209,7 @@ legend_markdown = f"""
|
|
| 202 |
CACHED_VIEWERS = {}
|
| 203 |
CACHED_TAG_MAPS = {}
|
| 204 |
|
| 205 |
-
|
| 206 |
class DummyViewer:
|
| 207 |
"""A mock viewer to be cached on error. It has a ._load() method
|
| 208 |
to ensure it behaves like the real LeaderboardViewer."""
|
|
@@ -284,9 +291,10 @@ def create_leaderboard_display(
|
|
| 284 |
axis=1
|
| 285 |
)
|
| 286 |
# Create mapping for Openness / tooling
|
| 287 |
-
df_view['
|
| 288 |
-
|
| 289 |
-
|
|
|
|
| 290 |
|
| 291 |
# Format cost columns
|
| 292 |
for col in df_view.columns:
|
|
@@ -303,11 +311,12 @@ def create_leaderboard_display(
|
|
| 303 |
df_view['LLM Base'] = df_view['LLM Base'].apply(format_llm_base_with_html)
|
| 304 |
|
| 305 |
all_cols = df_view.columns.tolist()
|
| 306 |
-
# Remove
|
|
|
|
| 307 |
all_cols.insert(0, all_cols.pop(all_cols.index('Pareto')))
|
| 308 |
df_view = df_view[all_cols]
|
| 309 |
# Drop internally used columns that are not needed in the display
|
| 310 |
-
columns_to_drop = ['id', 'agent_for_hover']
|
| 311 |
df_view = df_view.drop(columns=columns_to_drop, errors='ignore')
|
| 312 |
|
| 313 |
df_headers = df_view.columns.tolist()
|
|
@@ -315,15 +324,14 @@ def create_leaderboard_display(
|
|
| 315 |
for col in df_headers:
|
| 316 |
if col in ["Logs", "Agent"] or "Cost" in col or "Score" in col:
|
| 317 |
df_datatypes.append("markdown")
|
| 318 |
-
elif col in ["
|
| 319 |
df_datatypes.append("html")
|
| 320 |
else:
|
| 321 |
df_datatypes.append("str")
|
| 322 |
|
| 323 |
header_rename_map = {
|
| 324 |
"Pareto": "",
|
| 325 |
-
"
|
| 326 |
-
"Agent Tooling": ""
|
| 327 |
}
|
| 328 |
# 2. Create the final list of headers for display.
|
| 329 |
df_view = df_view.rename(columns=header_rename_map)
|
|
@@ -342,7 +350,7 @@ def create_leaderboard_display(
|
|
| 342 |
datatype=df_datatypes,
|
| 343 |
interactive=False,
|
| 344 |
wrap=True,
|
| 345 |
-
column_widths=[
|
| 346 |
elem_classes=["wrap-header-df"]
|
| 347 |
)
|
| 348 |
|
|
@@ -413,8 +421,10 @@ def create_benchmark_details_display(
|
|
| 413 |
axis=1
|
| 414 |
)
|
| 415 |
|
| 416 |
-
benchmark_table_df['
|
| 417 |
-
|
|
|
|
|
|
|
| 418 |
|
| 419 |
#Make pretty and format the LLM Base column
|
| 420 |
benchmark_table_df['LLM Base'] = benchmark_table_df['LLM Base'].apply(clean_llm_base_list)
|
|
@@ -442,8 +452,7 @@ def create_benchmark_details_display(
|
|
| 442 |
benchmark_table_df = format_score_column(benchmark_table_df, benchmark_score_col)
|
| 443 |
desired_cols_in_order = [
|
| 444 |
'Pareto',
|
| 445 |
-
'
|
| 446 |
-
'Agent Tooling',
|
| 447 |
'Agent',
|
| 448 |
'Submitter',
|
| 449 |
'LLM Base',
|
|
@@ -467,15 +476,14 @@ def create_benchmark_details_display(
|
|
| 467 |
for col in df_headers:
|
| 468 |
if "Logs" in col or "Cost" in col or "Score" in col:
|
| 469 |
df_datatypes.append("markdown")
|
| 470 |
-
elif col in ["
|
| 471 |
df_datatypes.append("html")
|
| 472 |
else:
|
| 473 |
df_datatypes.append("str")
|
| 474 |
# Remove Pareto, Openness, and Agent Tooling from the headers
|
| 475 |
header_rename_map = {
|
| 476 |
"Pareto": "",
|
| 477 |
-
"
|
| 478 |
-
"Agent Tooling": ""
|
| 479 |
}
|
| 480 |
# 2. Create the final list of headers for display.
|
| 481 |
benchmark_table_df = benchmark_table_df.rename(columns=header_rename_map)
|
|
@@ -498,7 +506,7 @@ def create_benchmark_details_display(
|
|
| 498 |
datatype=df_datatypes,
|
| 499 |
interactive=False,
|
| 500 |
wrap=True,
|
| 501 |
-
column_widths=[40, 40,
|
| 502 |
elem_classes=["wrap-header-df"]
|
| 503 |
)
|
| 504 |
|
|
|
|
| 51 |
MAX_UPLOAD_BYTES = 100 * 1024**2
|
| 52 |
AGENTEVAL_MANIFEST_NAME = "agenteval.json"
|
| 53 |
os.makedirs(EXTRACTED_DATA_DIR, exist_ok=True)
|
| 54 |
+
# Global variables
|
| 55 |
+
COMBINED_ICON_MAP = {
|
| 56 |
+
"Open Source + Open Weights": {
|
| 57 |
+
"Standard": "assets/os-ow-standard.svg", # Bright pink star
|
| 58 |
+
"Custom with Standard Search": "assets/os-ow-equivalent.svg", # Bright pink diamond
|
| 59 |
+
"Custom": "assets/os-ow-custom.svg", # Bright pink triangle
|
| 60 |
+
},
|
| 61 |
+
"Open Source": {
|
| 62 |
+
"Standard": "assets/os-standard.svg", # Orange/pink star
|
| 63 |
+
"Custom with Standard Search": "assets/os-equivalent.svg", # Orange/pink diamond
|
| 64 |
+
"Fully Custom": "assets/os-custom.svg", # Orange/pink triangle
|
| 65 |
+
},
|
| 66 |
+
"API Available": {
|
| 67 |
+
"Standard": "assets/api-standard.svg", # Yellow/pink star
|
| 68 |
+
"Custom with Standard Search": "assets/api-equivalent.svg", # Yellow/pink diamond
|
| 69 |
+
"Fully Custom": "assets/api-custom.svg", # Yellow/pink triangle
|
| 70 |
+
},
|
| 71 |
+
"Closed": {
|
| 72 |
+
"Standard": "assets/c-standard.svg", # Hollow pink star
|
| 73 |
+
"Equivalent": "assets/c-equivalent.svg", # Hollow pink diamond
|
| 74 |
+
"Fully Custom": "assets/c-custom.svg", # Hollow pink triangle
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
OPENNESS_SVG_MAP = {
|
| 78 |
+
"Open Source + Open Weights": "assets/os-ow-standard.svg",
|
| 79 |
+
"Open Source": "assets/os-standard.svg",
|
| 80 |
+
"API Available": "assets/api-standard.svg",
|
| 81 |
+
"Closed": "assets/c-standard.svg",
|
| 82 |
+
}
|
| 83 |
+
TOOLING_SVG_MAP = {
|
| 84 |
+
"Standard": "assets/os-ow-standard.svg",
|
| 85 |
+
"Custom with Standard Search": "assets/os-ow-equivalent.svg",
|
| 86 |
+
"Fully Custom": "assets/os-ow-custom.svg",
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
def get_svg_as_data_uri(path: str) -> str:
|
| 90 |
+
"""Reads an SVG file and returns it as a base64-encoded data URI."""
|
| 91 |
+
try:
|
| 92 |
+
with open(path, "rb") as svg_file:
|
| 93 |
+
encoded_svg = base64.b64encode(svg_file.read()).decode("utf-8")
|
| 94 |
+
return f"data:image/svg+xml;base64,{encoded_svg}"
|
| 95 |
+
except FileNotFoundError:
|
| 96 |
+
print(f"Warning: SVG file not found at {path}")
|
| 97 |
+
return ""
|
| 98 |
|
| 99 |
+
# Create a pre-loaded version of our map. This should be run ONCE when the app starts.
|
| 100 |
+
PRELOADED_URI_MAP = {
|
| 101 |
+
openness: {
|
| 102 |
+
tooling: get_svg_as_data_uri(path)
|
| 103 |
+
for tooling, path in tooling_map.items()
|
| 104 |
+
}
|
| 105 |
+
for openness, tooling_map in COMBINED_ICON_MAP.items()
|
| 106 |
+
}
|
| 107 |
|
| 108 |
+
def get_combined_icon_html(row, uri_map):
|
| 109 |
"""
|
| 110 |
+
Looks up the correct icon URI from the pre-loaded map based on the row's
|
| 111 |
+
'Openness' and 'Agent Tooling' values and returns an HTML <img> tag.
|
| 112 |
"""
|
| 113 |
+
openness_val = row['Openness']
|
| 114 |
+
tooling_val = row['Agent Tooling']
|
| 115 |
+
uri = uri_map.get(openness_val, {}).get(tooling_val, "")
|
| 116 |
+
# The tooltip will show the exact combination for clarity.
|
| 117 |
+
tooltip = f"Openness: {openness_val}, Tooling: {tooling_val}"
|
| 118 |
|
| 119 |
+
# Return the HTML string that Gradio will render in the DataFrame.
|
| 120 |
+
return f'<img src="{uri}" alt="{tooltip}" title="{tooltip}" style="width:24px; height:24px;">'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
def create_svg_html(value, svg_map):
|
| 123 |
"""
|
| 124 |
Generates the absolute simplest HTML for an icon, without any extra text.
|
| 125 |
This version is compatible with gr.DataFrame.
|
| 126 |
"""
|
|
|
|
| 127 |
if pd.isna(value) or value not in svg_map:
|
| 128 |
return ""
|
| 129 |
|
| 130 |
path_info = svg_map[value]
|
| 131 |
|
| 132 |
+
src = get_svg_as_data_uri(path_info)
|
| 133 |
+
# Generate the HTML for the single icon, with NO text.
|
| 134 |
+
if src:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
return f'<img src="{src}" style="width: 16px; height: 16px; vertical-align: middle;" alt="{value}" title="{value}">'
|
|
|
|
|
|
|
| 136 |
return ""
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
# Dynamically generate the correct HTML for the legend parts
|
| 139 |
openness_html = " ".join([create_svg_html(name, OPENNESS_SVG_MAP) for name in OPENNESS_SVG_MAP])
|
| 140 |
tooling_html = " ".join([create_svg_html(name, TOOLING_SVG_MAP) for name in TOOLING_SVG_MAP])
|
|
|
|
| 153 |
|
| 154 |
# Create HTML for the "Tooling" legend items
|
| 155 |
tooling_html_items = []
|
| 156 |
+
for name, path in TOOLING_SVG_MAP.items():
|
| 157 |
+
uri = get_svg_as_data_uri(path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
tooling_html_items.append(
|
| 159 |
f'<div style="display: flex; align-items: center; white-space: nowrap;">'
|
| 160 |
+
f'<img src="{uri}" alt="{name}" title="{name}" style="width:16px; height:16px; margin-right: 4px; flex-shrink: 0;">'
|
| 161 |
+
f'<span>{name}</span>'
|
| 162 |
f'</div>'
|
| 163 |
)
|
| 164 |
tooling_html = " ".join(tooling_html_items)
|
|
|
|
| 209 |
CACHED_VIEWERS = {}
|
| 210 |
CACHED_TAG_MAPS = {}
|
| 211 |
|
| 212 |
+
|
| 213 |
class DummyViewer:
|
| 214 |
"""A mock viewer to be cached on error. It has a ._load() method
|
| 215 |
to ensure it behaves like the real LeaderboardViewer."""
|
|
|
|
| 291 |
axis=1
|
| 292 |
)
|
| 293 |
# Create mapping for Openness / tooling
|
| 294 |
+
df_view['Icon'] = df_view.apply(
|
| 295 |
+
lambda row: get_combined_icon_html(row, PRELOADED_URI_MAP),
|
| 296 |
+
axis=1 # IMPORTANT: axis=1 tells pandas to process row-by-row
|
| 297 |
+
)
|
| 298 |
|
| 299 |
# Format cost columns
|
| 300 |
for col in df_view.columns:
|
|
|
|
| 311 |
df_view['LLM Base'] = df_view['LLM Base'].apply(format_llm_base_with_html)
|
| 312 |
|
| 313 |
all_cols = df_view.columns.tolist()
|
| 314 |
+
# Remove pareto and Icon columns and insert it at the beginning
|
| 315 |
+
all_cols.insert(0, all_cols.pop(all_cols.index('Icon')))
|
| 316 |
all_cols.insert(0, all_cols.pop(all_cols.index('Pareto')))
|
| 317 |
df_view = df_view[all_cols]
|
| 318 |
# Drop internally used columns that are not needed in the display
|
| 319 |
+
columns_to_drop = ['id', 'agent_for_hover', 'Openness', 'Agent Tooling']
|
| 320 |
df_view = df_view.drop(columns=columns_to_drop, errors='ignore')
|
| 321 |
|
| 322 |
df_headers = df_view.columns.tolist()
|
|
|
|
| 324 |
for col in df_headers:
|
| 325 |
if col in ["Logs", "Agent"] or "Cost" in col or "Score" in col:
|
| 326 |
df_datatypes.append("markdown")
|
| 327 |
+
elif col in ["Icon","LLM Base"]:
|
| 328 |
df_datatypes.append("html")
|
| 329 |
else:
|
| 330 |
df_datatypes.append("str")
|
| 331 |
|
| 332 |
header_rename_map = {
|
| 333 |
"Pareto": "",
|
| 334 |
+
"Icon": "",
|
|
|
|
| 335 |
}
|
| 336 |
# 2. Create the final list of headers for display.
|
| 337 |
df_view = df_view.rename(columns=header_rename_map)
|
|
|
|
| 350 |
datatype=df_datatypes,
|
| 351 |
interactive=False,
|
| 352 |
wrap=True,
|
| 353 |
+
column_widths=[40, 40, 200, 200],
|
| 354 |
elem_classes=["wrap-header-df"]
|
| 355 |
)
|
| 356 |
|
|
|
|
| 421 |
axis=1
|
| 422 |
)
|
| 423 |
|
| 424 |
+
benchmark_table_df['Icon'] = benchmark_table_df.apply(
|
| 425 |
+
lambda row: get_combined_icon_html(row, PRELOADED_URI_MAP),
|
| 426 |
+
axis=1 # IMPORTANT: axis=1 tells pandas to process row-by-row
|
| 427 |
+
)
|
| 428 |
|
| 429 |
#Make pretty and format the LLM Base column
|
| 430 |
benchmark_table_df['LLM Base'] = benchmark_table_df['LLM Base'].apply(clean_llm_base_list)
|
|
|
|
| 452 |
benchmark_table_df = format_score_column(benchmark_table_df, benchmark_score_col)
|
| 453 |
desired_cols_in_order = [
|
| 454 |
'Pareto',
|
| 455 |
+
'Icon',
|
|
|
|
| 456 |
'Agent',
|
| 457 |
'Submitter',
|
| 458 |
'LLM Base',
|
|
|
|
| 476 |
for col in df_headers:
|
| 477 |
if "Logs" in col or "Cost" in col or "Score" in col:
|
| 478 |
df_datatypes.append("markdown")
|
| 479 |
+
elif col in ["Icon", "LLM Base"]:
|
| 480 |
df_datatypes.append("html")
|
| 481 |
else:
|
| 482 |
df_datatypes.append("str")
|
| 483 |
# Remove Pareto, Openness, and Agent Tooling from the headers
|
| 484 |
header_rename_map = {
|
| 485 |
"Pareto": "",
|
| 486 |
+
"Icon": "",
|
|
|
|
| 487 |
}
|
| 488 |
# 2. Create the final list of headers for display.
|
| 489 |
benchmark_table_df = benchmark_table_df.rename(columns=header_rename_map)
|
|
|
|
| 506 |
datatype=df_datatypes,
|
| 507 |
interactive=False,
|
| 508 |
wrap=True,
|
| 509 |
+
column_widths=[40, 40, 200, 150, 175, 85],
|
| 510 |
elem_classes=["wrap-header-df"]
|
| 511 |
)
|
| 512 |
|