Spaces:
Running
on
Zero
Running
on
Zero
Considering the image-video interleave conversation.
Browse files
app.py
CHANGED
|
@@ -132,22 +132,24 @@ def generate(image, video, message, chatbot, textbox_in, temperature, top_p, max
|
|
| 132 |
else:
|
| 133 |
# scanning the last image or video
|
| 134 |
length = len(chatbot)
|
| 135 |
-
for i in range(length - 1, -1):
|
| 136 |
previous_image = re.findall(r'<img src="./file=(.+?)"', chatbot[i][0])
|
| 137 |
previous_video = re.findall(r'<video controls playsinline width="500" style="display: inline-block;" src="./file=(.+?)"', chatbot[i][0])
|
| 138 |
|
| 139 |
if len(previous_image) > 0:
|
| 140 |
previous_image = previous_image[-1]
|
| 141 |
# 2.1 new image append or pure text input will start a new conversation
|
| 142 |
-
if video is not None or (image is not None and os.path.basename(previous_image) != os.path.basename(image)):
|
| 143 |
message.clear()
|
| 144 |
one_turn_chat[0] += "\n" + show_images
|
|
|
|
| 145 |
elif len(previous_video) > 0:
|
| 146 |
previous_video = previous_video[-1]
|
| 147 |
# 2.2 new video append or pure text input will start a new conversation
|
| 148 |
if image is not None or (video is not None and os.path.basename(previous_video) != os.path.basename(video)):
|
| 149 |
message.clear()
|
| 150 |
one_turn_chat[0] += "\n" + show_images
|
|
|
|
| 151 |
|
| 152 |
message.append({'role': 'user', 'content': textbox_in})
|
| 153 |
text_en_out = handler.generate(data, message, temperature=temperature, top_p=top_p, max_output_tokens=max_output_tokens)
|
|
|
|
| 132 |
else:
|
| 133 |
# scanning the last image or video
|
| 134 |
length = len(chatbot)
|
| 135 |
+
for i in range(length - 1, -1, -1):
|
| 136 |
previous_image = re.findall(r'<img src="./file=(.+?)"', chatbot[i][0])
|
| 137 |
previous_video = re.findall(r'<video controls playsinline width="500" style="display: inline-block;" src="./file=(.+?)"', chatbot[i][0])
|
| 138 |
|
| 139 |
if len(previous_image) > 0:
|
| 140 |
previous_image = previous_image[-1]
|
| 141 |
# 2.1 new image append or pure text input will start a new conversation
|
| 142 |
+
if (video is not None) or (image is not None and os.path.basename(previous_image) != os.path.basename(image)):
|
| 143 |
message.clear()
|
| 144 |
one_turn_chat[0] += "\n" + show_images
|
| 145 |
+
break
|
| 146 |
elif len(previous_video) > 0:
|
| 147 |
previous_video = previous_video[-1]
|
| 148 |
# 2.2 new video append or pure text input will start a new conversation
|
| 149 |
if image is not None or (video is not None and os.path.basename(previous_video) != os.path.basename(video)):
|
| 150 |
message.clear()
|
| 151 |
one_turn_chat[0] += "\n" + show_images
|
| 152 |
+
break
|
| 153 |
|
| 154 |
message.append({'role': 'user', 'content': textbox_in})
|
| 155 |
text_en_out = handler.generate(data, message, temperature=temperature, top_p=top_p, max_output_tokens=max_output_tokens)
|