Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -168,7 +168,12 @@ 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
global enable_btn
|
| 173 |
user_input = textbox
|
| 174 |
if len(user_input) > 400:
|
|
@@ -275,11 +280,11 @@ with gr.Blocks() as demo:
|
|
| 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)"
|
| 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)"
|
| 280 |
|
| 281 |
with gr.Row():
|
| 282 |
-
user_name = gr.Textbox(label="Your Name", value="You", placeholder="Enter your name
|
| 283 |
# ...
|
| 284 |
|
| 285 |
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 |
+
if character_name and len(character_name) > 20:
|
| 172 |
+
character_name = character_name[:20] # Limit character name to 20 characters
|
| 173 |
+
if character_description and len(character_description) > 200:
|
| 174 |
+
character_description = character_description[:200] # Limit character description to 200 characters
|
| 175 |
+
if user_name and len(user_name) > 20:
|
| 176 |
+
user_name = user_name[:20] # Limit user name to 20 characters
|
| 177 |
global enable_btn
|
| 178 |
user_input = textbox
|
| 179 |
if len(user_input) > 400:
|
|
|
|
| 280 |
with gr.Row():
|
| 281 |
reset_btn = gr.Button(value="🗑️ Reset")
|
| 282 |
with gr.Row():
|
| 283 |
+
character_name = gr.Textbox(label="Character Name", value="Ryan", placeholder="Enter character name (max 20 chars)")
|
| 284 |
+
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)")
|
| 285 |
|
| 286 |
with gr.Row():
|
| 287 |
+
user_name = gr.Textbox(label="Your Name", value="You", placeholder="Enter your name (max 20 chars)")
|
| 288 |
# ...
|
| 289 |
|
| 290 |
reset_btn.click(clear_chat, inputs=[state], outputs=[state, chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
|