Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update UI #2446

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 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 @@ -429,9 +439,9 @@ def build_side_by_side_ui_anony(models):
with gr.Column(scale=1, min_width=50):
send_btn = gr.Button(value="Battle", 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,
)
30 changes: 20 additions & 10 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 @@ -361,7 +372,7 @@ def build_side_by_side_ui_named(models):
with gr.Column(scale=1, min_width=50):
send_btn = gr.Button(value="Battle", 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,
)
3 changes: 2 additions & 1 deletion fastchat/serve/gradio_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
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
Expand Down
4 changes: 0 additions & 4 deletions fastchat/serve/gradio_web_server_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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