mirror of
https://github.com/open-webui/open-webui
synced 2025-06-22 18:07:17 +00:00
Update Chat.svelte
This commit is contained in:
parent
e97bd47336
commit
62ff79d350
@ -36,7 +36,11 @@
|
|||||||
chatTitle,
|
chatTitle,
|
||||||
showArtifacts,
|
showArtifacts,
|
||||||
tools,
|
tools,
|
||||||
toolServers
|
toolServers,
|
||||||
|
pendingFolderId,
|
||||||
|
pendingFolderName,
|
||||||
|
folders,
|
||||||
|
refreshSidebar
|
||||||
} from '$lib/stores';
|
} from '$lib/stores';
|
||||||
import {
|
import {
|
||||||
convertMessagesToHistory,
|
convertMessagesToHistory,
|
||||||
@ -65,6 +69,7 @@
|
|||||||
getTagsById,
|
getTagsById,
|
||||||
updateChatById
|
updateChatById
|
||||||
} from '$lib/apis/chats';
|
} from '$lib/apis/chats';
|
||||||
|
import { getFolders } from '$lib/apis/folders';
|
||||||
import { generateOpenAIChatCompletion } from '$lib/apis/openai';
|
import { generateOpenAIChatCompletion } from '$lib/apis/openai';
|
||||||
import { processWeb, processWebSearch, processYoutubeVideo } from '$lib/apis/retrieval';
|
import { processWeb, processWebSearch, processYoutubeVideo } from '$lib/apis/retrieval';
|
||||||
import { createOpenAITextStream } from '$lib/apis/streaming';
|
import { createOpenAITextStream } from '$lib/apis/streaming';
|
||||||
@ -308,11 +313,9 @@
|
|||||||
}
|
}
|
||||||
} else if (type === 'chat:title') {
|
} else if (type === 'chat:title') {
|
||||||
chatTitle.set(data);
|
chatTitle.set(data);
|
||||||
currentChatPage.set(1);
|
await $refreshSidebar();
|
||||||
await chats.set(await getChatList(localStorage.token, $currentChatPage));
|
|
||||||
} else if (type === 'chat:tags') {
|
} else if (type === 'chat:tags') {
|
||||||
chat = await getChatById(localStorage.token, $chatId);
|
await $refreshSidebar();
|
||||||
allTags.set(await getAllTags(localStorage.token));
|
|
||||||
} else if (type === 'source' || type === 'citation') {
|
} else if (type === 'source' || type === 'citation') {
|
||||||
if (data?.type === 'code_execution') {
|
if (data?.type === 'code_execution') {
|
||||||
// Code execution; update existing code execution by ID, or add new one.
|
// Code execution; update existing code execution by ID, or add new one.
|
||||||
@ -708,7 +711,8 @@
|
|||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
|
||||||
const initNewChat = async () => {
|
const initNewChat = async () => {
|
||||||
const availableModels = $models
|
|
||||||
|
const availableModels = $models
|
||||||
.filter((m) => !(m?.info?.meta?.hidden ?? false))
|
.filter((m) => !(m?.info?.meta?.hidden ?? false))
|
||||||
.map((m) => m.id);
|
.map((m) => m.id);
|
||||||
|
|
||||||
@ -1958,14 +1962,17 @@
|
|||||||
history: history,
|
history: history,
|
||||||
messages: createMessagesList(history, history.currentId),
|
messages: createMessagesList(history, history.currentId),
|
||||||
tags: [],
|
tags: [],
|
||||||
|
folder_id: $pendingFolderId,
|
||||||
timestamp: Date.now()
|
timestamp: Date.now()
|
||||||
});
|
});
|
||||||
|
|
||||||
_chatId = chat.id;
|
_chatId = chat.id;
|
||||||
await chatId.set(_chatId);
|
await chatId.set(_chatId);
|
||||||
|
|
||||||
await chats.set(await getChatList(localStorage.token, $currentChatPage));
|
// Clear the pending folder after creating the chat
|
||||||
currentChatPage.set(1);
|
$refreshSidebar();
|
||||||
|
pendingFolderId.set(null);
|
||||||
|
pendingFolderName.set(null);
|
||||||
|
|
||||||
window.history.replaceState(history.state, '', `/c/${_chatId}`);
|
window.history.replaceState(history.state, '', `/c/${_chatId}`);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user