Update vlm.py
Browse files
vlm.py
CHANGED
|
@@ -62,7 +62,12 @@ def build_messages(message: dict, history: list[tuple]):
|
|
| 62 |
combined_user_input = [] #Combine images and text if found in same turn.
|
| 63 |
for user_turn, bot_turn in history:
|
| 64 |
if isinstance(user_turn, tuple): # Image input
|
| 65 |
-
image_content = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
combined_user_input.extend(image_content)
|
| 67 |
elif isinstance(user_turn, str): #Text input
|
| 68 |
combined_user_input.append({"type":"text", "text": user_turn})
|
|
|
|
| 62 |
combined_user_input = [] #Combine images and text if found in same turn.
|
| 63 |
for user_turn, bot_turn in history:
|
| 64 |
if isinstance(user_turn, tuple): # Image input
|
| 65 |
+
image_content = [
|
| 66 |
+
{
|
| 67 |
+
"type": "image_url",
|
| 68 |
+
"image_url": f"data:image/jpeg;base64,{encode_image(image)}"
|
| 69 |
+
} for image_url in user_turn
|
| 70 |
+
]
|
| 71 |
combined_user_input.extend(image_content)
|
| 72 |
elif isinstance(user_turn, str): #Text input
|
| 73 |
combined_user_input.append({"type":"text", "text": user_turn})
|