Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -204,6 +204,10 @@ def generate_leaderboard(collection):
|
|
204 |
def refresh_leaderboard():
|
205 |
collection = init_database()
|
206 |
return generate_leaderboard(collection)
|
|
|
|
|
|
|
|
|
207 |
|
208 |
# ...
|
209 |
refresh_leaderboard()
|
@@ -232,6 +236,13 @@ with gr.Blocks() as demo:
|
|
232 |
collection = init_database()
|
233 |
upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1, chatbot2], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|
234 |
upvote_btn_b.click(vote_down_model, inputs=[state, chatbot1, chatbot2], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
with gr.Tab("Leaderboard"):
|
236 |
try:
|
237 |
leaderboard = gr.Dataframe(refresh_leaderboard())
|
|
|
204 |
def refresh_leaderboard():
|
205 |
collection = init_database()
|
206 |
return generate_leaderboard(collection)
|
207 |
+
async def direct_chat(model, user_input, chatbot):
|
208 |
+
response = await get_bot_response(model, user_input, None, 0)
|
209 |
+
chatbot.append((user_input, response))
|
210 |
+
return "", chatbot
|
211 |
|
212 |
# ...
|
213 |
refresh_leaderboard()
|
|
|
236 |
collection = init_database()
|
237 |
upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1, chatbot2], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|
238 |
upvote_btn_b.click(vote_down_model, inputs=[state, chatbot1, chatbot2], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|
239 |
+
with gr.Tab("Direct Chat"):
|
240 |
+
model_dropdown = gr.Dropdown(choices=chatbots, label="Select a model")
|
241 |
+
direct_chatbot = gr.Chatbot(label="Direct Chat").style(height=600)
|
242 |
+
direct_textbox = gr.Textbox(placeholder="Enter your message")
|
243 |
+
direct_submit_btn = gr.Button(value="Send")
|
244 |
+
direct_textbox.submit(direct_chat, inputs=[model_dropdown, direct_textbox, direct_chatbot], outputs=[direct_textbox, direct_chatbot])
|
245 |
+
direct_submit_btn.click(direct_chat, inputs=[model_dropdown, direct_textbox, direct_chatbot], outputs=[direct_textbox, direct_chatbot])
|
246 |
with gr.Tab("Leaderboard"):
|
247 |
try:
|
248 |
leaderboard = gr.Dataframe(refresh_leaderboard())
|