diff --git a/backend/open_webui/models/chats.py b/backend/open_webui/models/chats.py index 194823e96a..b9de2e5a4e 100644 --- a/backend/open_webui/models/chats.py +++ b/backend/open_webui/models/chats.py @@ -73,7 +73,6 @@ class ChatForm(BaseModel): class ChatImportForm(ChatForm): meta: Optional[dict] = {} pinned: Optional[bool] = False - folder_id: Optional[str] = None created_at: Optional[int] = None updated_at: Optional[int] = None diff --git a/src/lib/apis/chats/index.ts b/src/lib/apis/chats/index.ts index 68650aa214..b1e7d5f23b 100644 --- a/src/lib/apis/chats/index.ts +++ b/src/lib/apis/chats/index.ts @@ -1,7 +1,7 @@ import { WEBUI_API_BASE_URL } from '$lib/constants'; import { getTimeRange } from '$lib/utils'; -export const createNewChat = async (token: string, chat: object) => { +export const createNewChat = async (token: string, chat: object, folderId: string | null) => { let error = null; const res = await fetch(`${WEBUI_API_BASE_URL}/chats/new`, { @@ -12,7 +12,8 @@ export const createNewChat = async (token: string, chat: object) => { authorization: `Bearer ${token}` }, body: JSON.stringify({ - chat: chat + chat: chat, + folder_id: folderId ?? null }) }) .then(async (res) => { diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index c51a1dd8cd..6d0b31e85d 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -1979,18 +1979,22 @@ let _chatId = $chatId; if (!$temporaryChatEnabled) { - chat = await createNewChat(localStorage.token, { - id: _chatId, - title: $i18n.t('New Chat'), - models: selectedModels, - system: $settings.system ?? undefined, - params: params, - history: history, - messages: createMessagesList(history, history.currentId), - tags: [], - ...($selectedFolder ? { folder_id: $selectedFolder?.id } : {}), - timestamp: Date.now() - }); + chat = await createNewChat( + localStorage.token, + { + id: _chatId, + title: $i18n.t('New Chat'), + models: selectedModels, + system: $settings.system ?? undefined, + params: params, + history: history, + messages: createMessagesList(history, history.currentId), + tags: [], + + timestamp: Date.now() + }, + $selectedFolder?.id + ); _chatId = chat.id; await chatId.set(_chatId);