mtmd: Use the base64 attachment for the UI preview instead of the file

This commit is contained in:
oobabooga 2025-08-08 20:13:54 -07:00
parent 6e9de75727
commit 8fcadff8d3
2 changed files with 2 additions and 4 deletions

View file

@ -640,7 +640,6 @@ def add_message_attachment(history, row_idx, file_path, is_user=True):
"type": "image", "type": "image",
"image_data": data_url, "image_data": data_url,
"image_id": image_id, "image_id": image_id,
"file_path": str(path) # For UI preview
} }
elif file_extension == '.pdf': elif file_extension == '.pdf':
# Process PDF file # Process PDF file

View file

@ -407,11 +407,10 @@ def format_message_attachments(history, role, index):
name = html.escape(attachment["name"]) name = html.escape(attachment["name"])
if attachment.get("type") == "image": if attachment.get("type") == "image":
# Show image preview image_data = attachment.get("image_data", "")
file_path = attachment.get("file_path", "")
attachments_html += ( attachments_html += (
f'<div class="attachment-box image-attachment">' f'<div class="attachment-box image-attachment">'
f'<img src="file/{file_path}" alt="{name}" class="image-preview" />' f'<img src="{image_data}" alt="{name}" class="image-preview" />'
f'<div class="attachment-name">{name}</div>' f'<div class="attachment-name">{name}</div>'
f'</div>' f'</div>'
) )