Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import os
|
|
4 |
import json
|
5 |
import random
|
6 |
from elo import update_elo_ratings # Custom function for ELO ratings
|
|
|
7 |
|
8 |
# Load the chatbot URLs and their respective model names from a JSON file
|
9 |
with open('chatbot_urls.json', 'r') as file:
|
@@ -78,7 +79,8 @@ def vote_down_model(state, chatbot):
|
|
78 |
update_message = update_ratings(state, 1)
|
79 |
chatbot.append(update_message)
|
80 |
return chatbot
|
81 |
-
def user_ask(state, chatbot1, chatbot2, textbox):
|
|
|
82 |
state.update({"elo_ratings":read_elo_ratings()})
|
83 |
user_input = textbox
|
84 |
bot1_response, bot2_response = chat_with_bots(user_input, state)
|
@@ -88,13 +90,10 @@ def user_ask(state, chatbot1, chatbot2, textbox):
|
|
88 |
chatbot2.append((user_input, bot2_response))
|
89 |
|
90 |
# Enable voting buttons
|
91 |
-
global upvote_btn_a,upvote_btn_b
|
92 |
-
upvote_btn_a.interactive = True
|
93 |
-
upvote_btn_b.interactive = True
|
94 |
|
95 |
updated_elo_ratings = get_user_elo_ratings(state)
|
96 |
state.update({'elo_ratings': updated_elo_ratings})
|
97 |
-
return state, chatbot1, chatbot2,textbox
|
98 |
|
99 |
# ... [Rest of your existing functions] ...
|
100 |
|
@@ -117,8 +116,8 @@ with gr.Blocks() as demo:
|
|
117 |
submit_btn = gr.Button(value="Send")
|
118 |
|
119 |
# Interaction logic
|
120 |
-
textbox.submit(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2,textbox])
|
121 |
-
submit_btn.click(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2,textbox])
|
122 |
upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1], outputs=[chatbot1])
|
123 |
upvote_btn_b.click(vote_up_model, inputs=[state, chatbot2], outputs=[chatbot2])
|
124 |
|
|
|
4 |
import json
|
5 |
import random
|
6 |
from elo import update_elo_ratings # Custom function for ELO ratings
|
7 |
+
enable_btn = gr.Button.update(interactive=True)
|
8 |
|
9 |
# Load the chatbot URLs and their respective model names from a JSON file
|
10 |
with open('chatbot_urls.json', 'r') as file:
|
|
|
79 |
update_message = update_ratings(state, 1)
|
80 |
chatbot.append(update_message)
|
81 |
return chatbot
|
82 |
+
def user_ask(state, chatbot1, chatbot2, textbox,upvote_btn_a,upvote_btn_b):
|
83 |
+
global enable_btn
|
84 |
state.update({"elo_ratings":read_elo_ratings()})
|
85 |
user_input = textbox
|
86 |
bot1_response, bot2_response = chat_with_bots(user_input, state)
|
|
|
90 |
chatbot2.append((user_input, bot2_response))
|
91 |
|
92 |
# Enable voting buttons
|
|
|
|
|
|
|
93 |
|
94 |
updated_elo_ratings = get_user_elo_ratings(state)
|
95 |
state.update({'elo_ratings': updated_elo_ratings})
|
96 |
+
return state, chatbot1, chatbot2,textbox, enable_btn,enable_btn
|
97 |
|
98 |
# ... [Rest of your existing functions] ...
|
99 |
|
|
|
116 |
submit_btn = gr.Button(value="Send")
|
117 |
|
118 |
# Interaction logic
|
119 |
+
textbox.submit(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2,textbox,upvote_btn_a,upvote_btn_b])
|
120 |
+
submit_btn.click(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2,textbox,upvote_btn_a,upvote_btn_b])
|
121 |
upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1], outputs=[chatbot1])
|
122 |
upvote_btn_b.click(vote_up_model, inputs=[state, chatbot2], outputs=[chatbot2])
|
123 |
|