paralym commited on
Commit
a8435ba
·
verified ·
1 Parent(s): b871c52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -10
app.py CHANGED
@@ -236,25 +236,40 @@ def clear_response(history):
236
 
237
  def add_message(history, message):
238
  # history=[]
239
- global our_chatbot
240
  if len(history) == 0:
241
  our_chatbot = InferenceDemo(
242
  args, model_path, tokenizer, model, image_processor, context_len
243
  )
244
-
245
  if len(message["files"]) <= 1:
246
  for x in message["files"]:
247
  history.append(((x,), None))
 
 
 
 
 
 
 
 
 
 
 
 
248
  else:
249
- return None, gr.MultimodalTextbox(value=None, interactive=False)
250
- # elif len(message["files"]) > 1:
251
- # history.append((tuple(message["files"]), None))
252
- # if len(message["files"]) > 1:
253
- # return
254
- if message["text"] is not None:
255
- history.append((message["text"], None))
 
 
 
256
 
257
- return history, gr.MultimodalTextbox(value=None, interactive=False)
258
 
259
 
260
  @spaces.GPU
 
236
 
237
  def add_message(history, message):
238
  # history=[]
239
+ global our_chatbot, chat_image_num
240
  if len(history) == 0:
241
  our_chatbot = InferenceDemo(
242
  args, model_path, tokenizer, model, image_processor, context_len
243
  )
244
+
245
  if len(message["files"]) <= 1:
246
  for x in message["files"]:
247
  history.append(((x,), None))
248
+ chat_image_num += 1
249
+ if chat_image_num > 1:
250
+ history = []
251
+ our_chatbot = InferenceDemo(
252
+ args, model_path, tokenizer, model, image_processor, context_len
253
+ )
254
+ for x in message["files"]:
255
+ history.append(((x,), None))
256
+ chat_image_num += 1
257
+ if message["text"] is not None:
258
+ history.append((message["text"], None))
259
+ return history, gr.MultimodalTextbox(value=None, interactive=False)
260
  else:
261
+ # for x in message["files"]:
262
+ history.append(((message["files"],), None))
263
+ chat_image_num += len(message["files"])
264
+ if message["text"] is not None:
265
+ history.append((message["text"], None))
266
+
267
+ return history, gr.MultimodalTextbox(value=None, interactive=False)
268
+
269
+ # if message["text"] is not None:
270
+ # history.append((message["text"], None))
271
 
272
+ # return history, gr.MultimodalTextbox(value=None, interactive=False)
273
 
274
 
275
  @spaces.GPU