diff --git a/backend/open_webui/models/chats.py b/backend/open_webui/models/chats.py index a19cdf1a6b..4a40a049a0 100644 --- a/backend/open_webui/models/chats.py +++ b/backend/open_webui/models/chats.py @@ -1514,20 +1514,6 @@ class ChatTable: except Exception: return False - async def delete_all_tags_by_id_and_user_id(self, id: str, user_id: str, db: AsyncSession | None = None) -> bool: - try: - async with get_async_db_context(db) as db: - chat = await db.get(Chat, id) - chat.meta = { - **chat.meta, - 'tags': [], - } - await db.commit() - - return True - except Exception: - return False - async def delete_chat_by_id(self, id: str, db: AsyncSession | None = None) -> bool: try: async with get_async_db_context(db) as db: diff --git a/backend/open_webui/routers/chats.py b/backend/open_webui/routers/chats.py index 7c6f3dea9d..4fdde37200 100644 --- a/backend/open_webui/routers/chats.py +++ b/backend/open_webui/routers/chats.py @@ -1591,23 +1591,3 @@ async def delete_tag_by_id_and_tag_name( return await Tags.get_tags_by_ids_and_user_id(tags, user.id, db=db) else: raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail=ERROR_MESSAGES.NOT_FOUND) - - -############################ -# DeleteAllTagsById -############################ - - -@router.delete('/{id}/tags/all', response_model=bool | None) -async def delete_all_tags_by_id( - id: str, user=Depends(get_verified_user), db: AsyncSession = Depends(get_async_session) -): - chat = await Chats.get_chat_by_id_and_user_id(id, user.id, db=db) - if chat: - old_tags = chat.meta.get('tags', []) - await Chats.delete_all_tags_by_id_and_user_id(id, user.id, db=db) - await Chats.delete_orphan_tags_for_user(old_tags, user.id, db=db) - - return True - else: - raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail=ERROR_MESSAGES.NOT_FOUND) diff --git a/src/lib/apis/chats/index.ts b/src/lib/apis/chats/index.ts index 48f1a4812d..1916e35086 100644 --- a/src/lib/apis/chats/index.ts +++ b/src/lib/apis/chats/index.ts @@ -1206,37 +1206,6 @@ export const deleteTagById = async (token: string, id: string, tagName: string) return res; }; -export const deleteTagsById = async (token: string, id: string) => { - let error = null; - - const res = await fetch(`${WEBUI_API_BASE_URL}/chats/${id}/tags/all`, { - method: 'DELETE', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - ...(token && { authorization: `Bearer ${token}` }) - } - }) - .then(async (res) => { - if (!res.ok) throw await res.json(); - return res.json(); - }) - .then((json) => { - return json; - }) - .catch((err) => { - error = err; - - console.error(err); - return null; - }); - - if (error) { - throw error; - } - - return res; -}; export const deleteAllChats = async (token: string) => { let error = null;