mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-13 04:45:19 +00:00
refac: folder chat handling
Co-Authored-By: Classic298 <27028174+Classic298@users.noreply.github.com>
This commit is contained in:
parent
5b14d15b00
commit
80f3c97668
1 changed files with 21 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ from starlette.responses import Response, StreamingResponse
|
|||
|
||||
|
||||
from open_webui.models.chats import Chats
|
||||
from open_webui.models.folders import Folders
|
||||
from open_webui.models.users import Users
|
||||
from open_webui.socket.main import (
|
||||
get_event_call,
|
||||
|
|
@ -755,6 +756,26 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||
events = []
|
||||
sources = []
|
||||
|
||||
# Folder "Project" handling
|
||||
# Check if the request has chat_id and is inside of a folder
|
||||
chat_id = metadata.get("chat_id", None)
|
||||
if chat_id and user:
|
||||
chat = Chats.get_chat_by_id_and_user_id(chat_id, user.id)
|
||||
if chat and chat.folder_id:
|
||||
folder = Folders.get_folder_by_id_and_user_id(chat.folder_id, user.id)
|
||||
|
||||
if folder and folder.data:
|
||||
if "system_prompt" in folder.data:
|
||||
form_data["messages"] = add_or_update_system_message(
|
||||
folder.data["system_prompt"], form_data["messages"]
|
||||
)
|
||||
if "files" in folder.data:
|
||||
form_data["files"] = [
|
||||
*folder.data["files"],
|
||||
*form_data.get("files", []),
|
||||
]
|
||||
|
||||
# Model "Knowledge" handling
|
||||
user_message = get_last_user_message(form_data["messages"])
|
||||
model_knowledge = model.get("info", {}).get("meta", {}).get("knowledge", False)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue