Spaces:
Runtime error
Runtime error
Commit
·
080128f
1
Parent(s):
7f83c82
Update app.py
Browse files
app.py
CHANGED
@@ -31,18 +31,25 @@ with gr.Blocks() as demo:
|
|
31 |
msg = gr.Textbox()
|
32 |
clear = gr.ClearButton([msg, chatbot])
|
33 |
|
34 |
-
def
|
|
|
|
|
35 |
# chat_history.append(message) # Initialize chat history
|
36 |
bot_message = palm.chat(
|
37 |
context=context,
|
38 |
examples=examples,
|
39 |
messages=message
|
40 |
)
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
46 |
msg.submit(respond,[msg,chatbot],[msg, chatbot])
|
47 |
|
|
|
48 |
demo.launch()
|
|
|
31 |
msg = gr.Textbox()
|
32 |
clear = gr.ClearButton([msg, chatbot])
|
33 |
|
34 |
+
def user(user_message, history):
|
35 |
+
return gr.update(value="", interactive=False), history + [[user_message, None]]
|
36 |
+
def bot(history):
|
37 |
# chat_history.append(message) # Initialize chat history
|
38 |
bot_message = palm.chat(
|
39 |
context=context,
|
40 |
examples=examples,
|
41 |
messages=message
|
42 |
)
|
43 |
+
history[-1][1] = ""
|
44 |
+
for character in bot_message:
|
45 |
+
history[-1][1] += character
|
46 |
+
time.sleep(0.05)
|
47 |
+
yield history
|
48 |
+
response = msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
49 |
+
bot, chatbot, chatbot
|
50 |
+
)
|
51 |
+
response.then(lambda: gr.update(interactive=True), None, [msg], queue=False)
|
52 |
msg.submit(respond,[msg,chatbot],[msg, chatbot])
|
53 |
|
54 |
+
demo.queue()
|
55 |
demo.launch()
|