rwitz commited on
Commit
5c74d7e
β€’
1 Parent(s): 30ed04f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -27
app.py CHANGED
@@ -240,55 +240,77 @@ refresh_leaderboard()
240
  # Gradio interface setup
241
  with gr.Blocks() as demo:
242
  state = gr.State({})
243
- with gr.Tab("Chatbot Arena"):
 
 
 
244
  with gr.Row():
245
  with gr.Column():
246
- chatbot1 = gr.Chatbot(label='Model A').style(height=600)
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=600)
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
- submit_btn = gr.Button(value="Send")
259
- reset_btn = gr.Button(value="Reset")
260
- regenerate_btn = gr.Button(value="Regenerate")
 
 
 
 
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
- with gr.Tab("Direct Chat"):
272
- model_dropdown = gr.Dropdown(choices=chatbots, label="Select a model")
273
- direct_chatbot = gr.Chatbot(label="Direct Chat").style(height=600)
274
- direct_textbox = gr.Textbox(placeholder="Enter your message")
275
- direct_submit_btn = gr.Button(value="Send")
276
- direct_reset_btn = gr.Button(value="Reset Chat") # Add this line
277
- direct_regenerate_btn = gr.Button(value="Regenerate")
 
 
 
 
 
 
 
 
 
 
 
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
- with gr.Tab("Leaderboard"):
 
 
 
285
  try:
286
  leaderboard = gr.Dataframe(refresh_leaderboard())
287
  except:
288
  leaderboard = gr.Dataframe()
289
- refresh_btn = gr.Button("Refresh Leaderboard")
290
- reset_db_btn = gr.Button("Reset Database")
 
 
 
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