diff --git a/backend/apps/webui/routers/chats.py b/backend/apps/webui/routers/chats.py index 02c9335e0..5d52f40c9 100644 --- a/backend/apps/webui/routers/chats.py +++ b/backend/apps/webui/routers/chats.py @@ -148,7 +148,7 @@ async def get_archived_session_user_chat_list( ############################ -@router.get("/archive/all", response_model=List[ChatTitleIdResponse]) +@router.post("/archive/all", response_model=List[ChatTitleIdResponse]) async def archive_all_chats(user=Depends(get_current_user)): return Chats.archive_all_chats_by_user_id(user.id) diff --git a/src/lib/apis/chats/index.ts b/src/lib/apis/chats/index.ts index a72b51939..834e29d29 100644 --- a/src/lib/apis/chats/index.ts +++ b/src/lib/apis/chats/index.ts @@ -654,3 +654,35 @@ export const deleteAllChats = async (token: string) => { return res; }; + +export const archiveAllChats = async (token: string) => { + let error = null; + + const res = await fetch(`${WEBUI_API_BASE_URL}/chats/archive/all`, { + method: 'POST', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + ...(token && { authorization: `Bearer ${token}` }) + } + }) + .then(async (res) => { + if (!res.ok) throw await res.json(); + return res.json(); + }) + .then((json) => { + return json; + }) + .catch((err) => { + error = err.detail; + + console.log(err); + return null; + }); + + if (error) { + throw error; + } + + return res; +}; diff --git a/src/lib/components/chat/Settings/Chats.svelte b/src/lib/components/chat/Settings/Chats.svelte index ef16ca1d8..9837b79b9 100644 --- a/src/lib/components/chat/Settings/Chats.svelte +++ b/src/lib/components/chat/Settings/Chats.svelte @@ -5,6 +5,7 @@ import { chats, user, config } from '$lib/stores'; import { + archiveAllChats, createNewChat, deleteAllChats, getAllChats, @@ -22,7 +23,10 @@ // Chats let saveChatHistory = true; let importFiles; + + let showArchiveConfirm = false; let showDeleteConfirm = false; + let chatImportInputElement: HTMLInputElement; $: if (importFiles) { @@ -68,6 +72,14 @@ saveAs(blob, `chat-export-${Date.now()}.json`); }; + const archiveAllChatsHandler = async () => { + await goto('/'); + await archiveAllChats(localStorage.token).catch((error) => { + toast.error(error); + }); + await chats.set(await getChatList(localStorage.token)); + }; + const deleteAllChatsHandler = async () => { await goto('/'); await deleteAllChats(localStorage.token).catch((error) => { @@ -210,88 +222,177 @@
{$i18n.t('Name')} | - -- | ||||
---|---|---|---|---|---|
-
-
- {chat.title}
-
-
- |
-
-
-
-
-
-
- |
+
{$i18n.t('Name')} | + +
---|