2024-05-15 06:16:22 +00:00
|
|
|
<script lang="ts">
|
2024-09-21 20:12:41 +00:00
|
|
|
import { marked } from 'marked';
|
|
|
|
|
|
2024-05-15 06:16:22 +00:00
|
|
|
import { toast } from 'svelte-sonner';
|
2024-05-31 20:11:04 +00:00
|
|
|
import Sortable from 'sortablejs';
|
|
|
|
|
|
2024-05-15 06:16:22 +00:00
|
|
|
import fileSaver from 'file-saver';
|
|
|
|
|
const { saveAs } = fileSaver;
|
|
|
|
|
|
2024-05-31 20:11:04 +00:00
|
|
|
import { onMount, getContext, tick } from 'svelte';
|
2024-11-14 10:20:34 +00:00
|
|
|
import { goto } from '$app/navigation';
|
|
|
|
|
const i18n = getContext('i18n');
|
2024-05-15 06:16:22 +00:00
|
|
|
|
2024-11-14 10:20:34 +00:00
|
|
|
import { WEBUI_NAME, config, mobile, models as _models, settings, user } from '$lib/stores';
|
2025-11-21 01:43:59 +00:00
|
|
|
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
|
2024-11-15 10:05:43 +00:00
|
|
|
import {
|
|
|
|
|
createNewModel,
|
|
|
|
|
deleteModelById,
|
2025-11-02 23:41:57 +00:00
|
|
|
getModelItems as getWorkspaceModels,
|
2025-11-23 04:20:51 +00:00
|
|
|
getModelTags,
|
2024-11-16 02:21:41 +00:00
|
|
|
toggleModelById,
|
2024-11-15 10:05:43 +00:00
|
|
|
updateModelById
|
|
|
|
|
} from '$lib/apis/models';
|
2024-05-25 01:26:36 +00:00
|
|
|
|
2024-05-24 09:17:48 +00:00
|
|
|
import { getModels } from '$lib/apis';
|
2025-01-10 18:44:26 +00:00
|
|
|
import { getGroups } from '$lib/apis/groups';
|
2024-05-31 20:11:04 +00:00
|
|
|
|
2025-10-05 02:44:51 +00:00
|
|
|
import { capitalizeFirstLetter, copyToClipboard } from '$lib/utils';
|
|
|
|
|
|
2024-05-31 09:11:25 +00:00
|
|
|
import EllipsisHorizontal from '../icons/EllipsisHorizontal.svelte';
|
|
|
|
|
import ModelMenu from './Models/ModelMenu.svelte';
|
2024-06-15 10:13:30 +00:00
|
|
|
import ModelDeleteConfirmDialog from '../common/ConfirmDialog.svelte';
|
2024-08-19 12:58:15 +00:00
|
|
|
import Tooltip from '../common/Tooltip.svelte';
|
|
|
|
|
import GarbageBin from '../icons/GarbageBin.svelte';
|
2024-11-07 05:45:48 +00:00
|
|
|
import Search from '../icons/Search.svelte';
|
|
|
|
|
import Plus from '../icons/Plus.svelte';
|
2024-11-16 01:36:46 +00:00
|
|
|
import ChevronRight from '../icons/ChevronRight.svelte';
|
2024-11-16 02:21:41 +00:00
|
|
|
import Switch from '../common/Switch.svelte';
|
2024-11-17 02:35:14 +00:00
|
|
|
import Spinner from '../common/Spinner.svelte';
|
2025-05-18 22:36:15 +00:00
|
|
|
import XMark from '../icons/XMark.svelte';
|
2025-05-24 22:32:32 +00:00
|
|
|
import EyeSlash from '../icons/EyeSlash.svelte';
|
|
|
|
|
import Eye from '../icons/Eye.svelte';
|
2025-10-05 02:44:51 +00:00
|
|
|
import ViewSelector from './common/ViewSelector.svelte';
|
|
|
|
|
import TagSelector from './common/TagSelector.svelte';
|
2025-11-23 04:20:51 +00:00
|
|
|
import Pagination from '../common/Pagination.svelte';
|
2024-05-15 06:16:22 +00:00
|
|
|
|
2024-08-19 12:58:15 +00:00
|
|
|
let shiftKey = false;
|
|
|
|
|
|
2024-05-15 06:16:22 +00:00
|
|
|
let importFiles;
|
2024-05-25 05:40:36 +00:00
|
|
|
let modelsImportInputElement: HTMLInputElement;
|
2025-07-08 19:05:39 +00:00
|
|
|
let tagsContainerElement: HTMLDivElement;
|
|
|
|
|
|
2024-11-17 02:35:14 +00:00
|
|
|
let loaded = false;
|
2024-05-15 06:16:22 +00:00
|
|
|
|
2025-11-23 04:20:51 +00:00
|
|
|
let showModelDeleteConfirm = false;
|
2024-10-14 19:46:05 +00:00
|
|
|
|
2024-06-15 10:13:30 +00:00
|
|
|
let selectedModel = null;
|
2024-05-31 20:11:04 +00:00
|
|
|
|
2025-11-23 04:20:51 +00:00
|
|
|
let groupIds = [];
|
|
|
|
|
|
|
|
|
|
let tags = [];
|
|
|
|
|
let selectedTag = '';
|
2024-11-14 10:20:34 +00:00
|
|
|
|
2025-11-23 04:20:51 +00:00
|
|
|
let query = '';
|
|
|
|
|
let viewOption = '';
|
2025-01-10 18:44:26 +00:00
|
|
|
|
2025-11-23 04:20:51 +00:00
|
|
|
let page = 1;
|
|
|
|
|
let models = null;
|
|
|
|
|
let total = null;
|
|
|
|
|
|
|
|
|
|
$: if (
|
|
|
|
|
page !== undefined &&
|
|
|
|
|
query !== undefined &&
|
|
|
|
|
selectedTag !== undefined &&
|
|
|
|
|
viewOption !== undefined
|
|
|
|
|
) {
|
|
|
|
|
getModelList();
|
2025-10-05 02:44:51 +00:00
|
|
|
}
|
|
|
|
|
|
2025-11-23 04:20:51 +00:00
|
|
|
const getModelList = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getWorkspaceModels(
|
|
|
|
|
localStorage.token,
|
|
|
|
|
query,
|
|
|
|
|
viewOption,
|
|
|
|
|
selectedTag,
|
|
|
|
|
null,
|
|
|
|
|
null,
|
|
|
|
|
page
|
|
|
|
|
).catch((error) => {
|
|
|
|
|
toast.error(`${error}`);
|
|
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
models = res.items;
|
|
|
|
|
total = res.total;
|
|
|
|
|
|
|
|
|
|
// get tags
|
|
|
|
|
tags = await getModelTags(localStorage.token).catch((error) => {
|
|
|
|
|
toast.error(`${error}`);
|
|
|
|
|
return [];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error(err);
|
|
|
|
|
}
|
2025-10-05 02:44:51 +00:00
|
|
|
};
|
2024-10-14 19:46:05 +00:00
|
|
|
|
2024-05-25 01:26:36 +00:00
|
|
|
const deleteModelHandler = async (model) => {
|
2024-11-15 11:02:08 +00:00
|
|
|
const res = await deleteModelById(localStorage.token, model.id).catch((e) => {
|
2025-01-30 05:56:28 +00:00
|
|
|
toast.error(`${e}`);
|
2024-11-15 11:02:08 +00:00
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
|
2024-05-25 01:32:48 +00:00
|
|
|
if (res) {
|
|
|
|
|
toast.success($i18n.t(`Deleted {{name}}`, { name: model.id }));
|
2025-11-23 04:20:51 +00:00
|
|
|
|
|
|
|
|
page = 1;
|
|
|
|
|
getModelList();
|
2024-05-25 01:32:48 +00:00
|
|
|
}
|
|
|
|
|
|
2025-02-12 09:22:53 +00:00
|
|
|
await _models.set(
|
|
|
|
|
await getModels(
|
|
|
|
|
localStorage.token,
|
2025-02-12 09:32:49 +00:00
|
|
|
$config?.features?.enable_direct_connections && ($settings?.directConnections ?? null)
|
2025-02-12 09:22:53 +00:00
|
|
|
)
|
|
|
|
|
);
|
2024-05-25 01:26:36 +00:00
|
|
|
};
|
2024-05-15 06:16:22 +00:00
|
|
|
|
2024-05-25 01:26:36 +00:00
|
|
|
const cloneModelHandler = async (model) => {
|
2024-11-15 10:05:43 +00:00
|
|
|
sessionStorage.model = JSON.stringify({
|
|
|
|
|
...model,
|
|
|
|
|
id: `${model.id}-clone`,
|
|
|
|
|
name: `${model.name} (Clone)`
|
|
|
|
|
});
|
|
|
|
|
goto('/workspace/models/create');
|
2024-05-15 06:16:22 +00:00
|
|
|
};
|
|
|
|
|
|
2024-05-24 08:40:48 +00:00
|
|
|
const shareModelHandler = async (model) => {
|
2025-02-10 06:19:02 +00:00
|
|
|
toast.success($i18n.t('Redirecting you to Open WebUI Community'));
|
2024-05-15 06:16:22 +00:00
|
|
|
|
|
|
|
|
const url = 'https://openwebui.com';
|
|
|
|
|
|
2024-05-24 08:40:48 +00:00
|
|
|
const tab = await window.open(`${url}/models/create`, '_blank');
|
2024-06-09 18:57:33 +00:00
|
|
|
|
|
|
|
|
const messageHandler = (event) => {
|
|
|
|
|
if (event.origin !== url) return;
|
|
|
|
|
if (event.data === 'loaded') {
|
|
|
|
|
tab.postMessage(JSON.stringify(model), '*');
|
|
|
|
|
window.removeEventListener('message', messageHandler);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
window.addEventListener('message', messageHandler, false);
|
2024-05-15 06:16:22 +00:00
|
|
|
};
|
|
|
|
|
|
2024-05-31 09:11:25 +00:00
|
|
|
const hideModelHandler = async (model) => {
|
2025-05-24 22:32:32 +00:00
|
|
|
model.meta = {
|
|
|
|
|
...model.meta,
|
|
|
|
|
hidden: !(model?.meta?.hidden ?? false)
|
2024-05-31 09:11:25 +00:00
|
|
|
};
|
|
|
|
|
|
2025-05-24 22:32:32 +00:00
|
|
|
console.log(model);
|
2024-05-31 09:11:25 +00:00
|
|
|
|
2025-05-24 22:32:32 +00:00
|
|
|
const res = await updateModelById(localStorage.token, model.id, model);
|
2024-05-31 09:11:25 +00:00
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
toast.success(
|
|
|
|
|
$i18n.t(`Model {{name}} is now {{status}}`, {
|
2025-05-24 22:32:32 +00:00
|
|
|
name: model.id,
|
|
|
|
|
status: model.meta.hidden ? 'hidden' : 'visible'
|
2024-05-31 09:11:25 +00:00
|
|
|
})
|
|
|
|
|
);
|
2025-11-23 04:20:51 +00:00
|
|
|
|
|
|
|
|
page = 1;
|
|
|
|
|
getModelList();
|
2024-05-31 09:11:25 +00:00
|
|
|
}
|
|
|
|
|
|
2025-02-12 09:22:53 +00:00
|
|
|
await _models.set(
|
|
|
|
|
await getModels(
|
|
|
|
|
localStorage.token,
|
2025-02-12 09:32:49 +00:00
|
|
|
$config?.features?.enable_direct_connections && ($settings?.directConnections ?? null)
|
2025-02-12 09:22:53 +00:00
|
|
|
)
|
|
|
|
|
);
|
2024-05-31 09:11:25 +00:00
|
|
|
};
|
|
|
|
|
|
2025-05-26 18:29:03 +00:00
|
|
|
const copyLinkHandler = async (model) => {
|
|
|
|
|
const baseUrl = window.location.origin;
|
|
|
|
|
const res = await copyToClipboard(`${baseUrl}/?model=${encodeURIComponent(model.id)}`);
|
|
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
toast.success($i18n.t('Copied link to clipboard'));
|
|
|
|
|
} else {
|
|
|
|
|
toast.error($i18n.t('Failed to copy link'));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2024-05-24 08:40:48 +00:00
|
|
|
const downloadModels = async (models) => {
|
|
|
|
|
let blob = new Blob([JSON.stringify(models)], {
|
2024-05-15 06:16:22 +00:00
|
|
|
type: 'application/json'
|
|
|
|
|
});
|
2024-05-24 08:40:48 +00:00
|
|
|
saveAs(blob, `models-export-${Date.now()}.json`);
|
2024-05-15 06:16:22 +00:00
|
|
|
};
|
|
|
|
|
|
2024-06-02 20:53:02 +00:00
|
|
|
const exportModelHandler = async (model) => {
|
|
|
|
|
let blob = new Blob([JSON.stringify([model])], {
|
|
|
|
|
type: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
saveAs(blob, `${model.id}-${Date.now()}.json`);
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-05 02:44:51 +00:00
|
|
|
onMount(async () => {
|
|
|
|
|
viewOption = localStorage.workspaceViewOption ?? '';
|
2025-11-23 04:20:51 +00:00
|
|
|
page = 1;
|
|
|
|
|
|
|
|
|
|
await getModelList();
|
2025-07-08 19:05:39 +00:00
|
|
|
|
2025-10-05 02:44:51 +00:00
|
|
|
let groups = await getGroups(localStorage.token);
|
2025-11-23 04:20:51 +00:00
|
|
|
groupIds = groups.map((group) => group.id);
|
2025-10-05 02:44:51 +00:00
|
|
|
|
2024-11-17 02:35:14 +00:00
|
|
|
loaded = true;
|
|
|
|
|
|
2024-08-19 12:58:15 +00:00
|
|
|
const onKeyDown = (event) => {
|
|
|
|
|
if (event.key === 'Shift') {
|
|
|
|
|
shiftKey = true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onKeyUp = (event) => {
|
|
|
|
|
if (event.key === 'Shift') {
|
|
|
|
|
shiftKey = false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onBlur = () => {
|
|
|
|
|
shiftKey = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
window.addEventListener('keydown', onKeyDown);
|
|
|
|
|
window.addEventListener('keyup', onKeyUp);
|
2025-02-16 03:27:25 +00:00
|
|
|
window.addEventListener('blur-sm', onBlur);
|
2024-08-19 12:58:15 +00:00
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
window.removeEventListener('keydown', onKeyDown);
|
|
|
|
|
window.removeEventListener('keyup', onKeyUp);
|
2025-02-16 03:27:25 +00:00
|
|
|
window.removeEventListener('blur-sm', onBlur);
|
2024-08-19 12:58:15 +00:00
|
|
|
};
|
2024-05-15 06:16:22 +00:00
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<svelte:head>
|
|
|
|
|
<title>
|
2025-05-03 14:16:32 +00:00
|
|
|
{$i18n.t('Models')} • {$WEBUI_NAME}
|
2024-05-15 06:16:22 +00:00
|
|
|
</title>
|
|
|
|
|
</svelte:head>
|
|
|
|
|
|
2024-11-17 02:35:14 +00:00
|
|
|
{#if loaded}
|
|
|
|
|
<ModelDeleteConfirmDialog
|
|
|
|
|
bind:show={showModelDeleteConfirm}
|
|
|
|
|
on:confirm={() => {
|
|
|
|
|
deleteModelHandler(selectedModel);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
|
2025-10-05 05:25:40 +00:00
|
|
|
<div class="flex flex-col gap-1 px-1 mt-1.5 mb-3">
|
2025-10-04 07:35:15 +00:00
|
|
|
<input
|
|
|
|
|
id="models-import-input"
|
|
|
|
|
bind:this={modelsImportInputElement}
|
|
|
|
|
bind:files={importFiles}
|
|
|
|
|
type="file"
|
|
|
|
|
accept=".json"
|
|
|
|
|
hidden
|
|
|
|
|
on:change={() => {
|
|
|
|
|
console.log(importFiles);
|
|
|
|
|
|
|
|
|
|
let reader = new FileReader();
|
|
|
|
|
reader.onload = async (event) => {
|
2025-11-23 04:20:51 +00:00
|
|
|
let savedModels = [];
|
2025-11-19 08:21:28 +00:00
|
|
|
try {
|
2025-11-23 04:20:51 +00:00
|
|
|
savedModels = JSON.parse(event.target.result);
|
2025-11-19 08:21:28 +00:00
|
|
|
console.log(savedModels);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
toast.error($i18n.t('Invalid JSON file'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-10-04 07:35:15 +00:00
|
|
|
|
|
|
|
|
for (const model of savedModels) {
|
|
|
|
|
if (model?.info ?? false) {
|
|
|
|
|
if ($_models.find((m) => m.id === model.id)) {
|
|
|
|
|
await updateModelById(localStorage.token, model.id, model.info).catch((error) => {
|
2025-11-23 04:20:51 +00:00
|
|
|
toast.error(`${error}`);
|
2025-10-04 07:35:15 +00:00
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await createNewModel(localStorage.token, model.info).catch((error) => {
|
2025-11-23 04:20:51 +00:00
|
|
|
toast.error(`${error}`);
|
2025-10-04 07:35:15 +00:00
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (model?.id && model?.name) {
|
|
|
|
|
await createNewModel(localStorage.token, model).catch((error) => {
|
2025-11-23 04:20:51 +00:00
|
|
|
toast.error(`${error}`);
|
2025-10-04 07:35:15 +00:00
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _models.set(
|
|
|
|
|
await getModels(
|
|
|
|
|
localStorage.token,
|
|
|
|
|
$config?.features?.enable_direct_connections && ($settings?.directConnections ?? null)
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-11-23 04:20:51 +00:00
|
|
|
|
|
|
|
|
page = 1;
|
|
|
|
|
getModelList();
|
2025-10-04 07:35:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
reader.readAsText(importFiles[0]);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2024-11-17 02:35:14 +00:00
|
|
|
<div class="flex justify-between items-center">
|
2025-10-04 07:35:15 +00:00
|
|
|
<div class="flex items-center md:self-center text-xl font-medium px-0.5 gap-2 shrink-0">
|
|
|
|
|
<div>
|
|
|
|
|
{$i18n.t('Models')}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="text-lg font-medium text-gray-500 dark:text-gray-500">
|
2025-11-23 04:20:51 +00:00
|
|
|
{total}
|
2025-10-04 07:35:15 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="flex w-full justify-end gap-1.5">
|
2025-11-17 23:25:23 +00:00
|
|
|
{#if $user?.role === 'admin' || $user?.permissions?.workspace?.models_import}
|
2025-10-04 07:35:15 +00:00
|
|
|
<button
|
|
|
|
|
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
modelsImportInputElement.click();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div class=" self-center font-medium line-clamp-1">
|
|
|
|
|
{$i18n.t('Import')}
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
2025-11-17 23:25:23 +00:00
|
|
|
{/if}
|
2025-10-04 07:35:15 +00:00
|
|
|
|
2025-11-23 04:20:51 +00:00
|
|
|
{#if total && ($user?.role === 'admin' || $user?.permissions?.workspace?.models_export)}
|
2025-11-17 23:25:23 +00:00
|
|
|
<button
|
|
|
|
|
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
|
|
|
|
|
on:click={async () => {
|
|
|
|
|
downloadModels(models);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div class=" self-center font-medium line-clamp-1">
|
|
|
|
|
{$i18n.t('Export')}
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
2025-10-04 07:35:15 +00:00
|
|
|
{/if}
|
|
|
|
|
<a
|
2025-10-05 05:25:40 +00:00
|
|
|
class=" px-2 py-1.5 rounded-xl bg-black text-white dark:bg-white dark:text-black transition font-medium text-sm flex items-center"
|
2025-10-04 07:35:15 +00:00
|
|
|
href="/workspace/models/create"
|
2024-11-17 02:35:14 +00:00
|
|
|
>
|
2025-10-04 07:35:15 +00:00
|
|
|
<Plus className="size-3" strokeWidth="2.5" />
|
|
|
|
|
|
|
|
|
|
<div class=" hidden md:block md:ml-1 text-xs">{$i18n.t('New Model')}</div>
|
|
|
|
|
</a>
|
2024-11-17 02:35:14 +00:00
|
|
|
</div>
|
2024-05-26 06:52:17 +00:00
|
|
|
</div>
|
2025-10-05 05:25:40 +00:00
|
|
|
</div>
|
2024-05-26 06:52:17 +00:00
|
|
|
|
2025-10-05 05:25:40 +00:00
|
|
|
<div
|
|
|
|
|
class="py-2 bg-white dark:bg-gray-900 rounded-3xl border border-gray-100 dark:border-gray-850"
|
|
|
|
|
>
|
2025-10-05 06:06:40 +00:00
|
|
|
<div class="px-3.5 flex flex-1 items-center w-full space-x-2 py-0.5 pb-2">
|
2024-11-17 02:35:14 +00:00
|
|
|
<div class="flex flex-1 items-center">
|
|
|
|
|
<div class=" self-center ml-1 mr-3">
|
|
|
|
|
<Search className="size-3.5" />
|
|
|
|
|
</div>
|
|
|
|
|
<input
|
2025-02-16 03:27:25 +00:00
|
|
|
class=" w-full text-sm py-1 rounded-r-xl outline-hidden bg-transparent"
|
2025-05-18 22:36:15 +00:00
|
|
|
bind:value={query}
|
2024-11-17 02:35:14 +00:00
|
|
|
placeholder={$i18n.t('Search Models')}
|
|
|
|
|
/>
|
2025-05-18 22:36:15 +00:00
|
|
|
|
|
|
|
|
{#if query}
|
|
|
|
|
<div class="self-center pl-1.5 translate-y-[0.5px] rounded-l-xl bg-transparent">
|
|
|
|
|
<button
|
|
|
|
|
class="p-0.5 rounded-full hover:bg-gray-100 dark:hover:bg-gray-900 transition"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
query = '';
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<XMark className="size-3" strokeWidth="2" />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2024-11-07 05:45:48 +00:00
|
|
|
</div>
|
2024-10-14 19:46:05 +00:00
|
|
|
</div>
|
2024-11-17 02:35:14 +00:00
|
|
|
|
2025-07-08 19:05:39 +00:00
|
|
|
<div
|
2025-10-05 05:25:40 +00:00
|
|
|
class="px-3 flex w-full bg-transparent overflow-x-auto scrollbar-none"
|
|
|
|
|
on:wheel={(e) => {
|
|
|
|
|
if (e.deltaY !== 0) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
e.currentTarget.scrollLeft += e.deltaY;
|
|
|
|
|
}
|
|
|
|
|
}}
|
2025-07-08 19:05:39 +00:00
|
|
|
>
|
2024-11-17 02:35:14 +00:00
|
|
|
<div
|
2025-10-05 05:25:40 +00:00
|
|
|
class="flex gap-0.5 w-fit text-center text-sm rounded-full bg-transparent px-0.5 whitespace-nowrap"
|
|
|
|
|
bind:this={tagsContainerElement}
|
2024-05-15 06:16:22 +00:00
|
|
|
>
|
2025-10-05 05:25:40 +00:00
|
|
|
<ViewSelector
|
|
|
|
|
bind:value={viewOption}
|
|
|
|
|
onChange={async (value) => {
|
|
|
|
|
localStorage.workspaceViewOption = value;
|
|
|
|
|
await tick();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2024-05-15 06:16:22 +00:00
|
|
|
|
2025-10-05 05:25:40 +00:00
|
|
|
{#if (tags ?? []).length > 0}
|
|
|
|
|
<TagSelector
|
|
|
|
|
bind:value={selectedTag}
|
|
|
|
|
items={tags.map((tag) => {
|
|
|
|
|
return { value: tag, label: tag };
|
|
|
|
|
})}
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-11-23 04:20:51 +00:00
|
|
|
{#if (models ?? []).length !== 0}
|
2025-10-05 05:25:40 +00:00
|
|
|
<div class=" px-3 my-2 gap-1 lg:gap-2 grid lg:grid-cols-2" id="model-list">
|
2025-11-23 04:20:51 +00:00
|
|
|
{#each models as model (model.id)}
|
2025-10-27 05:20:57 +00:00
|
|
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
|
|
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
2025-10-27 04:06:32 +00:00
|
|
|
<div
|
2025-10-05 06:06:40 +00:00
|
|
|
class=" flex cursor-pointer dark:hover:bg-gray-850/50 hover:bg-gray-50 transition rounded-2xl w-full p-2.5"
|
2025-10-05 05:25:40 +00:00
|
|
|
id="model-item-{model.id}"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
if (
|
|
|
|
|
$user?.role === 'admin' ||
|
|
|
|
|
model.user_id === $user?.id ||
|
2025-11-23 04:20:51 +00:00
|
|
|
model.access_control.write.group_ids.some((wg) => groupIds.includes(wg))
|
2025-10-05 05:25:40 +00:00
|
|
|
) {
|
|
|
|
|
goto(`/workspace/models/edit?id=${encodeURIComponent(model.id)}`);
|
|
|
|
|
}
|
|
|
|
|
}}
|
2024-11-18 14:02:14 +00:00
|
|
|
>
|
2025-10-05 05:25:40 +00:00
|
|
|
<div class="flex group/item gap-3.5 w-full">
|
|
|
|
|
<div class="self-center pl-0.5">
|
|
|
|
|
<div class="flex bg-white rounded-2xl">
|
|
|
|
|
<div
|
2025-11-21 01:43:59 +00:00
|
|
|
class="{model.is_active
|
|
|
|
|
? ''
|
|
|
|
|
: 'opacity-50 dark:opacity-50'} bg-transparent rounded-2xl"
|
2025-10-05 05:25:40 +00:00
|
|
|
>
|
|
|
|
|
<img
|
2025-11-21 01:43:59 +00:00
|
|
|
src={`${WEBUI_API_BASE_URL}/models/model/profile/image?id=${model.id}&lang=${$i18n.language}`}
|
2025-10-05 05:25:40 +00:00
|
|
|
alt="modelfile profile"
|
|
|
|
|
class=" rounded-2xl size-12 object-cover"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-11-18 13:37:04 +00:00
|
|
|
</div>
|
2024-11-18 14:02:14 +00:00
|
|
|
</div>
|
|
|
|
|
|
2025-10-05 05:25:40 +00:00
|
|
|
<div class=" shrink-0 flex w-full min-w-0 flex-1 pr-1 self-center">
|
|
|
|
|
<div class="flex h-full w-full flex-1 flex-col justify-start self-center group">
|
|
|
|
|
<div class="flex-1 w-full">
|
|
|
|
|
<div class="flex items-center justify-between w-full">
|
|
|
|
|
<Tooltip content={model.name} className=" w-fit" placement="top-start">
|
|
|
|
|
<a
|
|
|
|
|
class=" font-semibold line-clamp-1 hover:underline capitalize"
|
|
|
|
|
href={`/?models=${encodeURIComponent(model.id)}`}
|
|
|
|
|
>
|
|
|
|
|
{model.name}
|
|
|
|
|
</a>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
|
|
<div class=" flex items-center gap-1">
|
|
|
|
|
<div
|
|
|
|
|
class="flex justify-end w-full {model.is_active ? '' : 'text-gray-500'}"
|
|
|
|
|
>
|
|
|
|
|
<div class="flex justify-between items-center w-full">
|
|
|
|
|
<div class=""></div>
|
|
|
|
|
<div class="flex flex-row gap-0.5 items-center">
|
|
|
|
|
{#if shiftKey}
|
|
|
|
|
<Tooltip
|
|
|
|
|
content={model?.meta?.hidden ? $i18n.t('Show') : $i18n.t('Hide')}
|
|
|
|
|
>
|
|
|
|
|
<button
|
|
|
|
|
class="self-center w-fit text-sm p-1.5 dark:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
|
|
|
|
type="button"
|
|
|
|
|
on:click={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
hideModelHandler(model);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{#if model?.meta?.hidden}
|
|
|
|
|
<EyeSlash />
|
|
|
|
|
{:else}
|
|
|
|
|
<Eye />
|
|
|
|
|
{/if}
|
|
|
|
|
</button>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
|
|
<Tooltip content={$i18n.t('Delete')}>
|
|
|
|
|
<button
|
|
|
|
|
class="self-center w-fit text-sm p-1.5 dark:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
|
|
|
|
type="button"
|
|
|
|
|
on:click={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
deleteModelHandler(model);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<GarbageBin />
|
|
|
|
|
</button>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
{:else}
|
|
|
|
|
<ModelMenu
|
|
|
|
|
user={$user}
|
|
|
|
|
{model}
|
2025-10-27 05:20:57 +00:00
|
|
|
editHandler={() => {
|
|
|
|
|
goto(
|
|
|
|
|
`/workspace/models/edit?id=${encodeURIComponent(model.id)}`
|
|
|
|
|
);
|
|
|
|
|
}}
|
2025-10-05 05:25:40 +00:00
|
|
|
shareHandler={() => {
|
|
|
|
|
shareModelHandler(model);
|
|
|
|
|
}}
|
|
|
|
|
cloneHandler={() => {
|
|
|
|
|
cloneModelHandler(model);
|
|
|
|
|
}}
|
|
|
|
|
exportHandler={() => {
|
|
|
|
|
exportModelHandler(model);
|
|
|
|
|
}}
|
|
|
|
|
hideHandler={() => {
|
|
|
|
|
hideModelHandler(model);
|
|
|
|
|
}}
|
|
|
|
|
copyLinkHandler={() => {
|
|
|
|
|
copyLinkHandler(model);
|
|
|
|
|
}}
|
|
|
|
|
deleteHandler={() => {
|
|
|
|
|
selectedModel = model;
|
|
|
|
|
showModelDeleteConfirm = true;
|
|
|
|
|
}}
|
|
|
|
|
onClose={() => {}}
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
class="self-center w-fit p-1 text-sm dark:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
|
|
|
|
>
|
|
|
|
|
<EllipsisHorizontal className="size-5" />
|
|
|
|
|
</div>
|
|
|
|
|
</ModelMenu>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
on:click={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Tooltip
|
|
|
|
|
content={model.is_active ? $i18n.t('Enabled') : $i18n.t('Disabled')}
|
|
|
|
|
>
|
|
|
|
|
<Switch
|
|
|
|
|
bind:state={model.is_active}
|
|
|
|
|
on:change={async () => {
|
|
|
|
|
toggleModelById(localStorage.token, model.id);
|
|
|
|
|
_models.set(
|
|
|
|
|
await getModels(
|
|
|
|
|
localStorage.token,
|
|
|
|
|
$config?.features?.enable_direct_connections &&
|
|
|
|
|
($settings?.directConnections ?? null)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class=" flex gap-1 pr-2 -mt-1 items-center">
|
|
|
|
|
<Tooltip
|
|
|
|
|
content={model?.user?.email ?? $i18n.t('Deleted User')}
|
|
|
|
|
className="flex shrink-0"
|
|
|
|
|
placement="top-start"
|
|
|
|
|
>
|
|
|
|
|
<div class="shrink-0 text-gray-500 text-xs">
|
|
|
|
|
{$i18n.t('By {{name}}', {
|
|
|
|
|
name: capitalizeFirstLetter(
|
|
|
|
|
model?.user?.name ?? model?.user?.email ?? $i18n.t('Deleted User')
|
|
|
|
|
)
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
|
|
<div>·</div>
|
|
|
|
|
|
|
|
|
|
<Tooltip
|
|
|
|
|
content={marked.parse(model?.meta?.description ?? model.id)}
|
|
|
|
|
className=" w-fit text-left"
|
|
|
|
|
placement="top-start"
|
|
|
|
|
>
|
|
|
|
|
<div class="flex gap-1 text-xs overflow-hidden">
|
|
|
|
|
<div class="line-clamp-1">
|
|
|
|
|
{#if (model?.meta?.description ?? '').trim()}
|
|
|
|
|
{model?.meta?.description}
|
|
|
|
|
{:else}
|
|
|
|
|
{model.id}
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-11-18 14:02:14 +00:00
|
|
|
</div>
|
2025-10-05 05:25:40 +00:00
|
|
|
</div>
|
2025-10-27 04:06:32 +00:00
|
|
|
</div>
|
2025-10-05 05:25:40 +00:00
|
|
|
{/each}
|
|
|
|
|
</div>
|
2025-11-23 04:20:51 +00:00
|
|
|
|
|
|
|
|
{#if total > 30}
|
|
|
|
|
<Pagination bind:page count={total} perPage={30} />
|
|
|
|
|
{/if}
|
2025-10-05 05:25:40 +00:00
|
|
|
{:else}
|
|
|
|
|
<div class=" w-full h-full flex flex-col justify-center items-center my-16 mb-24">
|
|
|
|
|
<div class="max-w-md text-center">
|
|
|
|
|
<div class=" text-3xl mb-3">😕</div>
|
|
|
|
|
<div class=" text-lg font-medium mb-1">{$i18n.t('No models found')}</div>
|
|
|
|
|
<div class=" text-gray-500 text-center text-xs">
|
|
|
|
|
{$i18n.t('Try adjusting your search or filter to find what you are looking for.')}
|
2024-11-18 14:02:14 +00:00
|
|
|
</div>
|
2024-11-17 02:35:14 +00:00
|
|
|
</div>
|
2024-05-15 06:16:22 +00:00
|
|
|
</div>
|
2025-10-05 05:25:40 +00:00
|
|
|
{/if}
|
2024-11-17 02:35:14 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{#if $config?.features.enable_community_sharing}
|
|
|
|
|
<div class=" my-16">
|
2024-11-18 14:34:25 +00:00
|
|
|
<div class=" text-xl font-medium mb-1 line-clamp-1">
|
2025-02-10 06:19:02 +00:00
|
|
|
{$i18n.t('Made by Open WebUI Community')}
|
2024-11-17 02:35:14 +00:00
|
|
|
</div>
|
2024-05-15 06:16:22 +00:00
|
|
|
|
2024-11-17 02:35:14 +00:00
|
|
|
<a
|
|
|
|
|
class=" flex cursor-pointer items-center justify-between hover:bg-gray-50 dark:hover:bg-gray-850 w-full mb-2 px-3.5 py-1.5 rounded-xl transition"
|
2025-07-26 21:32:55 +00:00
|
|
|
href="https://openwebui.com/models"
|
2024-11-17 02:35:14 +00:00
|
|
|
target="_blank"
|
2024-11-13 11:09:46 +00:00
|
|
|
>
|
|
|
|
|
<div class=" self-center">
|
2024-11-17 02:35:14 +00:00
|
|
|
<div class=" font-semibold line-clamp-1">{$i18n.t('Discover a model')}</div>
|
|
|
|
|
<div class=" text-sm line-clamp-1">
|
|
|
|
|
{$i18n.t('Discover, download, and explore model presets')}
|
|
|
|
|
</div>
|
2024-10-19 09:12:34 +00:00
|
|
|
</div>
|
2024-11-16 01:36:46 +00:00
|
|
|
|
|
|
|
|
<div>
|
2024-11-17 02:35:14 +00:00
|
|
|
<div>
|
|
|
|
|
<ChevronRight />
|
|
|
|
|
</div>
|
2024-11-16 01:36:46 +00:00
|
|
|
</div>
|
2024-11-17 02:35:14 +00:00
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
{:else}
|
|
|
|
|
<div class="w-full h-full flex justify-center items-center">
|
2025-06-27 12:15:16 +00:00
|
|
|
<Spinner className="size-5" />
|
2024-10-19 09:12:34 +00:00
|
|
|
</div>
|
|
|
|
|
{/if}
|