refac
This commit is contained in:
@@ -262,6 +262,21 @@
|
||||
} else {
|
||||
message.statusHistory = [data];
|
||||
}
|
||||
} else if (type === 'chat:completion') {
|
||||
chatCompletionEventHandler(data, message, event.chat_id);
|
||||
} else if (type === 'chat:message:delta' || type === 'message') {
|
||||
message.content += data.content;
|
||||
} else if (type === 'chat:message' || type === 'replace') {
|
||||
message.content = data.content;
|
||||
} else if (type === 'chat:message:files' || type === 'files') {
|
||||
message.files = data.files;
|
||||
} else if (type === 'chat:title') {
|
||||
chatTitle.set(data);
|
||||
currentChatPage.set(1);
|
||||
await chats.set(await getChatList(localStorage.token, $currentChatPage));
|
||||
} else if (type === 'chat:tags') {
|
||||
chat = await getChatById(localStorage.token, $chatId);
|
||||
allTags.set(await getAllTags(localStorage.token));
|
||||
} else if (type === 'source' || type === 'citation') {
|
||||
if (data?.type === 'code_execution') {
|
||||
// Code execution; update existing code execution by ID, or add new one.
|
||||
@@ -288,19 +303,19 @@
|
||||
message.sources = [data];
|
||||
}
|
||||
}
|
||||
} else if (type === 'chat:completion') {
|
||||
chatCompletionEventHandler(data, message, event.chat_id);
|
||||
} else if (type === 'chat:title') {
|
||||
chatTitle.set(data);
|
||||
currentChatPage.set(1);
|
||||
await chats.set(await getChatList(localStorage.token, $currentChatPage));
|
||||
} else if (type === 'chat:tags') {
|
||||
chat = await getChatById(localStorage.token, $chatId);
|
||||
allTags.set(await getAllTags(localStorage.token));
|
||||
} else if (type === 'chat:message:delta' || type === 'message') {
|
||||
message.content += data.content;
|
||||
} else if (type === 'chat:message' || type === 'replace') {
|
||||
message.content = data.content;
|
||||
} else if (type === 'notification') {
|
||||
const toastType = data?.type ?? 'info';
|
||||
const toastContent = data?.content ?? '';
|
||||
|
||||
if (toastType === 'success') {
|
||||
toast.success(toastContent);
|
||||
} else if (toastType === 'error') {
|
||||
toast.error(toastContent);
|
||||
} else if (toastType === 'warning') {
|
||||
toast.warning(toastContent);
|
||||
} else {
|
||||
toast.info(toastContent);
|
||||
}
|
||||
} else if (type === 'confirmation') {
|
||||
eventCallback = cb;
|
||||
|
||||
@@ -333,19 +348,6 @@
|
||||
eventConfirmationMessage = data.message;
|
||||
eventConfirmationInputPlaceholder = data.placeholder;
|
||||
eventConfirmationInputValue = data?.value ?? '';
|
||||
} else if (type === 'notification') {
|
||||
const toastType = data?.type ?? 'info';
|
||||
const toastContent = data?.content ?? '';
|
||||
|
||||
if (toastType === 'success') {
|
||||
toast.success(toastContent);
|
||||
} else if (toastType === 'error') {
|
||||
toast.error(toastContent);
|
||||
} else if (toastType === 'warning') {
|
||||
toast.warning(toastContent);
|
||||
} else {
|
||||
toast.info(toastContent);
|
||||
}
|
||||
} else {
|
||||
console.log('Unknown message type', data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user