Spaces:
Running
on
Zero
Running
on
Zero
Rewrote interruption & improved UI (#9)
Browse files- Rewrote interruption & improved UI (23f15c31c502d9e13b24caa75169353cae64aa1f)
Co-authored-by: Kai <kai-aizip@users.noreply.huggingface.co>
app.py
CHANGED
|
@@ -3,15 +3,12 @@ import random
|
|
| 3 |
import pandas as pd
|
| 4 |
import os
|
| 5 |
import threading
|
| 6 |
-
from threading import Event
|
| 7 |
from utils.data_loader import get_random_example
|
| 8 |
from utils.models import generate_summaries, model_names
|
| 9 |
from utils.ui_helpers import toggle_context_display, update_feedback, get_context_html
|
| 10 |
from utils.leaderboard import load_leaderboard_data, submit_vote_with_elo, generate_leaderboard_html
|
| 11 |
from utils.vote_logger import save_vote_details
|
| 12 |
-
|
| 13 |
-
# Global interrupt mechanism for model generation
|
| 14 |
-
generation_interrupt = Event()
|
| 15 |
|
| 16 |
# Feedback options for different voting outcomes
|
| 17 |
feedback_options = {
|
|
@@ -251,7 +248,7 @@ with gr.Blocks(theme=gr.themes.Default(
|
|
| 251 |
gr.Markdown("### Model B was actually:", elem_classes="section-heading")
|
| 252 |
model_b_reveal = gr.Markdown("", elem_classes="model-reveal model-b-reveal")
|
| 253 |
|
| 254 |
-
gr.HTML("<
|
| 255 |
|
| 256 |
# Try another button
|
| 257 |
with gr.Row(elem_classes=["control-buttons"]):
|
|
@@ -266,7 +263,6 @@ with gr.Blocks(theme=gr.themes.Default(
|
|
| 266 |
gr.Markdown("""### About Elo Ratings
|
| 267 |
|
| 268 |
The Elo rating system provides a more accurate ranking than simple win rates:
|
| 269 |
-
|
| 270 |
- All models start at 1500 points
|
| 271 |
- Points are exchanged after each comparison based on the expected outcome
|
| 272 |
- Beating a stronger model earns more points than beating a weaker one
|
|
@@ -289,6 +285,17 @@ The Elo rating system provides a more accurate ranking than simple win rates:
|
|
| 289 |
False
|
| 290 |
]
|
| 291 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
# Event handling
|
| 293 |
# Toggle context display
|
| 294 |
context_toggle_btn.click(
|
|
@@ -323,6 +330,11 @@ The Elo rating system provides a more accurate ranking than simple win rates:
|
|
| 323 |
# Random Question and Try Another buttons with interruption
|
| 324 |
for btn in [random_question_btn, try_another_btn]:
|
| 325 |
btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
fn=handle_new_example_click,
|
| 327 |
inputs=[],
|
| 328 |
outputs=[current_example]
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
import os
|
| 5 |
import threading
|
|
|
|
| 6 |
from utils.data_loader import get_random_example
|
| 7 |
from utils.models import generate_summaries, model_names
|
| 8 |
from utils.ui_helpers import toggle_context_display, update_feedback, get_context_html
|
| 9 |
from utils.leaderboard import load_leaderboard_data, submit_vote_with_elo, generate_leaderboard_html
|
| 10 |
from utils.vote_logger import save_vote_details
|
| 11 |
+
from utils.shared import generation_interrupt # Import from shared module
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# Feedback options for different voting outcomes
|
| 14 |
feedback_options = {
|
|
|
|
| 248 |
gr.Markdown("### Model B was actually:", elem_classes="section-heading")
|
| 249 |
model_b_reveal = gr.Markdown("", elem_classes="model-reveal model-b-reveal")
|
| 250 |
|
| 251 |
+
gr.HTML("<hr>")
|
| 252 |
|
| 253 |
# Try another button
|
| 254 |
with gr.Row(elem_classes=["control-buttons"]):
|
|
|
|
| 263 |
gr.Markdown("""### About Elo Ratings
|
| 264 |
|
| 265 |
The Elo rating system provides a more accurate ranking than simple win rates:
|
|
|
|
| 266 |
- All models start at 1500 points
|
| 267 |
- Points are exchanged after each comparison based on the expected outcome
|
| 268 |
- Beating a stronger model earns more points than beating a weaker one
|
|
|
|
| 285 |
False
|
| 286 |
]
|
| 287 |
|
| 288 |
+
# Add this new function to show a loading state
|
| 289 |
+
def show_loading_state():
|
| 290 |
+
return [
|
| 291 |
+
gr.update(value="Loading new question and summaries...", interactive=False),
|
| 292 |
+
gr.update(value="Loading new question and summaries...", interactive=False),
|
| 293 |
+
gr.update(interactive=False),
|
| 294 |
+
gr.update(interactive=False),
|
| 295 |
+
gr.update(interactive=False),
|
| 296 |
+
gr.update(interactive=False)
|
| 297 |
+
]
|
| 298 |
+
|
| 299 |
# Event handling
|
| 300 |
# Toggle context display
|
| 301 |
context_toggle_btn.click(
|
|
|
|
| 330 |
# Random Question and Try Another buttons with interruption
|
| 331 |
for btn in [random_question_btn, try_another_btn]:
|
| 332 |
btn.click(
|
| 333 |
+
fn=show_loading_state, # First show loading state
|
| 334 |
+
inputs=[],
|
| 335 |
+
outputs=[summary_a_display, summary_b_display, vote_button_a,
|
| 336 |
+
vote_button_b, vote_button_tie, vote_button_neither]
|
| 337 |
+
).then(
|
| 338 |
fn=handle_new_example_click,
|
| 339 |
inputs=[],
|
| 340 |
outputs=[current_example]
|