diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 9ed493401..a35432566 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -541,7 +541,7 @@ async def process_chat_response(request, response, user, events, metadata, tasks for event in events: await event_emitter( { - "type": "chat-completion", + "type": "chat:completion", "data": event, } ) @@ -590,7 +590,7 @@ async def process_chat_response(request, response, user, events, metadata, tasks await event_emitter( { - "type": "chat-completion", + "type": "chat:completion", "data": data, } ) @@ -623,7 +623,7 @@ async def process_chat_response(request, response, user, events, metadata, tasks await event_emitter( { - "type": "chat-title", + "type": "chat:title", "data": title, } ) @@ -658,7 +658,7 @@ async def process_chat_response(request, response, user, events, metadata, tasks await event_emitter( { - "type": "chat-tags", + "type": "chat:tags", "data": tags, } ) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index d5cf55fc2..be2bd3566 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -244,13 +244,13 @@ message.sources = [data]; } } - } else if (type === 'chat-completion') { + } else if (type === 'chat:completion') { chatCompletionEventHandler(data, message, event.chat_id); - } else if (type === 'chat-title') { + } else if (type === 'chat:title') { chatTitle.set(data); currentChatPage.set(1); await chats.set(await getChatList(localStorage.token, $currentChatPage)); - } else if (type === 'chat-tags') { + } else if (type === 'chat:tags') { chat = await getChatById(localStorage.token, $chatId); allTags.set(await getAllTags(localStorage.token)); } else if (type === 'message') { @@ -303,6 +303,17 @@ history.messages[event.message_id] = message; } + } else { + await tick(); + const type = event?.data?.type ?? null; + const data = event?.data?.data ?? null; + + if (type === 'chat:title') { + currentChatPage.set(1); + await chats.set(await getChatList(localStorage.token, $currentChatPage)); + } else if (type === 'chat:tags') { + allTags.set(await getAllTags(localStorage.token)); + } } };