From 5eb9b00f8d92aabb215281b3389ac942872c3849 Mon Sep 17 00:00:00 2001 From: Jun Siang Cheah Date: Tue, 21 May 2024 18:30:31 +0100 Subject: [PATCH 1/2] refac: consolidate chat logic into single component --- src/lib/components/chat/Chat.svelte | 1052 ++++++++++++++++++++++++++ src/routes/(app)/+page.svelte | 987 +----------------------- src/routes/(app)/c/[id]/+page.svelte | 1001 +----------------------- 3 files changed, 1058 insertions(+), 1982 deletions(-) create mode 100644 src/lib/components/chat/Chat.svelte diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte new file mode 100644 index 000000000..1701d97e6 --- /dev/null +++ b/src/lib/components/chat/Chat.svelte @@ -0,0 +1,1052 @@ + + + + + {title + ? `${title.length > 30 ? `${title.slice(0, 30)}...` : title} | ${$WEBUI_NAME}` + : `${$WEBUI_NAME}`} + + + +{#if !chatIdProp || (loaded && chatIdProp)} +
+ 0} + {chat} + {initNewChat} + /> +
+ +
+
+ + +{/if} diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index ddb5fd35e..3af455a94 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -1,986 +1,5 @@ - - - - {title - ? `${title.length > 30 ? `${title.slice(0, 30)}...` : title} | ${$WEBUI_NAME}` - : `${$WEBUI_NAME}`} - - - -
- 0} - {chat} - {initNewChat} - /> -
- -
-
- - + diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index 34aa88b99..6e468b729 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -1,1001 +1,6 @@ - - - - {title - ? `${title.length > 30 ? `${title.slice(0, 30)}...` : title} | ${$WEBUI_NAME}` - : `${$WEBUI_NAME}`} - - - -{#if loaded} -
- 0} - initNewChat={async () => { - if (currentRequestId !== null) { - await cancelOllamaRequest(localStorage.token, currentRequestId); - currentRequestId = null; - } - - goto('/'); - }} - /> -
- -
-
- - -{/if} + From 6d237999dc1acb0a1d254b2934201402a4eada13 Mon Sep 17 00:00:00 2001 From: Jun Siang Cheah Date: Tue, 21 May 2024 18:45:03 +0100 Subject: [PATCH 2/2] fix: formatting --- src/lib/components/chat/Chat.svelte | 7 ++++++- src/routes/(app)/+page.svelte | 2 +- src/routes/(app)/c/[id]/+page.svelte | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 1701d97e6..f37e168b4 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -35,7 +35,12 @@ import MessageInput from '$lib/components/chat/MessageInput.svelte'; import Messages from '$lib/components/chat/Messages.svelte'; import Navbar from '$lib/components/layout/Navbar.svelte'; - import { LITELLM_API_BASE_URL, OLLAMA_API_BASE_URL, OPENAI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants'; + import { + LITELLM_API_BASE_URL, + OLLAMA_API_BASE_URL, + OPENAI_API_BASE_URL, + WEBUI_BASE_URL + } from '$lib/constants'; import { createOpenAITextStream } from '$lib/apis/streaming'; import { queryMemory } from '$lib/apis/memories'; import type { Writable } from 'svelte/store'; diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index 3af455a94..dcc0d4547 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -1,4 +1,4 @@ - diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index 6e468b729..4e0b565a6 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -1,4 +1,4 @@ -