Spaces:
Runtime error
Runtime error
Update chatbot.py
Browse files- chatbot.py +8 -8
chatbot.py
CHANGED
@@ -243,12 +243,12 @@ def model_inference( user_prompt, chat_history, web_search):
|
|
243 |
yield output
|
244 |
else:
|
245 |
message = user_prompt
|
246 |
-
if len(message.files) == 1:
|
247 |
-
image = [message.files[0].path]
|
248 |
-
elif len(message.files) > 1:
|
249 |
-
image = [msg.path for msg in message.files]
|
250 |
|
251 |
-
txt = message.text
|
252 |
|
253 |
video_extensions = ("avi", "mp4", "mov", "mkv", "flv", "wmv", "mjpeg", "wav", "gif", "webm", "m4v", "3gp")
|
254 |
image_extensions = Image.registered_extensions()
|
@@ -259,10 +259,10 @@ def model_inference( user_prompt, chat_history, web_search):
|
|
259 |
image = sample_frames(image)
|
260 |
print(len(image))
|
261 |
image_tokens = "<image>" * int(len(image))
|
262 |
-
prompt = f"<|im_start|>user {image_tokens}\n{
|
263 |
elif image.endswith(image_extensions):
|
264 |
image = Image.open(image).convert("RGB")
|
265 |
-
prompt = f"<|im_start|>user <image>\n{
|
266 |
|
267 |
elif len(image) > 1:
|
268 |
image_list = []
|
@@ -278,7 +278,7 @@ def model_inference( user_prompt, chat_history, web_search):
|
|
278 |
image_list.append(frame)
|
279 |
|
280 |
toks = "<image>" * len(image_list)
|
281 |
-
prompt = f"<|im_start|>user {toks}\n{
|
282 |
image = image_list
|
283 |
|
284 |
prompt = f"<|im_start|>system\nYou are OpenGPT 4o, an exceptionally capable and versatile AI assistant made by KingNish. Your task is to fulfill users query in best possible way. You are provided with image, videos and 3d structures as input with question your task is to give best possible detailed results to user according to their query. Reply the question asked by user properly and best possible way.<|im_end|>\n{prompt}"
|
|
|
243 |
yield output
|
244 |
else:
|
245 |
message = user_prompt
|
246 |
+
if len(message.["files"]) == 1:
|
247 |
+
image = [message.["files"][0].path]
|
248 |
+
elif len(message.["files"]) > 1:
|
249 |
+
image = [msg.path for msg in message.["files"]]
|
250 |
|
251 |
+
txt = message.["text"]
|
252 |
|
253 |
video_extensions = ("avi", "mp4", "mov", "mkv", "flv", "wmv", "mjpeg", "wav", "gif", "webm", "m4v", "3gp")
|
254 |
image_extensions = Image.registered_extensions()
|
|
|
259 |
image = sample_frames(image)
|
260 |
print(len(image))
|
261 |
image_tokens = "<image>" * int(len(image))
|
262 |
+
prompt = f"<|im_start|>user {image_tokens}\n{user_prompt}<|im_end|><|im_start|>assistant"
|
263 |
elif image.endswith(image_extensions):
|
264 |
image = Image.open(image).convert("RGB")
|
265 |
+
prompt = f"<|im_start|>user <image>\n{user_prompt}<|im_end|><|im_start|>assistant"
|
266 |
|
267 |
elif len(image) > 1:
|
268 |
image_list = []
|
|
|
278 |
image_list.append(frame)
|
279 |
|
280 |
toks = "<image>" * len(image_list)
|
281 |
+
prompt = f"<|im_start|>user {toks}\n{user_prompt}<|im_end|><|im_start|>assistant"
|
282 |
image = image_list
|
283 |
|
284 |
prompt = f"<|im_start|>system\nYou are OpenGPT 4o, an exceptionally capable and versatile AI assistant made by KingNish. Your task is to fulfill users query in best possible way. You are provided with image, videos and 3d structures as input with question your task is to give best possible detailed results to user according to their query. Reply the question asked by user properly and best possible way.<|im_end|>\n{prompt}"
|