Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -257,23 +257,27 @@ def bot(history, temperature, top_p, max_output_tokens):
|
|
| 257 |
num_new_images = 0
|
| 258 |
for i, message in enumerate(history[:-1]):
|
| 259 |
if type(message[0]) is tuple:
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
raise ValueError("Video is not supported")
|
| 264 |
-
num_new_images += our_chatbot.num_frames
|
| 265 |
-
elif is_valid_image_filename(message[0][0]):
|
| 266 |
-
print("#### Load image from local file",message[0][0])
|
| 267 |
-
num_new_images += 1
|
| 268 |
else:
|
| 269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
else:
|
| 271 |
num_new_images = 0
|
| 272 |
|
| 273 |
# for message in history[-i-1:]:
|
| 274 |
# images_this_term.append(message[0][0])
|
| 275 |
|
| 276 |
-
assert len(images_this_term) > 0, "must have an image"
|
| 277 |
# image_files = (args.image_file).split(',')
|
| 278 |
# image = [load_image(f) for f in images_this_term if f]
|
| 279 |
|
|
@@ -329,9 +333,6 @@ def bot(history, temperature, top_p, max_output_tokens):
|
|
| 329 |
our_chatbot.conversation.append_message(our_chatbot.conversation.roles[1], None)
|
| 330 |
prompt = our_chatbot.conversation.get_prompt()
|
| 331 |
|
| 332 |
-
if len(images_this_term) == 0:
|
| 333 |
-
gr.Warning("You should upload an image. Please upload the image and try again.")
|
| 334 |
-
return history
|
| 335 |
|
| 336 |
if len(images_this_term) > 1:
|
| 337 |
gr.Warning("Only one image can be uploaded in a conversation. Please reduce the number of images and start a new conversation.")
|
|
|
|
| 257 |
num_new_images = 0
|
| 258 |
for i, message in enumerate(history[:-1]):
|
| 259 |
if type(message[0]) is tuple:
|
| 260 |
+
if len(message[0])>1:
|
| 261 |
+
gr.Warning("Only one image can be uploaded in a conversation. Please reduce the number of images and start a new conversation.")
|
| 262 |
+
return history
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
else:
|
| 264 |
+
images_this_term.append(message[0][0])
|
| 265 |
+
if is_valid_video_filename(message[0][0]):
|
| 266 |
+
# 不接受视频
|
| 267 |
+
raise ValueError("Video is not supported")
|
| 268 |
+
num_new_images += our_chatbot.num_frames
|
| 269 |
+
elif is_valid_image_filename(message[0][0]):
|
| 270 |
+
print("#### Load image from local file",message[0][0])
|
| 271 |
+
num_new_images += 1
|
| 272 |
+
else:
|
| 273 |
+
raise ValueError("Invalid image file")
|
| 274 |
else:
|
| 275 |
num_new_images = 0
|
| 276 |
|
| 277 |
# for message in history[-i-1:]:
|
| 278 |
# images_this_term.append(message[0][0])
|
| 279 |
|
| 280 |
+
# assert len(images_this_term) > 0, "must have an image"
|
| 281 |
# image_files = (args.image_file).split(',')
|
| 282 |
# image = [load_image(f) for f in images_this_term if f]
|
| 283 |
|
|
|
|
| 333 |
our_chatbot.conversation.append_message(our_chatbot.conversation.roles[1], None)
|
| 334 |
prompt = our_chatbot.conversation.get_prompt()
|
| 335 |
|
|
|
|
|
|
|
|
|
|
| 336 |
|
| 337 |
if len(images_this_term) > 1:
|
| 338 |
gr.Warning("Only one image can be uploaded in a conversation. Please reduce the number of images and start a new conversation.")
|