Tafazzul-Nadeeem commited on
Commit
860758d
·
1 Parent(s): efa0b1f

Bot initial message

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -66,13 +66,17 @@ You can also answer questions based on the information provided by the user.
66
  return [
67
  {"role": "assistant", "content": bot_welcome_message}
68
  ]
 
 
 
 
69
 
70
  def add_message(history, message):
71
  for x in message["files"]:
72
  history.append({"role": "user", "content": {"path": x}})
73
  if message["text"] is not None:
74
  history.append({"role": "user", "content": message["text"]})
75
- return history, gr.MultimodalTextbox(value=None, interactive=False)
76
 
77
  def respond(history):
78
  # print("history", history)
@@ -139,8 +143,12 @@ You can also answer questions based on the information provided by the user.
139
 
140
 
141
  ##########################################################################
142
- clear = gr.ClearButton([chat_input, chatbot])
143
- clear.then(load_welcome, None, chatbot)
 
 
 
 
144
  demo.load(load_welcome, None, chatbot, api_name="load_welcome")
145
  chat_msg = chat_input.submit(
146
  add_message, [chatbot, chat_input], [chatbot, chat_input]
 
66
  return [
67
  {"role": "assistant", "content": bot_welcome_message}
68
  ]
69
+
70
+ def clear_and_load():
71
+ # Return the welcome message
72
+ return [{"role": "assistant", "content": bot_welcome_message}], None
73
 
74
  def add_message(history, message):
75
  for x in message["files"]:
76
  history.append({"role": "user", "content": {"path": x}})
77
  if message["text"] is not None:
78
  history.append({"role": "user", "content": message["text"]})
79
+ return history, gr.MultimodalTextbox(value=None, interactive=False, file_count="multiple", placeholder="Enter message or upload file...")
80
 
81
  def respond(history):
82
  # print("history", history)
 
143
 
144
 
145
  ##########################################################################
146
+ clear = gr.Button("Refresh Chat")
147
+ clear.click(
148
+ clear_and_load,
149
+ inputs=None,
150
+ outputs=[chatbot, chat_input]
151
+ )
152
  demo.load(load_welcome, None, chatbot, api_name="load_welcome")
153
  chat_msg = chat_input.submit(
154
  add_message, [chatbot, chat_input], [chatbot, chat_input]