Spaces:
Running
Running
Update UI
Browse files- app.py +22 -71
- src/display/styles.py +23 -158
app.py
CHANGED
|
@@ -141,43 +141,18 @@ def search_models(df: pd.DataFrame, search_text: str) -> pd.DataFrame:
|
|
| 141 |
return df[mask]
|
| 142 |
|
| 143 |
|
| 144 |
-
def
|
| 145 |
"""
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
Args:
|
| 149 |
-
df: Full dataframe
|
| 150 |
-
selected_cols: List of column names to display
|
| 151 |
-
|
| 152 |
-
Returns:
|
| 153 |
-
Dataframe with selected columns
|
| 154 |
-
"""
|
| 155 |
-
# Always include model and score columns
|
| 156 |
-
required_cols = ["model", "score"]
|
| 157 |
-
|
| 158 |
-
# Combine required and selected columns
|
| 159 |
-
cols_to_show = required_cols.copy()
|
| 160 |
-
for col in selected_cols:
|
| 161 |
-
if col not in cols_to_show and col in df.columns:
|
| 162 |
-
cols_to_show.append(col)
|
| 163 |
-
|
| 164 |
-
return df[cols_to_show]
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
def update_leaderboard(search_text: str, selected_cols: list[str]) -> pd.DataFrame:
|
| 168 |
-
"""
|
| 169 |
-
Update leaderboard table based on search and column selection.
|
| 170 |
|
| 171 |
Args:
|
| 172 |
search_text: Search query
|
| 173 |
-
selected_cols: Selected columns to display
|
| 174 |
|
| 175 |
Returns:
|
| 176 |
-
Filtered
|
| 177 |
"""
|
| 178 |
df = build_leaderboard_df()
|
| 179 |
df = search_models(df, search_text)
|
| 180 |
-
df = filter_columns(df, selected_cols)
|
| 181 |
return df
|
| 182 |
|
| 183 |
|
|
@@ -207,15 +182,6 @@ def build_demo() -> gr.Blocks:
|
|
| 207 |
# Get leaderboard data
|
| 208 |
leaderboard_df = build_leaderboard_df()
|
| 209 |
|
| 210 |
-
# Get all column names for checkbox selection (use actual column names from dataframe)
|
| 211 |
-
all_columns = list(leaderboard_df.columns)
|
| 212 |
-
|
| 213 |
-
# Columns available for selection (exclude model/score which are always shown)
|
| 214 |
-
available_columns = [col for col in all_columns if col not in ["model", "score"]]
|
| 215 |
-
|
| 216 |
-
# Columns displayed by default (exclude system_prompt)
|
| 217 |
-
default_columns = [col for col in available_columns if col != "system_prompt"]
|
| 218 |
-
|
| 219 |
# Build interface
|
| 220 |
with demo:
|
| 221 |
# Add theme detection script
|
|
@@ -233,31 +199,19 @@ def build_demo() -> gr.Blocks:
|
|
| 233 |
with gr.TabItem("🏅 Лидерборд", elem_id="llm-benchmark-tab-table", id=0):
|
| 234 |
gr.Markdown("### Таблица результатов моделей DeathMath")
|
| 235 |
|
| 236 |
-
#
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
scale=1,
|
| 243 |
-
)
|
| 244 |
-
|
| 245 |
-
column_selector = gr.CheckboxGroup(
|
| 246 |
-
choices=available_columns, # All columns available (including system_prompt)
|
| 247 |
-
value=default_columns, # Default excludes system_prompt
|
| 248 |
-
label="Отображаемые колонки",
|
| 249 |
-
elem_classes=["column-selector"],
|
| 250 |
-
scale=2,
|
| 251 |
-
)
|
| 252 |
|
| 253 |
-
# Leaderboard table - show ALL
|
| 254 |
-
|
| 255 |
-
initial_df = filter_columns(leaderboard_df, default_columns)
|
| 256 |
|
| 257 |
-
# Define datatypes for
|
| 258 |
-
displayed_cols = ["model", "score"] + default_columns
|
| 259 |
column_datatypes = []
|
| 260 |
-
for col in
|
| 261 |
if col == "model":
|
| 262 |
column_datatypes.append("markdown")
|
| 263 |
elif col == "system_prompt":
|
|
@@ -265,25 +219,22 @@ def build_demo() -> gr.Blocks:
|
|
| 265 |
else:
|
| 266 |
column_datatypes.append("number")
|
| 267 |
|
|
|
|
|
|
|
|
|
|
| 268 |
leaderboard_table = gr.Dataframe(
|
| 269 |
-
value=
|
| 270 |
-
headers=
|
| 271 |
datatype=column_datatypes,
|
| 272 |
-
max_height="75vh",
|
| 273 |
wrap=True,
|
| 274 |
interactive=False,
|
| 275 |
-
column_widths=
|
| 276 |
elem_id="leaderboard-table",
|
| 277 |
)
|
| 278 |
|
| 279 |
-
# Update table when search
|
| 280 |
-
search_box.change(
|
| 281 |
-
fn=update_leaderboard, inputs=[search_box, column_selector], outputs=[leaderboard_table]
|
| 282 |
-
)
|
| 283 |
-
|
| 284 |
-
column_selector.change(
|
| 285 |
-
fn=update_leaderboard, inputs=[search_box, column_selector], outputs=[leaderboard_table]
|
| 286 |
-
)
|
| 287 |
|
| 288 |
# Submit results tab
|
| 289 |
with gr.TabItem("🚀 Отправить результаты", elem_id="submit-tab", id=1):
|
|
|
|
| 141 |
return df[mask]
|
| 142 |
|
| 143 |
|
| 144 |
+
def update_leaderboard(search_text: str) -> pd.DataFrame:
|
| 145 |
"""
|
| 146 |
+
Update leaderboard table based on search query.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
Args:
|
| 149 |
search_text: Search query
|
|
|
|
| 150 |
|
| 151 |
Returns:
|
| 152 |
+
Filtered dataframe
|
| 153 |
"""
|
| 154 |
df = build_leaderboard_df()
|
| 155 |
df = search_models(df, search_text)
|
|
|
|
| 156 |
return df
|
| 157 |
|
| 158 |
|
|
|
|
| 182 |
# Get leaderboard data
|
| 183 |
leaderboard_df = build_leaderboard_df()
|
| 184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
# Build interface
|
| 186 |
with demo:
|
| 187 |
# Add theme detection script
|
|
|
|
| 199 |
with gr.TabItem("🏅 Лидерборд", elem_id="llm-benchmark-tab-table", id=0):
|
| 200 |
gr.Markdown("### Таблица результатов моделей DeathMath")
|
| 201 |
|
| 202 |
+
# Centered search box
|
| 203 |
+
search_box = gr.Textbox(
|
| 204 |
+
label="Поиск по названию модели",
|
| 205 |
+
placeholder="Введите название модели...",
|
| 206 |
+
elem_classes=["search-box-centered"],
|
| 207 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
|
| 209 |
+
# Leaderboard table - show ALL columns including system_prompt
|
| 210 |
+
all_cols = leaderboard_df.columns.tolist()
|
|
|
|
| 211 |
|
| 212 |
+
# Define datatypes for all columns
|
|
|
|
| 213 |
column_datatypes = []
|
| 214 |
+
for col in all_cols:
|
| 215 |
if col == "model":
|
| 216 |
column_datatypes.append("markdown")
|
| 217 |
elif col == "system_prompt":
|
|
|
|
| 219 |
else:
|
| 220 |
column_datatypes.append("number")
|
| 221 |
|
| 222 |
+
# Set column widths: model=240px, scores=85px, system_prompt=200px
|
| 223 |
+
column_widths = ["240px"] + ["85px"] * (len(all_cols) - 2) + ["200px"]
|
| 224 |
+
|
| 225 |
leaderboard_table = gr.Dataframe(
|
| 226 |
+
value=leaderboard_df,
|
| 227 |
+
headers=all_cols,
|
| 228 |
datatype=column_datatypes,
|
| 229 |
+
max_height="75vh",
|
| 230 |
wrap=True,
|
| 231 |
interactive=False,
|
| 232 |
+
column_widths=column_widths,
|
| 233 |
elem_id="leaderboard-table",
|
| 234 |
)
|
| 235 |
|
| 236 |
+
# Update table when search changes
|
| 237 |
+
search_box.change(fn=update_leaderboard, inputs=[search_box], outputs=[leaderboard_table])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
|
| 239 |
# Submit results tab
|
| 240 |
with gr.TabItem("🚀 Отправить результаты", elem_id="submit-tab", id=1):
|
src/display/styles.py
CHANGED
|
@@ -147,6 +147,12 @@ h1, h2, h3, h4, h5, h6 {
|
|
| 147 |
Tab Buttons
|
| 148 |
======================================== */
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
.tab-buttons button {
|
| 151 |
font-size: 18px;
|
| 152 |
color: var(--foreground);
|
|
@@ -197,171 +203,39 @@ h1, h2, h3, h4, h5, h6 {
|
|
| 197 |
}
|
| 198 |
|
| 199 |
/* ========================================
|
| 200 |
-
Search Bar
|
| 201 |
======================================== */
|
| 202 |
|
| 203 |
-
.
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
margin
|
| 207 |
-
align-items: flex-start;
|
| 208 |
-
flex-wrap: wrap;
|
| 209 |
-
}
|
| 210 |
-
|
| 211 |
-
.search-box {
|
| 212 |
-
flex: 1;
|
| 213 |
-
min-width: 250px;
|
| 214 |
}
|
| 215 |
|
| 216 |
-
.search-box input,
|
|
|
|
| 217 |
width: 100%;
|
| 218 |
-
padding:
|
| 219 |
-
font-size:
|
| 220 |
-
background:
|
| 221 |
border: 1px solid var(--border) !important;
|
| 222 |
border-radius: var(--radius) !important;
|
| 223 |
color: var(--foreground) !important;
|
| 224 |
transition: all 0.2s ease;
|
|
|
|
| 225 |
}
|
| 226 |
|
| 227 |
-
.search-box input:focus,
|
|
|
|
| 228 |
border-color: var(--ring) !important;
|
| 229 |
-
box-shadow: 0 0 0
|
| 230 |
outline: none !important;
|
| 231 |
}
|
| 232 |
|
| 233 |
-
.search-box input::placeholder,
|
|
|
|
| 234 |
color: var(--muted-foreground) !important;
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
/* ========================================
|
| 238 |
-
Column Selector - Compact ASR Style
|
| 239 |
-
======================================== */
|
| 240 |
-
|
| 241 |
-
.column-selector {
|
| 242 |
-
flex: 2;
|
| 243 |
-
min-width: 350px;
|
| 244 |
-
}
|
| 245 |
-
|
| 246 |
-
.column-selector label.block {
|
| 247 |
-
font-size: 13px !important;
|
| 248 |
-
font-weight: 500 !important;
|
| 249 |
-
color: var(--muted-foreground) !important;
|
| 250 |
-
margin-bottom: 8px !important;
|
| 251 |
-
}
|
| 252 |
-
|
| 253 |
-
/* Gradio checkbox group - horizontal compact layout */
|
| 254 |
-
.column-selector .checkboxgroup-container,
|
| 255 |
-
.checkboxgroup-container {
|
| 256 |
-
display: flex !important;
|
| 257 |
-
flex-wrap: wrap !important;
|
| 258 |
-
gap: 8px !important;
|
| 259 |
-
padding: 0 !important;
|
| 260 |
-
}
|
| 261 |
-
|
| 262 |
-
.column-selector .checkboxgroup-container label,
|
| 263 |
-
.checkboxgroup-container label {
|
| 264 |
-
display: inline-flex !important;
|
| 265 |
-
align-items: center !important;
|
| 266 |
-
padding: 6px 12px !important;
|
| 267 |
-
margin: 0 !important;
|
| 268 |
-
background: var(--card) !important;
|
| 269 |
-
border: 1px solid var(--border) !important;
|
| 270 |
-
border-radius: calc(var(--radius) - 2px) !important;
|
| 271 |
-
cursor: pointer !important;
|
| 272 |
-
font-size: 13px !important;
|
| 273 |
-
font-weight: 500 !important;
|
| 274 |
-
color: var(--foreground) !important;
|
| 275 |
-
transition: all 0.15s ease !important;
|
| 276 |
-
white-space: nowrap !important;
|
| 277 |
-
}
|
| 278 |
-
|
| 279 |
-
.column-selector .checkboxgroup-container label:hover,
|
| 280 |
-
.checkboxgroup-container label:hover {
|
| 281 |
-
background: var(--accent) !important;
|
| 282 |
-
border-color: var(--primary) !important;
|
| 283 |
-
}
|
| 284 |
-
|
| 285 |
-
.column-selector .checkboxgroup-container input[type="checkbox"],
|
| 286 |
-
.checkboxgroup-container input[type="checkbox"] {
|
| 287 |
-
width: 16px !important;
|
| 288 |
-
height: 16px !important;
|
| 289 |
-
margin: 0 6px 0 0 !important;
|
| 290 |
-
cursor: pointer !important;
|
| 291 |
-
accent-color: var(--primary) !important;
|
| 292 |
-
}
|
| 293 |
-
|
| 294 |
-
.column-selector .checkboxgroup-container label:has(input:checked),
|
| 295 |
-
.checkboxgroup-container label:has(input:checked) {
|
| 296 |
-
background: var(--primary) !important;
|
| 297 |
-
color: var(--primary-foreground) !important;
|
| 298 |
-
border-color: var(--primary) !important;
|
| 299 |
-
font-weight: 600 !important;
|
| 300 |
-
}
|
| 301 |
-
|
| 302 |
-
/* Custom checkbox using ::before pseudo-element */
|
| 303 |
-
|
| 304 |
-
/* Completely hide native checkbox and its checkmark */
|
| 305 |
-
.checkboxgroup-container label input[type="checkbox"],
|
| 306 |
-
.column-selector .checkboxgroup-container label input[type="checkbox"] {
|
| 307 |
-
position: absolute !important;
|
| 308 |
-
opacity: 0 !important;
|
| 309 |
-
width: 0 !important;
|
| 310 |
-
height: 0 !important;
|
| 311 |
-
margin: 0 !important;
|
| 312 |
-
pointer-events: none !important;
|
| 313 |
-
}
|
| 314 |
-
|
| 315 |
-
/* Hide any SVG icons/checkmarks that Gradio adds */
|
| 316 |
-
.checkboxgroup-container label svg,
|
| 317 |
-
.column-selector .checkboxgroup-container label svg,
|
| 318 |
-
.checkboxgroup-container label input[type="checkbox"] + *,
|
| 319 |
-
.column-selector .checkboxgroup-container label input[type="checkbox"] + * {
|
| 320 |
-
display: none !important;
|
| 321 |
-
visibility: hidden !important;
|
| 322 |
-
}
|
| 323 |
-
|
| 324 |
-
/* Position label to make room for custom indicator */
|
| 325 |
-
.checkboxgroup-container label,
|
| 326 |
-
.column-selector .checkboxgroup-container label {
|
| 327 |
-
position: relative !important;
|
| 328 |
-
padding-left: 26px !important;
|
| 329 |
-
}
|
| 330 |
-
|
| 331 |
-
/* Create custom circle indicator using ::before */
|
| 332 |
-
.checkboxgroup-container label::before,
|
| 333 |
-
.column-selector .checkboxgroup-container label::before {
|
| 334 |
-
content: "" !important;
|
| 335 |
-
position: absolute !important;
|
| 336 |
-
left: 6px !important;
|
| 337 |
-
top: 50% !important;
|
| 338 |
-
transform: translateY(-50%) !important;
|
| 339 |
-
width: 16px !important;
|
| 340 |
-
height: 16px !important;
|
| 341 |
-
border: 2px solid var(--border) !important;
|
| 342 |
-
border-radius: 50% !important;
|
| 343 |
-
background: transparent !important;
|
| 344 |
-
transition: all 0.2s ease !important;
|
| 345 |
-
display: block !important;
|
| 346 |
-
visibility: visible !important;
|
| 347 |
-
opacity: 1 !important;
|
| 348 |
-
}
|
| 349 |
-
|
| 350 |
-
/* Fill circle when checked */
|
| 351 |
-
.checkboxgroup-container label:has(input:checked)::before,
|
| 352 |
-
.column-selector .checkboxgroup-container label:has(input:checked)::before {
|
| 353 |
-
background: var(--primary) !important;
|
| 354 |
-
border-color: var(--primary) !important;
|
| 355 |
-
}
|
| 356 |
-
|
| 357 |
-
/* Keep text label visible */
|
| 358 |
-
.checkboxgroup-container label > span,
|
| 359 |
-
.column-selector .checkboxgroup-container label > span {
|
| 360 |
-
font-size: 13px !important;
|
| 361 |
-
line-height: normal !important;
|
| 362 |
-
font-weight: 500 !important;
|
| 363 |
-
display: inline !important;
|
| 364 |
-
visibility: visible !important;
|
| 365 |
}
|
| 366 |
|
| 367 |
/* ========================================
|
|
@@ -554,11 +428,6 @@ input:focus, textarea:focus, select:focus {
|
|
| 554 |
padding: 16px;
|
| 555 |
}
|
| 556 |
|
| 557 |
-
.checkbox-group {
|
| 558 |
-
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
| 559 |
-
gap: 8px;
|
| 560 |
-
}
|
| 561 |
-
|
| 562 |
.tab-buttons button {
|
| 563 |
font-size: 16px;
|
| 564 |
padding: 10px 16px;
|
|
@@ -577,10 +446,6 @@ input:focus, textarea:focus, select:focus {
|
|
| 577 |
}
|
| 578 |
|
| 579 |
@media (max-width: 600px) {
|
| 580 |
-
.checkbox-group {
|
| 581 |
-
grid-template-columns: 1fr;
|
| 582 |
-
}
|
| 583 |
-
|
| 584 |
table {
|
| 585 |
font-size: 13px;
|
| 586 |
}
|
|
|
|
| 147 |
Tab Buttons
|
| 148 |
======================================== */
|
| 149 |
|
| 150 |
+
.tab-buttons {
|
| 151 |
+
display: flex !important;
|
| 152 |
+
justify-content: center !important;
|
| 153 |
+
align-items: center !important;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
.tab-buttons button {
|
| 157 |
font-size: 18px;
|
| 158 |
color: var(--foreground);
|
|
|
|
| 203 |
}
|
| 204 |
|
| 205 |
/* ========================================
|
| 206 |
+
Centered Search Bar (Transparent Background)
|
| 207 |
======================================== */
|
| 208 |
|
| 209 |
+
.search-box-centered {
|
| 210 |
+
max-width: 1200px;
|
| 211 |
+
width: 85%;
|
| 212 |
+
margin: 0 auto 24px auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
}
|
| 214 |
|
| 215 |
+
.search-box-centered input,
|
| 216 |
+
.search-box-centered textarea {
|
| 217 |
width: 100%;
|
| 218 |
+
padding: 12px 16px !important;
|
| 219 |
+
font-size: 15px !important;
|
| 220 |
+
background: transparent !important;
|
| 221 |
border: 1px solid var(--border) !important;
|
| 222 |
border-radius: var(--radius) !important;
|
| 223 |
color: var(--foreground) !important;
|
| 224 |
transition: all 0.2s ease;
|
| 225 |
+
text-align: center;
|
| 226 |
}
|
| 227 |
|
| 228 |
+
.search-box-centered input:focus,
|
| 229 |
+
.search-box-centered textarea:focus {
|
| 230 |
border-color: var(--ring) !important;
|
| 231 |
+
box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08) !important;
|
| 232 |
outline: none !important;
|
| 233 |
}
|
| 234 |
|
| 235 |
+
.search-box-centered input::placeholder,
|
| 236 |
+
.search-box-centered textarea::placeholder {
|
| 237 |
color: var(--muted-foreground) !important;
|
| 238 |
+
text-align: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
}
|
| 240 |
|
| 241 |
/* ========================================
|
|
|
|
| 428 |
padding: 16px;
|
| 429 |
}
|
| 430 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 431 |
.tab-buttons button {
|
| 432 |
font-size: 16px;
|
| 433 |
padding: 10px 16px;
|
|
|
|
| 446 |
}
|
| 447 |
|
| 448 |
@media (max-width: 600px) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 449 |
table {
|
| 450 |
font-size: 13px;
|
| 451 |
}
|