This commit is contained in:
Timothy Jaeryang Baek
2026-07-15 23:55:31 -04:00
parent 2b8ef9340e
commit e389874fe2
2 changed files with 26 additions and 13 deletions
+26
View File
@@ -45,6 +45,7 @@ from open_webui.models.config import Config
from open_webui.models.folders import Folders
from open_webui.models.functions import Functions
from open_webui.models.models import Models
from open_webui.models.notes import Notes
from open_webui.models.oauth_sessions import OAuthSessions
from open_webui.models.users import UserModel, Users
from open_webui.retrieval.utils import get_sources_from_items
@@ -74,6 +75,7 @@ from open_webui.socket.main import (
get_event_emitter,
)
from open_webui.utils.access_control import has_connection_access, has_permission
from open_webui.models.access_grants import AccessGrants
from open_webui.utils.access_control.folders import has_folder_access
from open_webui.utils.chat import generate_chat_completion
from open_webui.utils.code_interpreter import execute_code_jupyter
@@ -2526,6 +2528,30 @@ async def process_chat_payload(request, form_data, user, metadata, model):
chat = None
if metadata.get('chat_id') and not metadata['chat_id'].startswith(('local:', 'channel:')):
chat = await Chats.get_chat_by_id(metadata['chat_id'])
if chat and (chat.meta or {}).get('internal') is True and (chat.meta or {}).get('type') == 'note':
note_id = (chat.meta or {}).get('note_id')
note = await Notes.get_note_by_id(note_id) if note_id else None
if note and (
user.role == 'admin'
or note.user_id == user.id
or await AccessGrants.has_access(
user_id=user.id,
resource_type='note',
resource_id=note.id,
permission='read',
)
):
note_files = [
file
for file in ((note.data or {}).get('files') or [])
if isinstance(file, dict)
and file.get('type') != 'image'
and not (file.get('content_type') or '').startswith('image/')
]
if note_files:
files = [*(files or []), *note_files]
use_builtin_tools = (
(chat and (chat.meta or {}).get('internal') is True and (chat.meta or {}).get('type') == 'note')
or (
@@ -143,22 +143,10 @@
let noteChatCreating = false;
let selectedContent = null;
let noteChatFiles = [];
let noteAttachmentFiles = [];
let pendingNoteEvent = null;
let pendingNoteEventTimer = null;
let lastLocalContentChangeAt = 0;
$: {
const seen = new Set();
noteChatFiles = note
? (note?.data?.files ?? files ?? []).filter((file) => {
const key = `${file?.type ?? ''}:${file?.id ?? file?.url ?? file?.name ?? ''}`;
if (seen.has(key)) return false;
seen.add(key);
return true;
})
: [];
}
$: noteAttachmentFiles = (files ?? []).filter(
(file) => file?.type !== 'image' && !(file?.content_type ?? '').startsWith('image/')
);
@@ -1482,7 +1470,6 @@ ${content}
chatIdProp={noteChatId ?? ''}
embeddedChats={noteChats}
embeddedDraftKey={noteChatDraftKey}
initialFiles={noteChatFiles}
selectedText={selectedContent?.text ?? ''}
onInsertToNote={insertHandler}
onNewEmbeddedChat={createNoteChat}