From 8f22e911e0555ab725ae99546e94580a55f85cbe Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 4 Oct 2024 11:11:53 -0700 Subject: [PATCH] fix: empty knowledge delete issue --- backend/open_webui/apps/webui/routers/knowledge.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/apps/webui/routers/knowledge.py b/backend/open_webui/apps/webui/routers/knowledge.py index 821f02ed1..1628bb382 100644 --- a/backend/open_webui/apps/webui/routers/knowledge.py +++ b/backend/open_webui/apps/webui/routers/knowledge.py @@ -2,7 +2,7 @@ import json from typing import Optional, Union from pydantic import BaseModel from fastapi import APIRouter, Depends, HTTPException, status - +import logging from open_webui.apps.webui.models.knowledge import ( Knowledges, @@ -17,8 +17,12 @@ from open_webui.apps.retrieval.main import process_file, ProcessFileForm from open_webui.constants import ERROR_MESSAGES from open_webui.utils.utils import get_admin_user, get_verified_user +from open_webui.env import SRC_LOG_LEVELS +log = logging.getLogger(__name__) +log.setLevel(SRC_LOG_LEVELS["MODELS"]) + router = APIRouter() ############################ @@ -315,6 +319,10 @@ def remove_file_from_knowledge_by_id( @router.delete("/{id}/delete", response_model=bool) async def delete_knowledge_by_id(id: str, user=Depends(get_admin_user)): - VECTOR_DB_CLIENT.delete_collection(collection_name=id) + try: + VECTOR_DB_CLIENT.delete_collection(collection_name=id) + except Exception as e: + log.debug(e) + pass result = Knowledges.delete_knowledge_by_id(id=id) return result