Spaces:
Runtime error
Runtime error
AlekseyKorshuk
commited on
Commit
•
d7f914d
1
Parent(s):
cb80e0b
updates
Browse files- app.py +4 -0
- tabs/arena_battle.py +12 -3
- tabs/arena_side_by_side.py +11 -3
- tabs/playground.py +11 -3
app.py
CHANGED
@@ -172,6 +172,10 @@ def get_bot_profile(bot_config):
|
|
172 |
|
173 |
|
174 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
175 |
with gr.Tabs():
|
176 |
with gr.TabItem("Playground"):
|
177 |
get_tab_playground(download_bot_config, get_bot_profile, model_mapping)
|
|
|
172 |
|
173 |
|
174 |
with gr.Blocks() as demo:
|
175 |
+
gr.Markdown("""
|
176 |
+
# Chai: Model Evaluation
|
177 |
+
Visit each tab for details ⬇️
|
178 |
+
""")
|
179 |
with gr.Tabs():
|
180 |
with gr.TabItem("Playground"):
|
181 |
get_tab_playground(download_bot_config, get_bot_profile, model_mapping)
|
tabs/arena_battle.py
CHANGED
@@ -6,6 +6,14 @@ from conversation import Conversation
|
|
6 |
|
7 |
|
8 |
def get_tab_arena_battle(download_bot_config, get_bot_profile, model_mapping, client):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
default_bot_id = "_bot_e21de304-6151-4a04-b025-4c553ae8cbca"
|
10 |
bot_config = download_bot_config(default_bot_id)
|
11 |
user_state = gr.State(
|
@@ -16,7 +24,7 @@ def get_tab_arena_battle(download_bot_config, get_bot_profile, model_mapping, cl
|
|
16 |
reload_bot_button = gr.Button("Reload bot")
|
17 |
bot_profile = gr.HTML(get_bot_profile(bot_config))
|
18 |
with gr.Accordion("Bot config:", open=False):
|
19 |
-
gr.Markdown(f"# Memory\n{bot_config['memory']}\n# Prompt\n{bot_config['prompt']}\n")
|
20 |
|
21 |
with gr.Row():
|
22 |
values = list(model_mapping.keys())
|
@@ -81,7 +89,8 @@ def get_tab_arena_battle(download_bot_config, get_bot_profile, model_mapping, cl
|
|
81 |
def reload_bot(bot_id):
|
82 |
bot_config = download_bot_config(bot_id)
|
83 |
bot_profile = get_bot_profile(bot_config)
|
84 |
-
return bot_profile, [(None, bot_config["firstMessage"])], [(None, bot_config[
|
|
|
85 |
|
86 |
def get_generation_args(model_tag):
|
87 |
model = model_mapping[model_tag]
|
@@ -212,7 +221,7 @@ def get_tab_arena_battle(download_bot_config, get_bot_profile, model_mapping, cl
|
|
212 |
# model_a.change(enable_voting, None, [vote_a, vote_b, vote_tie, vote_bad], queue=False)
|
213 |
# model_b.change(enable_voting, None, [vote_a, vote_b, vote_tie, vote_bad], queue=False)
|
214 |
reload_bot_button.click(disable_voting, None, [vote_a, vote_b, vote_tie, vote_bad], queue=False)
|
215 |
-
reload_bot_button.click(reload_bot, [bot_id], [bot_profile, chatbot_a, chatbot_b, user_state],
|
216 |
queue=False)
|
217 |
send.click(enable_voting, None, [vote_a, vote_b, vote_tie, vote_bad], queue=False)
|
218 |
clear.click(disable_voting, None, [vote_a, vote_b, vote_tie, vote_bad], queue=False)
|
|
|
6 |
|
7 |
|
8 |
def get_tab_arena_battle(download_bot_config, get_bot_profile, model_mapping, client):
|
9 |
+
gr.Markdown("""
|
10 |
+
# ⚔️ Chatbot Arena (battle) ⚔️
|
11 |
+
## Rules
|
12 |
+
* Chat with two anonymous models side-by-side and vote for which one is better!
|
13 |
+
* You can do multiple rounds of conversations before voting or vote for each message.
|
14 |
+
* The names of the models will be revealed of the top after your voted and pressed "Show models".
|
15 |
+
* Click “Restart” to start a new round with new models.
|
16 |
+
""")
|
17 |
default_bot_id = "_bot_e21de304-6151-4a04-b025-4c553ae8cbca"
|
18 |
bot_config = download_bot_config(default_bot_id)
|
19 |
user_state = gr.State(
|
|
|
24 |
reload_bot_button = gr.Button("Reload bot")
|
25 |
bot_profile = gr.HTML(get_bot_profile(bot_config))
|
26 |
with gr.Accordion("Bot config:", open=False):
|
27 |
+
bot_config_text = gr.Markdown(f"# Memory\n{bot_config['memory']}\n# Prompt\n{bot_config['prompt']}\n")
|
28 |
|
29 |
with gr.Row():
|
30 |
values = list(model_mapping.keys())
|
|
|
89 |
def reload_bot(bot_id):
|
90 |
bot_config = download_bot_config(bot_id)
|
91 |
bot_profile = get_bot_profile(bot_config)
|
92 |
+
return bot_profile, [(None, bot_config["firstMessage"])], [(None, bot_config[
|
93 |
+
"firstMessage"])], bot_config, f"# Memory\n{bot_config['memory']}\n# Prompt\n{bot_config['prompt']}"
|
94 |
|
95 |
def get_generation_args(model_tag):
|
96 |
model = model_mapping[model_tag]
|
|
|
221 |
# model_a.change(enable_voting, None, [vote_a, vote_b, vote_tie, vote_bad], queue=False)
|
222 |
# model_b.change(enable_voting, None, [vote_a, vote_b, vote_tie, vote_bad], queue=False)
|
223 |
reload_bot_button.click(disable_voting, None, [vote_a, vote_b, vote_tie, vote_bad], queue=False)
|
224 |
+
reload_bot_button.click(reload_bot, [bot_id], [bot_profile, chatbot_a, chatbot_b, user_state, bot_config_text],
|
225 |
queue=False)
|
226 |
send.click(enable_voting, None, [vote_a, vote_b, vote_tie, vote_bad], queue=False)
|
227 |
clear.click(disable_voting, None, [vote_a, vote_b, vote_tie, vote_bad], queue=False)
|
tabs/arena_side_by_side.py
CHANGED
@@ -6,6 +6,13 @@ from conversation import Conversation
|
|
6 |
|
7 |
|
8 |
def get_tab_arena_side_by_side(download_bot_config, get_bot_profile, model_mapping, client):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
default_bot_id = "_bot_e21de304-6151-4a04-b025-4c553ae8cbca"
|
10 |
bot_config = download_bot_config(default_bot_id)
|
11 |
user_state = gr.State(
|
@@ -16,7 +23,7 @@ def get_tab_arena_side_by_side(download_bot_config, get_bot_profile, model_mappi
|
|
16 |
reload_bot_button = gr.Button("Reload bot")
|
17 |
bot_profile = gr.HTML(get_bot_profile(bot_config))
|
18 |
with gr.Accordion("Bot config:", open=False):
|
19 |
-
gr.Markdown(f"# Memory\n{bot_config['memory']}\n# Prompt\n{bot_config['prompt']}\n")
|
20 |
|
21 |
with gr.Row():
|
22 |
values = list(model_mapping.keys())
|
@@ -80,7 +87,8 @@ def get_tab_arena_side_by_side(download_bot_config, get_bot_profile, model_mappi
|
|
80 |
def reload_bot(bot_id):
|
81 |
bot_config = download_bot_config(bot_id)
|
82 |
bot_profile = get_bot_profile(bot_config)
|
83 |
-
return bot_profile, [(None, bot_config["firstMessage"])], [(None, bot_config[
|
|
|
84 |
|
85 |
def get_generation_args(model_tag):
|
86 |
model = model_mapping[model_tag]
|
@@ -184,7 +192,7 @@ def get_tab_arena_side_by_side(download_bot_config, get_bot_profile, model_mappi
|
|
184 |
model_b.change(get_generation_args, [model_b],
|
185 |
[temperature_model_b, repetition_penalty_model_b, max_new_tokens_model_b, top_k_model_b,
|
186 |
top_p_model_b], queue=False)
|
187 |
-
reload_bot_button.click(reload_bot, [bot_id], [bot_profile, chatbot_a, chatbot_b, user_state],
|
188 |
queue=False)
|
189 |
clear.click(clear_chat, [user_state], [msg, chatbot_a, chatbot_b], queue=False)
|
190 |
model_a.change(clear_chat, [user_state], [msg, chatbot_a, chatbot_b], queue=False)
|
|
|
6 |
|
7 |
|
8 |
def get_tab_arena_side_by_side(download_bot_config, get_bot_profile, model_mapping, client):
|
9 |
+
gr.Markdown("""
|
10 |
+
# ⚔️ Chatbot Arena (side-by-side) ⚔️
|
11 |
+
## Rules
|
12 |
+
* Chat with two models side-by-side and vote for which one is better!
|
13 |
+
* You pick the models you want to chat with.
|
14 |
+
* You can continue chatting and voting or click “Clear” to start a new round.
|
15 |
+
""")
|
16 |
default_bot_id = "_bot_e21de304-6151-4a04-b025-4c553ae8cbca"
|
17 |
bot_config = download_bot_config(default_bot_id)
|
18 |
user_state = gr.State(
|
|
|
23 |
reload_bot_button = gr.Button("Reload bot")
|
24 |
bot_profile = gr.HTML(get_bot_profile(bot_config))
|
25 |
with gr.Accordion("Bot config:", open=False):
|
26 |
+
bot_config_text = gr.Markdown(f"# Memory\n{bot_config['memory']}\n# Prompt\n{bot_config['prompt']}\n")
|
27 |
|
28 |
with gr.Row():
|
29 |
values = list(model_mapping.keys())
|
|
|
87 |
def reload_bot(bot_id):
|
88 |
bot_config = download_bot_config(bot_id)
|
89 |
bot_profile = get_bot_profile(bot_config)
|
90 |
+
return bot_profile, [(None, bot_config["firstMessage"])], [(None, bot_config[
|
91 |
+
"firstMessage"])], bot_config, f"# Memory\n{bot_config['memory']}\n# Prompt\n{bot_config['prompt']}"
|
92 |
|
93 |
def get_generation_args(model_tag):
|
94 |
model = model_mapping[model_tag]
|
|
|
192 |
model_b.change(get_generation_args, [model_b],
|
193 |
[temperature_model_b, repetition_penalty_model_b, max_new_tokens_model_b, top_k_model_b,
|
194 |
top_p_model_b], queue=False)
|
195 |
+
reload_bot_button.click(reload_bot, [bot_id], [bot_profile, chatbot_a, chatbot_b, user_state, bot_config_text],
|
196 |
queue=False)
|
197 |
clear.click(clear_chat, [user_state], [msg, chatbot_a, chatbot_b], queue=False)
|
198 |
model_a.change(clear_chat, [user_state], [msg, chatbot_a, chatbot_b], queue=False)
|
tabs/playground.py
CHANGED
@@ -3,6 +3,12 @@ from conversation import Conversation
|
|
3 |
|
4 |
|
5 |
def get_tab_playground(download_bot_config, get_bot_profile, model_mapping):
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
default_bot_id = "_bot_e21de304-6151-4a04-b025-4c553ae8cbca"
|
7 |
bot_config = download_bot_config(default_bot_id)
|
8 |
user_state = gr.State(
|
@@ -14,7 +20,7 @@ def get_tab_playground(download_bot_config, get_bot_profile, model_mapping):
|
|
14 |
|
15 |
bot_profile = gr.HTML(get_bot_profile(bot_config))
|
16 |
with gr.Accordion("Bot config:", open=False):
|
17 |
-
gr.Markdown(f"# Memory\n{bot_config['memory']}\n# Prompt\n{bot_config['prompt']}
|
18 |
|
19 |
first_message = (None, bot_config["firstMessage"])
|
20 |
chatbot = gr.Chatbot([first_message])
|
@@ -85,7 +91,8 @@ def get_tab_playground(download_bot_config, get_bot_profile, model_mapping):
|
|
85 |
def reload_bot(bot_id, bot_profile, chat_history):
|
86 |
bot_config = download_bot_config(bot_id)
|
87 |
bot_profile = get_bot_profile(bot_config)
|
88 |
-
return bot_profile, [(None, bot_config[
|
|
|
89 |
|
90 |
def get_generation_args(model_tag):
|
91 |
model = model_mapping[model_tag]
|
@@ -111,5 +118,6 @@ def get_tab_playground(download_bot_config, get_bot_profile, model_mapping):
|
|
111 |
regenerate.click(regenerate_response,
|
112 |
[chatbot, user_state, model_tag, temperature, repetition_penalty, max_new_tokens, top_k,
|
113 |
top_p], [chatbot], queue=False)
|
114 |
-
reload_bot_button.click(reload_bot, [bot_id, bot_profile, chatbot],
|
|
|
115 |
queue=False)
|
|
|
3 |
|
4 |
|
5 |
def get_tab_playground(download_bot_config, get_bot_profile, model_mapping):
|
6 |
+
gr.Markdown("""
|
7 |
+
# 🎢.️ Playground 🎢.️
|
8 |
+
## Rules
|
9 |
+
* Chat with any model you would like with any bot from the Chai app.
|
10 |
+
* Click “Clear” to start a new conversation.
|
11 |
+
""")
|
12 |
default_bot_id = "_bot_e21de304-6151-4a04-b025-4c553ae8cbca"
|
13 |
bot_config = download_bot_config(default_bot_id)
|
14 |
user_state = gr.State(
|
|
|
20 |
|
21 |
bot_profile = gr.HTML(get_bot_profile(bot_config))
|
22 |
with gr.Accordion("Bot config:", open=False):
|
23 |
+
bot_config_text = gr.Markdown(f"# Memory\n{bot_config['memory']}\n# Prompt\n{bot_config['prompt']}")
|
24 |
|
25 |
first_message = (None, bot_config["firstMessage"])
|
26 |
chatbot = gr.Chatbot([first_message])
|
|
|
91 |
def reload_bot(bot_id, bot_profile, chat_history):
|
92 |
bot_config = download_bot_config(bot_id)
|
93 |
bot_profile = get_bot_profile(bot_config)
|
94 |
+
return bot_profile, [(None, bot_config[
|
95 |
+
"firstMessage"])], bot_config, f"# Memory\n{bot_config['memory']}\n# Prompt\n{bot_config['prompt']}"
|
96 |
|
97 |
def get_generation_args(model_tag):
|
98 |
model = model_mapping[model_tag]
|
|
|
118 |
regenerate.click(regenerate_response,
|
119 |
[chatbot, user_state, model_tag, temperature, repetition_penalty, max_new_tokens, top_k,
|
120 |
top_p], [chatbot], queue=False)
|
121 |
+
reload_bot_button.click(reload_bot, [bot_id, bot_profile, chatbot],
|
122 |
+
[bot_profile, chatbot, user_state, bot_config_text],
|
123 |
queue=False)
|