Tonic commited on
Commit
16bb86c
·
1 Parent(s): 0b0cd44

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -105,6 +105,8 @@ def _launch_demo(args, model, tokenizer):
105
  )
106
 
107
  def predict(_chatbot, task_history):
 
 
108
  chat_query = _chatbot[-1][0]
109
  query = task_history[-1][0]
110
  print("User: " + _parse_text(query))
@@ -171,6 +173,9 @@ def _launch_demo(args, model, tokenizer):
171
  return history, task_history, ""
172
 
173
  def add_file(history, task_history, file):
 
 
 
174
  history = history + [((file.name,), None)]
175
  task_history = task_history + [((file.name,), None)]
176
  return history, task_history
@@ -201,7 +206,6 @@ def _launch_demo(args, model, tokenizer):
201
  empty_bin = gr.Button("🧹 Clear History")
202
  task_history = gr.State([])
203
 
204
- # Linking the buttons and inputs to their functions
205
  submit_btn.click(
206
  fn=predict,
207
  inputs=[chatbot, task_history],
 
105
  )
106
 
107
  def predict(_chatbot, task_history):
108
+ if not _chatbot:
109
+ return _chatbot
110
  chat_query = _chatbot[-1][0]
111
  query = task_history[-1][0]
112
  print("User: " + _parse_text(query))
 
173
  return history, task_history, ""
174
 
175
  def add_file(history, task_history, file):
176
+ if file is None:
177
+ return history, task_history # Return if no file is uploaded
178
+ file_path = file.name
179
  history = history + [((file.name,), None)]
180
  task_history = task_history + [((file.name,), None)]
181
  return history, task_history
 
206
  empty_bin = gr.Button("🧹 Clear History")
207
  task_history = gr.State([])
208
 
 
209
  submit_btn.click(
210
  fn=predict,
211
  inputs=[chatbot, task_history],