Spaces:
Runtime error
Runtime error
Commit
·
1b555fc
1
Parent(s):
4ac79c2
Update app.py
Browse files
app.py
CHANGED
@@ -22,37 +22,25 @@ examples = [
|
|
22 |
]
|
23 |
]
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
37 |
|
38 |
with gr.Blocks() as demo:
|
39 |
chatbot = gr.Chatbot()
|
40 |
msg = gr.Textbox()
|
41 |
clear = gr.ClearButton([msg, chatbot])
|
42 |
|
43 |
-
def respond(msg):
|
44 |
-
messages.append(msg)
|
45 |
-
bot_message = palm.chat(
|
46 |
-
**defaults,
|
47 |
-
context=context,
|
48 |
-
examples=examples,
|
49 |
-
messages=messages
|
50 |
-
)
|
51 |
-
time.sleep(2)
|
52 |
-
return bot_message['message'], messages
|
53 |
-
|
54 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
55 |
|
56 |
demo.launch()
|
57 |
-
|
58 |
-
iface.launch()
|
|
|
22 |
]
|
23 |
]
|
24 |
|
25 |
+
user_input = []
|
26 |
+
|
27 |
+
def respond(messages):
|
28 |
+
global user_input
|
29 |
+
user_input.append(messages[0])
|
30 |
+
bot_message = palm.chat(
|
31 |
+
**defaults,
|
32 |
+
context=context,
|
33 |
+
examples=examples,
|
34 |
+
messages=user_input
|
35 |
+
)
|
36 |
+
time.sleep(2)
|
37 |
+
return bot_message['message'], user_input
|
38 |
|
39 |
with gr.Blocks() as demo:
|
40 |
chatbot = gr.Chatbot()
|
41 |
msg = gr.Textbox()
|
42 |
clear = gr.ClearButton([msg, chatbot])
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
45 |
|
46 |
demo.launch()
|
|
|
|