Jae-Won Chung commited on
Commit
64446b4
1 Parent(s): 3c356de

Add option to mark Colosseum as down

Browse files
Files changed (1) hide show
  1. app.py +23 -7
app.py CHANGED
@@ -22,6 +22,9 @@ pio.templates.default = "plotly_white"
22
 
23
  from spitfight.colosseum.client import ControllerClient
24
 
 
 
 
25
 
26
  class TableManager:
27
  def __init__(self, data_dir: str) -> None:
@@ -348,6 +351,12 @@ table th:first-child {
348
  animation: blink 3s ease-in-out 1; /* One complete cycle of animation, lasting 3 seconds */
349
  -webkit-animation: blink 3s ease-in-out 1; /* Older browser compatibility */
350
  }
 
 
 
 
 
 
351
  """
352
 
353
  intro_text = """
@@ -368,7 +377,7 @@ global_controller_client = ControllerClient(controller_addr=controller_addr, tim
368
  # Load the list of models. To reload, the app should be restarted.
369
  RANDOM_MODEL_NAME = "Random"
370
  RANDOM_USER_PREFERENCE = "Two random models"
371
- global_available_models = global_controller_client.get_available_models()
372
  model_name_to_user_pref = {model: f"One is {model}" for model in global_available_models}
373
  model_name_to_user_pref[RANDOM_MODEL_NAME] = RANDOM_USER_PREFERENCE
374
  user_pref_to_model_name = {v: k for k, v in model_name_to_user_pref.items()}
@@ -529,13 +538,18 @@ with gr.Blocks(css=custom_css) as block:
529
  with gr.Tabs():
530
  # Tab: Colosseum.
531
  with gr.TabItem("Colosseum ⚔️️"):
532
- gr.Markdown(open("docs/colosseum_top.md").read())
 
 
 
 
533
 
534
  with gr.Row():
535
  model_preference_dropdown = gr.Dropdown(
536
  value=RANDOM_USER_PREFERENCE,
537
  label="Prefer a specific model?",
538
- interactive=True,
 
539
  )
540
 
541
  with gr.Group():
@@ -545,13 +559,15 @@ with gr.Blocks(css=custom_css) as block:
545
  placeholder="Input your prompt, e.g., 'Explain machine learning in simple terms.'",
546
  container=False,
547
  scale=20,
548
- elem_id="prompt-textarea",
 
549
  )
550
  prompt_submit_btn = gr.Button(
551
  value="⚔️️ Fight!",
552
- elem_classes=["btn-submit"],
553
  min_width=60,
554
  scale=1,
 
555
  )
556
 
557
  with gr.Row():
@@ -562,7 +578,7 @@ with gr.Blocks(css=custom_css) as block:
562
  with gr.Row():
563
  masked_model_names.append(gr.Markdown(visible=False, elem_classes=["model-name-text"]))
564
  with gr.Row():
565
- chatbots.append(gr.Chatbot(label="Model A", elem_id="chatbot", height=400))
566
  with gr.Row():
567
  left_resp_vote_btn = gr.Button(value="👈 Model A is better", interactive=False)
568
  resp_vote_btn_list.append(left_resp_vote_btn)
@@ -571,7 +587,7 @@ with gr.Blocks(css=custom_css) as block:
571
  with gr.Row():
572
  masked_model_names.append(gr.Markdown(visible=False, elem_classes=["model-name-text"]))
573
  with gr.Row():
574
- chatbots.append(gr.Chatbot(label="Model B", elem_id="chatbot", height=400))
575
  with gr.Row():
576
  right_resp_vote_btn = gr.Button(value="👉 Model B is better", interactive=False)
577
  resp_vote_btn_list.append(right_resp_vote_btn)
 
22
 
23
  from spitfight.colosseum.client import ControllerClient
24
 
25
+ COLOSSEUM_UP = True
26
+ COLOSSEUM_BACK_ON = "September 4th"
27
+
28
 
29
  class TableManager:
30
  def __init__(self, data_dir: str) -> None:
 
351
  animation: blink 3s ease-in-out 1; /* One complete cycle of animation, lasting 3 seconds */
352
  -webkit-animation: blink 3s ease-in-out 1; /* Older browser compatibility */
353
  }
354
+
355
+ /* Grey out components when the Colosseum is down. */
356
+ .greyed-out {
357
+ pointer-events: none;
358
+ opacity: 0.4;
359
+ }
360
  """
361
 
362
  intro_text = """
 
377
  # Load the list of models. To reload, the app should be restarted.
378
  RANDOM_MODEL_NAME = "Random"
379
  RANDOM_USER_PREFERENCE = "Two random models"
380
+ global_available_models = global_controller_client.get_available_models() if COLOSSEUM_UP else []
381
  model_name_to_user_pref = {model: f"One is {model}" for model in global_available_models}
382
  model_name_to_user_pref[RANDOM_MODEL_NAME] = RANDOM_USER_PREFERENCE
383
  user_pref_to_model_name = {v: k for k, v in model_name_to_user_pref.items()}
 
538
  with gr.Tabs():
539
  # Tab: Colosseum.
540
  with gr.TabItem("Colosseum ⚔️️"):
541
+ if COLOSSEUM_UP:
542
+ gr.Markdown(open("docs/colosseum_top.md").read())
543
+ else:
544
+ gr.HTML(f"<br/><h2 style='text-align: center'>The Colosseum is currently down. We'll be back on <u><b>{COLOSSEUM_BACK_ON}</b></u>.</h2>")
545
+ gr.HTML("<h3 style='text-align: center'>The energy leaderboard is still available.</h3><br/>")
546
 
547
  with gr.Row():
548
  model_preference_dropdown = gr.Dropdown(
549
  value=RANDOM_USER_PREFERENCE,
550
  label="Prefer a specific model?",
551
+ interactive=COLOSSEUM_UP,
552
+ elem_classes=None if COLOSSEUM_UP else ["greyed-out"],
553
  )
554
 
555
  with gr.Group():
 
559
  placeholder="Input your prompt, e.g., 'Explain machine learning in simple terms.'",
560
  container=False,
561
  scale=20,
562
+ interactive=COLOSSEUM_UP,
563
+ elem_classes=None if COLOSSEUM_UP else ["greyed-out"],
564
  )
565
  prompt_submit_btn = gr.Button(
566
  value="⚔️️ Fight!",
567
+ elem_classes=["btn-submit"] if COLOSSEUM_UP else ["greyed-out"],
568
  min_width=60,
569
  scale=1,
570
+ interactive=COLOSSEUM_UP,
571
  )
572
 
573
  with gr.Row():
 
578
  with gr.Row():
579
  masked_model_names.append(gr.Markdown(visible=False, elem_classes=["model-name-text"]))
580
  with gr.Row():
581
+ chatbots.append(gr.Chatbot(label="Model A", elem_id="chatbot", height=400, elem_classes=None if COLOSSEUM_UP else ["greyed-out"]))
582
  with gr.Row():
583
  left_resp_vote_btn = gr.Button(value="👈 Model A is better", interactive=False)
584
  resp_vote_btn_list.append(left_resp_vote_btn)
 
587
  with gr.Row():
588
  masked_model_names.append(gr.Markdown(visible=False, elem_classes=["model-name-text"]))
589
  with gr.Row():
590
+ chatbots.append(gr.Chatbot(label="Model B", elem_id="chatbot", height=400, elem_classes=None if COLOSSEUM_UP else ["greyed-out"]))
591
  with gr.Row():
592
  right_resp_vote_btn = gr.Button(value="👉 Model B is better", interactive=False)
593
  resp_vote_btn_list.append(right_resp_vote_btn)