hoshingakag commited on
Commit
4bde294
β€’
1 Parent(s): e9f71ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
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
- value="",
75
- icon="./send-message.png",
76
- scale=1
77
- )
78
- # clear = gr.Button("Clear")
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
- bot, chatbot, chatbot
96
- )
97
- # clear.click(lambda: None, None, chatbot, queue=False)
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