update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ from src.about import (
|
|
| 12 |
LLM_BENCHMARKS_TEXT,
|
| 13 |
TITLE,
|
| 14 |
)
|
| 15 |
-
from src.display.css_html_js import custom_css
|
| 16 |
from src.display.utils import (
|
| 17 |
COLUMNS,
|
| 18 |
COLS,
|
|
@@ -28,33 +28,6 @@ from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REP
|
|
| 28 |
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
| 29 |
from src.submission.submit import add_new_eval
|
| 30 |
|
| 31 |
-
# Add this CSS to make column selection more compact
|
| 32 |
-
custom_css_additions = """
|
| 33 |
-
.select-columns-container {
|
| 34 |
-
max-height: 300px;
|
| 35 |
-
overflow-y: auto;
|
| 36 |
-
display: grid;
|
| 37 |
-
grid-template-columns: repeat(4, 1fr);
|
| 38 |
-
gap: 5px;
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
.select-columns-container label {
|
| 42 |
-
font-size: 0.9em;
|
| 43 |
-
padding: 2px;
|
| 44 |
-
margin: 0;
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
.column-categories {
|
| 48 |
-
margin-bottom: 10px;
|
| 49 |
-
}
|
| 50 |
-
"""
|
| 51 |
-
|
| 52 |
-
# Update your CSS
|
| 53 |
-
if 'custom_css' in locals():
|
| 54 |
-
custom_css += custom_css_additions
|
| 55 |
-
else:
|
| 56 |
-
custom_css = custom_css_additions
|
| 57 |
-
|
| 58 |
def restart_space():
|
| 59 |
API.restart_space(repo_id=REPO_ID)
|
| 60 |
|
|
@@ -82,18 +55,34 @@ print("LEADERBOARD_DF Columns:", LEADERBOARD_DF.columns.tolist()) # Debug
|
|
| 82 |
# Load the evaluation queue DataFrames
|
| 83 |
finished_eval_queue_df, running_eval_queue_df, pending_eval_queue_df = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
}
|
|
|
|
| 95 |
|
| 96 |
-
demo = gr.Blocks(css=custom_css)
|
| 97 |
with demo:
|
| 98 |
gr.HTML(TITLE)
|
| 99 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
|
@@ -111,24 +100,12 @@ with demo:
|
|
| 111 |
default_selection.insert(0, "model_name")
|
| 112 |
print("Default Selection after ensuring 'model_name':", default_selection) # Debug
|
| 113 |
|
| 114 |
-
#
|
| 115 |
-
with gr.Accordion("Select Columns to Display", open=False):
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
for category, cols in COLUMN_CATEGORIES.items():
|
| 119 |
-
# Filter to only include columns that exist
|
| 120 |
-
available_cols = [c for c in cols if c in [col.name for col in COLUMNS]]
|
| 121 |
-
|
| 122 |
-
if available_cols:
|
| 123 |
-
with gr.Column(elem_classes="column-categories"):
|
| 124 |
-
gr.Markdown(f"**{category}**")
|
| 125 |
-
column_selections[category] = gr.CheckboxGroup(
|
| 126 |
-
choices=available_cols,
|
| 127 |
-
value=[c for c in available_cols if c in default_selection],
|
| 128 |
-
label=""
|
| 129 |
-
)
|
| 130 |
|
| 131 |
-
# Create the leaderboard with
|
| 132 |
leaderboard = Leaderboard(
|
| 133 |
value=LEADERBOARD_DF,
|
| 134 |
datatype=[col.type for col in COLUMNS],
|
|
@@ -136,7 +113,6 @@ with demo:
|
|
| 136 |
default_selection=default_selection,
|
| 137 |
cant_deselect=[col.name for col in COLUMNS if col.never_hidden],
|
| 138 |
label="Select Columns to Display:",
|
| 139 |
-
render=False, # Don't render the built-in selector if this option is available
|
| 140 |
),
|
| 141 |
search_columns=[col.name for col in COLUMNS if col.name in ["model_name", "license"]],
|
| 142 |
hide_columns=[col.name for col in COLUMNS if col.hidden],
|
|
@@ -150,16 +126,6 @@ with demo:
|
|
| 150 |
bool_checkboxgroup_label="Hide models",
|
| 151 |
interactive=False,
|
| 152 |
)
|
| 153 |
-
|
| 154 |
-
# Add event handlers to update visible columns when custom checkboxes are changed
|
| 155 |
-
for category, checkbox_group in column_selections.items():
|
| 156 |
-
# For each category, when checkboxes change, update the visible columns
|
| 157 |
-
# This might need adjustment based on how the Leaderboard component works
|
| 158 |
-
checkbox_group.change(
|
| 159 |
-
fn=lambda *values: leaderboard.update(visible_columns=sum(values, [])),
|
| 160 |
-
inputs=list(column_selections.values()),
|
| 161 |
-
outputs=[leaderboard]
|
| 162 |
-
)
|
| 163 |
|
| 164 |
with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=2):
|
| 165 |
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
|
|
|
| 12 |
LLM_BENCHMARKS_TEXT,
|
| 13 |
TITLE,
|
| 14 |
)
|
| 15 |
+
from src.display.css_html_js import custom_css, get_window_url_params
|
| 16 |
from src.display.utils import (
|
| 17 |
COLUMNS,
|
| 18 |
COLS,
|
|
|
|
| 28 |
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
| 29 |
from src.submission.submit import add_new_eval
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
def restart_space():
|
| 32 |
API.restart_space(repo_id=REPO_ID)
|
| 33 |
|
|
|
|
| 55 |
# Load the evaluation queue DataFrames
|
| 56 |
finished_eval_queue_df, running_eval_queue_df, pending_eval_queue_df = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
|
| 57 |
|
| 58 |
+
demo = gr.Blocks(css=custom_css + """
|
| 59 |
+
/* Column selection improvements */
|
| 60 |
+
.select-columns-container label {
|
| 61 |
+
display: inline-block;
|
| 62 |
+
width: 24%;
|
| 63 |
+
font-size: 0.9em;
|
| 64 |
+
padding: 2px 5px;
|
| 65 |
+
margin: 2px 0;
|
| 66 |
+
vertical-align: top;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/* Make column section more compact */
|
| 70 |
+
.select-columns-section {
|
| 71 |
+
max-height: 300px;
|
| 72 |
+
overflow-y: auto;
|
| 73 |
+
padding: 0 !important;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/* Add category headers */
|
| 77 |
+
.column-category {
|
| 78 |
+
font-weight: bold;
|
| 79 |
+
margin-top: 10px;
|
| 80 |
+
margin-bottom: 5px;
|
| 81 |
+
border-bottom: 1px solid #eee;
|
| 82 |
+
padding-bottom: 3px;
|
| 83 |
}
|
| 84 |
+
""")
|
| 85 |
|
|
|
|
| 86 |
with demo:
|
| 87 |
gr.HTML(TITLE)
|
| 88 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
|
|
|
| 100 |
default_selection.insert(0, "model_name")
|
| 101 |
print("Default Selection after ensuring 'model_name':", default_selection) # Debug
|
| 102 |
|
| 103 |
+
# Add a custom accordion for better organization of column options
|
| 104 |
+
with gr.Accordion("📊 Select Columns to Display", open=False):
|
| 105 |
+
# Will be visually hidden and replaced with our custom layout
|
| 106 |
+
gr.HTML("<div class='column-category'>Keep using the checkboxes below to select columns.</div>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
+
# Create the leaderboard with the built-in SelectColumns
|
| 109 |
leaderboard = Leaderboard(
|
| 110 |
value=LEADERBOARD_DF,
|
| 111 |
datatype=[col.type for col in COLUMNS],
|
|
|
|
| 113 |
default_selection=default_selection,
|
| 114 |
cant_deselect=[col.name for col in COLUMNS if col.never_hidden],
|
| 115 |
label="Select Columns to Display:",
|
|
|
|
| 116 |
),
|
| 117 |
search_columns=[col.name for col in COLUMNS if col.name in ["model_name", "license"]],
|
| 118 |
hide_columns=[col.name for col in COLUMNS if col.hidden],
|
|
|
|
| 126 |
bool_checkboxgroup_label="Hide models",
|
| 127 |
interactive=False,
|
| 128 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=2):
|
| 131 |
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|