Jae-Won Chung commited on
Commit
68a9e7e
1 Parent(s): d4e66cd

Flash model names

Browse files
Files changed (1) hide show
  1. app.py +27 -15
app.py CHANGED
@@ -322,6 +322,21 @@ table th:first-child {
322
  .red-text {
323
  color: #ff3860 !important;
324
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  """
326
 
327
  intro_text = """
@@ -339,8 +354,6 @@ Every benchmark is limited in some sense -- Before you interpret the results, pl
339
  controller_addr = os.environ["COLOSSEUM_CONTROLLER_ADDR"]
340
  global_controller_client = ControllerClient(controller_addr=controller_addr, timeout=15)
341
 
342
- ANONYMOUS_MODEL_TEXT = "## Anonymous Model 🤫"
343
-
344
  # Colosseum helper functions.
345
  def enable_interact():
346
  return [gr.update(interactive=True)] * 2
@@ -413,7 +426,7 @@ def make_resp_vote_func(victory_index: Literal[0, 1]):
413
  # Disable response vote buttons
414
  gr.Button.update(interactive=False), gr.Button.update(interactive=False),
415
  # Reveal model names
416
- gr.Markdown.update(model_name_a), gr.Markdown.update(model_name_b),
417
  # Display energy consumption comparison message
418
  gr.Markdown.update(energy_message, visible=True),
419
  # Keep energy vote buttons hidden
@@ -428,7 +441,7 @@ def make_resp_vote_func(victory_index: Literal[0, 1]):
428
  # Disable response vote buttons
429
  gr.Button.update(interactive=False), gr.Button.update(interactive=False),
430
  # Leave model names hidden
431
- gr.Markdown.update(ANONYMOUS_MODEL_TEXT), gr.Markdown.update(ANONYMOUS_MODEL_TEXT),
432
  # Display energy consumption comparison message
433
  gr.Markdown.update(energy_message, visible=True),
434
  # Reveal and enable energy vote buttons
@@ -445,7 +458,7 @@ def make_energy_vote_func(is_worth: bool):
445
  model_name_a, model_name_b = map(lambda n: f"## {n}", vote_response.model_names)
446
  return [
447
  # Reveal model names
448
- gr.Markdown.update(model_name_a), gr.Markdown.update(model_name_b),
449
  # Disable energy vote buttons
450
  gr.Button.update(interactive=False), gr.Button.update(interactive=False),
451
  # Enable reset button
@@ -462,8 +475,7 @@ def play_again():
462
  # Turn on prompt textbox and submit button
463
  gr.Textbox.update(value="", interactive=True), gr.Button.update(interactive=True),
464
  # Mask model names
465
- gr.Markdown.update(ANONYMOUS_MODEL_TEXT),
466
- gr.Markdown.update(ANONYMOUS_MODEL_TEXT),
467
  # Hide energy vote buttons and message
468
  gr.Button.update(visible=False), gr.Button.update(visible=False), gr.Markdown.update(visible=False),
469
  # Disable reset button
@@ -514,21 +526,21 @@ with gr.Blocks(css=custom_css) as block:
514
  resp_vote_btn_list: list[gr.component.Component] = []
515
  with gr.Column():
516
  with gr.Row():
517
- chatbots.append(gr.Chatbot(label="Model A", elem_id="chatbot", height=600))
 
 
518
  with gr.Row():
519
  left_resp_vote_btn = gr.Button(value="👈 Model A is better", interactive=False)
520
  resp_vote_btn_list.append(left_resp_vote_btn)
521
- with gr.Row():
522
- masked_model_names.append(gr.Markdown(ANONYMOUS_MODEL_TEXT))
523
 
524
  with gr.Column():
525
  with gr.Row():
526
- chatbots.append(gr.Chatbot(label="Model B", elem_id="chatbot", height=600))
 
 
527
  with gr.Row():
528
  right_resp_vote_btn = gr.Button(value="👉 Model B is better", interactive=False)
529
  resp_vote_btn_list.append(right_resp_vote_btn)
530
- with gr.Row():
531
- masked_model_names.append(gr.Markdown(ANONYMOUS_MODEL_TEXT))
532
 
533
  with gr.Row():
534
  energy_comparison_message = gr.HTML(visible=False)
@@ -548,11 +560,11 @@ with gr.Blocks(css=custom_css) as block:
548
 
549
  (prompt_input
550
  .submit(add_prompt_disable_submit, [prompt_input, *chatbots], [prompt_input, prompt_submit_btn, *chatbots, controller_client], queue=False)
551
- .then(generate_responses, [controller_client, *chatbots], [*chatbots], queue=True)
552
  .then(enable_interact, None, resp_vote_btn_list, queue=False))
553
  (prompt_submit_btn
554
  .click(add_prompt_disable_submit, [prompt_input, *chatbots], [prompt_input, prompt_submit_btn, *chatbots, controller_client], queue=False)
555
- .then(generate_responses, [controller_client, *chatbots], [*chatbots], queue=True)
556
  .then(enable_interact, None, resp_vote_btn_list, queue=False))
557
 
558
  left_resp_vote_btn.click(
 
322
  .red-text {
323
  color: #ff3860 !important;
324
  }
325
+
326
+ /* Flashing model name borders. */
327
+ @keyframes blink {
328
+ 0%, 33%, 67%, 100% {
329
+ border-color: transparent;
330
+ }
331
+ 17%, 50%, 83% {
332
+ border-color: #23d175;
333
+ }
334
+ }
335
+
336
+ .model-name-text {
337
+ border: 2px solid transparent; /* Transparent border initially */
338
+ animation: blink 3s ease-in-out 1; /* One complete cycle of animation, lasting 3 seconds */
339
+ }
340
  """
341
 
342
  intro_text = """
 
354
  controller_addr = os.environ["COLOSSEUM_CONTROLLER_ADDR"]
355
  global_controller_client = ControllerClient(controller_addr=controller_addr, timeout=15)
356
 
 
 
357
  # Colosseum helper functions.
358
  def enable_interact():
359
  return [gr.update(interactive=True)] * 2
 
426
  # Disable response vote buttons
427
  gr.Button.update(interactive=False), gr.Button.update(interactive=False),
428
  # Reveal model names
429
+ gr.Markdown.update(model_name_a, visible=True), gr.Markdown.update(model_name_b, visible=True),
430
  # Display energy consumption comparison message
431
  gr.Markdown.update(energy_message, visible=True),
432
  # Keep energy vote buttons hidden
 
441
  # Disable response vote buttons
442
  gr.Button.update(interactive=False), gr.Button.update(interactive=False),
443
  # Leave model names hidden
444
+ gr.Markdown.update(visible=False), gr.Markdown.update(visible=False),
445
  # Display energy consumption comparison message
446
  gr.Markdown.update(energy_message, visible=True),
447
  # Reveal and enable energy vote buttons
 
458
  model_name_a, model_name_b = map(lambda n: f"## {n}", vote_response.model_names)
459
  return [
460
  # Reveal model names
461
+ gr.Markdown.update(model_name_a, visible=True), gr.Markdown.update(model_name_b, visible=True),
462
  # Disable energy vote buttons
463
  gr.Button.update(interactive=False), gr.Button.update(interactive=False),
464
  # Enable reset button
 
475
  # Turn on prompt textbox and submit button
476
  gr.Textbox.update(value="", interactive=True), gr.Button.update(interactive=True),
477
  # Mask model names
478
+ gr.Markdown.update(value="", visible=False), gr.Markdown.update(value="", visible=False),
 
479
  # Hide energy vote buttons and message
480
  gr.Button.update(visible=False), gr.Button.update(visible=False), gr.Markdown.update(visible=False),
481
  # Disable reset button
 
526
  resp_vote_btn_list: list[gr.component.Component] = []
527
  with gr.Column():
528
  with gr.Row():
529
+ masked_model_names.append(gr.Markdown(visible=False, elem_classes=["model-name-text"]))
530
+ with gr.Row():
531
+ chatbots.append(gr.Chatbot(label="Model A", elem_id="chatbot", height=400))
532
  with gr.Row():
533
  left_resp_vote_btn = gr.Button(value="👈 Model A is better", interactive=False)
534
  resp_vote_btn_list.append(left_resp_vote_btn)
 
 
535
 
536
  with gr.Column():
537
  with gr.Row():
538
+ masked_model_names.append(gr.Markdown(visible=False, elem_classes=["model-name-text"]))
539
+ with gr.Row():
540
+ chatbots.append(gr.Chatbot(label="Model B", elem_id="chatbot", height=400))
541
  with gr.Row():
542
  right_resp_vote_btn = gr.Button(value="👉 Model B is better", interactive=False)
543
  resp_vote_btn_list.append(right_resp_vote_btn)
 
 
544
 
545
  with gr.Row():
546
  energy_comparison_message = gr.HTML(visible=False)
 
560
 
561
  (prompt_input
562
  .submit(add_prompt_disable_submit, [prompt_input, *chatbots], [prompt_input, prompt_submit_btn, *chatbots, controller_client], queue=False)
563
+ .then(generate_responses, [controller_client, *chatbots], [*chatbots], queue=True, show_progress="hidden")
564
  .then(enable_interact, None, resp_vote_btn_list, queue=False))
565
  (prompt_submit_btn
566
  .click(add_prompt_disable_submit, [prompt_input, *chatbots], [prompt_input, prompt_submit_btn, *chatbots, controller_client], queue=False)
567
+ .then(generate_responses, [controller_client, *chatbots], [*chatbots], queue=True, show_progress="hidden")
568
  .then(enable_interact, None, resp_vote_btn_list, queue=False))
569
 
570
  left_resp_vote_btn.click(