LTW-1181203031 commited on
Commit
768dac1
1 Parent(s): e73ea32

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -98,6 +98,7 @@ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
98
 
99
  chat_history = []
100
  answer_counter = 0
 
101
  def chatbot_interface(message):
102
  global answer_counter
103
  global result
@@ -146,6 +147,11 @@ def chatbot_interface(message):
146
 
147
  return response, chat_history_text
148
 
 
 
 
 
 
149
  # Create a Gradio interface
150
  iface = gr.Interface(
151
  fn=chatbot_interface,
@@ -156,4 +162,4 @@ iface = gr.Interface(
156
  )
157
 
158
  #Demo for the chatbot
159
- iface.launch(inline = False)
 
98
 
99
  chat_history = []
100
  answer_counter = 0
101
+
102
  def chatbot_interface(message):
103
  global answer_counter
104
  global result
 
147
 
148
  return response, chat_history_text
149
 
150
+ def clear_chat_history():
151
+ # Clear the chat history
152
+ chat_history.clear()
153
+
154
+ clear_button = gr.outputs.Button(label="Clear Chat", type="button", onclick=clear_chat_history)
155
  # Create a Gradio interface
156
  iface = gr.Interface(
157
  fn=chatbot_interface,
 
162
  )
163
 
164
  #Demo for the chatbot
165
+ iface.launch(inline = False, additional_outputs=[clear_button])