Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -240,55 +240,77 @@ refresh_leaderboard()
|
|
240 |
# Gradio interface setup
|
241 |
with gr.Blocks() as demo:
|
242 |
state = gr.State({})
|
243 |
-
|
|
|
|
|
|
|
244 |
with gr.Row():
|
245 |
with gr.Column():
|
246 |
-
chatbot1 = gr.Chatbot(label='Model A').style(height=
|
247 |
-
upvote_btn_a = gr.Button(value="π Upvote A", interactive=False)
|
248 |
-
|
249 |
with gr.Column():
|
250 |
-
chatbot2 = gr.Chatbot(label='Model B').style(height=
|
251 |
-
upvote_btn_b = gr.Button(value="π Upvote B", interactive=False)
|
252 |
-
|
253 |
-
textbox = gr.Textbox(placeholder="Enter your prompt (up to 200 characters)")
|
254 |
-
with gr.Row():
|
255 |
-
submit_btn = gr.Button(value="Send")
|
256 |
-
reset_btn = gr.Button(value="Reset")
|
257 |
with gr.Row():
|
258 |
-
|
259 |
-
|
260 |
-
|
|
|
|
|
|
|
|
|
261 |
# ...
|
|
|
262 |
regenerate_btn.click(regenerate_responses, inputs=[state, chatbot1, chatbot2], outputs=[chatbot1, chatbot2])
|
263 |
-
|
264 |
reset_btn.click(clear_chat, inputs=[state], outputs=[state, chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|
265 |
textbox.submit(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox, upvote_btn_a, upvote_btn_b], queue=True)
|
266 |
submit_btn.click(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox, upvote_btn_a, upvote_btn_b], queue=True)
|
267 |
-
|
268 |
collection = init_database()
|
|
|
269 |
upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1, chatbot2], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|
270 |
upvote_btn_b.click(vote_down_model, inputs=[state, chatbot1, chatbot2], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
# ...
|
|
|
279 |
direct_regenerate_btn.click(direct_regenerate, inputs=[model_dropdown, direct_textbox, direct_chatbot], outputs=[direct_textbox, direct_chatbot])
|
280 |
-
|
281 |
direct_textbox.submit(direct_chat, inputs=[model_dropdown, direct_textbox, direct_chatbot], outputs=[direct_textbox, direct_chatbot])
|
282 |
direct_submit_btn.click(direct_chat, inputs=[model_dropdown, direct_textbox, direct_chatbot], outputs=[direct_textbox, direct_chatbot])
|
283 |
direct_reset_btn.click(reset_direct_chat, None, [direct_textbox, direct_chatbot, model_dropdown])
|
284 |
-
|
|
|
|
|
|
|
285 |
try:
|
286 |
leaderboard = gr.Dataframe(refresh_leaderboard())
|
287 |
except:
|
288 |
leaderboard = gr.Dataframe()
|
289 |
-
|
290 |
-
|
|
|
|
|
|
|
291 |
reset_message = gr.Textbox()
|
|
|
292 |
reset_db_btn.click(reset_database, outputs=[reset_message])
|
293 |
refresh_btn.click(refresh_leaderboard, outputs=[leaderboard])
|
294 |
|
|
|
240 |
# Gradio interface setup
|
241 |
with gr.Blocks() as demo:
|
242 |
state = gr.State({})
|
243 |
+
|
244 |
+
with gr.Tab("π€ Chatbot Arena"):
|
245 |
+
gr.Markdown("## π₯ Let's see which chatbot wins!")
|
246 |
+
|
247 |
with gr.Row():
|
248 |
with gr.Column():
|
249 |
+
chatbot1 = gr.Chatbot(label='π€ Model A').style(height=500)
|
250 |
+
upvote_btn_a = gr.Button(value="π Upvote A", interactive=False).style(full_width=True)
|
251 |
+
|
252 |
with gr.Column():
|
253 |
+
chatbot2 = gr.Chatbot(label='π€ Model B').style(height=500)
|
254 |
+
upvote_btn_b = gr.Button(value="π Upvote B", interactive=False).style(full_width=True)
|
255 |
+
|
|
|
|
|
|
|
|
|
256 |
with gr.Row():
|
257 |
+
with gr.Column(scale=5):
|
258 |
+
textbox = gr.Textbox(placeholder="π€ Enter your prompt (up to 200 characters)", lines=2, max_lines=5)
|
259 |
+
with gr.Column(min_width=150):
|
260 |
+
submit_btn = gr.Button(value="π Send")
|
261 |
+
regenerate_btn = gr.Button(value="π Regenerate")
|
262 |
+
reset_btn = gr.Button(value="ποΈ Reset")
|
263 |
+
|
264 |
# ...
|
265 |
+
|
266 |
regenerate_btn.click(regenerate_responses, inputs=[state, chatbot1, chatbot2], outputs=[chatbot1, chatbot2])
|
|
|
267 |
reset_btn.click(clear_chat, inputs=[state], outputs=[state, chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|
268 |
textbox.submit(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox, upvote_btn_a, upvote_btn_b], queue=True)
|
269 |
submit_btn.click(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox, upvote_btn_a, upvote_btn_b], queue=True)
|
270 |
+
|
271 |
collection = init_database()
|
272 |
+
|
273 |
upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1, chatbot2], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|
274 |
upvote_btn_b.click(vote_down_model, inputs=[state, chatbot1, chatbot2], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|
275 |
+
|
276 |
+
with gr.Tab("π¬ Direct Chat"):
|
277 |
+
gr.Markdown("## π£οΈ Chat directly with a model!")
|
278 |
+
|
279 |
+
with gr.Row():
|
280 |
+
with gr.Column(scale=4):
|
281 |
+
direct_chatbot = gr.Chatbot(label="π¬ Direct Chat").style(height=500)
|
282 |
+
with gr.Column(scale=1):
|
283 |
+
model_dropdown = gr.Dropdown(choices=chatbots, label="π€ Select a model")
|
284 |
+
|
285 |
+
with gr.Row():
|
286 |
+
with gr.Column(scale=5):
|
287 |
+
direct_textbox = gr.Textbox(placeholder="π Enter your message", lines=2, max_lines=5)
|
288 |
+
with gr.Column(min_width=150):
|
289 |
+
direct_submit_btn = gr.Button(value="π© Send")
|
290 |
+
direct_regenerate_btn = gr.Button(value="π Regenerate")
|
291 |
+
direct_reset_btn = gr.Button(value="ποΈ Reset Chat")
|
292 |
+
|
293 |
# ...
|
294 |
+
|
295 |
direct_regenerate_btn.click(direct_regenerate, inputs=[model_dropdown, direct_textbox, direct_chatbot], outputs=[direct_textbox, direct_chatbot])
|
|
|
296 |
direct_textbox.submit(direct_chat, inputs=[model_dropdown, direct_textbox, direct_chatbot], outputs=[direct_textbox, direct_chatbot])
|
297 |
direct_submit_btn.click(direct_chat, inputs=[model_dropdown, direct_textbox, direct_chatbot], outputs=[direct_textbox, direct_chatbot])
|
298 |
direct_reset_btn.click(reset_direct_chat, None, [direct_textbox, direct_chatbot, model_dropdown])
|
299 |
+
|
300 |
+
with gr.Tab("π Leaderboard"):
|
301 |
+
gr.Markdown("## π Check out the top-performing models!")
|
302 |
+
|
303 |
try:
|
304 |
leaderboard = gr.Dataframe(refresh_leaderboard())
|
305 |
except:
|
306 |
leaderboard = gr.Dataframe()
|
307 |
+
|
308 |
+
with gr.Row():
|
309 |
+
refresh_btn = gr.Button("π Refresh Leaderboard")
|
310 |
+
reset_db_btn = gr.Button("ποΈ Reset Database")
|
311 |
+
|
312 |
reset_message = gr.Textbox()
|
313 |
+
|
314 |
reset_db_btn.click(reset_database, outputs=[reset_message])
|
315 |
refresh_btn.click(refresh_leaderboard, outputs=[leaderboard])
|
316 |
|