diff --git a/src/lib/components/chat/ModelSelector/Selector.svelte b/src/lib/components/chat/ModelSelector/Selector.svelte index b4cb5d003..8a126d85a 100644 --- a/src/lib/components/chat/ModelSelector/Selector.svelte +++ b/src/lib/components/chat/ModelSelector/Selector.svelte @@ -52,12 +52,17 @@ export let className = 'w-[32rem]'; export let triggerClassName = 'text-lg'; + let tagsContainerElement; + let show = false; + let tags = []; let selectedModel = ''; $: selectedModel = items.find((item) => item.value === value) ?? ''; let searchValue = ''; + let selectedTag = ''; + let ollamaVersion = null; let selectedModelIdx = 0; @@ -79,10 +84,23 @@ ); $: filteredItems = searchValue - ? fuse.search(searchValue).map((e) => { - return e.item; - }) - : items; + ? fuse + .search(searchValue) + .map((e) => { + return e.item; + }) + .filter((item) => { + if (selectedTag === '') { + return true; + } + return item.model?.info?.meta?.tags?.map((tag) => tag.name).includes(selectedTag); + }) + : items.filter((item) => { + if (selectedTag === '') { + return true; + } + return item.model?.info?.meta?.tags?.map((tag) => tag.name).includes(selectedTag); + }); const pullModelHandler = async () => { const sanitizedModelTag = searchValue.trim().replace(/^ollama\s+(run|pull)\s+/, ''); @@ -214,6 +232,11 @@ onMount(async () => { ollamaVersion = await getOllamaVersion(localStorage.token).catch((error) => false); + + if (items) { + tags = items.flatMap((item) => item.model?.info?.meta?.tags ?? []); + tags = [...new Set(tags)].map((tag) => tag.name).sort(); + } }); const cancelModelPullHandler = async (model: string) => { @@ -298,10 +321,43 @@ /> -