diff --git a/backend/apps/web/routers/chats.py b/backend/apps/web/routers/chats.py index 54b529e6..794eb7f7 100644 --- a/backend/apps/web/routers/chats.py +++ b/backend/apps/web/routers/chats.py @@ -107,3 +107,13 @@ async def update_chat_by_id( async def delete_chat_by_id(id: str, user=Depends(get_current_user)): result = Chats.delete_chat_by_id_and_user_id(id, user.id) return result + +############################ +# DeleteAllChats +############################ + + +@router.delete("/", response_model=bool) +async def delete_all_user_chats(user=Depends(get_current_user)): + result = Chats.delete_chats_by_user_id(user.id) + return result diff --git a/src/lib/apis/chats/index.ts b/src/lib/apis/chats/index.ts index 354e4f74..0eddf5b4 100644 --- a/src/lib/apis/chats/index.ts +++ b/src/lib/apis/chats/index.ts @@ -191,3 +191,35 @@ export const deleteChatById = async (token: string, id: string) => { return res; }; + +export const deleteAllChats = async (token: string) => { + let error = null; + + const res = await fetch(`${WEBUI_API_BASE_URL}/chats/`, { + method: 'DELETE', + 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; + + console.log(err); + return null; + }); + + if (error) { + throw error; + } + + return res; +}; diff --git a/src/lib/components/chat/Messages.svelte b/src/lib/components/chat/Messages.svelte index df8a72b8..3920a40d 100644 --- a/src/lib/components/chat/Messages.svelte +++ b/src/lib/components/chat/Messages.svelte @@ -1,12 +1,5 @@ {#if messages.length == 0} -
-
- {#if selectedModelfile && selectedModelfile.imageUrl} - modelfile - {:else} - ollama - {/if} -
-
- {#if selectedModelfile} - - {selectedModelfile.title} - -
- {selectedModelfile.desc} -
- {#if selectedModelfile.user} - - {/if} - {:else} - How can I help you today? - {/if} -
-
+ {:else} {#each messages as message, messageIdx}
-
-
- {#if message.role === 'user'} - {#if $config === null || !($config?.auth ?? true)} - User profile - {:else} - User profile - {/if} - {:else if selectedModelfile} - Ollama profile - {:else} - Ollama profile - {/if} -
- -
-
- {#if message.role === 'user'} - You - {:else if selectedModelfile} - - {selectedModelfile.title} - - {:else} - Ollama {message.model ? ` ${message.model}` : ''} - {/if} -
- - {#if message.role !== 'user' && message.content === ''} -
-
-
-
- -
-
-
-
-
-
-
-
-
- -
-
-
-
- {:else} -
- {#if message.role == 'user'} - {#if message.files} -
- {#each message.files as file} -
- {#if file.type === 'image'} - input - {/if} -
- {/each} -
- {/if} - - {#if message?.edit === true} -
-