Skip to content

Commit

Permalink
Update UI (#2446)
Browse files Browse the repository at this point in the history
  • Loading branch information
merrymercy committed Sep 19, 2023
1 parent 16be5cf commit e4758da
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 35 deletions.
43 changes: 26 additions & 17 deletions fastchat/serve/gradio_block_arena_anony.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
no_change_btn,
enable_btn,
disable_btn,
invisible_btn,
acknowledgment_md,
ip_expiration_dict,
)
Expand Down Expand Up @@ -64,7 +65,6 @@ def load_demo_side_by_side_anony(models_, url_params):
gr.Textbox.update(visible=True),
gr.Box.update(visible=True),
gr.Row.update(visible=True),
gr.Row.update(visible=True),
gr.Accordion.update(visible=True),
)
)
Expand Down Expand Up @@ -148,7 +148,12 @@ def regenerate(state0, state1, request: gr.Request):
def clear_history(request: gr.Request):
logger.info(f"clear_history (anony). ip: {request.client.host}")
return (
[None] * num_sides + [None] * num_sides + anony_names + [""] + [disable_btn] * 6
[None] * num_sides
+ [None] * num_sides
+ anony_names
+ [""]
+ [invisible_btn] * 4
+ [disable_btn] * 2
)


Expand Down Expand Up @@ -397,11 +402,6 @@ def build_side_by_side_ui_anony(models):
gr.Markdown(notice_markdown, elem_id="notice_markdown")

with gr.Box(elem_id="share-region-anony"):
with gr.Row():
for i in range(num_sides):
with gr.Column():
model_selectors[i] = gr.Markdown(anony_names[i])

with gr.Row():
for i in range(num_sides):
label = "Model A" if i == 0 else "Model B"
Expand All @@ -410,12 +410,22 @@ def build_side_by_side_ui_anony(models):
label=label, elem_id=f"chatbot", visible=False, height=550
)

with gr.Box() as button_row:
with gr.Row():
leftvote_btn = gr.Button(value="👈 A is better", interactive=False)
rightvote_btn = gr.Button(value="👉 B is better", interactive=False)
tie_btn = gr.Button(value="🤝 Tie", interactive=False)
bothbad_btn = gr.Button(value="👎 Both are bad", interactive=False)
with gr.Row():
for i in range(num_sides):
with gr.Column():
model_selectors[i] = gr.Markdown(anony_names[i])

with gr.Row():
leftvote_btn = gr.Button(
value="👈 A is better", visible=False, interactive=False
)
rightvote_btn = gr.Button(
value="👉 B is better", visible=False, interactive=False
)
tie_btn = gr.Button(value="🤝 Tie", visible=False, interactive=False)
bothbad_btn = gr.Button(
value="👎 Both are bad", visible=False, interactive=False
)

with gr.Row():
with gr.Column(scale=20):
Expand All @@ -427,11 +437,11 @@ def build_side_by_side_ui_anony(models):
elem_id="input_box",
)
with gr.Column(scale=1, min_width=50):
send_btn = gr.Button(value="Battle", visible=False, variant="primary")
send_btn = gr.Button(value="Send", visible=False, variant="primary")

with gr.Row() as button_row2:
regenerate_btn = gr.Button(value="🔄 Regenerate", interactive=False)
with gr.Row() as button_row:
clear_btn = gr.Button(value="🗑️ Clear history", interactive=False)
regenerate_btn = gr.Button(value="🔄 Regenerate", interactive=False)
share_btn = gr.Button(value="📷 Share")

with gr.Accordion("Parameters", open=False, visible=True) as parameter_row:
Expand Down Expand Up @@ -557,6 +567,5 @@ def build_side_by_side_ui_anony(models):
textbox,
send_btn,
button_row,
button_row2,
parameter_row,
)
32 changes: 21 additions & 11 deletions fastchat/serve/gradio_block_arena_named.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
no_change_btn,
enable_btn,
disable_btn,
invisible_btn,
acknowledgment_md,
get_model_description_md,
ip_expiration_dict,
Expand Down Expand Up @@ -69,7 +70,6 @@ def load_demo_side_by_side_named(models, url_params):
gr.Textbox.update(visible=True),
gr.Box.update(visible=True),
gr.Row.update(visible=True),
gr.Row.update(visible=True),
gr.Accordion.update(visible=True),
)
)
Expand Down Expand Up @@ -137,7 +137,13 @@ def regenerate(state0, state1, request: gr.Request):

def clear_history(request: gr.Request):
logger.info(f"clear_history (named). ip: {request.client.host}")
return [None] * num_sides + [None] * num_sides + [""] + [disable_btn] * 6
return (
[None] * num_sides
+ [None] * num_sides
+ [""]
+ [invisible_btn] * 4
+ [disable_btn] * 2
)


def share_click(state0, state1, model_selector0, model_selector1, request: gr.Request):
Expand Down Expand Up @@ -342,12 +348,17 @@ def build_side_by_side_ui_named(models):
label=label, elem_id=f"chatbot", visible=False, height=550
)

with gr.Box() as button_row:
with gr.Row():
leftvote_btn = gr.Button(value="👈 A is better", interactive=False)
rightvote_btn = gr.Button(value="👉 B is better", interactive=False)
tie_btn = gr.Button(value="🤝 Tie", interactive=False)
bothbad_btn = gr.Button(value="👎 Both are bad", interactive=False)
with gr.Row():
leftvote_btn = gr.Button(
value="👈 A is better", visible=False, interactive=False
)
rightvote_btn = gr.Button(
value="👉 B is better", visible=False, interactive=False
)
tie_btn = gr.Button(value="🤝 Tie", visible=False, interactive=False)
bothbad_btn = gr.Button(
value="👎 Both are bad", visible=False, interactive=False
)

with gr.Row():
with gr.Column(scale=20):
Expand All @@ -359,9 +370,9 @@ def build_side_by_side_ui_named(models):
elem_id="input_box",
)
with gr.Column(scale=1, min_width=50):
send_btn = gr.Button(value="Battle", visible=False, variant="primary")
send_btn = gr.Button(value="Send", visible=False, variant="primary")

with gr.Row() as button_row2:
with gr.Row() as button_row:
regenerate_btn = gr.Button(value="🔄 Regenerate", interactive=False)
clear_btn = gr.Button(value="🗑️ Clear history", interactive=False)
share_btn = gr.Button(value="📷 Share")
Expand Down Expand Up @@ -491,6 +502,5 @@ def build_side_by_side_ui_named(models):
textbox,
send_btn,
button_row,
button_row2,
parameter_row,
)
6 changes: 4 additions & 2 deletions fastchat/serve/gradio_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@
headers = {"User-Agent": "FastChat Client"}

no_change_btn = gr.Button.update()
enable_btn = gr.Button.update(interactive=True)
enable_btn = gr.Button.update(interactive=True, visible=True)
disable_btn = gr.Button.update(interactive=False)
invisible_btn = gr.Button.update(interactive=False, visible=False)

controller_url = None
enable_moderation = False

acknowledgment_md = """
### Acknowledgment
<div class="image-container">
<p> <strong>Acknowledgment: </strong> We thank <a href="https://www.kaggle.com/" target="_blank">Kaggle</a>, <a href="https://mbzuai.ac.ae/" target="_blank">MBZUAI</a>, <a href="https://www.anyscale.com/" target="_blank">AnyScale</a>, and <a href="https://huggingface.co/" target="_blank">HuggingFace</a> for their sponsorship. </p>
<p> We thank <a href="https://www.kaggle.com/" target="_blank">Kaggle</a>, <a href="https://mbzuai.ac.ae/" target="_blank">MBZUAI</a>, <a href="https://www.anyscale.com/" target="_blank">AnyScale</a>, and <a href="https://huggingface.co/" target="_blank">HuggingFace</a> for their <a href="https://lmsys.org/donations/" target="_blank">sponsorship</a>. </p>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/Kaggle_logo.png/400px-Kaggle_logo.png" alt="Image 1">
<img src="https://mma.prnewswire.com/media/1227419/MBZUAI_Logo.jpg?p=facebookg" alt="Image 2">
<img src="https://docs.anyscale.com/site-assets/logo.png" alt="Image 3">
Expand Down
6 changes: 1 addition & 5 deletions fastchat/serve/gradio_web_server_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def load_demo(url_params, request: gr.Request):
def build_demo(models, elo_results_file, leaderboard_table_file):
with gr.Blocks(
title="Chat with Open Large Language Models",
theme=gr.themes.Base(),
theme=gr.themes.Default(),
css=block_css,
) as demo:
with gr.Tabs() as tabs:
Expand All @@ -112,7 +112,6 @@ def build_demo(models, elo_results_file, leaderboard_table_file):
b_textbox,
b_send_btn,
b_button_row,
b_button_row2,
b_parameter_row,
) = build_side_by_side_ui_anony(models)
b_list = (
Expand All @@ -123,7 +122,6 @@ def build_demo(models, elo_results_file, leaderboard_table_file):
b_textbox,
b_send_btn,
b_button_row,
b_button_row2,
b_parameter_row,
]
)
Expand All @@ -136,7 +134,6 @@ def build_demo(models, elo_results_file, leaderboard_table_file):
c_textbox,
c_send_btn,
c_button_row,
c_button_row2,
c_parameter_row,
) = build_side_by_side_ui_named(models)
c_list = (
Expand All @@ -147,7 +144,6 @@ def build_demo(models, elo_results_file, leaderboard_table_file):
c_textbox,
c_send_btn,
c_button_row,
c_button_row2,
c_parameter_row,
]
)
Expand Down

0 comments on commit e4758da

Please sign in to comment.