Update app.py
Browse files
app.py
CHANGED
@@ -74,24 +74,18 @@ def bot(history):
|
|
74 |
history[-1][1] = ""
|
75 |
for character in bot_message:
|
76 |
history[-1][1] += character
|
77 |
-
time.sleep(0.01) #
|
78 |
yield history
|
79 |
|
80 |
-
# Define Gradio Blocks interface
|
81 |
with gr.Blocks() as demo:
|
82 |
chatbot = gr.Chatbot()
|
83 |
-
msg = gr.Textbox(
|
84 |
-
submit_btn = gr.Button("Submit")
|
85 |
clear = gr.Button("Clear")
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
# Bind the submit button to handle_message function
|
92 |
-
submit_btn.click(handle_message, [msg, chatbot], chatbot, queue=False)
|
93 |
-
|
94 |
-
# Bind the clear button to clear the chat history
|
95 |
clear.click(lambda: None, None, chatbot, queue=False)
|
96 |
|
97 |
if __name__ == "__main__":
|
|
|
74 |
history[-1][1] = ""
|
75 |
for character in bot_message:
|
76 |
history[-1][1] += character
|
77 |
+
time.sleep(0.01) # Reduced sleep time to make response appear faster
|
78 |
yield history
|
79 |
|
80 |
+
# Define Gradio Blocks interface
|
81 |
with gr.Blocks() as demo:
|
82 |
chatbot = gr.Chatbot()
|
83 |
+
msg = gr.Textbox()
|
|
|
84 |
clear = gr.Button("Clear")
|
85 |
|
86 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
87 |
+
bot, chatbot, chatbot
|
88 |
+
)
|
|
|
|
|
|
|
|
|
|
|
89 |
clear.click(lambda: None, None, chatbot, queue=False)
|
90 |
|
91 |
if __name__ == "__main__":
|