Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -168,13 +168,15 @@ def vote_down_model(state, chatbot, chatbot2):
|
|
168 |
return chatbot, chatbot2, gr.Button.update(interactive=False), gr.Button.update(interactive=False), gr.Textbox.update(interactive=False), gr.Button.update(interactive=False)
|
169 |
|
170 |
async def user_ask(state, chatbot1, chatbot2, textbox, character_name, character_description, user_name):
|
|
|
171 |
global enable_btn
|
172 |
user_input = textbox
|
173 |
-
if len(user_input) >
|
174 |
-
user_input = user_input[:
|
175 |
|
176 |
collection = init_database() # Initialize the collection object
|
177 |
-
|
|
|
178 |
# Updating state with the current ELO ratings
|
179 |
state["elo_ratings"] = get_user_elo_ratings(collection)
|
180 |
if "history" not in state:
|
@@ -273,11 +275,11 @@ with gr.Blocks() as demo:
|
|
273 |
with gr.Row():
|
274 |
reset_btn = gr.Button(value="🗑️ Reset")
|
275 |
with gr.Row():
|
276 |
-
|
277 |
-
|
278 |
-
with gr.Row():
|
279 |
-
user_name = gr.Textbox(label="Your Name",value="You", placeholder="Enter your name", max_lines=1)
|
280 |
|
|
|
|
|
281 |
# ...
|
282 |
|
283 |
reset_btn.click(clear_chat, inputs=[state], outputs=[state, chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|
|
|
168 |
return chatbot, chatbot2, gr.Button.update(interactive=False), gr.Button.update(interactive=False), gr.Textbox.update(interactive=False), gr.Button.update(interactive=False)
|
169 |
|
170 |
async def user_ask(state, chatbot1, chatbot2, textbox, character_name, character_description, user_name):
|
171 |
+
|
172 |
global enable_btn
|
173 |
user_input = textbox
|
174 |
+
if len(user_input) > 400:
|
175 |
+
user_input = user_input[:400] # Limit user input to 200 characters
|
176 |
|
177 |
collection = init_database() # Initialize the collection object
|
178 |
+
# Keep only the last 10 messages in history
|
179 |
+
state["history"] = state["history"][-10:]
|
180 |
# Updating state with the current ELO ratings
|
181 |
state["elo_ratings"] = get_user_elo_ratings(collection)
|
182 |
if "history" not in state:
|
|
|
275 |
with gr.Row():
|
276 |
reset_btn = gr.Button(value="🗑️ Reset")
|
277 |
with gr.Row():
|
278 |
+
character_name = gr.Textbox(label="Character Name", value="Ryan", placeholder="Enter character name (max 20 chars)", max_lines=1)
|
279 |
+
character_description = gr.Textbox(label="Character Description", value="Ryan is a college student who is always willing to help. He knows a lot about math and coding.", placeholder="Enter character description (max 200 chars)", max_lines=5)
|
|
|
|
|
280 |
|
281 |
+
with gr.Row():
|
282 |
+
user_name = gr.Textbox(label="Your Name", value="You", placeholder="Enter your name", max_lines=1)
|
283 |
# ...
|
284 |
|
285 |
reset_btn.click(clear_chat, inputs=[state], outputs=[state, chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|