diff --git a/fastchat/serve/gradio_block_arena_anony.py b/fastchat/serve/gradio_block_arena_anony.py index a92cd9790..62db08159 100644 --- a/fastchat/serve/gradio_block_arena_anony.py +++ b/fastchat/serve/gradio_block_arena_anony.py @@ -25,6 +25,7 @@ no_change_btn, enable_btn, disable_btn, + invisible_btn, acknowledgment_md, ip_expiration_dict, ) @@ -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), ) ) @@ -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 ) @@ -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" @@ -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): @@ -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: @@ -557,6 +567,5 @@ def build_side_by_side_ui_anony(models): textbox, send_btn, button_row, - button_row2, parameter_row, ) diff --git a/fastchat/serve/gradio_block_arena_named.py b/fastchat/serve/gradio_block_arena_named.py index 868a5759a..45d37490f 100644 --- a/fastchat/serve/gradio_block_arena_named.py +++ b/fastchat/serve/gradio_block_arena_named.py @@ -24,6 +24,7 @@ no_change_btn, enable_btn, disable_btn, + invisible_btn, acknowledgment_md, get_model_description_md, ip_expiration_dict, @@ -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), ) ) @@ -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): @@ -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): @@ -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") @@ -491,6 +502,5 @@ def build_side_by_side_ui_named(models): textbox, send_btn, button_row, - button_row2, parameter_row, ) diff --git a/fastchat/serve/gradio_web_server.py b/fastchat/serve/gradio_web_server.py index b17cee42c..395c4b8b6 100644 --- a/fastchat/serve/gradio_web_server.py +++ b/fastchat/serve/gradio_web_server.py @@ -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 diff --git a/fastchat/serve/gradio_web_server_multi.py b/fastchat/serve/gradio_web_server_multi.py index 09e227f90..881e99655 100644 --- a/fastchat/serve/gradio_web_server_multi.py +++ b/fastchat/serve/gradio_web_server_multi.py @@ -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 = ( @@ -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, ] ) @@ -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 = ( @@ -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, ] )