Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
gradio 4.17
  • Loading branch information
infwinston committed Feb 7, 2024
commit 330e9564b5419e2416e5901254ffec9aa39b8795
4 changes: 2 additions & 2 deletions fastchat/llm_judge/qa_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

def display_question(category_selector, request: gr.Request):
choices = category_selector_map[category_selector]
return gr.Dropdown.update(
return gr.Dropdown(
value=choices[0],
choices=choices,
)
Expand Down Expand Up @@ -413,6 +413,6 @@ def build_demo():
) = load_pairwise_model_judgments(pairwise_model_judgment_file)

demo = build_demo()
demo.queue(concurrency_count=10, status_update_rate=10, api_open=False).launch(
demo.queue(default_concurrency_limit=10, status_update_rate=10, api_open=False).launch(
server_name=args.host, server_port=args.port, share=args.share, max_threads=200
)
7 changes: 7 additions & 0 deletions fastchat/model/model_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def get_model_info(name: str) -> ModelInfo:
"qwen1.5-1.8b-chat",
"qwen1.5-0.5b-chat",
"qwen-14b-chat"],
"Qwen 1.5",
"https://qwenlm.github.io/blog/qwen1.5/",
"a large language model by Alibaba Cloud",
)

register_model_info(
["qwen-14b-chat"],
"Qwen",
"https://huggingface.co/Qwen",
"a large language model by Alibaba Cloud",
Expand Down
42 changes: 21 additions & 21 deletions fastchat/serve/gradio_block_arena_anony.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def load_demo_side_by_side_anony(models_, url_params):

states = (None,) * num_sides
selector_updates = (
gr.Markdown.update(visible=True),
gr.Markdown.update(visible=True),
gr.Markdown(visible=True),
gr.Markdown(visible=True),
)

return states + selector_updates
Expand All @@ -74,13 +74,13 @@ def vote_last_response(states, vote_type, model_selectors, request: gr.Request):
fout.write(json.dumps(data) + "\n")

if ":" not in model_selectors[0]:
for i in range(15):
for i in range(5):
names = (
"### Model A: " + states[0].model_name,
"### Model B: " + states[1].model_name,
)
yield names + ("",) + (disable_btn,) * 4
time.sleep(0.2)
time.sleep(0.1)
else:
names = (
"### Model A: " + states[0].model_name,
Expand Down Expand Up @@ -613,15 +613,15 @@ def bot_response_multi(

def build_side_by_side_ui_anony(models):
notice_markdown = """
# ⚔️ Chatbot Arena ⚔️ : Benchmarking LLMs in the Wild
# ⚔️ Chatbot Arena: Benchmarking LLMs in the Wild
| [Blog](https://lmsys.org/blog/2023-05-03-arena/) | [GitHub](https://github.com/lm-sys/FastChat) | [Paper](https://arxiv.org/abs/2306.05685) | [Dataset](https://github.com/lm-sys/FastChat/blob/main/docs/dataset_release.md) | [Twitter](https://twitter.com/lmsysorg) | [Discord](https://discord.gg/HSWAKCrnFx) |

## 📜 Rules
- Ask any question to two anonymous models (e.g., ChatGPT, Claude, Llama) and vote for the better one!
- You can continue chatting until you identify a winner.
- Vote won't be counted if model identity is revealed during conversation.

## 🏆 Arena Elo [Leaderboard](https://huggingface.co/spaces/lmsys/chatbot-arena-leaderboard)
## 🏆 Arena Elo ([Leaderboard](https://huggingface.co/spaces/lmsys/chatbot-arena-leaderboard))
We collect **200K+** human votes to compute an Elo-based LLM leaderboard.
Find out who is the 🥇LLM Champion!

Expand All @@ -635,7 +635,7 @@ 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.Group(elem_id="share-region-anony"):
with gr.Accordion("🔍 Expand to see 20+ Arena players", open=False):
model_description_md = get_model_description_md(models)
gr.Markdown(model_description_md, elem_id="model_description_markdown")
Expand All @@ -645,29 +645,29 @@ def build_side_by_side_ui_anony(models):
with gr.Column():
chatbots[i] = gr.Chatbot(
label=label,
elem_id=f"chatbot",
elem_id="chatbot",
height=550,
show_copy_button=True,
)

with gr.Row():
for i in range(num_sides):
with gr.Column():
model_selectors[i] = gr.Markdown(anony_names[i])
model_selectors[i] = gr.Markdown(anony_names[i], elem_id="model_selector_md")
with gr.Row():
slow_warning = gr.Markdown("", elem_id="notice_markdown")

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():
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():
textbox = gr.Textbox(
Expand Down Expand Up @@ -774,7 +774,7 @@ def build_side_by_side_ui_anony(models):
return [a, b, c, d];
}
"""
share_btn.click(share_click, states + model_selectors, [], _js=share_js)
share_btn.click(share_click, states + model_selectors, [], js=share_js)

textbox.submit(
add_text,
Expand Down
34 changes: 17 additions & 17 deletions fastchat/serve/gradio_block_arena_named.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def load_demo_side_by_side_named(models, url_params):
model_right = model_left

selector_updates = (
gr.Dropdown.update(choices=models, value=model_left, visible=True),
gr.Dropdown.update(choices=models, value=model_right, visible=True),
gr.Dropdown(choices=models, value=model_left, visible=True),
gr.Dropdown(choices=models, value=model_right, visible=True),
)

return states + selector_updates
Expand Down Expand Up @@ -273,12 +273,12 @@ def flash_buttons():
]
for i in range(4):
yield btn_updates[i % 2]
time.sleep(0.5)
time.sleep(0.3)


def build_side_by_side_ui_named(models):
notice_markdown = """
# ⚔️ Chatbot Arena ⚔️ : Benchmarking LLMs in the Wild
# ⚔️ Chatbot Arena: Benchmarking LLMs in the Wild
| [Blog](https://lmsys.org/blog/2023-05-03-arena/) | [GitHub](https://github.com/lm-sys/FastChat) | [Paper](https://arxiv.org/abs/2306.05685) | [Dataset](https://github.com/lm-sys/FastChat/blob/main/docs/dataset_release.md) | [Twitter](https://twitter.com/lmsysorg) | [Discord](https://discord.gg/HSWAKCrnFx) |

## 📜 Rules
Expand All @@ -295,7 +295,7 @@ def build_side_by_side_ui_named(models):

notice = gr.Markdown(notice_markdown, elem_id="notice_markdown")

with gr.Box(elem_id="share-region-named"):
with gr.Group(elem_id="share-region-named"):
with gr.Row():
for i in range(num_sides):
with gr.Column():
Expand All @@ -322,17 +322,17 @@ def build_side_by_side_ui_named(models):
show_copy_button=True,
)

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():
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():
textbox = gr.Textbox(
Expand Down Expand Up @@ -435,7 +435,7 @@ def build_side_by_side_ui_named(models):
return [a, b, c, d];
}
"""
share_btn.click(share_click, states + model_selectors, [], _js=share_js)
share_btn.click(share_click, states + model_selectors, [], js=share_js)

for i in range(num_sides):
model_selectors[i].change(
Expand Down
44 changes: 23 additions & 21 deletions fastchat/serve/gradio_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@

headers = {"User-Agent": "FastChat Client"}

no_change_btn = gr.Button.update()
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)
no_change_btn = gr.Button()
enable_btn = gr.Button(interactive=True, visible=True)
disable_btn = gr.Button(interactive=False)
invisible_btn = gr.Button(interactive=False, visible=False)

controller_url = None
enable_moderation = False
Expand Down Expand Up @@ -177,7 +177,7 @@ def load_demo_single(models, url_params):
if model in models:
selected_model = model

dropdown_update = gr.Dropdown.update(
dropdown_update = gr.Dropdown(
choices=models, value=selected_model, visible=True
)

Expand Down Expand Up @@ -573,8 +573,11 @@ def bot_response(


block_css = """
#notice_markdown {
font-size: 110%
#chatbot {
line-height: 1.5;
}
#notice_markdown .prose {
font-size: 120% !important;
}
#notice_markdown th {
display: none;
Expand All @@ -584,10 +587,10 @@ def bot_response(
padding-bottom: 6px;
}
#model_description_markdown {
font-size: 110%
font-size: 120% !important;
}
#leaderboard_markdown {
font-size: 110%
#leaderboard_markdown .prose {
font-size: 120% !important;
}
#leaderboard_markdown td {
padding-top: 6px;
Expand All @@ -596,16 +599,16 @@ def bot_response(
#leaderboard_dataframe td {
line-height: 0.1em;
}
#about_markdown {
font-size: 110%
#about_markdown .prose {
font-size: 120% !important;
}
#ack_markdown {
font-size: 110%
#ack_markdown .prose {
font-size: 120% !important;
}
#input_box textarea {
}
footer {
display:none !important
display:none !important;
}
.image-container {
display: flex;
Expand All @@ -620,12 +623,11 @@ def bot_response(
max-width: 20%;
}
.image-about img {
margin: 0 30px;
margin-top: 30px;
height: 50px;
margin: 0 20px;
margin-top: 20px;
height: 40px;
max-height: 100%;
width: auto;
max-width: 20%;
float: left;
}
"""
Expand Down Expand Up @@ -715,7 +717,7 @@ def build_single_model_ui(models, add_promotion_links=False):
state = gr.State()
gr.Markdown(notice_markdown, elem_id="notice_markdown")

with gr.Box(elem_id="share-region-named"):
with gr.Group(elem_id="share-region-named"):
with gr.Row(elem_id="model_selector_row"):
model_selector = gr.Dropdown(
choices=models,
Expand Down Expand Up @@ -931,7 +933,7 @@ def build_demo(models):
# Launch the demo
demo = build_demo(models)
demo.queue(
concurrency_count=args.concurrency_count, status_update_rate=10, api_open=False
default_concurrency_limit=args.concurrency_count, status_update_rate=10, api_open=False
).launch(
server_name=args.host,
server_port=args.port,
Expand Down
Loading