From 287668f84ea295ace9517960029c048b1a98d5a4 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Wed, 17 Jan 2024 22:49:58 -0800 Subject: [PATCH] feat: tag add/remove frontend --- src/lib/components/layout/Navbar.svelte | 127 +++++++++++++++++++++--- 1 file changed, 112 insertions(+), 15 deletions(-) diff --git a/src/lib/components/layout/Navbar.svelte b/src/lib/components/layout/Navbar.svelte index e75dafd6..521e7abc 100644 --- a/src/lib/components/layout/Navbar.svelte +++ b/src/lib/components/layout/Navbar.svelte @@ -6,6 +6,7 @@ import { getChatById } from '$lib/apis/chats'; import { chatId, modelfiles } from '$lib/stores'; import ShareChatModal from '../chat/ShareChatModal.svelte'; + import { stringify } from 'postcss'; export let initNewChat: Function; export let title: string = 'Ollama Web UI'; @@ -13,6 +14,24 @@ let showShareChatModal = false; + let tags = [ + // { + // name: 'general' + // }, + // { + // name: 'medicine' + // }, + // { + // name: 'cooking' + // }, + // { + // name: 'education' + // } + ]; + + let tagName = ''; + let showTagInput = false; + const shareChat = async () => { const chat = (await getChatById(localStorage.token, $chatId)).chat; console.log('share', chat); @@ -54,6 +73,20 @@ saveAs(blob, `chat-${chat.title}.txt`); }; + + const addTag = () => { + if (!tags.find((e) => e.name === tagName)) { + tags = [ + ...tags, + { + name: JSON.parse(JSON.stringify(tagName)) + } + ]; + } + + tagName = ''; + showTagInput = false; + }; @@ -93,23 +126,87 @@
-
-
-
Add Tags
-
- + {#each tags as tag} +
+
+ {tag.name} +
+
+ {/each} + +
+ {#if showTagInput} +
+ + + +
+ + + {/if} + +