Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
52cae406
Commit
52cae406
authored
Jul 01, 2024
by
Timothy J. Baek
Browse files
feat: chat event handler
parent
d6dbd73e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
src/lib/components/chat/Chat.svelte
src/lib/components/chat/Chat.svelte
+22
-3
No files found.
src/lib/components/chat/Chat.svelte
View file @
52cae406
...
...
@@ -126,6 +126,27 @@
})();
}
const chatEventHandler = async (data) => {
if (data.chat_id === $chatId) {
await tick();
console.log(data);
let message = history.messages[data.message_id];
const status = {
done: data?.data?.done ?? null,
description: data?.data?.status ?? null
};
if (message.statusHistory) {
message.statusHistory.push(status);
} else {
message.statusHistory = [status];
}
messages = messages;
}
};
onMount(async () => {
const onMessageHandler = async (event) => {
if (event.origin === window.origin) {
...
...
@@ -163,9 +184,7 @@
};
window.addEventListener('message', onMessageHandler);
$socket.on('chat-events', async (data) => {
console.log(data);
});
$socket.on('chat-events', chatEventHandler);
if (!$chatId) {
chatId.subscribe(async (value) => {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment