Tonic commited on
Commit
b5ca7ca
·
1 Parent(s): 5fbed6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -152,6 +152,8 @@ def predict(_chatbot, task_history) -> tuple:
152
  else:
153
  _chatbot[-1] = (chat_query, response)
154
 
 
 
155
  return _chatbot, task_history
156
 
157
  def save_uploaded_image(image_file, upload_dir):
@@ -180,12 +182,15 @@ def regenerate(_chatbot, task_history) -> list:
180
  return predict(_chatbot, task_history)
181
 
182
  def add_text(history, task_history, text) -> tuple:
 
 
183
  task_text = text
184
  if len(text) >= 2 and text[-1] in PUNCTUATION and text[-2] not in PUNCTUATION:
185
  task_text = text[:-1]
186
- history = history + [(_parse_text(text), None)]
187
- task_history = task_history + [(task_text, None)]
188
- return history, task_history, ""
 
189
 
190
  def add_file(history, task_history, file):
191
  if file is None:
 
152
  else:
153
  _chatbot[-1] = (chat_query, response)
154
 
155
+ task_history[-1] = _chatbot[-1]
156
+
157
  return _chatbot, task_history
158
 
159
  def save_uploaded_image(image_file, upload_dir):
 
182
  return predict(_chatbot, task_history)
183
 
184
  def add_text(history, task_history, text) -> tuple:
185
+ if not text.strip():
186
+ return history, task_history, ""
187
  task_text = text
188
  if len(text) >= 2 and text[-1] in PUNCTUATION and text[-2] not in PUNCTUATION:
189
  task_text = text[:-1]
190
+ history_item = (_parse_text(task_text), None)
191
+ history.append(history_item)
192
+ task_history.append(history_item)
193
+ return history, task_history, ""
194
 
195
  def add_file(history, task_history, file):
196
  if file is None: