mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
enh: delete_file query param
This commit is contained in:
parent
182408a52e
commit
22c4ef4fb0
1 changed files with 14 additions and 12 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from fastapi import APIRouter, Depends, HTTPException, status, Request
|
from fastapi import APIRouter, Depends, HTTPException, status, Request, Query
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from open_webui.models.knowledge import (
|
from open_webui.models.knowledge import (
|
||||||
|
|
@ -492,6 +492,7 @@ def update_file_from_knowledge_by_id(
|
||||||
def remove_file_from_knowledge_by_id(
|
def remove_file_from_knowledge_by_id(
|
||||||
id: str,
|
id: str,
|
||||||
form_data: KnowledgeFileIdForm,
|
form_data: KnowledgeFileIdForm,
|
||||||
|
delete_file: bool = Query(True),
|
||||||
user=Depends(get_verified_user),
|
user=Depends(get_verified_user),
|
||||||
):
|
):
|
||||||
knowledge = Knowledges.get_knowledge_by_id(id=id)
|
knowledge = Knowledges.get_knowledge_by_id(id=id)
|
||||||
|
|
@ -528,6 +529,7 @@ def remove_file_from_knowledge_by_id(
|
||||||
log.debug(e)
|
log.debug(e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if delete_file:
|
||||||
try:
|
try:
|
||||||
# Remove the file's collection from vector database
|
# Remove the file's collection from vector database
|
||||||
file_collection = f"file-{form_data.file_id}"
|
file_collection = f"file-{form_data.file_id}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue