diff --git a/backend/open_webui/models/chats.py b/backend/open_webui/models/chats.py index 23b5276786..46131dc8e9 100644 --- a/backend/open_webui/models/chats.py +++ b/backend/open_webui/models/chats.py @@ -1988,10 +1988,8 @@ class ChatTable: ] # Extract folder names - folders = await Folders.search_folders_by_names( - user_id, - [word.replace('folder:', '') for word in search_text_words if word.startswith('folder:')], - ) + folder_names = [word.replace('folder:', '') for word in search_text_words if word.startswith('folder:')] + folders = await Folders.search_folders_by_names(user_id, folder_names) folder_ids = [folder.id for folder in folders] is_pinned = None @@ -2035,7 +2033,7 @@ class ChatTable: else: stmt = stmt.filter(Chat.share_id.is_(None)) - if folder_ids: + if folder_names: stmt = stmt.filter(Chat.folder_id.in_(folder_ids)) # Check if the database dialect is either 'sqlite' or 'postgresql'