mirror of
https://github.com/open-webui/open-webui
synced 2025-06-23 02:16:52 +00:00
Update chats.py
This commit is contained in:
parent
e50cde80f3
commit
033e5c1e00
@ -634,7 +634,7 @@ class ChatTable:
|
|||||||
).params(title_key=f"%{search_text}%", content_key=search_text)
|
).params(title_key=f"%{search_text}%", content_key=search_text)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Tag filtering
|
# Check if there are any tags to filter, it should have all the tags
|
||||||
if "none" in tag_ids:
|
if "none" in tag_ids:
|
||||||
query = query.filter(
|
query = query.filter(
|
||||||
text(
|
text(
|
||||||
@ -651,7 +651,13 @@ class ChatTable:
|
|||||||
and_(
|
and_(
|
||||||
*[
|
*[
|
||||||
text(
|
text(
|
||||||
f"EXISTS (SELECT 1 FROM json_each(Chat.meta, '$.tags') AS tag WHERE tag.value = :tag_id_{tag_idx})"
|
f"""
|
||||||
|
EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM json_each(Chat.meta, '$.tags') AS tag
|
||||||
|
WHERE tag.value = :tag_id_{tag_idx}
|
||||||
|
)
|
||||||
|
"""
|
||||||
).params(**{f"tag_id_{tag_idx}": tag_id})
|
).params(**{f"tag_id_{tag_idx}": tag_id})
|
||||||
for tag_idx, tag_id in enumerate(tag_ids)
|
for tag_idx, tag_id in enumerate(tag_ids)
|
||||||
]
|
]
|
||||||
@ -675,7 +681,7 @@ class ChatTable:
|
|||||||
).params(title_key=f"%{search_text}%", content_key=search_text)
|
).params(title_key=f"%{search_text}%", content_key=search_text)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Tag filtering
|
# Check if there are any tags to filter, it should have all the tags
|
||||||
if "none" in tag_ids:
|
if "none" in tag_ids:
|
||||||
query = query.filter(
|
query = query.filter(
|
||||||
text(
|
text(
|
||||||
@ -692,7 +698,13 @@ class ChatTable:
|
|||||||
and_(
|
and_(
|
||||||
*[
|
*[
|
||||||
text(
|
text(
|
||||||
f"EXISTS (SELECT 1 FROM json_array_elements_text(Chat.meta->'tags') AS tag WHERE tag = :tag_id_{tag_idx})"
|
f"""
|
||||||
|
EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM json_array_elements_text(Chat.meta->'tags') AS tag
|
||||||
|
WHERE tag = :tag_id_{tag_idx}
|
||||||
|
)
|
||||||
|
"""
|
||||||
).params(**{f"tag_id_{tag_idx}": tag_id})
|
).params(**{f"tag_id_{tag_idx}": tag_id})
|
||||||
for tag_idx, tag_id in enumerate(tag_ids)
|
for tag_idx, tag_id in enumerate(tag_ids)
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user