mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-13 04:45:19 +00:00
feat: chat event handler
This commit is contained in:
parent
d6dbd73ec9
commit
52cae406b4
1 changed files with 22 additions and 3 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue