Spaces:
Sleeping
Sleeping
nroggendorff
commited on
Commit
•
93abc8e
1
Parent(s):
bed7948
Update app.py
Browse files
app.py
CHANGED
@@ -36,24 +36,23 @@ model.generation_config.eos_token_id = 128009
|
|
36 |
@spaces.GPU
|
37 |
def bot_streaming(message, history):
|
38 |
print(message)
|
|
|
39 |
if message["files"]:
|
40 |
# message["files"][-1] is a Dict or just a string
|
41 |
if type(message["files"][-1]) == dict:
|
42 |
-
|
43 |
-
image = "http://files.tatl.tv/ignore.png"
|
44 |
-
else:
|
45 |
-
image = message["files"][-1]["path"]
|
46 |
else:
|
47 |
-
|
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}")
|
|
|
36 |
@spaces.GPU
|
37 |
def bot_streaming(message, history):
|
38 |
print(message)
|
39 |
+
image = None # Initialize image variable
|
40 |
if message["files"]:
|
41 |
# message["files"][-1] is a Dict or just a string
|
42 |
if type(message["files"][-1]) == dict:
|
43 |
+
image = message["files"][-1]["path"]
|
|
|
|
|
|
|
44 |
else:
|
45 |
+
image = message["files"][-1]
|
|
|
|
|
|
|
46 |
else:
|
47 |
# if there's no image uploaded for this turn, look for images in the past turns
|
48 |
# kept inside tuples, take the last one
|
49 |
for hist in history:
|
50 |
if type(hist[0]) == tuple:
|
51 |
image = hist[0][0]
|
52 |
+
break # Exit loop after finding the first image
|
53 |
+
|
54 |
+
if image is None:
|
55 |
+
image = "http://files.tatl.tv/ignore.png"
|
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}")
|