From b58b0ea7ca849b89d217e1077498a8a3fc92471f Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 29 Jun 2026 04:13:17 -0500 Subject: [PATCH] refac --- src/lib/components/common/Tags.svelte | 144 +++++++++++++++--- .../workspace/Models/ModelEditor.svelte | 13 ++ 2 files changed, 138 insertions(+), 19 deletions(-) diff --git a/src/lib/components/common/Tags.svelte b/src/lib/components/common/Tags.svelte index 65340f3320..1203feba9e 100644 --- a/src/lib/components/common/Tags.svelte +++ b/src/lib/components/common/Tags.svelte @@ -1,25 +1,81 @@ + +
{#if !disabled} - { - if (event.key === 'Enter' || event.key === ' ') { - event.preventDefault(); - addTag(); - } - }} - /> +
+ 0} + autocomplete="off" + on:focus={() => { + suggestionsOpen = true; + positionPopup(); + }} + on:input={() => { + suggestionsOpen = true; + positionPopup(); + }} + on:keydown={(event) => { + if (event.key === 'Enter' || event.key === ' ') { + event.preventDefault(); + addTag(); + } else if (event.key === 'Escape') { + suggestionsOpen = false; + } + }} + on:blur={() => { + setTimeout(() => { + if (!popupElement?.contains(document.activeElement)) { + suggestionsOpen = false; + } + }, 0); + }} + /> + + {#if suggestionsOpen && filteredSuggestionTags.length > 0} +
+ {#each filteredSuggestionTags as tag (tag)} + + {/each} +
+ {/if} +
{/if}
diff --git a/src/lib/components/workspace/Models/ModelEditor.svelte b/src/lib/components/workspace/Models/ModelEditor.svelte index 27cf77aa46..24bbc75edf 100644 --- a/src/lib/components/workspace/Models/ModelEditor.svelte +++ b/src/lib/components/workspace/Models/ModelEditor.svelte @@ -9,6 +9,7 @@ import { getSkills } from '$lib/apis/skills'; import { getFunctions } from '$lib/apis/functions'; import { getModelsDefaults } from '$lib/apis/configs'; + import { getBaseModelTags, getModelTags } from '$lib/apis/models'; import AdvancedParams from '$lib/components/chat/Settings/Advanced/AdvancedParams.svelte'; import Tags from '$lib/components/common/Tags.svelte'; @@ -106,6 +107,14 @@ let accessGrants = []; let terminalId = ''; let tts = { voice: '' }; + export let suggestionTags: { name: string }[] = []; + + const loadSuggestionTags = async () => { + const res: string[] = await (preset ? getModelTags : getBaseModelTags)( + localStorage.token + ).catch(() => []); + suggestionTags = res.map((tag) => ({ name: tag })); + }; const submitHandler = async () => { loading = true; @@ -255,6 +264,9 @@ if (!$functions) { await functions.set(await getFunctions(localStorage.token)); } + if (suggestionTags.length === 0) { + await loadSuggestionTags(); + } // Fetch admin-configured default model metadata so the editor // reflects the actual defaults rather than hardcoded values @@ -651,6 +663,7 @@
{ const tagName = e.detail; info.meta.tags = info.meta.tags.filter((tag) => tag.name !== tagName);