rwitz commited on
Commit
f1d1dd8
β€’
1 Parent(s): 1823a15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -21
app.py CHANGED
@@ -134,24 +134,44 @@ def user_ask(state, chatbot1, chatbot2, textbox):
134
  # Gradio interface setup
135
  with gr.Blocks() as demo:
136
  state = gr.State({})
137
-
138
- with gr.Row():
139
- with gr.Column():
140
- chatbot1 = gr.Chatbot(label='Model A').style(height=600)
141
- upvote_btn_a = gr.Button(value="πŸ‘ Upvote A",interactive=False)
142
-
143
- with gr.Column():
144
- chatbot2 = gr.Chatbot(label='Model B').style(height=600)
145
- upvote_btn_b = gr.Button(value="πŸ‘ Upvote B",interactive=False)
146
-
147
- textbox = gr.Textbox(placeholder="Enter your prompt (up to 200 characters)", max_chars=200)
148
- with gr.Row():
149
- submit_btn = gr.Button(value="Send")
150
- reset_btn = gr.Button(value="Reset")
151
- reset_btn.click(clear_chat, inputs=[state], outputs=[state, chatbot1, chatbot2, upvote_btn_a, upvote_btn_b])
152
- textbox.submit(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox,upvote_btn_a,upvote_btn_b])
153
- submit_btn.click(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox,upvote_btn_a,upvote_btn_b])
154
- upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1], outputs=[chatbot1,upvote_btn_a,upvote_btn_b])
155
- upvote_btn_b.click(vote_down_model, inputs=[state, chatbot2], outputs=[chatbot2,upvote_btn_a,upvote_btn_b])
156
-
157
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  # Gradio interface setup
135
  with gr.Blocks() as demo:
136
  state = gr.State({})
137
+ with gr.Tab("Chatbot Arena"):
138
+ with gr.Row():
139
+ with gr.Column():
140
+ chatbot1 = gr.Chatbot(label='Model A').style(height=600)
141
+ upvote_btn_a = gr.Button(value="πŸ‘ Upvote A",interactive=False)
142
+
143
+ with gr.Column():
144
+ chatbot2 = gr.Chatbot(label='Model B').style(height=600)
145
+ upvote_btn_b = gr.Button(value="πŸ‘ Upvote B",interactive=False)
146
+
147
+ textbox = gr.Textbox(placeholder="Enter your prompt (up to 200 characters)", max_chars=200)
148
+ with gr.Row():
149
+ submit_btn = gr.Button(value="Send")
150
+ reset_btn = gr.Button(value="Reset")
151
+ reset_btn.click(clear_chat, inputs=[state], outputs=[state, chatbot1, chatbot2, upvote_btn_a, upvote_btn_b])
152
+ textbox.submit(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox,upvote_btn_a,upvote_btn_b])
153
+ submit_btn.click(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox,upvote_btn_a,upvote_btn_b])
154
+ upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1], outputs=[chatbot1,upvote_btn_a,upvote_btn_b])
155
+ upvote_btn_b.click(vote_down_model, inputs=[state, chatbot2], outputs=[chatbot2,upvote_btn_a,upvote_btn_b])
156
+ with gr.Tab("Leaderboard"):
157
+ leaderboard = gr.Dataframe()
158
+ refresh_btn = gr.Button("Refresh Leaderboard")
159
+
160
+ # Function to refresh leaderboard
161
+ def refresh_leaderboard():
162
+ return generate_leaderboard()
163
+
164
+ # Event handler for the refresh button
165
+ refresh_btn.click(refresh_leaderboard, inputs=[], outputs=[leaderboard])
166
+
167
+ # Launch the Gradio interface
168
+
169
+ demo.launch()
170
+ import pandas as pd
171
+
172
+ # Function to generate leaderboard data
173
+ def generate_leaderboard():
174
+ elo_ratings = read_elo_ratings() # Assuming this function returns a dict of {bot_name: elo_score}
175
+ leaderboard_data = pd.DataFrame(list(elo_ratings.items()), columns=['Chatbot', 'ELO Score'])
176
+ leaderboard_data = leaderboard_data.sort_values('ELO Score', ascending=False)
177
+ return leaderboard_data