diff --git a/backend/open_webui/models/chats.py b/backend/open_webui/models/chats.py index 0e1c6bef9d..7583f93429 100644 --- a/backend/open_webui/models/chats.py +++ b/backend/open_webui/models/chats.py @@ -1536,11 +1536,11 @@ class ChatTable: if not file_ids: return None - chat_message_file_ids = [ + chat_message_file_ids = { item.id for item in await self.get_chat_files_by_chat_id_and_message_id(chat_id, message_id, db=db) - ] + } # Remove duplicates and existing file_ids - file_ids = list(set([file_id for file_id in file_ids if file_id and file_id not in chat_message_file_ids])) + file_ids = list({file_id for file_id in file_ids if file_id and file_id not in chat_message_file_ids}) if not file_ids: return None