mirror of
https://github.com/open-webui/open-webui
synced 2024-11-07 00:59:52 +00:00
fix: empty knowledge delete issue
This commit is contained in:
parent
650ca95784
commit
8f22e911e0
@ -2,7 +2,7 @@ import json
|
|||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
|
import logging
|
||||||
|
|
||||||
from open_webui.apps.webui.models.knowledge import (
|
from open_webui.apps.webui.models.knowledge import (
|
||||||
Knowledges,
|
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.constants import ERROR_MESSAGES
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
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()
|
router = APIRouter()
|
||||||
|
|
||||||
############################
|
############################
|
||||||
@ -315,6 +319,10 @@ def remove_file_from_knowledge_by_id(
|
|||||||
|
|
||||||
@router.delete("/{id}/delete", response_model=bool)
|
@router.delete("/{id}/delete", response_model=bool)
|
||||||
async def delete_knowledge_by_id(id: str, user=Depends(get_admin_user)):
|
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)
|
result = Knowledges.delete_knowledge_by_id(id=id)
|
||||||
return result
|
return result
|
||||||
|
Loading…
Reference in New Issue
Block a user