Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -166,23 +166,25 @@ def update_ratings(state, winner_index, collection, category):
|
|
166 |
update_elo_rating(collection, elo_ratings, winner_adapter, loser_adapter, category)
|
167 |
return [('Winner: ', winner), ('Loser: ', loser)]
|
168 |
|
169 |
-
def vote_up_model(state, chatbot, chatbot2,
|
|
|
170 |
collection = init_database()
|
171 |
top_category = classify_vote(user_input)
|
172 |
if top_category:
|
173 |
update_message = update_ratings(state, 0, collection, top_category)
|
174 |
chatbot.append(update_message[0])
|
175 |
chatbot2.append(update_message[1])
|
176 |
-
return chatbot, chatbot2, gr.Button.update(interactive=
|
177 |
|
178 |
-
def vote_down_model(state, chatbot, chatbot2,
|
|
|
179 |
collection = init_database()
|
180 |
top_category = classify_vote(user_input)
|
181 |
if top_category:
|
182 |
update_message = update_ratings(state, 1, collection, top_category)
|
183 |
chatbot2.append(update_message[0])
|
184 |
chatbot.append(update_message[1])
|
185 |
-
return chatbot, chatbot2, gr.Button.update(interactive=
|
186 |
|
187 |
async def user_ask(state, chatbot1, chatbot2, textbox, character_name, character_description, user_name):
|
188 |
if character_name and len(character_name) > 20:
|
@@ -347,8 +349,10 @@ with gr.Blocks() as demo:
|
|
347 |
textbox.submit(user_ask, inputs=[state, chatbot1, chatbot2, textbox, character_name, character_description, user_name], outputs=[state, chatbot1, chatbot2, textbox, upvote_btn_a, upvote_btn_b], queue=True)
|
348 |
collection = init_database()
|
349 |
|
350 |
-
upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1, chatbot2,
|
351 |
-
upvote_btn_b.click(vote_down_model, inputs=[state, chatbot1, chatbot2,
|
|
|
|
|
352 |
with gr.Tab("💬 Direct Chat"):
|
353 |
gr.Markdown("## 🗣️ Chat directly with a model!")
|
354 |
|
|
|
166 |
update_elo_rating(collection, elo_ratings, winner_adapter, loser_adapter, category)
|
167 |
return [('Winner: ', winner), ('Loser: ', loser)]
|
168 |
|
169 |
+
def vote_up_model(state, chatbot, chatbot2, character_name, character_description, user_name):
|
170 |
+
user_input = format_prompt(state, 0, character_name, character_description, user_name)
|
171 |
collection = init_database()
|
172 |
top_category = classify_vote(user_input)
|
173 |
if top_category:
|
174 |
update_message = update_ratings(state, 0, collection, top_category)
|
175 |
chatbot.append(update_message[0])
|
176 |
chatbot2.append(update_message[1])
|
177 |
+
return chatbot, chatbot2, gr.Button.update(interactive=True), gr.Button.update(interactive=True), gr.Textbox.update(value='', interactive=True), gr.Button.update(interactive=True)
|
178 |
|
179 |
+
def vote_down_model(state, chatbot, chatbot2, character_name, character_description, user_name):
|
180 |
+
user_input = format_prompt(state, 1, character_name, character_description, user_name)
|
181 |
collection = init_database()
|
182 |
top_category = classify_vote(user_input)
|
183 |
if top_category:
|
184 |
update_message = update_ratings(state, 1, collection, top_category)
|
185 |
chatbot2.append(update_message[0])
|
186 |
chatbot.append(update_message[1])
|
187 |
+
return chatbot, chatbot2, gr.Button.update(interactive=True), gr.Button.update(interactive=True), gr.Textbox.update(value='', interactive=True), gr.Button.update(interactive=True)
|
188 |
|
189 |
async def user_ask(state, chatbot1, chatbot2, textbox, character_name, character_description, user_name):
|
190 |
if character_name and len(character_name) > 20:
|
|
|
349 |
textbox.submit(user_ask, inputs=[state, chatbot1, chatbot2, textbox, character_name, character_description, user_name], outputs=[state, chatbot1, chatbot2, textbox, upvote_btn_a, upvote_btn_b], queue=True)
|
350 |
collection = init_database()
|
351 |
|
352 |
+
upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1, chatbot2, character_name, character_description, user_name], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|
353 |
+
upvote_btn_b.click(vote_down_model, inputs=[state, chatbot1, chatbot2, character_name, character_description, user_name], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|
354 |
+
|
355 |
+
# ...
|
356 |
with gr.Tab("💬 Direct Chat"):
|
357 |
gr.Markdown("## 🗣️ Chat directly with a model!")
|
358 |
|