diff --git a/backend/apps/web/routers/chats.py b/backend/apps/web/routers/chats.py
index 798972e7..d5e63c0f 100644
--- a/backend/apps/web/routers/chats.py
+++ b/backend/apps/web/routers/chats.py
@@ -159,3 +159,23 @@ async def delete_chat_by_id(id: str, cred=Depends(bearer_scheme)):
status_code=status.HTTP_401_UNAUTHORIZED,
detail=ERROR_MESSAGES.INVALID_TOKEN,
)
+
+
+############################
+# DeleteAllChats
+############################
+
+
+@router.delete("/", response_model=bool)
+async def delete_all_user_chats(cred=Depends(bearer_scheme)):
+ token = cred.credentials
+ user = Users.get_user_by_token(token)
+
+ if user:
+ result = Chats.delete_chats_by_user_id(user.id)
+ return result
+ else:
+ raise HTTPException(
+ status_code=status.HTTP_401_UNAUTHORIZED,
+ detail=ERROR_MESSAGES.INVALID_TOKEN,
+ )
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}
-
- {:else}
-
- {/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)}
-
- {:else}
-
- {/if}
- {:else if selectedModelfile}
-
- {:else}
-
- {/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'}
-
- {/if}
-
- {/each}
-
- {/if}
-
- {#if message?.edit === true}
-
- {:else}
-
-
{message.content}
-
-
- {#if message.parentId !== null && message.parentId in history.messages && (history.messages[message.parentId]?.childrenIds.length ?? 0) > 1}
-
-
-
-
- {history.messages[message.parentId].childrenIds.indexOf(message.id) +
- 1} / {history.messages[message.parentId].childrenIds.length}
-
-
-
-
- {:else if message.parentId === null && Object.values(history.messages).filter((message) => message.parentId === null).length > 1}
-
-
-
-
- {Object.values(history.messages)
- .filter((message) => message.parentId === null)
- .map((message) => message.id)
- .indexOf(message.id) + 1} / {Object.values(history.messages).filter(
- (message) => message.parentId === null
- ).length}
-
-
-
-
- {/if}
-
-
-
-
-
-
- {/if}
- {/if}
-
- {#if message.role === 'assistant'}
-
- {#if message?.edit === true}
-
- {:else}
-
- {#if message?.error === true}
-
-
-
-
- {message.content}
-
-
- {:else}
- {@html marked(message.content.replace('\\\\', '\\\\\\'))}
- {/if}
-
- {#if message.done}
-
- {#if message.parentId !== null && message.parentId in history.messages && (history.messages[message.parentId]?.childrenIds.length ?? 0) > 1}
-
-
-
-
- {history.messages[message.parentId].childrenIds.indexOf(
- message.id
- ) + 1} / {history.messages[message.parentId].childrenIds.length}
-
-
-
-
- {/if}
-
-
-
-
-
-
-
-
-
-
- {#if message.info}
-
- {/if}
-
- {#if messageIdx + 1 === messages.length}
-
- {/if}
-
- {/if}
-
- {/if}
-
- {/if}
-
- {/if}
-
-
-
+ {#if message.role === 'user'}
+
message.parentId === null)
+ .map((message) => message.id) ?? []}
+ {confirmEditMessage}
+ {showPreviousMessage}
+ {showNextMessage}
+ {copyToClipboard}
+ />
+ {:else}
+
+ {/if}
{/each}
diff --git a/src/lib/components/chat/Messages/Name.svelte b/src/lib/components/chat/Messages/Name.svelte
new file mode 100644
index 00000000..4638e3b7
--- /dev/null
+++ b/src/lib/components/chat/Messages/Name.svelte
@@ -0,0 +1,3 @@
+
+
+
diff --git a/src/lib/components/chat/Messages/Placeholder.svelte b/src/lib/components/chat/Messages/Placeholder.svelte
new file mode 100644
index 00000000..1d709b5f
--- /dev/null
+++ b/src/lib/components/chat/Messages/Placeholder.svelte
@@ -0,0 +1,71 @@
+
+
+{#if models.length > 0}
+
+
+
+ {#each models as model, modelIdx}
+
+ {/each}
+
+
+
+ {#if modelfile}
+
+ {modelfile.title}
+
+
+ {modelfile.desc}
+
+ {#if modelfile.user}
+
+ {/if}
+ {:else}
+ How can I help you today?
+ {/if}
+
+
+{/if}
diff --git a/src/lib/components/chat/Messages/ProfileImage.svelte b/src/lib/components/chat/Messages/ProfileImage.svelte
new file mode 100644
index 00000000..84410d91
--- /dev/null
+++ b/src/lib/components/chat/Messages/ProfileImage.svelte
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte
new file mode 100644
index 00000000..bb81b2c9
--- /dev/null
+++ b/src/lib/components/chat/Messages/ResponseMessage.svelte
@@ -0,0 +1,537 @@
+
+
+
+
+
+
+
+ {#if message.model in modelfiles}
+ {modelfiles[message.model]?.title}
+ {:else}
+ Ollama {message.model ? ` ${message.model}` : ''}
+ {/if}
+
+
+ {#if message.content === ''}
+
+ {:else}
+
+
+ {#if edit === true}
+
+ {:else}
+
+ {#if message?.error === true}
+
+
+
+
+ {message.content}
+
+
+ {:else}
+ {@html marked(message.content.replace('\\\\', '\\\\\\'))}
+ {/if}
+
+ {#if message.done}
+
+ {#if siblings.length > 1}
+
+
+
+
+ {siblings.indexOf(message.id) + 1} / {siblings.length}
+
+
+
+
+ {/if}
+
+
+
+
+
+
+
+
+
+
+ {#if message.info}
+
+ {/if}
+
+ {#if isLastMessage}
+
+ {/if}
+
+ {/if}
+
+ {/if}
+
+
+ {/if}
+
+
diff --git a/src/lib/components/chat/Messages/Skeleton.svelte b/src/lib/components/chat/Messages/Skeleton.svelte
new file mode 100644
index 00000000..af8ca3fd
--- /dev/null
+++ b/src/lib/components/chat/Messages/Skeleton.svelte
@@ -0,0 +1,19 @@
+
diff --git a/src/lib/components/chat/Messages/UserMessage.svelte b/src/lib/components/chat/Messages/UserMessage.svelte
new file mode 100644
index 00000000..a760ce3a
--- /dev/null
+++ b/src/lib/components/chat/Messages/UserMessage.svelte
@@ -0,0 +1,195 @@
+
+
+
+
+
+
+
You
+
+
+ {#if message.files}
+
+ {#each message.files as file}
+
+ {#if file.type === 'image'}
+
+ {/if}
+
+ {/each}
+
+ {/if}
+
+ {#if edit === true}
+
+ {:else}
+
+
{message.content}
+
+
+ {#if siblings.length > 1}
+
+
+
+
+ {siblings.indexOf(message.id) + 1} / {siblings.length}
+
+
+
+
+ {/if}
+
+
+
+
+
+
+ {/if}
+
+
+
diff --git a/src/lib/components/chat/ModelSelector.svelte b/src/lib/components/chat/ModelSelector.svelte
index 626755e0..b4a0f47c 100644
--- a/src/lib/components/chat/ModelSelector.svelte
+++ b/src/lib/components/chat/ModelSelector.svelte
@@ -6,8 +6,8 @@
export let disabled = false;
const saveDefaultModel = () => {
- const hasEmptyModel = selectedModels.filter(it => it === '');
- if(hasEmptyModel.length){
+ const hasEmptyModel = selectedModels.filter((it) => it === '');
+ if (hasEmptyModel.length) {
toast.error('Choose a model before saving...');
return;
}
@@ -88,8 +88,9 @@
{#if selectedModelIdx === 0}