mirror of
https://github.com/open-webui/open-webui
synced 2025-04-20 22:35:03 +00:00
enh: local, external, direct model list filter
Co-Authored-By: recrudesce <6450799+recrudesce@users.noreply.github.com>
This commit is contained in:
parent
c58f0844a3
commit
53a2acd541
@ -61,7 +61,9 @@
|
|||||||
$: selectedModel = items.find((item) => item.value === value) ?? '';
|
$: selectedModel = items.find((item) => item.value === value) ?? '';
|
||||||
|
|
||||||
let searchValue = '';
|
let searchValue = '';
|
||||||
|
|
||||||
let selectedTag = '';
|
let selectedTag = '';
|
||||||
|
let selectedConnectionType = '';
|
||||||
|
|
||||||
let ollamaVersion = null;
|
let ollamaVersion = null;
|
||||||
|
|
||||||
@ -95,12 +97,35 @@
|
|||||||
}
|
}
|
||||||
return item.model?.info?.meta?.tags?.map((tag) => tag.name).includes(selectedTag);
|
return item.model?.info?.meta?.tags?.map((tag) => tag.name).includes(selectedTag);
|
||||||
})
|
})
|
||||||
: items.filter((item) => {
|
.filter((item) => {
|
||||||
if (selectedTag === '') {
|
if (selectedConnectionType === '') {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (selectedConnectionType === 'ollama') {
|
||||||
return item.model?.info?.meta?.tags?.map((tag) => tag.name).includes(selectedTag);
|
return item.model?.owned_by === 'ollama';
|
||||||
});
|
} else if (selectedConnectionType === 'openai') {
|
||||||
|
return item.model?.owned_by === 'openai';
|
||||||
|
} else if (selectedConnectionType === 'direct') {
|
||||||
|
return item.model?.direct;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
: items
|
||||||
|
.filter((item) => {
|
||||||
|
if (selectedTag === '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return item.model?.info?.meta?.tags?.map((tag) => tag.name).includes(selectedTag);
|
||||||
|
})
|
||||||
|
.filter((item) => {
|
||||||
|
if (selectedConnectionType === '') {
|
||||||
|
return true;
|
||||||
|
} else if (selectedConnectionType === 'ollama') {
|
||||||
|
return item.model?.owned_by === 'ollama';
|
||||||
|
} else if (selectedConnectionType === 'openai') {
|
||||||
|
return item.model?.owned_by === 'openai';
|
||||||
|
} else if (selectedConnectionType === 'direct') {
|
||||||
|
return item.model?.direct;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const pullModelHandler = async () => {
|
const pullModelHandler = async () => {
|
||||||
const sanitizedModelTag = searchValue.trim().replace(/^ollama\s+(run|pull)\s+/, '');
|
const sanitizedModelTag = searchValue.trim().replace(/^ollama\s+(run|pull)\s+/, '');
|
||||||
@ -332,48 +357,59 @@
|
|||||||
bind:this={tagsContainerElement}
|
bind:this={tagsContainerElement}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="min-w-fit outline-none p-1.5 {selectedTag === ''
|
class="min-w-fit outline-none p-1.5 {selectedTag === '' &&
|
||||||
|
selectedConnectionType === ''
|
||||||
? ''
|
? ''
|
||||||
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
selectedConnectionType = '';
|
||||||
selectedTag = '';
|
selectedTag = '';
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{$i18n.t('All')}
|
{$i18n.t('All')}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
{#if items.find((item) => item.model?.owned_by === 'ollama')}
|
||||||
class="min-w-fit outline-none p-1.5 {selectedTag === ''
|
<button
|
||||||
? ''
|
class="min-w-fit outline-none p-1.5 {selectedConnectionType === 'ollama'
|
||||||
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
? ''
|
||||||
on:click={() => {
|
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
||||||
selectedTag = '';
|
on:click={() => {
|
||||||
}}
|
selectedTag = '';
|
||||||
>
|
selectedConnectionType = 'ollama';
|
||||||
{$i18n.t('Local')}
|
}}
|
||||||
</button>
|
>
|
||||||
|
{$i18n.t('Local')}
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<button
|
{#if items.find((item) => item.model?.owned_by === 'openai')}
|
||||||
class="min-w-fit outline-none p-1.5 {selectedTag === ''
|
<button
|
||||||
? ''
|
class="min-w-fit outline-none p-1.5 {selectedConnectionType === 'openai'
|
||||||
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
? ''
|
||||||
on:click={() => {
|
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
||||||
selectedTag = '';
|
on:click={() => {
|
||||||
}}
|
selectedTag = '';
|
||||||
>
|
selectedConnectionType = 'openai';
|
||||||
{$i18n.t('External')}
|
}}
|
||||||
</button>
|
>
|
||||||
|
{$i18n.t('External')}
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<button
|
{#if items.find((item) => item.model?.direct)}
|
||||||
class="min-w-fit outline-none p-1.5 {selectedTag === ''
|
<button
|
||||||
? ''
|
class="min-w-fit outline-none p-1.5 {selectedConnectionType === 'direct'
|
||||||
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
? ''
|
||||||
on:click={() => {
|
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
||||||
selectedTag = '';
|
on:click={() => {
|
||||||
}}
|
selectedTag = '';
|
||||||
>
|
selectedConnectionType = 'direct';
|
||||||
{$i18n.t('Direct')}
|
}}
|
||||||
</button>
|
>
|
||||||
|
{$i18n.t('Direct')}
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#each tags as tag}
|
{#each tags as tag}
|
||||||
<button
|
<button
|
||||||
@ -381,6 +417,7 @@
|
|||||||
? ''
|
? ''
|
||||||
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
selectedConnectionType = '';
|
||||||
selectedTag = tag;
|
selectedTag = tag;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user