Spaces:
Running
Running
hoshingakag
commited on
Commit
β’
4bde294
1
Parent(s):
e9f71ef
Update app.py
Browse files
app.py
CHANGED
@@ -19,6 +19,10 @@ chat_defaults = {
|
|
19 |
|
20 |
chat_history = []
|
21 |
|
|
|
|
|
|
|
|
|
22 |
def generate_chat(prompt: str, chat_messages=chat_history):
|
23 |
print(chat_messages)
|
24 |
context = """
|
@@ -70,12 +74,12 @@ with gr.Blocks() as app:
|
|
70 |
placeholder="Hi Gerard, can you introduce yourself?",
|
71 |
container=False,
|
72 |
scale=6)
|
73 |
-
send = gr.Button(
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
)
|
78 |
-
|
79 |
|
80 |
def user(user_message, history):
|
81 |
return "", history + [[user_message, None]]
|
@@ -91,10 +95,10 @@ with gr.Blocks() as app:
|
|
91 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
92 |
bot, chatbot, chatbot
|
93 |
)
|
94 |
-
send.click(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
95 |
-
|
96 |
-
)
|
97 |
-
|
98 |
|
99 |
gr.HTML("<h3><center>Hosted on π€ Spaces. Powered by Gradio & Google π΄ PaLM.</center></h3>")
|
100 |
|
|
|
19 |
|
20 |
chat_history = []
|
21 |
|
22 |
+
def clear_chat():
|
23 |
+
chat_history = []
|
24 |
+
return None
|
25 |
+
|
26 |
def generate_chat(prompt: str, chat_messages=chat_history):
|
27 |
print(chat_messages)
|
28 |
context = """
|
|
|
74 |
placeholder="Hi Gerard, can you introduce yourself?",
|
75 |
container=False,
|
76 |
scale=6)
|
77 |
+
# send = gr.Button(
|
78 |
+
# value="",
|
79 |
+
# icon="./send-message.png",
|
80 |
+
# scale=1
|
81 |
+
# )
|
82 |
+
clear = gr.Button("Clear")
|
83 |
|
84 |
def user(user_message, history):
|
85 |
return "", history + [[user_message, None]]
|
|
|
95 |
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
96 |
bot, chatbot, chatbot
|
97 |
)
|
98 |
+
# send.click(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
99 |
+
# bot, chatbot, chatbot
|
100 |
+
# )
|
101 |
+
clear.click(clear_chat, None, chatbot, queue=False)
|
102 |
|
103 |
gr.HTML("<h3><center>Hosted on π€ Spaces. Powered by Gradio & Google π΄ PaLM.</center></h3>")
|
104 |
|