mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
feat: __event_call__ support
This commit is contained in:
@@ -61,6 +61,7 @@
|
||||
import CallOverlay from './MessageInput/CallOverlay.svelte';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import ChatControls from './ChatControls.svelte';
|
||||
import EventConfirmDialog from '../common/ConfirmDialog.svelte';
|
||||
|
||||
const i18n: Writable<i18nType> = getContext('i18n');
|
||||
|
||||
@@ -74,6 +75,11 @@
|
||||
let processing = '';
|
||||
let messagesContainerElement: HTMLDivElement;
|
||||
|
||||
let showEventConfirmation = false;
|
||||
let eventConfirmationTitle = '';
|
||||
let eventConfirmationMessage = '';
|
||||
let eventCallback = null;
|
||||
|
||||
let showModelSelector = true;
|
||||
|
||||
let selectedModels = [''];
|
||||
@@ -129,7 +135,7 @@
|
||||
})();
|
||||
}
|
||||
|
||||
const chatEventHandler = async (event) => {
|
||||
const chatEventHandler = async (event, cb) => {
|
||||
if (event.chat_id === $chatId) {
|
||||
await tick();
|
||||
console.log(event);
|
||||
@@ -139,17 +145,23 @@
|
||||
const data = event?.data?.data ?? null;
|
||||
|
||||
if (type === 'status') {
|
||||
if (message.statusHistory) {
|
||||
if (message?.statusHistory) {
|
||||
message.statusHistory.push(data);
|
||||
} else {
|
||||
message.statusHistory = [data];
|
||||
}
|
||||
} else if (type === 'citation') {
|
||||
if (message.citations) {
|
||||
if (message?.citations) {
|
||||
message.citations.push(data);
|
||||
} else {
|
||||
message.citations = [data];
|
||||
}
|
||||
} else if (type === 'confirmation') {
|
||||
eventCallback = cb;
|
||||
showEventConfirmation = true;
|
||||
|
||||
eventConfirmationTitle = data.title;
|
||||
eventConfirmationMessage = data.message;
|
||||
} else {
|
||||
console.log('Unknown message type', data);
|
||||
}
|
||||
@@ -1392,6 +1404,18 @@
|
||||
|
||||
<audio id="audioElement" src="" style="display: none;" />
|
||||
|
||||
<EventConfirmDialog
|
||||
bind:show={showEventConfirmation}
|
||||
title={eventConfirmationTitle}
|
||||
message={eventConfirmationMessage}
|
||||
on:confirm={(e) => {
|
||||
eventCallback(true);
|
||||
}}
|
||||
on:cancel={() => {
|
||||
eventCallback(false);
|
||||
}}
|
||||
/>
|
||||
|
||||
{#if $showCallOverlay}
|
||||
<CallOverlay
|
||||
{submitPrompt}
|
||||
|
||||
Reference in New Issue
Block a user