Spaces:
Running
Running
Amber Tanaka
commited on
Add Dynamic Column Sizes (#61)
Browse files- content.py +4 -1
- leaderboard_transformer.py +4 -31
- ui_components.py +15 -4
content.py
CHANGED
|
@@ -264,7 +264,6 @@ nav.svelte-ti537g.svelte-ti537g {
|
|
| 264 |
/*------ Global tooltip styles ------*/
|
| 265 |
.tooltip-icon {
|
| 266 |
display: inline-block;
|
| 267 |
-
margin-left: 6px;
|
| 268 |
cursor: help;
|
| 269 |
position: relative;
|
| 270 |
}
|
|
@@ -543,4 +542,8 @@ span.wrap[tabindex="0"][role="button"][data-editable="false"] {
|
|
| 543 |
.divider-line {
|
| 544 |
opacity: 40%;
|
| 545 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 546 |
"""
|
|
|
|
| 264 |
/*------ Global tooltip styles ------*/
|
| 265 |
.tooltip-icon {
|
| 266 |
display: inline-block;
|
|
|
|
| 267 |
cursor: help;
|
| 268 |
position: relative;
|
| 269 |
}
|
|
|
|
| 542 |
.divider-line {
|
| 543 |
opacity: 40%;
|
| 544 |
}
|
| 545 |
+
#leaderboard-accordion table {
|
| 546 |
+
width: auto !important;
|
| 547 |
+
margin-right: auto !important;
|
| 548 |
+
}
|
| 549 |
"""
|
leaderboard_transformer.py
CHANGED
|
@@ -254,35 +254,8 @@ class DataTransformer:
|
|
| 254 |
|
| 255 |
df_view = df_sorted.copy()
|
| 256 |
|
| 257 |
-
# 3.
|
| 258 |
-
|
| 259 |
-
if 'Agent' in df_view.columns and 'Submitter' in df_view.columns:
|
| 260 |
-
#preserve just agent name for scatterplot hover
|
| 261 |
-
df_view['agent_for_hover'] = df_view['Agent']
|
| 262 |
-
|
| 263 |
-
def combine_agent_submitter(row):
|
| 264 |
-
agent = row['Agent']
|
| 265 |
-
submitter = row['Submitter']
|
| 266 |
-
|
| 267 |
-
# Check if submitter exists and is not empty
|
| 268 |
-
if pd.notna(submitter) and submitter.strip() != '':
|
| 269 |
-
# Create a two-line HTML string with styled submitter text
|
| 270 |
-
return (
|
| 271 |
-
f"<div>{agent}<br>"
|
| 272 |
-
f"<span style='font-size: 0.9em; color: #667876;'>{submitter}</span>"
|
| 273 |
-
f"</div>"
|
| 274 |
-
)
|
| 275 |
-
else:
|
| 276 |
-
# If no submitter, just return the agent name
|
| 277 |
-
return agent
|
| 278 |
-
|
| 279 |
-
# Apply the function to create the new combined 'Agent' column
|
| 280 |
-
df_view['Agent'] = df_view.apply(combine_agent_submitter, axis=1)
|
| 281 |
-
# The 'Submitter' column is no longer needed
|
| 282 |
-
df_view = df_view.drop(columns=['Submitter'])
|
| 283 |
-
|
| 284 |
-
# 4. Build the List of Columns to Display
|
| 285 |
-
base_cols = ["id","Agent","LLM Base", "agent_for_hover"]
|
| 286 |
new_cols = ["Openness", "Agent Tooling"]
|
| 287 |
ending_cols = ["Logs"]
|
| 288 |
|
|
@@ -342,7 +315,7 @@ class DataTransformer:
|
|
| 342 |
data=df_view,
|
| 343 |
x=primary_cost_col,
|
| 344 |
y=primary_score_col,
|
| 345 |
-
agent_col="
|
| 346 |
name=primary_metric
|
| 347 |
)
|
| 348 |
# Use a consistent key for easy retrieval later
|
|
@@ -363,7 +336,7 @@ def _plot_scatter_plotly(
|
|
| 363 |
data: pd.DataFrame,
|
| 364 |
x: Optional[str],
|
| 365 |
y: str,
|
| 366 |
-
agent_col: str = '
|
| 367 |
name: Optional[str] = None
|
| 368 |
) -> go.Figure:
|
| 369 |
|
|
|
|
| 254 |
|
| 255 |
df_view = df_sorted.copy()
|
| 256 |
|
| 257 |
+
# --- 3. Add Columns for Agent Openness and Tooling ---
|
| 258 |
+
base_cols = ["id","Agent","Submitter","LLM Base"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
new_cols = ["Openness", "Agent Tooling"]
|
| 260 |
ending_cols = ["Logs"]
|
| 261 |
|
|
|
|
| 315 |
data=df_view,
|
| 316 |
x=primary_cost_col,
|
| 317 |
y=primary_score_col,
|
| 318 |
+
agent_col="Agent",
|
| 319 |
name=primary_metric
|
| 320 |
)
|
| 321 |
# Use a consistent key for easy retrieval later
|
|
|
|
| 336 |
data: pd.DataFrame,
|
| 337 |
x: Optional[str],
|
| 338 |
y: str,
|
| 339 |
+
agent_col: str = 'Agent',
|
| 340 |
name: Optional[str] = None
|
| 341 |
) -> go.Figure:
|
| 342 |
|
ui_components.py
CHANGED
|
@@ -458,13 +458,13 @@ def create_leaderboard_display(
|
|
| 458 |
all_cols.insert(0, all_cols.pop(all_cols.index('Pareto')))
|
| 459 |
df_view = df_view[all_cols]
|
| 460 |
# Drop internally used columns that are not needed in the display
|
| 461 |
-
columns_to_drop = ['id', '
|
| 462 |
df_view = df_view.drop(columns=columns_to_drop, errors='ignore')
|
| 463 |
|
| 464 |
df_headers = df_view.columns.tolist()
|
| 465 |
df_datatypes = []
|
| 466 |
for col in df_headers:
|
| 467 |
-
if col
|
| 468 |
df_datatypes.append("markdown")
|
| 469 |
elif col in ["Icon","LLM Base"]:
|
| 470 |
df_datatypes.append("html")
|
|
@@ -477,6 +477,17 @@ def create_leaderboard_display(
|
|
| 477 |
}
|
| 478 |
# 2. Create the final list of headers for display.
|
| 479 |
df_view = df_view.rename(columns=header_rename_map)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 480 |
|
| 481 |
plot_component = gr.Plot(
|
| 482 |
value=scatter_plot,
|
|
@@ -491,7 +502,7 @@ def create_leaderboard_display(
|
|
| 491 |
datatype=df_datatypes,
|
| 492 |
interactive=False,
|
| 493 |
wrap=True,
|
| 494 |
-
column_widths=
|
| 495 |
elem_classes=["wrap-header-df"]
|
| 496 |
)
|
| 497 |
legend_markdown = create_legend_markdown(category_name)
|
|
@@ -649,7 +660,7 @@ def create_benchmark_details_display(
|
|
| 649 |
datatype=df_datatypes,
|
| 650 |
interactive=False,
|
| 651 |
wrap=True,
|
| 652 |
-
column_widths=[40, 40, 200, 150, 175, 85],
|
| 653 |
elem_classes=["wrap-header-df"]
|
| 654 |
)
|
| 655 |
legend_markdown = create_legend_markdown(benchmark_name)
|
|
|
|
| 458 |
all_cols.insert(0, all_cols.pop(all_cols.index('Pareto')))
|
| 459 |
df_view = df_view[all_cols]
|
| 460 |
# Drop internally used columns that are not needed in the display
|
| 461 |
+
columns_to_drop = ['id', 'Openness', 'Agent Tooling']
|
| 462 |
df_view = df_view.drop(columns=columns_to_drop, errors='ignore')
|
| 463 |
|
| 464 |
df_headers = df_view.columns.tolist()
|
| 465 |
df_datatypes = []
|
| 466 |
for col in df_headers:
|
| 467 |
+
if col == "Logs" or "Cost" in col or "Score" in col:
|
| 468 |
df_datatypes.append("markdown")
|
| 469 |
elif col in ["Icon","LLM Base"]:
|
| 470 |
df_datatypes.append("html")
|
|
|
|
| 477 |
}
|
| 478 |
# 2. Create the final list of headers for display.
|
| 479 |
df_view = df_view.rename(columns=header_rename_map)
|
| 480 |
+
# Dynamically set widths for the DataFrame columns
|
| 481 |
+
fixed_start_widths = [40, 40, 200, 100, 200]
|
| 482 |
+
num_score_cost_cols = 0
|
| 483 |
+
remaining_headers = df_headers[len(fixed_start_widths):]
|
| 484 |
+
for col in remaining_headers:
|
| 485 |
+
if "Score" in col or "Cost" in col:
|
| 486 |
+
num_score_cost_cols += 1
|
| 487 |
+
dynamic_widths = [80] * num_score_cost_cols
|
| 488 |
+
fixed_end_widths = [80, 40]
|
| 489 |
+
# 5. Combine all the lists to create the final, fully dynamic list.
|
| 490 |
+
final_column_widths = fixed_start_widths + dynamic_widths + fixed_end_widths
|
| 491 |
|
| 492 |
plot_component = gr.Plot(
|
| 493 |
value=scatter_plot,
|
|
|
|
| 502 |
datatype=df_datatypes,
|
| 503 |
interactive=False,
|
| 504 |
wrap=True,
|
| 505 |
+
column_widths=final_column_widths,
|
| 506 |
elem_classes=["wrap-header-df"]
|
| 507 |
)
|
| 508 |
legend_markdown = create_legend_markdown(category_name)
|
|
|
|
| 660 |
datatype=df_datatypes,
|
| 661 |
interactive=False,
|
| 662 |
wrap=True,
|
| 663 |
+
column_widths=[40, 40, 200, 150, 175, 85, 100, 100, 40],
|
| 664 |
elem_classes=["wrap-header-df"]
|
| 665 |
)
|
| 666 |
legend_markdown = create_legend_markdown(benchmark_name)
|