mirror of
https://github.com/open-webui/open-webui
synced 2025-03-04 03:18:03 +00:00
feat: chat event handler
This commit is contained in:
parent
d6dbd73ec9
commit
52cae406b4
@ -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 () => {
|
onMount(async () => {
|
||||||
const onMessageHandler = async (event) => {
|
const onMessageHandler = async (event) => {
|
||||||
if (event.origin === window.origin) {
|
if (event.origin === window.origin) {
|
||||||
@ -163,9 +184,7 @@
|
|||||||
};
|
};
|
||||||
window.addEventListener('message', onMessageHandler);
|
window.addEventListener('message', onMessageHandler);
|
||||||
|
|
||||||
$socket.on('chat-events', async (data) => {
|
$socket.on('chat-events', chatEventHandler);
|
||||||
console.log(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!$chatId) {
|
if (!$chatId) {
|
||||||
chatId.subscribe(async (value) => {
|
chatId.subscribe(async (value) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user