Update app.py
Browse files
app.py
CHANGED
@@ -245,9 +245,12 @@ def add_message(history, message):
|
|
245 |
if len(message["files"]) <= 1:
|
246 |
for x in message["files"]:
|
247 |
history.append(((x,), None))
|
248 |
-
|
249 |
-
|
250 |
-
|
|
|
|
|
|
|
251 |
if message["text"] is not None:
|
252 |
history.append((message["text"], None))
|
253 |
|
@@ -265,21 +268,21 @@ def bot(history, temperature, top_p, max_output_tokens):
|
|
265 |
num_new_images = 0
|
266 |
for i, message in enumerate(history[:-1]):
|
267 |
if type(message[0]) is tuple:
|
268 |
-
print("### message[0]",message[0])
|
269 |
-
if len(message[0])>1:
|
270 |
-
|
271 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
else:
|
273 |
-
|
274 |
-
if is_valid_video_filename(message[0][0]):
|
275 |
-
# 不接受视频
|
276 |
-
raise ValueError("Video is not supported")
|
277 |
-
num_new_images += our_chatbot.num_frames
|
278 |
-
elif is_valid_image_filename(message[0][0]):
|
279 |
-
print("#### Load image from local file",message[0][0])
|
280 |
-
num_new_images += 1
|
281 |
-
else:
|
282 |
-
raise ValueError("Invalid image file")
|
283 |
else:
|
284 |
num_new_images = 0
|
285 |
|
|
|
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 |
|
|
|
268 |
num_new_images = 0
|
269 |
for i, message in enumerate(history[:-1]):
|
270 |
if type(message[0]) is tuple:
|
271 |
+
# print("### message[0]",message[0])
|
272 |
+
# if len(message[0])>1:
|
273 |
+
# gr.Warning("Only one image can be uploaded in a conversation. Please reduce the number of images and start a new conversation.")
|
274 |
+
# return history
|
275 |
+
# else:
|
276 |
+
images_this_term.append(message[0][0])
|
277 |
+
if is_valid_video_filename(message[0][0]):
|
278 |
+
# 不接受视频
|
279 |
+
raise ValueError("Video is not supported")
|
280 |
+
num_new_images += our_chatbot.num_frames
|
281 |
+
elif is_valid_image_filename(message[0][0]):
|
282 |
+
print("#### Load image from local file",message[0][0])
|
283 |
+
num_new_images += 1
|
284 |
else:
|
285 |
+
raise ValueError("Invalid image file")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
else:
|
287 |
num_new_images = 0
|
288 |
|