Skip to content

Commit

Permalink
Show terms of use as an alert
Browse files Browse the repository at this point in the history
  • Loading branch information
merrymercy committed Sep 21, 2023
1 parent 3e4a869 commit 14a8ddc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
4 changes: 3 additions & 1 deletion fastchat/model/model_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def get_model_info(name: str) -> ModelInfo:
return model_info[name]
else:
# To fix this, please use `register_model_info` to register your model
return ModelInfo(name, "", "Register the description at fastchat/model/model_registry.py")
return ModelInfo(
name, "", "Register the description at fastchat/model/model_registry.py"
)


register_model_info(
Expand Down
11 changes: 7 additions & 4 deletions fastchat/serve/gradio_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,9 @@ def build_single_model_ui(models, add_promotion_links=False):
[state, chatbot] + btn_list,
)
send_btn.click(
add_text, [state, model_selector, textbox], [state, chatbot, textbox] + btn_list,
add_text,
[state, model_selector, textbox],
[state, chatbot, textbox] + btn_list,
).then(
bot_response,
[state, temperature, top_p, max_output_tokens],
Expand Down Expand Up @@ -690,7 +692,7 @@ def build_demo(models):
state,
model_selector,
],
_js=load_js
_js=load_js,
)

return demo
Expand Down Expand Up @@ -725,8 +727,9 @@ def build_demo(models):
help="Whether to load the model list once or reload the model list every time",
)
parser.add_argument(
"--moderate", action="store_true",
help="Enable content moderation to block unsafe inputs"
"--moderate",
action="store_true",
help="Enable content moderation to block unsafe inputs",
)
parser.add_argument(
"--show-terms-of-use",
Expand Down
22 changes: 16 additions & 6 deletions fastchat/serve/gradio_web_server_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ def build_demo(models, elo_results_file, leaderboard_table_file):
side_by_side_named_list = build_side_by_side_ui_named(models)

with gr.Tab("Single Model", id=2):
single_model_list = build_single_model_ui(models, add_promotion_links=True)
single_model_list = build_single_model_ui(
models, add_promotion_links=True
)

if elo_results_file:
with gr.Tab("Leaderboard", id=3):
Expand All @@ -131,7 +133,10 @@ def build_demo(models, elo_results_file, leaderboard_table_file):
demo.load(
load_demo,
[url_params],
[tabs] + single_model_list + side_by_side_anony_list + side_by_side_named_list,
[tabs]
+ single_model_list
+ side_by_side_anony_list
+ side_by_side_named_list,
_js=load_js,
)

Expand Down Expand Up @@ -167,8 +172,9 @@ def build_demo(models, elo_results_file, leaderboard_table_file):
help="Whether to load the model list once or reload the model list every time.",
)
parser.add_argument(
"--moderate", action="store_true",
help="Enable content moderation to block unsafe inputs"
"--moderate",
action="store_true",
help="Enable content moderation to block unsafe inputs",
)
parser.add_argument(
"--show-terms-of-use",
Expand Down Expand Up @@ -206,8 +212,12 @@ def build_demo(models, elo_results_file, leaderboard_table_file):
help='Set the gradio authentication file path. The file should contain one or more user:password pairs in this format: "u1:p1,u2:p2,u3:p3"',
default=None,
)
parser.add_argument("--elo-results-file", type=str, help="Load leaderboard results and plots")
parser.add_argument("--leaderboard-table-file", type=str, help="Load leaderboard results and plots")
parser.add_argument(
"--elo-results-file", type=str, help="Load leaderboard results and plots"
)
parser.add_argument(
"--leaderboard-table-file", type=str, help="Load leaderboard results and plots"
)
args = parser.parse_args()
logger.info(f"args: {args}")

Expand Down
7 changes: 5 additions & 2 deletions fastchat/serve/monitor/summarize_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ def truncate_string(s, l):
instruct = "Given a list of user messages, use less than 8 words to summarize a central topic for all messages in English. Your output should only include a single line. Try to be specific."
split = int(args.num_prompts * 0.8)
prompt = "\n".join(
[truncate_string(x, l=200) for x in topk_prompts[: split]] +
[truncate_string(x, l=200) for x in random_prompts[: args.num_prompts - split]]
[truncate_string(x, l=200) for x in topk_prompts[:split]]
+ [
truncate_string(x, l=200)
for x in random_prompts[: args.num_prompts - split]
]
)
prompt = "BEGIN OF THE MESSAGE LIST\n" + prompt + "\nEND OF THE MESSAGE LIST."

Expand Down

0 comments on commit 14a8ddc

Please sign in to comment.