Spaces:
Sleeping
Sleeping
nroggendorff
commited on
Commit
•
bed7948
1
Parent(s):
c14dfd6
Update app.py
Browse files
app.py
CHANGED
@@ -39,21 +39,22 @@ def bot_streaming(message, history):
|
|
39 |
if message["files"]:
|
40 |
# message["files"][-1] is a Dict or just a string
|
41 |
if type(message["files"][-1]) == dict:
|
42 |
-
image
|
|
|
|
|
|
|
43 |
else:
|
44 |
-
image
|
|
|
|
|
|
|
45 |
else:
|
46 |
# if there's no image uploaded for this turn, look for images in the past turns
|
47 |
# kept inside tuples, take the last one
|
48 |
for hist in history:
|
49 |
if type(hist[0]) == tuple:
|
50 |
image = hist[0][0]
|
51 |
-
|
52 |
-
# Handle the case where image is None
|
53 |
-
image = "http://files.tatl.tv/ignore.png"
|
54 |
-
else:
|
55 |
-
image = image
|
56 |
-
|
57 |
prompt = f"<|start_header_id|>user<|end_header_id|>\n\n<image>\n{message['text']}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
|
58 |
# print(f"prompt: {prompt}")
|
59 |
image = Image.open(image)
|
|
|
39 |
if message["files"]:
|
40 |
# message["files"][-1] is a Dict or just a string
|
41 |
if type(message["files"][-1]) == dict:
|
42 |
+
if image is None:
|
43 |
+
image = "http://files.tatl.tv/ignore.png"
|
44 |
+
else:
|
45 |
+
image = message["files"][-1]["path"]
|
46 |
else:
|
47 |
+
if image is None:
|
48 |
+
image = "http://files.tatl.tv/ignore.png"
|
49 |
+
else:
|
50 |
+
image = message["files"][-1]
|
51 |
else:
|
52 |
# if there's no image uploaded for this turn, look for images in the past turns
|
53 |
# kept inside tuples, take the last one
|
54 |
for hist in history:
|
55 |
if type(hist[0]) == tuple:
|
56 |
image = hist[0][0]
|
57 |
+
|
|
|
|
|
|
|
|
|
|
|
58 |
prompt = f"<|start_header_id|>user<|end_header_id|>\n\n<image>\n{message['text']}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
|
59 |
# print(f"prompt: {prompt}")
|
60 |
image = Image.open(image)
|