Feature: adjusted file upload to handle individual rag config (send knowledge base id to get rag config)

This commit is contained in:
Maytown
2025-05-06 12:53:24 +02:00
parent 49e4375263
commit 8fa985e3ba
3 changed files with 14 additions and 10 deletions

View File

@@ -15,6 +15,7 @@ from fastapi import (
UploadFile,
status,
Query,
Form
)
from fastapi.responses import FileResponse, StreamingResponse
from open_webui.constants import ERROR_MESSAGES
@@ -87,9 +88,10 @@ def upload_file(
user=Depends(get_verified_user),
file_metadata: dict = None,
process: bool = Query(True),
knowledge_id: Optional[str] = Form(...),
):
log.info(f"file.content_type: {file.content_type}")
print("KNOWLEDGE_ID: ", knowledge_id)
file_metadata = file_metadata if file_metadata else {}
try:
unsanitized_filename = file.filename
@@ -137,6 +139,7 @@ def upload_file(
process_file(
request,
ProcessFileForm(file_id=id, content=result.get("text", "")),
knowledge_id= knowledge_id,
user=user,
)
elif file.content_type not in [
@@ -148,7 +151,7 @@ def upload_file(
"video/quicktime",
"video/webm",
]:
process_file(request, ProcessFileForm(file_id=id), user=user)
process_file(request, ProcessFileForm(file_id=id), knowledge_id=knowledge_id, user=user)
file_item = Files.get_file_by_id(id=id)
except Exception as e: