Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -81,20 +81,21 @@ def vote_down_model(state, chatbot):
|
|
81 |
return chatbot
|
82 |
def user_ask(state, chatbot1, chatbot2, textbox, upvote_btn_a, upvote_btn_b):
|
83 |
user_input = textbox
|
84 |
-
bot1_response, bot2_response = chat_with_bots(user_input,state)
|
85 |
-
|
86 |
chatbot1.append("User: " + user_input)
|
87 |
chatbot1.append("Bot 1: " + bot1_response)
|
88 |
|
89 |
chatbot2.append("User: " + user_input)
|
90 |
-
chatbot2.append("Bot 2: " + bot2_response)
|
|
|
91 |
# Enable voting buttons
|
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
|
98 |
|
99 |
# ... [Rest of your existing functions] ...
|
100 |
|
@@ -104,25 +105,32 @@ with gr.Blocks() as demo:
|
|
104 |
# First column for Model A
|
105 |
with gr.Column():
|
106 |
chatbot1 = gr.Chatbot(label='Model A')
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
# Second column for Model B
|
111 |
with gr.Column():
|
112 |
chatbot2 = gr.Chatbot(label='Model B')
|
113 |
-
|
114 |
-
|
115 |
# Textbox and submit button at the bottom
|
116 |
-
|
117 |
-
|
118 |
-
submit_btn = gr.Button(value="Send")
|
119 |
|
120 |
# Interaction logic
|
121 |
-
textbox.submit(user_ask, [state, chatbot1, chatbot2, textbox,upvote_btn_a, upvote_btn_b], [state, chatbot1, chatbot2
|
122 |
-
submit_btn.click(user_ask, [state, chatbot1, chatbot2, textbox,upvote_btn_a, upvote_btn_b], [state, chatbot1, chatbot2
|
123 |
-
upvote_btn_a.click(vote_up_model, [state, chatbot1], [chatbot1])
|
124 |
-
upvote_btn_b.click(vote_up_model, [state, chatbot2], [chatbot2])
|
125 |
|
126 |
# Start the interface
|
127 |
-
demo.
|
128 |
-
demo.launch(server_name='0.0.0.0', server_port=7860)
|
|
|
81 |
return chatbot
|
82 |
def user_ask(state, chatbot1, chatbot2, textbox, upvote_btn_a, upvote_btn_b):
|
83 |
user_input = textbox
|
84 |
+
bot1_response, bot2_response = chat_with_bots(user_input, state)
|
85 |
+
|
86 |
chatbot1.append("User: " + user_input)
|
87 |
chatbot1.append("Bot 1: " + bot1_response)
|
88 |
|
89 |
chatbot2.append("User: " + user_input)
|
90 |
+
chatbot2.append("Bot 2: " + bot2_response)
|
91 |
+
|
92 |
# Enable voting buttons
|
93 |
upvote_btn_a.interactive = True
|
94 |
upvote_btn_b.interactive = True
|
95 |
+
|
96 |
updated_elo_ratings = get_user_elo_ratings(state)
|
97 |
state.update({'elo_ratings': updated_elo_ratings})
|
98 |
+
return state, chatbot1, chatbot2
|
99 |
|
100 |
# ... [Rest of your existing functions] ...
|
101 |
|
|
|
105 |
# First column for Model A
|
106 |
with gr.Column():
|
107 |
chatbot1 = gr.Chatbot(label='Model A')
|
108 |
+
upvote_btn_a = gr.Button(value="π
|
109 |
+
|
110 |
+
# ... [Rest of your existing functions] ...
|
111 |
+
|
112 |
+
with gr.Blocks() as demo:
|
113 |
+
state = gr.State({})
|
114 |
+
with gr.Row():
|
115 |
+
# First column for Model A
|
116 |
+
with gr.Column():
|
117 |
+
chatbot1 = gr.Chatbot(label='Model A')
|
118 |
+
upvote_btn_a = gr.Button(value="π Upvote A", interactive=False)
|
119 |
|
120 |
# Second column for Model B
|
121 |
with gr.Column():
|
122 |
chatbot2 = gr.Chatbot(label='Model B')
|
123 |
+
upvote_btn_b = gr.Button(value="π Upvote B", interactive=False)
|
124 |
+
|
125 |
# Textbox and submit button at the bottom
|
126 |
+
textbox = gr.Textbox(placeholder="Enter your prompt and press ENTER")
|
127 |
+
submit_btn = gr.Button(value="Send")
|
|
|
128 |
|
129 |
# Interaction logic
|
130 |
+
textbox.submit(user_ask, inputs=[state, chatbot1, chatbot2, textbox, upvote_btn_a, upvote_btn_b], outputs=[state, chatbot1, chatbot2])
|
131 |
+
submit_btn.click(user_ask, inputs=[state, chatbot1, chatbot2, textbox, upvote_btn_a, upvote_btn_b], outputs=[state, chatbot1, chatbot2])
|
132 |
+
upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1], outputs=[chatbot1])
|
133 |
+
upvote_btn_b.click(vote_up_model, inputs=[state, chatbot2], outputs=[chatbot2])
|
134 |
|
135 |
# Start the interface
|
136 |
+
demo.launch()
|
|