Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -262,58 +262,65 @@ with gr.Blocks(css="""
|
|
| 262 |
visible=True
|
| 263 |
)
|
| 264 |
|
| 265 |
-
# Track evaluation state
|
| 266 |
evaluation_state = gr.State({"running": False})
|
| 267 |
-
|
|
|
|
|
|
|
| 268 |
|
| 269 |
# Function to show/hide configuration based on selected dataset
|
| 270 |
-
def update_interface_based_on_dataset(dataset):
|
| 271 |
if dataset == "MMLU-Pro":
|
| 272 |
return (
|
| 273 |
gr.update(visible=True), # mmlu_config_container
|
| 274 |
gr.update(visible=True), # results_container
|
| 275 |
-
gr.update(interactive=True) # preview_toggle
|
|
|
|
|
|
|
|
|
|
| 276 |
)
|
| 277 |
else:
|
| 278 |
return (
|
| 279 |
gr.update(visible=False), # mmlu_config_container
|
| 280 |
gr.update(visible=False), # results_container
|
| 281 |
-
gr.update(interactive=False) # preview_toggle
|
|
|
|
|
|
|
|
|
|
| 282 |
)
|
| 283 |
|
| 284 |
# Connect dataset dropdown to show/hide appropriate configuration
|
| 285 |
dataset_dropdown.change(
|
| 286 |
fn=update_interface_based_on_dataset,
|
| 287 |
-
inputs=[dataset_dropdown],
|
| 288 |
-
outputs=[mmlu_config_container, results_container, preview_toggle]
|
| 289 |
)
|
| 290 |
|
| 291 |
# Function to toggle dataset preview visibility
|
| 292 |
-
def toggle_preview(
|
| 293 |
-
# Toggle visibility state
|
| 294 |
-
|
| 295 |
-
|
|
|
|
|
|
|
| 296 |
|
| 297 |
-
#
|
| 298 |
-
if
|
| 299 |
preview_data = mmlupro_dataset_preview()
|
| 300 |
formatted_preview = enhanced_format_preview_for_display(preview_data)
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
elif new_visible:
|
| 304 |
# For other datasets (not implemented yet)
|
| 305 |
-
|
| 306 |
-
return state, gr.update(visible=True), None, gr.update(value=button_text)
|
| 307 |
else:
|
| 308 |
# Hiding the preview
|
| 309 |
-
|
| 310 |
-
return state, gr.update(visible=False), None, gr.update(value=button_text)
|
| 311 |
|
| 312 |
# Connect preview toggle to show/hide dataset information
|
| 313 |
preview_toggle.click(
|
| 314 |
fn=toggle_preview,
|
| 315 |
-
inputs=[
|
| 316 |
-
outputs=[
|
| 317 |
)
|
| 318 |
|
| 319 |
# Update num_subjects_slider interactivity based on all_subjects checkbox
|
|
|
|
| 262 |
visible=True
|
| 263 |
)
|
| 264 |
|
| 265 |
+
# Track evaluation state
|
| 266 |
evaluation_state = gr.State({"running": False})
|
| 267 |
+
|
| 268 |
+
# Track preview visibility state
|
| 269 |
+
preview_visibility = gr.State(False)
|
| 270 |
|
| 271 |
# Function to show/hide configuration based on selected dataset
|
| 272 |
+
def update_interface_based_on_dataset(dataset, current_visibility):
|
| 273 |
if dataset == "MMLU-Pro":
|
| 274 |
return (
|
| 275 |
gr.update(visible=True), # mmlu_config_container
|
| 276 |
gr.update(visible=True), # results_container
|
| 277 |
+
gr.update(interactive=True), # preview_toggle
|
| 278 |
+
gr.update(visible=False), # dataset_preview_container - hide it initially
|
| 279 |
+
False, # Reset preview_visibility to False
|
| 280 |
+
gr.update(value="Show Preview") # Reset button text
|
| 281 |
)
|
| 282 |
else:
|
| 283 |
return (
|
| 284 |
gr.update(visible=False), # mmlu_config_container
|
| 285 |
gr.update(visible=False), # results_container
|
| 286 |
+
gr.update(interactive=False), # preview_toggle
|
| 287 |
+
gr.update(visible=False), # dataset_preview_container - hide when no dataset
|
| 288 |
+
False, # Reset preview_visibility to False
|
| 289 |
+
gr.update(value="Show Preview") # Reset button text
|
| 290 |
)
|
| 291 |
|
| 292 |
# Connect dataset dropdown to show/hide appropriate configuration
|
| 293 |
dataset_dropdown.change(
|
| 294 |
fn=update_interface_based_on_dataset,
|
| 295 |
+
inputs=[dataset_dropdown, preview_visibility],
|
| 296 |
+
outputs=[mmlu_config_container, results_container, preview_toggle, dataset_preview_container, preview_visibility, preview_toggle]
|
| 297 |
)
|
| 298 |
|
| 299 |
# Function to toggle dataset preview visibility
|
| 300 |
+
def toggle_preview(dataset, preview_visibility):
|
| 301 |
+
# Toggle the visibility state
|
| 302 |
+
is_visible = not preview_visibility
|
| 303 |
+
|
| 304 |
+
# Update button text based on new state
|
| 305 |
+
button_text = "Hide Preview" if is_visible else "Show Preview"
|
| 306 |
|
| 307 |
+
# Get preview data if becoming visible
|
| 308 |
+
if is_visible and dataset == "MMLU-Pro":
|
| 309 |
preview_data = mmlupro_dataset_preview()
|
| 310 |
formatted_preview = enhanced_format_preview_for_display(preview_data)
|
| 311 |
+
return is_visible, gr.update(visible=True), formatted_preview, gr.update(value=button_text)
|
| 312 |
+
elif is_visible:
|
|
|
|
| 313 |
# For other datasets (not implemented yet)
|
| 314 |
+
return is_visible, gr.update(visible=True), None, gr.update(value=button_text)
|
|
|
|
| 315 |
else:
|
| 316 |
# Hiding the preview
|
| 317 |
+
return is_visible, gr.update(visible=False), None, gr.update(value=button_text)
|
|
|
|
| 318 |
|
| 319 |
# Connect preview toggle to show/hide dataset information
|
| 320 |
preview_toggle.click(
|
| 321 |
fn=toggle_preview,
|
| 322 |
+
inputs=[dataset_dropdown, preview_visibility],
|
| 323 |
+
outputs=[preview_visibility, dataset_preview_container, preview_output, preview_toggle]
|
| 324 |
)
|
| 325 |
|
| 326 |
# Update num_subjects_slider interactivity based on all_subjects checkbox
|