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
Next Next commit
improve vision UI
  • Loading branch information
merrymercy committed Feb 12, 2024
commit ae4e131997f9b2862095b46c5e26d736ab27f455
14 changes: 12 additions & 2 deletions fastchat/serve/gradio_block_arena_vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
add_text,
clear_history,
regenerate,
get_ip,
disable_btn,
)
from fastchat.utils import (
build_logger,
Expand All @@ -29,6 +31,13 @@
logger = build_logger("gradio_web_server_multi", "gradio_web_server_multi.log")


def clear_history_example(request: gr.Request):
ip = get_ip(request)
logger.info(f"clear_history_example. ip: {ip}")
state = None
return (state, []) + (disable_btn,) * 5


def build_single_vision_language_model_ui(models, add_promotion_links=False):
promotion = (
"""
Expand Down Expand Up @@ -71,7 +80,7 @@ def build_single_vision_language_model_ui(models, add_promotion_links=False):
render=False,
elem_id="input_box",
)
imagebox = gr.Image(type="pil")
imagebox = gr.Image(type="pil", sources=["upload", "clipboard"])

cur_dir = os.path.dirname(os.path.abspath(__file__))

Expand Down Expand Up @@ -101,7 +110,7 @@ def build_single_vision_language_model_ui(models, add_promotion_links=False):
label="Max output tokens",
)

gr.Examples(
examples = gr.Examples(
examples=[
[
f"{cur_dir}/example_images/city.jpeg",
Expand Down Expand Up @@ -160,6 +169,7 @@ def build_single_vision_language_model_ui(models, add_promotion_links=False):
[state, chatbot] + btn_list,
)
clear_btn.click(clear_history, None, [state, chatbot, textbox, imagebox] + btn_list)
examples.dataset.click(clear_history_example, None, [state, chatbot] + btn_list)

model_selector.change(
clear_history, None, [state, chatbot, textbox, imagebox] + btn_list
Expand Down
3 changes: 2 additions & 1 deletion fastchat/serve/gradio_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@

The service is a research preview. It only provides limited safety measures and may generate offensive content.
It must not be used for any illegal, harmful, violent, racist, or sexual purposes.
The service collects user dialogue data and reserves the right to distribute it under a Creative Commons Attribution (CC-BY) or a similar license.
Please do not upload any private information.
The service collects user dialogue data, including both text and images, and reserves the right to distribute it under a Creative Commons Attribution (CC-BY) or a similar license.
Additionally, Bard is offered on LMSys for research purposes only. To access the Bard product, please visit its [website](http://bard.google.com).

### Acknowledgment
Expand Down
2 changes: 1 addition & 1 deletion fastchat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def pretty_print_semaphore(semaphore):
url_params = Object.fromEntries(params);
console.log("url_params", url_params);

msg = "Users of this website are required to agree to the following terms:\\n\\nThe service is a research preview. It only provides limited safety measures and may generate offensive content. It must not be used for any illegal, harmful, violent, racist, or sexual purposes.\\nThe service collects user dialogue data and reserves the right to distribute it under a Creative Commons Attribution (CC-BY) or a similar license."
msg = "Users of this website are required to agree to the following terms:\\n\\nThe service is a research preview. It only provides limited safety measures and may generate offensive content. It must not be used for any illegal, harmful, violent, racist, or sexual purposes.\\nPlease do not upload any private information.\\nThe service collects user dialogue data, including both text and images, and reserves the right to distribute it under a Creative Commons Attribution (CC-BY) or a similar license."
alert(msg);

return url_params;
Expand Down