From 64eba9576cb806d2213b7efbb82469aa70a9fd71 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Sun, 17 Aug 2025 14:08:40 -0700 Subject: [PATCH] mtmd: Fix a bug when "include past attachments" is unchecked --- modules/chat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/chat.py b/modules/chat.py index 7b1629dd..ab6b43c0 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -269,7 +269,7 @@ def generate_chat_prompt(user_input, state, **kwargs): enhanced_user_msg = user_msg # Add attachment content if present AND if past attachments are enabled - if (state.get('include_past_attachments', True) and user_key in metadata and "attachments" in metadata[user_key]): + if user_key in metadata and "attachments" in metadata[user_key]: attachments_text = "" image_refs = "" @@ -277,7 +277,7 @@ def generate_chat_prompt(user_input, state, **kwargs): if attachment.get("type") == "image": # Add image reference for multimodal models image_refs += "<__media__>" - else: + elif state.get('include_past_attachments', True): # Handle text/PDF attachments filename = attachment.get("name", "file") content = attachment.get("content", "")