diff --git a/backend/open_webui/routers/notes.py b/backend/open_webui/routers/notes.py index 185bc1e381..6cbb7b5fe2 100644 --- a/backend/open_webui/routers/notes.py +++ b/backend/open_webui/routers/notes.py @@ -580,7 +580,7 @@ async def update_note_by_id( note.is_pinned = note.id in pinned_note_ids await sio.emit( - 'note-events', + 'events:note', note.model_dump(), to=f'note:{note.id}', ) diff --git a/backend/open_webui/tools/builtin.py b/backend/open_webui/tools/builtin.py index 030164f902..553cacad10 100644 --- a/backend/open_webui/tools/builtin.py +++ b/backend/open_webui/tools/builtin.py @@ -75,7 +75,7 @@ async def _has_write_access_to_note(note, user_id: str) -> bool: async def _emit_note_updated(request: Request, user: dict, note) -> None: - await sio.emit('note-events', note.model_dump(), to=f'note:{note.id}') + await sio.emit('events:note', note.model_dump(), to=f'note:{note.id}') await publish_event( request, EVENTS.NOTE_UPDATED, diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index c4e650f430..35812cb803 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -2523,10 +2523,16 @@ async def process_chat_payload(request, form_data, user, metadata, model): ) available_skills = [] view_skill_ids = [] + 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']) use_builtin_tools = ( - bool(metadata.get('session_id')) - and metadata.get('params', {}).get('function_calling') != 'legacy' - and (model.get('info', {}).get('meta', {}).get('capabilities') or {}).get('builtin_tools', True) + (chat and (chat.meta or {}).get('internal') is True and (chat.meta or {}).get('type') == 'note') + or ( + bool(metadata.get('session_id')) + and metadata.get('params', {}).get('function_calling') != 'legacy' + and (model.get('info', {}).get('meta', {}).get('capabilities') or {}).get('builtin_tools', True) + ) ) if skill_ids: diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index 9e692eb857..5edf76a122 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -41,6 +41,7 @@ from open_webui.env import ( REDIS_KEY_PREFIX, ) from open_webui.models.access_grants import AccessGrants +from open_webui.models.chats import Chats from open_webui.models.config import Config from open_webui.models.groups import Groups from open_webui.models.tools import Tools @@ -606,7 +607,8 @@ async def get_builtin_tools( ): builtin_functions.extend([search_web, fetch_url]) - # Add image generation/edit tools if builtin category enabled AND enabled globally AND model has image_generation capability + # Add image generation/edit tools if builtin category enabled, + # globally enabled, and allowed by model capability. if ( is_builtin_tool_enabled('image_generation') and config.get('image_generation.enable') @@ -624,7 +626,8 @@ async def get_builtin_tools( ): builtin_functions.append(edit_image) - # Add code interpreter tool if builtin category enabled AND enabled globally AND model has code_interpreter capability + # Add code interpreter tool if builtin category enabled, + # globally enabled, and allowed by model capability. if ( is_builtin_tool_enabled('code_interpreter') and config.get('code_interpreter.enable') @@ -634,8 +637,17 @@ async def get_builtin_tools( ): builtin_functions.append(execute_code) + metadata = extra_params.get('__metadata__') or {} + chat_id = metadata.get('chat_id') or '' + chat = None + if chat_id and not chat_id.startswith(('local:', 'channel:')): + chat = await Chats.get_chat_by_id(chat_id) + # Notes tools - search, view, create, and update user's notes - if is_builtin_tool_enabled('notes') and config.get('notes.enable') and await has_user_permission('notes'): + if ( + (chat and (chat.meta or {}).get('internal') is True and (chat.meta or {}).get('type') == 'note') + or (is_builtin_tool_enabled('notes') and config.get('notes.enable') and await has_user_permission('notes')) + ): builtin_functions.extend([search_notes, view_note, write_note, replace_note_content, replace_note_text]) # Channels tools - search channels and messages diff --git a/src/app.css b/src/app.css index 702891eba8..ad4feae9cb 100644 --- a/src/app.css +++ b/src/app.css @@ -122,7 +122,7 @@ textarea::-webkit-scrollbar-corner { } .markdown-prose { - @apply prose prose-sm dark:prose-invert max-w-none break-words font-normal leading-relaxed prose-p:mt-0 prose-p:mb-2 prose-p:font-normal prose-p:leading-relaxed prose-headings:mt-2 prose-headings:mb-1 prose-headings:font-normal prose-headings:leading-snug prose-h1:text-xl prose-h2:text-lg prose-h3:text-base prose-strong:font-medium prose-code:before:content-none prose-code:after:content-none prose-ul:my-2 prose-ol:my-2 prose-li:my-0.5 prose-li:font-normal prose-pre:my-3 prose-table:my-0 prose-blockquote:my-3 prose-blockquote:font-normal prose-hr:my-4 prose-hr:border-gray-50 prose-hr:dark:border-gray-850/30 prose-img:my-2 [&>:first-child]:mt-0 [&>:last-child]:mb-0 [&_p:first-child]:mt-0 [&_h1:first-child]:mt-0 [&_h2:first-child]:mt-0 [&_h3:first-child]:mt-0 [&_h4:first-child]:mt-0 [&_h5:first-child]:mt-0 [&_h6:first-child]:mt-0; + @apply prose prose-sm dark:prose-invert max-w-none break-words !text-[0.9375rem] font-normal leading-relaxed prose-p:mt-0 prose-p:mb-2 prose-p:font-normal prose-p:leading-relaxed prose-headings:mt-2 prose-headings:mb-1 prose-headings:font-normal prose-headings:leading-snug prose-h1:text-xl prose-h2:text-lg prose-h3:text-base prose-strong:font-medium prose-code:before:content-none prose-code:after:content-none prose-ul:my-2 prose-ol:my-2 prose-li:my-0.5 prose-li:font-normal prose-pre:my-3 prose-table:my-0 prose-blockquote:my-3 prose-blockquote:font-normal prose-hr:my-4 prose-hr:border-gray-50 prose-hr:dark:border-gray-850/30 prose-img:my-2 [&>:first-child]:mt-0 [&>:last-child]:mb-0 [&_p:first-child]:mt-0 [&_h1:first-child]:mt-0 [&_h2:first-child]:mt-0 [&_h3:first-child]:mt-0 [&_h4:first-child]:mt-0 [&_h5:first-child]:mt-0 [&_h6:first-child]:mt-0; } .markdown-prose-sm { diff --git a/src/lib/components/chat/Messages/ContentRenderer.svelte b/src/lib/components/chat/Messages/ContentRenderer.svelte index bd34de9e90..dad616d39d 100644 --- a/src/lib/components/chat/Messages/ContentRenderer.svelte +++ b/src/lib/components/chat/Messages/ContentRenderer.svelte @@ -311,7 +311,7 @@ {/if} {#if extracted.plainContent} -
{extracted.plainContent}
+
{extracted.plainContent}
{/if} {/if} diff --git a/src/lib/components/chat/Messages/Markdown/ConsecutiveDetailsGroup.svelte b/src/lib/components/chat/Messages/Markdown/ConsecutiveDetailsGroup.svelte index 27770102aa..dbd737b236 100644 --- a/src/lib/components/chat/Messages/Markdown/ConsecutiveDetailsGroup.svelte +++ b/src/lib/components/chat/Messages/Markdown/ConsecutiveDetailsGroup.svelte @@ -112,7 +112,7 @@