mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-10 12:01:29 -05:00
feat: add pinned, shared and archived tags functionality for chat search moda
Co-Authored-By: G30 <50341825+silentoplayz@users.noreply.github.com>
This commit is contained in:
@@ -617,8 +617,34 @@ class ChatTable:
|
||||
if word.startswith("tag:")
|
||||
]
|
||||
|
||||
is_pinned = None
|
||||
if "pinned:true" in search_text_words:
|
||||
is_pinned = True
|
||||
elif "pinned:false" in search_text_words:
|
||||
is_pinned = False
|
||||
|
||||
is_archived = None
|
||||
if "archived:true" in search_text_words:
|
||||
is_archived = True
|
||||
elif "archived:false" in search_text_words:
|
||||
is_archived = False
|
||||
|
||||
is_shared = None
|
||||
if "shared:true" in search_text_words:
|
||||
is_shared = True
|
||||
elif "shared:false" in search_text_words:
|
||||
is_shared = False
|
||||
|
||||
search_text_words = [
|
||||
word for word in search_text_words if not word.startswith("tag:")
|
||||
word
|
||||
for word in search_text_words
|
||||
if (
|
||||
not word.startswith("tag:")
|
||||
and not word.startswith("folder:")
|
||||
and not word.startswith("pinned:")
|
||||
and not word.startswith("archived:")
|
||||
and not word.startswith("shared:")
|
||||
)
|
||||
]
|
||||
|
||||
search_text = " ".join(search_text_words)
|
||||
@@ -626,9 +652,20 @@ class ChatTable:
|
||||
with get_db() as db:
|
||||
query = db.query(Chat).filter(Chat.user_id == user_id)
|
||||
|
||||
if not include_archived:
|
||||
if is_archived is not None:
|
||||
query = query.filter(Chat.archived == is_archived)
|
||||
elif not include_archived:
|
||||
query = query.filter(Chat.archived == False)
|
||||
|
||||
if is_pinned is not None:
|
||||
query = query.filter(Chat.pinned == is_pinned)
|
||||
|
||||
if is_shared is not None:
|
||||
if is_shared:
|
||||
query = query.filter(Chat.share_id.isnot(None))
|
||||
else:
|
||||
query = query.filter(Chat.share_id.is_(None))
|
||||
|
||||
query = query.order_by(Chat.updated_at.desc())
|
||||
|
||||
# Check if the database dialect is either 'sqlite' or 'postgresql'
|
||||
|
||||
Reference in New Issue
Block a user