Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -262,14 +262,14 @@ def add_message(history, message):
|
|
| 262 |
if message["text"] is not None:
|
| 263 |
history.append((message["text"], None))
|
| 264 |
|
| 265 |
-
return
|
| 266 |
|
| 267 |
|
| 268 |
@spaces.GPU
|
| 269 |
def bot(history, temperature, top_p, max_output_tokens):
|
| 270 |
-
if not history:
|
| 271 |
-
|
| 272 |
-
|
| 273 |
print("### turn start history",history)
|
| 274 |
print("### turn start conv",our_chatbot.conversation)
|
| 275 |
text = history[-1][0]
|
|
@@ -277,9 +277,12 @@ def bot(history, temperature, top_p, max_output_tokens):
|
|
| 277 |
text_this_term = ""
|
| 278 |
# import pdb;pdb.set_trace()
|
| 279 |
num_new_images = 0
|
| 280 |
-
|
| 281 |
for i, message in enumerate(history[:-1]):
|
| 282 |
if type(message[0]) is tuple:
|
|
|
|
|
|
|
|
|
|
| 283 |
# print("### message[0]",message[0])
|
| 284 |
# if len(message[0])>1:
|
| 285 |
# gr.Warning("Only one image can be uploaded in a conversation. Please reduce the number of images and start a new conversation.")
|
|
@@ -294,8 +297,10 @@ def bot(history, temperature, top_p, max_output_tokens):
|
|
| 294 |
num_new_images += 1
|
| 295 |
else:
|
| 296 |
raise ValueError("Invalid image file")
|
|
|
|
| 297 |
else:
|
| 298 |
num_new_images = 0
|
|
|
|
| 299 |
|
| 300 |
# for message in history[-i-1:]:
|
| 301 |
# images_this_term.append(message[0][0])
|
|
|
|
| 262 |
if message["text"] is not None:
|
| 263 |
history.append((message["text"], None))
|
| 264 |
|
| 265 |
+
return history, gr.MultimodalTextbox(value=None, interactive=False)
|
| 266 |
|
| 267 |
|
| 268 |
@spaces.GPU
|
| 269 |
def bot(history, temperature, top_p, max_output_tokens):
|
| 270 |
+
# if not history:
|
| 271 |
+
# gr.Warning("Only one image can be uploaded in a conversation. Please reduce the number of images and start a new conversation.")
|
| 272 |
+
# return history
|
| 273 |
print("### turn start history",history)
|
| 274 |
print("### turn start conv",our_chatbot.conversation)
|
| 275 |
text = history[-1][0]
|
|
|
|
| 277 |
text_this_term = ""
|
| 278 |
# import pdb;pdb.set_trace()
|
| 279 |
num_new_images = 0
|
| 280 |
+
previous_image = False
|
| 281 |
for i, message in enumerate(history[:-1]):
|
| 282 |
if type(message[0]) is tuple:
|
| 283 |
+
if previous_image:
|
| 284 |
+
gr.Warning("Only one image can be uploaded in a conversation. Please reduce the number of images and start a new conversation.")
|
| 285 |
+
return history
|
| 286 |
# print("### message[0]",message[0])
|
| 287 |
# if len(message[0])>1:
|
| 288 |
# gr.Warning("Only one image can be uploaded in a conversation. Please reduce the number of images and start a new conversation.")
|
|
|
|
| 297 |
num_new_images += 1
|
| 298 |
else:
|
| 299 |
raise ValueError("Invalid image file")
|
| 300 |
+
previous_image = True
|
| 301 |
else:
|
| 302 |
num_new_images = 0
|
| 303 |
+
previous_image = False
|
| 304 |
|
| 305 |
# for message in history[-i-1:]:
|
| 306 |
# images_this_term.append(message[0][0])
|