From dc6ca61548927924ddbe82ce8dbf4fac41c5d7cb Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 15 Aug 2024 16:54:16 +0200 Subject: [PATCH] enh: temp chat deprecates chat history setting and introduces temp chat from model selector --- src/lib/components/chat/Chat.svelte | 17 +- .../chat/Messages/Placeholder.svelte | 15 +- src/lib/components/chat/ModelSelector.svelte | 1 + .../chat/ModelSelector/Selector.svelte | 30 +- src/lib/components/chat/Settings/Chats.svelte | 74 +---- .../documents/Settings/ChunkParams.svelte | 126 -------- .../documents/Settings/QueryParams.svelte | 119 -------- .../documents/Settings/WebParams.svelte | 285 ------------------ .../components/documents/SettingsModal.svelte | 187 ------------ .../components/icons/ChatBubbleOval.svelte | 19 ++ src/lib/components/icons/EyeSlash.svelte | 19 ++ src/lib/components/layout/Sidebar.svelte | 48 +-- src/lib/stores/index.ts | 2 +- 13 files changed, 99 insertions(+), 843 deletions(-) delete mode 100644 src/lib/components/documents/Settings/ChunkParams.svelte delete mode 100644 src/lib/components/documents/Settings/QueryParams.svelte delete mode 100644 src/lib/components/documents/Settings/WebParams.svelte delete mode 100644 src/lib/components/documents/SettingsModal.svelte create mode 100644 src/lib/components/icons/ChatBubbleOval.svelte create mode 100644 src/lib/components/icons/EyeSlash.svelte diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 64b51be96..b81315ced 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -26,7 +26,8 @@ socket, showCallOverlay, tools, - currentChatPage + currentChatPage, + temporaryChatEnabled } from '$lib/stores'; import { convertMessagesToHistory, @@ -238,7 +239,7 @@ } }); } else { - if (!($settings.saveChatHistory ?? true)) { + if ($temporaryChatEnabled) { await goto('/'); } } @@ -414,7 +415,7 @@ } if ($chatId == chatId) { - if ($settings.saveChatHistory ?? true) { + if (!$temporaryChatEnabled) { chat = await updateChatById(localStorage.token, chatId, { models: selectedModels, messages: messages, @@ -462,7 +463,7 @@ } if ($chatId == chatId) { - if ($settings.saveChatHistory ?? true) { + if (!$temporaryChatEnabled) { chat = await updateChatById(localStorage.token, chatId, { models: selectedModels, messages: messages, @@ -620,7 +621,7 @@ // Create new chat if only one message in messages if (newChat && messages.length == 2) { - if ($settings.saveChatHistory ?? true) { + if (!$temporaryChatEnabled) { chat = await createNewChat(localStorage.token, { id: $chatId, title: $i18n.t('New Chat'), @@ -954,7 +955,7 @@ } if ($chatId == _chatId) { - if ($settings.saveChatHistory ?? true) { + if (!$temporaryChatEnabled) { chat = await updateChatById(localStorage.token, _chatId, { messages: messages, history: history, @@ -1227,7 +1228,7 @@ } if ($chatId == _chatId) { - if ($settings.saveChatHistory ?? true) { + if (!$temporaryChatEnabled) { chat = await updateChatById(localStorage.token, _chatId, { models: selectedModels, messages: messages, @@ -1400,7 +1401,7 @@ title = _title; } - if ($settings.saveChatHistory ?? true) { + if (!$temporaryChatEnabled) { chat = await updateChatById(localStorage.token, _chatId, { title: _title }); currentChatPage.set(1); diff --git a/src/lib/components/chat/Messages/Placeholder.svelte b/src/lib/components/chat/Messages/Placeholder.svelte index 34038a608..6b4c41744 100644 --- a/src/lib/components/chat/Messages/Placeholder.svelte +++ b/src/lib/components/chat/Messages/Placeholder.svelte @@ -2,7 +2,7 @@ import { WEBUI_BASE_URL } from '$lib/constants'; import { marked } from 'marked'; - import { config, user, models as _models } from '$lib/stores'; + import { config, user, models as _models, temporaryChatEnabled } from '$lib/stores'; import { onMount, getContext } from 'svelte'; import { blur, fade } from 'svelte/transition'; @@ -10,6 +10,7 @@ import Suggestions from '../MessageInput/Suggestions.svelte'; import { sanitizeResponseContent } from '$lib/utils'; import Tooltip from '$lib/components/common/Tooltip.svelte'; + import EyeSlash from '$lib/components/icons/EyeSlash.svelte'; const i18n = getContext('i18n'); @@ -64,6 +65,18 @@ + {#if $temporaryChatEnabled} + +
+ Temporary Chat +
+
+ {/if} +
diff --git a/src/lib/components/chat/ModelSelector.svelte b/src/lib/components/chat/ModelSelector.svelte index c045d138e..eb4be9d81 100644 --- a/src/lib/components/chat/ModelSelector.svelte +++ b/src/lib/components/chat/ModelSelector.svelte @@ -46,6 +46,7 @@ label: model.name, model: model }))} + showTemporaryChatControl={true} bind:value={selectedModel} />
diff --git a/src/lib/components/chat/ModelSelector/Selector.svelte b/src/lib/components/chat/ModelSelector/Selector.svelte index b710bce25..5b312848c 100644 --- a/src/lib/components/chat/ModelSelector/Selector.svelte +++ b/src/lib/components/chat/ModelSelector/Selector.svelte @@ -12,12 +12,14 @@ import { deleteModel, getOllamaVersion, pullModel } from '$lib/apis/ollama'; - import { user, MODEL_DOWNLOAD_POOL, models, mobile } from '$lib/stores'; + import { user, MODEL_DOWNLOAD_POOL, models, mobile, temporaryChatEnabled } from '$lib/stores'; import { toast } from 'svelte-sonner'; import { capitalizeFirstLetter, sanitizeResponseContent, splitStream } from '$lib/utils'; import { getModels } from '$lib/apis'; import Tooltip from '$lib/components/common/Tooltip.svelte'; + import Switch from '$lib/components/common/Switch.svelte'; + import ChatBubbleOval from '$lib/components/icons/ChatBubbleOval.svelte'; const i18n = getContext('i18n'); const dispatch = createEventDispatcher(); @@ -27,6 +29,8 @@ export let searchEnabled = true; export let searchPlaceholder = $i18n.t('Search a model'); + export let showTemporaryChatControl = false; + export let items: { label: string; value: string; @@ -514,6 +518,30 @@ {/each} + {#if showTemporaryChatControl} +
+ +
+ +
+ {/if} +