mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 03:47:49 +01:00
enh: workspace loading indicator
This commit is contained in:
@@ -23,6 +23,9 @@
|
|||||||
import Badge from '../common/Badge.svelte';
|
import Badge from '../common/Badge.svelte';
|
||||||
import Search from '../icons/Search.svelte';
|
import Search from '../icons/Search.svelte';
|
||||||
import Plus from '../icons/Plus.svelte';
|
import Plus from '../icons/Plus.svelte';
|
||||||
|
import Spinner from '../common/Spinner.svelte';
|
||||||
|
|
||||||
|
let loaded = false;
|
||||||
|
|
||||||
let query = '';
|
let query = '';
|
||||||
let selectedItem = null;
|
let selectedItem = null;
|
||||||
@@ -61,6 +64,7 @@
|
|||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
knowledgeBases = await getKnowledgeBaseList(localStorage.token);
|
knowledgeBases = await getKnowledgeBaseList(localStorage.token);
|
||||||
|
loaded = true;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -70,104 +74,110 @@
|
|||||||
</title>
|
</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<DeleteConfirmDialog
|
{#if loaded}
|
||||||
bind:show={showDeleteConfirm}
|
<DeleteConfirmDialog
|
||||||
on:confirm={() => {
|
bind:show={showDeleteConfirm}
|
||||||
deleteHandler(selectedItem);
|
on:confirm={() => {
|
||||||
}}
|
deleteHandler(selectedItem);
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<div class="flex flex-col gap-1 mt-1.5 mb-2">
|
<div class="flex flex-col gap-1 mt-1.5 mb-2">
|
||||||
<div class="flex justify-between items-center">
|
<div class="flex justify-between items-center">
|
||||||
<div class="flex md:self-center text-xl font-medium px-0.5 items-center">
|
<div class="flex md:self-center text-xl font-medium px-0.5 items-center">
|
||||||
{$i18n.t('Knowledge')}
|
{$i18n.t('Knowledge')}
|
||||||
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50 dark:bg-gray-850" />
|
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50 dark:bg-gray-850" />
|
||||||
<span class="text-lg font-medium text-gray-500 dark:text-gray-300"
|
<span class="text-lg font-medium text-gray-500 dark:text-gray-300"
|
||||||
>{filteredItems.length}</span
|
>{filteredItems.length}</span
|
||||||
>
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class=" flex w-full space-x-2">
|
||||||
|
<div class="flex flex-1">
|
||||||
|
<div class=" self-center ml-1 mr-3">
|
||||||
|
<Search className="size-3.5" />
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
class=" w-full text-sm py-1 rounded-r-xl outline-none bg-transparent"
|
||||||
|
bind:value={query}
|
||||||
|
placeholder={$i18n.t('Search Knowledge')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
class=" px-2 py-2 rounded-xl hover:bg-gray-700/10 dark:hover:bg-gray-100/10 dark:text-gray-300 dark:hover:text-white transition font-medium text-sm flex items-center space-x-1"
|
||||||
|
aria-label={$i18n.t('Create Knowledge')}
|
||||||
|
on:click={() => {
|
||||||
|
goto('/workspace/knowledge/create');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Plus className="size-3.5" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class=" flex w-full space-x-2">
|
<div class="my-3 mb-5 grid lg:grid-cols-2 xl:grid-cols-3 gap-2">
|
||||||
<div class="flex flex-1">
|
{#each filteredItems as item}
|
||||||
<div class=" self-center ml-1 mr-3">
|
|
||||||
<Search className="size-3.5" />
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
class=" w-full text-sm py-1 rounded-r-xl outline-none bg-transparent"
|
|
||||||
bind:value={query}
|
|
||||||
placeholder={$i18n.t('Search Knowledge')}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<button
|
<button
|
||||||
class=" px-2 py-2 rounded-xl hover:bg-gray-700/10 dark:hover:bg-gray-100/10 dark:text-gray-300 dark:hover:text-white transition font-medium text-sm flex items-center space-x-1"
|
class=" flex space-x-4 cursor-pointer text-left w-full px-4 py-3 border border-gray-50 dark:border-gray-850 dark:hover:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-850 transition rounded-xl"
|
||||||
aria-label={$i18n.t('Create Knowledge')}
|
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
goto('/workspace/knowledge/create');
|
if (item?.meta?.document) {
|
||||||
|
toast.error(
|
||||||
|
$i18n.t(
|
||||||
|
'Only collections can be edited, create a new knowledge base to edit/add documents.'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
goto(`/workspace/knowledge/${item.id}`);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Plus className="size-3.5" />
|
<div class=" w-full">
|
||||||
|
<div class="flex items-center justify-between -mt-1">
|
||||||
|
<div class=" font-semibold line-clamp-1 h-fit">{item.name}</div>
|
||||||
|
|
||||||
|
<div class=" flex self-center">
|
||||||
|
<ItemMenu
|
||||||
|
on:delete={() => {
|
||||||
|
selectedItem = item;
|
||||||
|
showDeleteConfirm = true;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class=" self-center flex-1">
|
||||||
|
<div class=" text-xs overflow-hidden text-ellipsis line-clamp-1">
|
||||||
|
{item.description}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-5 flex justify-between">
|
||||||
|
<div>
|
||||||
|
{#if item?.meta?.document}
|
||||||
|
<Badge type="muted" content={$i18n.t('Document')} />
|
||||||
|
{:else}
|
||||||
|
<Badge type="success" content={$i18n.t('Collection')} />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div class=" text-xs text-gray-500 line-clamp-1">
|
||||||
|
{$i18n.t('Updated')}
|
||||||
|
{dayjs(item.updated_at * 1000).fromNow()}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="my-3 mb-5 grid lg:grid-cols-2 xl:grid-cols-3 gap-2">
|
<div class=" text-gray-500 text-xs mt-1 mb-2">
|
||||||
{#each filteredItems as item}
|
ⓘ {$i18n.t("Use '#' in the prompt input to load and include your knowledge.")}
|
||||||
<button
|
</div>
|
||||||
class=" flex space-x-4 cursor-pointer text-left w-full px-4 py-3 border border-gray-50 dark:border-gray-850 dark:hover:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-850 transition rounded-xl"
|
{:else}
|
||||||
on:click={() => {
|
<div class="w-full h-full flex justify-center items-center">
|
||||||
if (item?.meta?.document) {
|
<Spinner />
|
||||||
toast.error(
|
</div>
|
||||||
$i18n.t(
|
{/if}
|
||||||
'Only collections can be edited, create a new knowledge base to edit/add documents.'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
goto(`/workspace/knowledge/${item.id}`);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class=" w-full">
|
|
||||||
<div class="flex items-center justify-between -mt-1">
|
|
||||||
<div class=" font-semibold line-clamp-1 h-fit">{item.name}</div>
|
|
||||||
|
|
||||||
<div class=" flex self-center">
|
|
||||||
<ItemMenu
|
|
||||||
on:delete={() => {
|
|
||||||
selectedItem = item;
|
|
||||||
showDeleteConfirm = true;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class=" self-center flex-1">
|
|
||||||
<div class=" text-xs overflow-hidden text-ellipsis line-clamp-1">
|
|
||||||
{item.description}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-5 flex justify-between">
|
|
||||||
<div>
|
|
||||||
{#if item?.meta?.document}
|
|
||||||
<Badge type="muted" content={$i18n.t('Document')} />
|
|
||||||
{:else}
|
|
||||||
<Badge type="success" content={$i18n.t('Collection')} />
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
<div class=" text-xs text-gray-500 line-clamp-1">
|
|
||||||
{$i18n.t('Updated')}
|
|
||||||
{dayjs(item.updated_at * 1000).fromNow()}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class=" text-gray-500 text-xs mt-1 mb-2">
|
|
||||||
ⓘ {$i18n.t("Use '#' in the prompt input to load and include your knowledge.")}
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -31,11 +31,13 @@
|
|||||||
import Plus from '../icons/Plus.svelte';
|
import Plus from '../icons/Plus.svelte';
|
||||||
import ChevronRight from '../icons/ChevronRight.svelte';
|
import ChevronRight from '../icons/ChevronRight.svelte';
|
||||||
import Switch from '../common/Switch.svelte';
|
import Switch from '../common/Switch.svelte';
|
||||||
|
import Spinner from '../common/Spinner.svelte';
|
||||||
|
|
||||||
let shiftKey = false;
|
let shiftKey = false;
|
||||||
|
|
||||||
let importFiles;
|
let importFiles;
|
||||||
let modelsImportInputElement: HTMLInputElement;
|
let modelsImportInputElement: HTMLInputElement;
|
||||||
|
let loaded = false;
|
||||||
|
|
||||||
let models = [];
|
let models = [];
|
||||||
|
|
||||||
@@ -149,6 +151,8 @@
|
|||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
models = await getWorkspaceModels(localStorage.token);
|
models = await getWorkspaceModels(localStorage.token);
|
||||||
|
|
||||||
|
loaded = true;
|
||||||
|
|
||||||
const onKeyDown = (event) => {
|
const onKeyDown = (event) => {
|
||||||
if (event.key === 'Shift') {
|
if (event.key === 'Shift') {
|
||||||
shiftKey = true;
|
shiftKey = true;
|
||||||
@@ -183,304 +187,312 @@
|
|||||||
</title>
|
</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<ModelDeleteConfirmDialog
|
{#if loaded}
|
||||||
bind:show={showModelDeleteConfirm}
|
<ModelDeleteConfirmDialog
|
||||||
on:confirm={() => {
|
bind:show={showModelDeleteConfirm}
|
||||||
deleteModelHandler(selectedModel);
|
on:confirm={() => {
|
||||||
}}
|
deleteModelHandler(selectedModel);
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<div class="flex flex-col gap-1 mt-1.5 mb-2">
|
<div class="flex flex-col gap-1 mt-1.5 mb-2">
|
||||||
<div class="flex justify-between items-center">
|
<div class="flex justify-between items-center">
|
||||||
<div class="flex items-center md:self-center text-xl font-medium px-0.5">
|
<div class="flex items-center md:self-center text-xl font-medium px-0.5">
|
||||||
{$i18n.t('Models')}
|
{$i18n.t('Models')}
|
||||||
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50 dark:bg-gray-850" />
|
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50 dark:bg-gray-850" />
|
||||||
<span class="text-lg font-medium text-gray-500 dark:text-gray-300"
|
<span class="text-lg font-medium text-gray-500 dark:text-gray-300"
|
||||||
>{filteredModels.length}</span
|
>{filteredModels.length}</span
|
||||||
>
|
>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class=" flex flex-1 items-center w-full space-x-2">
|
|
||||||
<div class="flex flex-1 items-center">
|
|
||||||
<div class=" self-center ml-1 mr-3">
|
|
||||||
<Search className="size-3.5" />
|
|
||||||
</div>
|
</div>
|
||||||
<input
|
|
||||||
class=" w-full text-sm py-1 rounded-r-xl outline-none bg-transparent"
|
|
||||||
bind:value={searchValue}
|
|
||||||
placeholder={$i18n.t('Search Models')}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div class=" flex flex-1 items-center w-full space-x-2">
|
||||||
<a
|
<div class="flex flex-1 items-center">
|
||||||
class=" px-2 py-2 rounded-xl hover:bg-gray-700/10 dark:hover:bg-gray-100/10 dark:text-gray-300 dark:hover:text-white transition font-medium text-sm flex items-center space-x-1"
|
<div class=" self-center ml-1 mr-3">
|
||||||
href="/workspace/models/create"
|
<Search className="size-3.5" />
|
||||||
>
|
</div>
|
||||||
<Plus className="size-3.5" />
|
<input
|
||||||
</a>
|
class=" w-full text-sm py-1 rounded-r-xl outline-none bg-transparent"
|
||||||
</div>
|
bind:value={searchValue}
|
||||||
</div>
|
placeholder={$i18n.t('Search Models')}
|
||||||
</div>
|
|
||||||
|
|
||||||
<a class=" flex space-x-4 cursor-pointer w-full mb-2 px-3 py-1" href="/workspace/models/create">
|
|
||||||
<div class=" self-center w-8 flex-shrink-0">
|
|
||||||
<div
|
|
||||||
class="w-full h-8 flex justify-center rounded-full bg-transparent dark:bg-gray-700 border border-dashed border-gray-200"
|
|
||||||
>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6">
|
|
||||||
<path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
d="M12 3.75a.75.75 0 01.75.75v6.75h6.75a.75.75 0 010 1.5h-6.75v6.75a.75.75 0 01-1.5 0v-6.75H4.5a.75.75 0 010-1.5h6.75V4.5a.75.75 0 01.75-.75z"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
/>
|
/>
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class=" self-center">
|
|
||||||
<div class=" font-semibold line-clamp-1">{$i18n.t('Create a model')}</div>
|
|
||||||
<div class=" text-sm line-clamp-1 text-gray-500">
|
|
||||||
{$i18n.t('Customize models for a specific purpose')}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<div class=" my-2 mb-5" id="model-list">
|
|
||||||
{#each filteredModels as model}
|
|
||||||
<div
|
|
||||||
class=" flex space-x-4 cursor-pointer w-full px-3 py-2 dark:hover:bg-white/5 hover:bg-black/5 rounded-lg transition"
|
|
||||||
id="model-item-{model.id}"
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
class=" flex flex-1 space-x-3.5 cursor-pointer w-full"
|
|
||||||
href={`/?models=${encodeURIComponent(model.id)}`}
|
|
||||||
>
|
|
||||||
<div class=" self-center w-8">
|
|
||||||
<div
|
|
||||||
class=" rounded-full object-cover {model.is_active
|
|
||||||
? ''
|
|
||||||
: 'opacity-50 dark:opacity-50'} "
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
src={model?.meta?.profile_image_url ?? '/static/favicon.png'}
|
|
||||||
alt="modelfile profile"
|
|
||||||
class=" rounded-full w-full h-auto object-cover"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class=" flex-1 self-center {model.is_active ? '' : 'text-gray-500'}">
|
|
||||||
<Tooltip
|
|
||||||
content={marked.parse(model?.meta?.description ?? model.id)}
|
|
||||||
className=" w-fit"
|
|
||||||
placement="top-start"
|
|
||||||
>
|
|
||||||
<div class=" font-semibold line-clamp-1">{model.name}</div>
|
|
||||||
</Tooltip>
|
|
||||||
<div class=" text-xs overflow-hidden text-ellipsis line-clamp-1 text-gray-500">
|
|
||||||
{model?.meta?.description ?? model.id}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
<div class="flex flex-row gap-0.5 items-center self-center">
|
|
||||||
{#if shiftKey}
|
|
||||||
<Tooltip content={$i18n.t('Delete')}>
|
|
||||||
<button
|
|
||||||
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
|
||||||
type="button"
|
|
||||||
on:click={() => {
|
|
||||||
deleteModelHandler(model);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<GarbageBin />
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
{:else}
|
|
||||||
{#if $user?.role === 'admin' || model.user_id === $user?.id}
|
|
||||||
<a
|
|
||||||
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
|
||||||
type="button"
|
|
||||||
href={`/workspace/models/edit?id=${encodeURIComponent(model.id)}`}
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
stroke="currentColor"
|
|
||||||
class="w-4 h-4"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<ModelMenu
|
|
||||||
user={$user}
|
|
||||||
{model}
|
|
||||||
shareHandler={() => {
|
|
||||||
shareModelHandler(model);
|
|
||||||
}}
|
|
||||||
cloneHandler={() => {
|
|
||||||
cloneModelHandler(model);
|
|
||||||
}}
|
|
||||||
exportHandler={() => {
|
|
||||||
exportModelHandler(model);
|
|
||||||
}}
|
|
||||||
hideHandler={() => {
|
|
||||||
hideModelHandler(model);
|
|
||||||
}}
|
|
||||||
deleteHandler={() => {
|
|
||||||
selectedModel = model;
|
|
||||||
showModelDeleteConfirm = true;
|
|
||||||
}}
|
|
||||||
onClose={() => {}}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
class="self-center w-fit text-sm p-1.5 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
<EllipsisHorizontal className="size-5" />
|
|
||||||
</button>
|
|
||||||
</ModelMenu>
|
|
||||||
|
|
||||||
<div class="ml-1">
|
|
||||||
<Tooltip content={model.is_active ? $i18n.t('Enabled') : $i18n.t('Disabled')}>
|
|
||||||
<Switch
|
|
||||||
bind:state={model.is_active}
|
|
||||||
on:change={async (e) => {
|
|
||||||
toggleModelById(localStorage.token, model.id);
|
|
||||||
_models.set(await getModels(localStorage.token));
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{#if $user?.role === 'admin'}
|
|
||||||
<div class=" flex justify-end w-full mb-3">
|
|
||||||
<div class="flex space-x-1">
|
|
||||||
<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) => {
|
|
||||||
let savedModels = JSON.parse(event.target.result);
|
|
||||||
console.log(savedModels);
|
|
||||||
|
|
||||||
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) => {
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await createNewModel(localStorage.token, model.info).catch((error) => {
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await _models.set(await getModels(localStorage.token));
|
|
||||||
models = await getWorkspaceModels(localStorage.token);
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.readAsText(importFiles[0]);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<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-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
|
||||||
on:click={() => {
|
|
||||||
modelsImportInputElement.click();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Import Models')}</div>
|
|
||||||
|
|
||||||
<div class=" self-center">
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
viewBox="0 0 16 16"
|
|
||||||
fill="currentColor"
|
|
||||||
class="w-3.5 h-3.5"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 9.5a.75.75 0 0 1-.75-.75V8.06l-.72.72a.75.75 0 0 1-1.06-1.06l2-2a.75.75 0 0 1 1.06 0l2 2a.75.75 0 1 1-1.06 1.06l-.72-.72v2.69a.75.75 0 0 1-.75.75Z"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<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-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
|
||||||
on:click={async () => {
|
|
||||||
downloadModels($_models);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Models')}</div>
|
|
||||||
|
|
||||||
<div class=" self-center">
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
viewBox="0 0 16 16"
|
|
||||||
fill="currentColor"
|
|
||||||
class="w-3.5 h-3.5"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if $config?.features.enable_community_sharing}
|
|
||||||
<div class=" my-16">
|
|
||||||
<div class=" text-lg font-semibold mb-0.5 line-clamp-1">
|
|
||||||
{$i18n.t('Made by OpenWebUI Community')}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<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"
|
|
||||||
href="https://openwebui.com/#open-webui-community"
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
<div class=" self-center">
|
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<a
|
||||||
<ChevronRight />
|
class=" px-2 py-2 rounded-xl hover:bg-gray-700/10 dark:hover:bg-gray-100/10 dark:text-gray-300 dark:hover:text-white transition font-medium text-sm flex items-center space-x-1"
|
||||||
|
href="/workspace/models/create"
|
||||||
|
>
|
||||||
|
<Plus className="size-3.5" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a class=" flex space-x-4 cursor-pointer w-full mb-2 px-3 py-1" href="/workspace/models/create">
|
||||||
|
<div class=" self-center w-8 flex-shrink-0">
|
||||||
|
<div
|
||||||
|
class="w-full h-8 flex justify-center rounded-full bg-transparent dark:bg-gray-700 border border-dashed border-gray-200"
|
||||||
|
>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6">
|
||||||
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="M12 3.75a.75.75 0 01.75.75v6.75h6.75a.75.75 0 010 1.5h-6.75v6.75a.75.75 0 01-1.5 0v-6.75H4.5a.75.75 0 010-1.5h6.75V4.5a.75.75 0 01.75-.75z"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class=" self-center">
|
||||||
|
<div class=" font-semibold line-clamp-1">{$i18n.t('Create a model')}</div>
|
||||||
|
<div class=" text-sm line-clamp-1 text-gray-500">
|
||||||
|
{$i18n.t('Customize models for a specific purpose')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class=" my-2 mb-5" id="model-list">
|
||||||
|
{#each filteredModels as model}
|
||||||
|
<div
|
||||||
|
class=" flex space-x-4 cursor-pointer w-full px-3 py-2 dark:hover:bg-white/5 hover:bg-black/5 rounded-lg transition"
|
||||||
|
id="model-item-{model.id}"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
class=" flex flex-1 space-x-3.5 cursor-pointer w-full"
|
||||||
|
href={`/?models=${encodeURIComponent(model.id)}`}
|
||||||
|
>
|
||||||
|
<div class=" self-center w-8">
|
||||||
|
<div
|
||||||
|
class=" rounded-full object-cover {model.is_active
|
||||||
|
? ''
|
||||||
|
: 'opacity-50 dark:opacity-50'} "
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={model?.meta?.profile_image_url ?? '/static/favicon.png'}
|
||||||
|
alt="modelfile profile"
|
||||||
|
class=" rounded-full w-full h-auto object-cover"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class=" flex-1 self-center {model.is_active ? '' : 'text-gray-500'}">
|
||||||
|
<Tooltip
|
||||||
|
content={marked.parse(model?.meta?.description ?? model.id)}
|
||||||
|
className=" w-fit"
|
||||||
|
placement="top-start"
|
||||||
|
>
|
||||||
|
<div class=" font-semibold line-clamp-1">{model.name}</div>
|
||||||
|
</Tooltip>
|
||||||
|
<div class=" text-xs overflow-hidden text-ellipsis line-clamp-1 text-gray-500">
|
||||||
|
{model?.meta?.description ?? model.id}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div class="flex flex-row gap-0.5 items-center self-center">
|
||||||
|
{#if shiftKey}
|
||||||
|
<Tooltip content={$i18n.t('Delete')}>
|
||||||
|
<button
|
||||||
|
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
||||||
|
type="button"
|
||||||
|
on:click={() => {
|
||||||
|
deleteModelHandler(model);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<GarbageBin />
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
{:else}
|
||||||
|
{#if $user?.role === 'admin' || model.user_id === $user?.id}
|
||||||
|
<a
|
||||||
|
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
||||||
|
type="button"
|
||||||
|
href={`/workspace/models/edit?id=${encodeURIComponent(model.id)}`}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="w-4 h-4"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<ModelMenu
|
||||||
|
user={$user}
|
||||||
|
{model}
|
||||||
|
shareHandler={() => {
|
||||||
|
shareModelHandler(model);
|
||||||
|
}}
|
||||||
|
cloneHandler={() => {
|
||||||
|
cloneModelHandler(model);
|
||||||
|
}}
|
||||||
|
exportHandler={() => {
|
||||||
|
exportModelHandler(model);
|
||||||
|
}}
|
||||||
|
hideHandler={() => {
|
||||||
|
hideModelHandler(model);
|
||||||
|
}}
|
||||||
|
deleteHandler={() => {
|
||||||
|
selectedModel = model;
|
||||||
|
showModelDeleteConfirm = true;
|
||||||
|
}}
|
||||||
|
onClose={() => {}}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
class="self-center w-fit text-sm p-1.5 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<EllipsisHorizontal className="size-5" />
|
||||||
|
</button>
|
||||||
|
</ModelMenu>
|
||||||
|
|
||||||
|
<div class="ml-1">
|
||||||
|
<Tooltip content={model.is_active ? $i18n.t('Enabled') : $i18n.t('Disabled')}>
|
||||||
|
<Switch
|
||||||
|
bind:state={model.is_active}
|
||||||
|
on:change={async (e) => {
|
||||||
|
toggleModelById(localStorage.token, model.id);
|
||||||
|
_models.set(await getModels(localStorage.token));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if $user?.role === 'admin'}
|
||||||
|
<div class=" flex justify-end w-full mb-3">
|
||||||
|
<div class="flex space-x-1">
|
||||||
|
<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) => {
|
||||||
|
let savedModels = JSON.parse(event.target.result);
|
||||||
|
console.log(savedModels);
|
||||||
|
|
||||||
|
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) => {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await createNewModel(localStorage.token, model.info).catch((error) => {
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await _models.set(await getModels(localStorage.token));
|
||||||
|
models = await getWorkspaceModels(localStorage.token);
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.readAsText(importFiles[0]);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<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-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
||||||
|
on:click={() => {
|
||||||
|
modelsImportInputElement.click();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Import Models')}</div>
|
||||||
|
|
||||||
|
<div class=" self-center">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
fill="currentColor"
|
||||||
|
class="w-3.5 h-3.5"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 9.5a.75.75 0 0 1-.75-.75V8.06l-.72.72a.75.75 0 0 1-1.06-1.06l2-2a.75.75 0 0 1 1.06 0l2 2a.75.75 0 1 1-1.06 1.06l-.72-.72v2.69a.75.75 0 0 1-.75.75Z"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<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-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
||||||
|
on:click={async () => {
|
||||||
|
downloadModels($_models);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Models')}</div>
|
||||||
|
|
||||||
|
<div class=" self-center">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
fill="currentColor"
|
||||||
|
class="w-3.5 h-3.5"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if $config?.features.enable_community_sharing}
|
||||||
|
<div class=" my-16">
|
||||||
|
<div class=" text-lg font-semibold mb-0.5 line-clamp-1">
|
||||||
|
{$i18n.t('Made by OpenWebUI Community')}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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"
|
||||||
|
href="https://openwebui.com/#open-webui-community"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
<div class=" self-center">
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<ChevronRight />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{:else}
|
||||||
|
<div class="w-full h-full flex justify-center items-center">
|
||||||
|
<Spinner />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -20,9 +20,11 @@
|
|||||||
import Search from '../icons/Search.svelte';
|
import Search from '../icons/Search.svelte';
|
||||||
import Plus from '../icons/Plus.svelte';
|
import Plus from '../icons/Plus.svelte';
|
||||||
import ChevronRight from '../icons/ChevronRight.svelte';
|
import ChevronRight from '../icons/ChevronRight.svelte';
|
||||||
|
import Spinner from '../common/Spinner.svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
let promptsImportInputElement: HTMLInputElement;
|
let promptsImportInputElement: HTMLInputElement;
|
||||||
|
let loaded = false;
|
||||||
|
|
||||||
let importFiles = '';
|
let importFiles = '';
|
||||||
let query = '';
|
let query = '';
|
||||||
@@ -78,6 +80,7 @@
|
|||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
await init();
|
await init();
|
||||||
|
loaded = true;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -87,233 +90,239 @@
|
|||||||
</title>
|
</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<DeleteConfirmDialog
|
{#if loaded}
|
||||||
bind:show={showDeleteConfirm}
|
<DeleteConfirmDialog
|
||||||
title={$i18n.t('Delete prompt?')}
|
bind:show={showDeleteConfirm}
|
||||||
on:confirm={() => {
|
title={$i18n.t('Delete prompt?')}
|
||||||
deleteHandler(deletePrompt);
|
on:confirm={() => {
|
||||||
}}
|
deleteHandler(deletePrompt);
|
||||||
>
|
}}
|
||||||
<div class=" text-sm text-gray-500">
|
>
|
||||||
{$i18n.t('This will delete')} <span class=" font-semibold">{deletePrompt.command}</span>.
|
<div class=" text-sm text-gray-500">
|
||||||
</div>
|
{$i18n.t('This will delete')} <span class=" font-semibold">{deletePrompt.command}</span>.
|
||||||
</DeleteConfirmDialog>
|
|
||||||
|
|
||||||
<div class="flex flex-col gap-1 mt-1.5 mb-2">
|
|
||||||
<div class="flex justify-between items-center">
|
|
||||||
<div class="flex md:self-center text-xl font-medium px-0.5 items-center">
|
|
||||||
{$i18n.t('Prompts')}
|
|
||||||
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50 dark:bg-gray-850" />
|
|
||||||
<span class="text-lg font-medium text-gray-500 dark:text-gray-300"
|
|
||||||
>{filteredItems.length}</span
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</DeleteConfirmDialog>
|
||||||
|
|
||||||
<div class=" flex w-full space-x-2">
|
<div class="flex flex-col gap-1 mt-1.5 mb-2">
|
||||||
<div class="flex flex-1">
|
<div class="flex justify-between items-center">
|
||||||
<div class=" self-center ml-1 mr-3">
|
<div class="flex md:self-center text-xl font-medium px-0.5 items-center">
|
||||||
<Search className="size-3.5" />
|
{$i18n.t('Prompts')}
|
||||||
</div>
|
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50 dark:bg-gray-850" />
|
||||||
<input
|
<span class="text-lg font-medium text-gray-500 dark:text-gray-300"
|
||||||
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-none bg-transparent"
|
>{filteredItems.length}</span
|
||||||
bind:value={query}
|
|
||||||
placeholder={$i18n.t('Search Prompts')}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<a
|
|
||||||
class=" px-2 py-2 rounded-xl hover:bg-gray-700/10 dark:hover:bg-gray-100/10 dark:text-gray-300 dark:hover:text-white transition font-medium text-sm flex items-center space-x-1"
|
|
||||||
href="/workspace/prompts/create"
|
|
||||||
>
|
|
||||||
<Plus className="size-3.5" />
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-5">
|
|
||||||
{#each filteredItems as prompt}
|
|
||||||
<div
|
|
||||||
class=" flex space-x-4 cursor-pointer w-full px-3 py-2 dark:hover:bg-white/5 hover:bg-black/5 rounded-xl"
|
|
||||||
>
|
|
||||||
<div class=" flex flex-1 space-x-4 cursor-pointer w-full">
|
|
||||||
<a href={`/workspace/prompts/edit?command=${encodeURIComponent(prompt.command)}`}>
|
|
||||||
<div class=" flex-1 self-center pl-1.5">
|
|
||||||
<div class=" font-semibold line-clamp-1">{prompt.command}</div>
|
|
||||||
<div class=" text-xs overflow-hidden text-ellipsis line-clamp-1">
|
|
||||||
{prompt.title}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-row gap-0.5 self-center">
|
|
||||||
<a
|
|
||||||
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
|
||||||
type="button"
|
|
||||||
href={`/workspace/prompts/edit?command=${encodeURIComponent(prompt.command)}`}
|
|
||||||
>
|
>
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
stroke="currentColor"
|
|
||||||
class="w-4 h-4"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487zm0 0L19.5 7.125"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<PromptMenu
|
|
||||||
shareHandler={() => {
|
|
||||||
shareHandler(prompt);
|
|
||||||
}}
|
|
||||||
cloneHandler={() => {
|
|
||||||
cloneHandler(prompt);
|
|
||||||
}}
|
|
||||||
exportHandler={() => {
|
|
||||||
exportHandler(prompt);
|
|
||||||
}}
|
|
||||||
deleteHandler={async () => {
|
|
||||||
deletePrompt = prompt;
|
|
||||||
showDeleteConfirm = true;
|
|
||||||
}}
|
|
||||||
onClose={() => {}}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
class="self-center w-fit text-sm p-1.5 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
<EllipsisHorizontal className="size-5" />
|
|
||||||
</button>
|
|
||||||
</PromptMenu>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{#if $user?.role === 'admin'}
|
<div class=" flex w-full space-x-2">
|
||||||
<div class=" flex justify-end w-full mb-3">
|
<div class="flex flex-1">
|
||||||
<div class="flex space-x-2">
|
<div class=" self-center ml-1 mr-3">
|
||||||
<input
|
<Search className="size-3.5" />
|
||||||
id="prompts-import-input"
|
|
||||||
bind:this={promptsImportInputElement}
|
|
||||||
bind:files={importFiles}
|
|
||||||
type="file"
|
|
||||||
accept=".json"
|
|
||||||
hidden
|
|
||||||
on:change={() => {
|
|
||||||
console.log(importFiles);
|
|
||||||
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = async (event) => {
|
|
||||||
const savedPrompts = JSON.parse(event.target.result);
|
|
||||||
console.log(savedPrompts);
|
|
||||||
|
|
||||||
for (const prompt of savedPrompts) {
|
|
||||||
await createNewPrompt(
|
|
||||||
localStorage.token,
|
|
||||||
prompt.command.charAt(0) === '/' ? prompt.command.slice(1) : prompt.command,
|
|
||||||
prompt.title,
|
|
||||||
prompt.content
|
|
||||||
).catch((error) => {
|
|
||||||
toast.error(error);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
prompts = await getPromptList(localStorage.token);
|
|
||||||
await _prompts.set(await getPrompts(localStorage.token));
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.readAsText(importFiles[0]);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<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-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
|
||||||
on:click={() => {
|
|
||||||
promptsImportInputElement.click();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Import Prompts')}</div>
|
|
||||||
|
|
||||||
<div class=" self-center">
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
viewBox="0 0 16 16"
|
|
||||||
fill="currentColor"
|
|
||||||
class="w-4 h-4"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 9.5a.75.75 0 0 1-.75-.75V8.06l-.72.72a.75.75 0 0 1-1.06-1.06l2-2a.75.75 0 0 1 1.06 0l2 2a.75.75 0 1 1-1.06 1.06l-.72-.72v2.69a.75.75 0 0 1-.75.75Z"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<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-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
|
||||||
on:click={async () => {
|
|
||||||
// promptsImportInputElement.click();
|
|
||||||
let blob = new Blob([JSON.stringify(prompts)], {
|
|
||||||
type: 'application/json'
|
|
||||||
});
|
|
||||||
saveAs(blob, `prompts-export-${Date.now()}.json`);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Prompts')}</div>
|
|
||||||
|
|
||||||
<div class=" self-center">
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
viewBox="0 0 16 16"
|
|
||||||
fill="currentColor"
|
|
||||||
class="w-4 h-4"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if $config?.features.enable_community_sharing}
|
|
||||||
<div class=" my-16">
|
|
||||||
<div class=" text-lg font-semibold mb-0.5 line-clamp-1">
|
|
||||||
{$i18n.t('Made by OpenWebUI Community')}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<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"
|
|
||||||
href="https://openwebui.com/#open-webui-community"
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
<div class=" self-center">
|
|
||||||
<div class=" font-semibold line-clamp-1">{$i18n.t('Discover a prompt')}</div>
|
|
||||||
<div class=" text-sm line-clamp-1">
|
|
||||||
{$i18n.t('Discover, download, and explore custom prompts')}
|
|
||||||
</div>
|
</div>
|
||||||
|
<input
|
||||||
|
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-none bg-transparent"
|
||||||
|
bind:value={query}
|
||||||
|
placeholder={$i18n.t('Search Prompts')}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<a
|
||||||
<ChevronRight />
|
class=" px-2 py-2 rounded-xl hover:bg-gray-700/10 dark:hover:bg-gray-100/10 dark:text-gray-300 dark:hover:text-white transition font-medium text-sm flex items-center space-x-1"
|
||||||
|
href="/workspace/prompts/create"
|
||||||
|
>
|
||||||
|
<Plus className="size-3.5" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-5">
|
||||||
|
{#each filteredItems as prompt}
|
||||||
|
<div
|
||||||
|
class=" flex space-x-4 cursor-pointer w-full px-3 py-2 dark:hover:bg-white/5 hover:bg-black/5 rounded-xl"
|
||||||
|
>
|
||||||
|
<div class=" flex flex-1 space-x-4 cursor-pointer w-full">
|
||||||
|
<a href={`/workspace/prompts/edit?command=${encodeURIComponent(prompt.command)}`}>
|
||||||
|
<div class=" flex-1 self-center pl-1.5">
|
||||||
|
<div class=" font-semibold line-clamp-1">{prompt.command}</div>
|
||||||
|
<div class=" text-xs overflow-hidden text-ellipsis line-clamp-1">
|
||||||
|
{prompt.title}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row gap-0.5 self-center">
|
||||||
|
<a
|
||||||
|
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
||||||
|
type="button"
|
||||||
|
href={`/workspace/prompts/edit?command=${encodeURIComponent(prompt.command)}`}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="w-4 h-4"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487zm0 0L19.5 7.125"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<PromptMenu
|
||||||
|
shareHandler={() => {
|
||||||
|
shareHandler(prompt);
|
||||||
|
}}
|
||||||
|
cloneHandler={() => {
|
||||||
|
cloneHandler(prompt);
|
||||||
|
}}
|
||||||
|
exportHandler={() => {
|
||||||
|
exportHandler(prompt);
|
||||||
|
}}
|
||||||
|
deleteHandler={async () => {
|
||||||
|
deletePrompt = prompt;
|
||||||
|
showDeleteConfirm = true;
|
||||||
|
}}
|
||||||
|
onClose={() => {}}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
class="self-center w-fit text-sm p-1.5 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<EllipsisHorizontal className="size-5" />
|
||||||
|
</button>
|
||||||
|
</PromptMenu>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if $user?.role === 'admin'}
|
||||||
|
<div class=" flex justify-end w-full mb-3">
|
||||||
|
<div class="flex space-x-2">
|
||||||
|
<input
|
||||||
|
id="prompts-import-input"
|
||||||
|
bind:this={promptsImportInputElement}
|
||||||
|
bind:files={importFiles}
|
||||||
|
type="file"
|
||||||
|
accept=".json"
|
||||||
|
hidden
|
||||||
|
on:change={() => {
|
||||||
|
console.log(importFiles);
|
||||||
|
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = async (event) => {
|
||||||
|
const savedPrompts = JSON.parse(event.target.result);
|
||||||
|
console.log(savedPrompts);
|
||||||
|
|
||||||
|
for (const prompt of savedPrompts) {
|
||||||
|
await createNewPrompt(
|
||||||
|
localStorage.token,
|
||||||
|
prompt.command.charAt(0) === '/' ? prompt.command.slice(1) : prompt.command,
|
||||||
|
prompt.title,
|
||||||
|
prompt.content
|
||||||
|
).catch((error) => {
|
||||||
|
toast.error(error);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
prompts = await getPromptList(localStorage.token);
|
||||||
|
await _prompts.set(await getPrompts(localStorage.token));
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.readAsText(importFiles[0]);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<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-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
||||||
|
on:click={() => {
|
||||||
|
promptsImportInputElement.click();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Import Prompts')}</div>
|
||||||
|
|
||||||
|
<div class=" self-center">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
fill="currentColor"
|
||||||
|
class="w-4 h-4"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 9.5a.75.75 0 0 1-.75-.75V8.06l-.72.72a.75.75 0 0 1-1.06-1.06l2-2a.75.75 0 0 1 1.06 0l2 2a.75.75 0 1 1-1.06 1.06l-.72-.72v2.69a.75.75 0 0 1-.75.75Z"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<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-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
||||||
|
on:click={async () => {
|
||||||
|
// promptsImportInputElement.click();
|
||||||
|
let blob = new Blob([JSON.stringify(prompts)], {
|
||||||
|
type: 'application/json'
|
||||||
|
});
|
||||||
|
saveAs(blob, `prompts-export-${Date.now()}.json`);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Prompts')}</div>
|
||||||
|
|
||||||
|
<div class=" self-center">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
fill="currentColor"
|
||||||
|
class="w-4 h-4"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if $config?.features.enable_community_sharing}
|
||||||
|
<div class=" my-16">
|
||||||
|
<div class=" text-lg font-semibold mb-0.5 line-clamp-1">
|
||||||
|
{$i18n.t('Made by OpenWebUI Community')}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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"
|
||||||
|
href="https://openwebui.com/#open-webui-community"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
<div class=" self-center">
|
||||||
|
<div class=" font-semibold line-clamp-1">{$i18n.t('Discover a prompt')}</div>
|
||||||
|
<div class=" text-sm line-clamp-1">
|
||||||
|
{$i18n.t('Discover, download, and explore custom prompts')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<ChevronRight />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{:else}
|
||||||
|
<div class="w-full h-full flex justify-center items-center">
|
||||||
|
<Spinner />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -29,10 +29,12 @@
|
|||||||
import Search from '../icons/Search.svelte';
|
import Search from '../icons/Search.svelte';
|
||||||
import Plus from '../icons/Plus.svelte';
|
import Plus from '../icons/Plus.svelte';
|
||||||
import ChevronRight from '../icons/ChevronRight.svelte';
|
import ChevronRight from '../icons/ChevronRight.svelte';
|
||||||
|
import Spinner from '../common/Spinner.svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
let shiftKey = false;
|
let shiftKey = false;
|
||||||
|
let loaded = false;
|
||||||
|
|
||||||
let toolsImportInputElement: HTMLInputElement;
|
let toolsImportInputElement: HTMLInputElement;
|
||||||
let importFiles;
|
let importFiles;
|
||||||
@@ -131,8 +133,10 @@
|
|||||||
_tools.set(await getTools(localStorage.token));
|
_tools.set(await getTools(localStorage.token));
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(() => {
|
onMount(async () => {
|
||||||
init();
|
await init();
|
||||||
|
loaded = true;
|
||||||
|
|
||||||
const onKeyDown = (event) => {
|
const onKeyDown = (event) => {
|
||||||
if (event.key === 'Shift') {
|
if (event.key === 'Shift') {
|
||||||
shiftKey = true;
|
shiftKey = true;
|
||||||
@@ -167,330 +171,336 @@
|
|||||||
</title>
|
</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class="flex flex-col gap-1 mt-1.5 mb-2">
|
{#if loaded}
|
||||||
<div class="flex justify-between items-center">
|
<div class="flex flex-col gap-1 mt-1.5 mb-2">
|
||||||
<div class="flex md:self-center text-xl font-medium px-0.5 items-center">
|
<div class="flex justify-between items-center">
|
||||||
{$i18n.t('Tools')}
|
<div class="flex md:self-center text-xl font-medium px-0.5 items-center">
|
||||||
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50 dark:bg-gray-850" />
|
{$i18n.t('Tools')}
|
||||||
<span class="text-lg font-medium text-gray-500 dark:text-gray-300"
|
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50 dark:bg-gray-850" />
|
||||||
>{filteredItems.length}</span
|
<span class="text-lg font-medium text-gray-500 dark:text-gray-300"
|
||||||
>
|
>{filteredItems.length}</span
|
||||||
</div>
|
>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class=" flex w-full space-x-2">
|
|
||||||
<div class="flex flex-1">
|
|
||||||
<div class=" self-center ml-1 mr-3">
|
|
||||||
<Search className="size-3.5" />
|
|
||||||
</div>
|
</div>
|
||||||
<input
|
|
||||||
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-none bg-transparent"
|
|
||||||
bind:value={query}
|
|
||||||
placeholder={$i18n.t('Search Tools')}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div class=" flex w-full space-x-2">
|
||||||
<a
|
<div class="flex flex-1">
|
||||||
class=" px-2 py-2 rounded-xl hover:bg-gray-700/10 dark:hover:bg-gray-100/10 dark:text-gray-300 dark:hover:text-white transition font-medium text-sm flex items-center space-x-1"
|
<div class=" self-center ml-1 mr-3">
|
||||||
href="/workspace/tools/create"
|
<Search className="size-3.5" />
|
||||||
>
|
</div>
|
||||||
<Plus className="size-3.5" />
|
<input
|
||||||
</a>
|
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-none bg-transparent"
|
||||||
|
bind:value={query}
|
||||||
|
placeholder={$i18n.t('Search Tools')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<a
|
||||||
|
class=" px-2 py-2 rounded-xl hover:bg-gray-700/10 dark:hover:bg-gray-100/10 dark:text-gray-300 dark:hover:text-white transition font-medium text-sm flex items-center space-x-1"
|
||||||
|
href="/workspace/tools/create"
|
||||||
|
>
|
||||||
|
<Plus className="size-3.5" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-5">
|
<div class="mb-5">
|
||||||
{#each filteredItems as tool}
|
{#each filteredItems as tool}
|
||||||
<div
|
<div
|
||||||
class=" flex space-x-4 cursor-pointer w-full px-3 py-2 dark:hover:bg-white/5 hover:bg-black/5 rounded-xl"
|
class=" flex space-x-4 cursor-pointer w-full px-3 py-2 dark:hover:bg-white/5 hover:bg-black/5 rounded-xl"
|
||||||
>
|
|
||||||
<a
|
|
||||||
class=" flex flex-1 space-x-3.5 cursor-pointer w-full"
|
|
||||||
href={`/workspace/tools/edit?id=${encodeURIComponent(tool.id)}`}
|
|
||||||
>
|
>
|
||||||
<div class="flex items-center text-left">
|
<a
|
||||||
<div class=" flex-1 self-center pl-1">
|
class=" flex flex-1 space-x-3.5 cursor-pointer w-full"
|
||||||
<div class=" font-semibold flex items-center gap-1.5">
|
href={`/workspace/tools/edit?id=${encodeURIComponent(tool.id)}`}
|
||||||
<div
|
>
|
||||||
class=" text-xs font-bold px-1 rounded uppercase line-clamp-1 bg-gray-500/20 text-gray-700 dark:text-gray-200"
|
<div class="flex items-center text-left">
|
||||||
>
|
<div class=" flex-1 self-center pl-1">
|
||||||
TOOL
|
<div class=" font-semibold flex items-center gap-1.5">
|
||||||
</div>
|
|
||||||
|
|
||||||
{#if tool?.meta?.manifest?.version}
|
|
||||||
<div
|
<div
|
||||||
class="text-xs font-bold px-1 rounded line-clamp-1 bg-gray-500/20 text-gray-700 dark:text-gray-200"
|
class=" text-xs font-bold px-1 rounded uppercase line-clamp-1 bg-gray-500/20 text-gray-700 dark:text-gray-200"
|
||||||
>
|
>
|
||||||
v{tool?.meta?.manifest?.version ?? ''}
|
TOOL
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
|
||||||
|
|
||||||
<div class="line-clamp-1">
|
{#if tool?.meta?.manifest?.version}
|
||||||
{tool.name}
|
<div
|
||||||
|
class="text-xs font-bold px-1 rounded line-clamp-1 bg-gray-500/20 text-gray-700 dark:text-gray-200"
|
||||||
|
>
|
||||||
|
v{tool?.meta?.manifest?.version ?? ''}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="line-clamp-1">
|
||||||
|
{tool.name}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex gap-1.5 px-1">
|
<div class="flex gap-1.5 px-1">
|
||||||
<div class=" text-gray-500 text-xs font-medium flex-shrink-0">{tool.id}</div>
|
<div class=" text-gray-500 text-xs font-medium flex-shrink-0">{tool.id}</div>
|
||||||
|
|
||||||
<div class=" text-xs overflow-hidden text-ellipsis line-clamp-1">
|
<div class=" text-xs overflow-hidden text-ellipsis line-clamp-1">
|
||||||
{tool.meta.description}
|
{tool.meta.description}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</a>
|
||||||
</a>
|
<div class="flex flex-row gap-0.5 self-center">
|
||||||
<div class="flex flex-row gap-0.5 self-center">
|
{#if shiftKey}
|
||||||
{#if shiftKey}
|
<Tooltip content={$i18n.t('Delete')}>
|
||||||
<Tooltip content={$i18n.t('Delete')}>
|
<button
|
||||||
<button
|
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
||||||
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
type="button"
|
||||||
type="button"
|
on:click={() => {
|
||||||
on:click={() => {
|
deleteHandler(tool);
|
||||||
deleteHandler(tool);
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<GarbageBin />
|
||||||
<GarbageBin />
|
</button>
|
||||||
</button>
|
</Tooltip>
|
||||||
</Tooltip>
|
{:else}
|
||||||
{:else}
|
{#if tool?.meta?.manifest?.funding_url ?? false}
|
||||||
{#if tool?.meta?.manifest?.funding_url ?? false}
|
<Tooltip content="Support">
|
||||||
<Tooltip content="Support">
|
<button
|
||||||
|
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
||||||
|
type="button"
|
||||||
|
on:click={() => {
|
||||||
|
selectedTool = tool;
|
||||||
|
showManifestModal = true;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Heart />
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<Tooltip content={$i18n.t('Valves')}>
|
||||||
<button
|
<button
|
||||||
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
||||||
type="button"
|
type="button"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
selectedTool = tool;
|
selectedTool = tool;
|
||||||
showManifestModal = true;
|
showValvesModal = true;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Heart />
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="size-4"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28Z"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
{/if}
|
|
||||||
|
|
||||||
<Tooltip content={$i18n.t('Valves')}>
|
<ToolMenu
|
||||||
<button
|
editHandler={() => {
|
||||||
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
goto(`/workspace/tools/edit?id=${encodeURIComponent(tool.id)}`);
|
||||||
type="button"
|
|
||||||
on:click={() => {
|
|
||||||
selectedTool = tool;
|
|
||||||
showValvesModal = true;
|
|
||||||
}}
|
}}
|
||||||
|
shareHandler={() => {
|
||||||
|
shareHandler(tool);
|
||||||
|
}}
|
||||||
|
cloneHandler={() => {
|
||||||
|
cloneHandler(tool);
|
||||||
|
}}
|
||||||
|
exportHandler={() => {
|
||||||
|
exportHandler(tool);
|
||||||
|
}}
|
||||||
|
deleteHandler={async () => {
|
||||||
|
selectedTool = tool;
|
||||||
|
showDeleteConfirm = true;
|
||||||
|
}}
|
||||||
|
onClose={() => {}}
|
||||||
>
|
>
|
||||||
<svg
|
<button
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
class="self-center w-fit text-sm p-1.5 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
||||||
fill="none"
|
type="button"
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
stroke="currentColor"
|
|
||||||
class="size-4"
|
|
||||||
>
|
>
|
||||||
<path
|
<EllipsisHorizontal className="size-5" />
|
||||||
stroke-linecap="round"
|
</button>
|
||||||
stroke-linejoin="round"
|
</ToolMenu>
|
||||||
d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28Z"
|
{/if}
|
||||||
/>
|
</div>
|
||||||
<path
|
</div>
|
||||||
stroke-linecap="round"
|
{/each}
|
||||||
stroke-linejoin="round"
|
</div>
|
||||||
d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
|
|
||||||
<ToolMenu
|
{#if $user?.role === 'admin'}
|
||||||
editHandler={() => {
|
<div class=" flex justify-end w-full mb-2">
|
||||||
goto(`/workspace/tools/edit?id=${encodeURIComponent(tool.id)}`);
|
<div class="flex space-x-2">
|
||||||
}}
|
<input
|
||||||
shareHandler={() => {
|
id="documents-import-input"
|
||||||
shareHandler(tool);
|
bind:this={toolsImportInputElement}
|
||||||
}}
|
bind:files={importFiles}
|
||||||
cloneHandler={() => {
|
type="file"
|
||||||
cloneHandler(tool);
|
accept=".json"
|
||||||
}}
|
hidden
|
||||||
exportHandler={() => {
|
on:change={() => {
|
||||||
exportHandler(tool);
|
console.log(importFiles);
|
||||||
}}
|
showConfirm = true;
|
||||||
deleteHandler={async () => {
|
}}
|
||||||
selectedTool = tool;
|
/>
|
||||||
showDeleteConfirm = true;
|
|
||||||
}}
|
<button
|
||||||
onClose={() => {}}
|
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-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
||||||
>
|
on:click={() => {
|
||||||
<button
|
toolsImportInputElement.click();
|
||||||
class="self-center w-fit text-sm p-1.5 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
}}
|
||||||
type="button"
|
>
|
||||||
|
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Import Tools')}</div>
|
||||||
|
|
||||||
|
<div class=" self-center">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
fill="currentColor"
|
||||||
|
class="w-4 h-4"
|
||||||
>
|
>
|
||||||
<EllipsisHorizontal className="size-5" />
|
<path
|
||||||
</button>
|
fill-rule="evenodd"
|
||||||
</ToolMenu>
|
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 9.5a.75.75 0 0 1-.75-.75V8.06l-.72.72a.75.75 0 0 1-1.06-1.06l2-2a.75.75 0 0 1 1.06 0l2 2a.75.75 0 1 1-1.06 1.06l-.72-.72v2.69a.75.75 0 0 1-.75.75Z"
|
||||||
{/if}
|
clip-rule="evenodd"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<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-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
||||||
|
on:click={async () => {
|
||||||
|
const _tools = await exportTools(localStorage.token).catch((error) => {
|
||||||
|
toast.error(error);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (_tools) {
|
||||||
|
let blob = new Blob([JSON.stringify(_tools)], {
|
||||||
|
type: 'application/json'
|
||||||
|
});
|
||||||
|
saveAs(blob, `tools-export-${Date.now()}.json`);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Tools')}</div>
|
||||||
|
|
||||||
|
<div class=" self-center">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
fill="currentColor"
|
||||||
|
class="w-4 h-4"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/if}
|
||||||
</div>
|
|
||||||
|
|
||||||
{#if $user?.role === 'admin'}
|
{#if $config?.features.enable_community_sharing}
|
||||||
<div class=" flex justify-end w-full mb-2">
|
<div class=" my-16">
|
||||||
<div class="flex space-x-2">
|
<div class=" text-lg font-semibold mb-0.5 line-clamp-1">
|
||||||
<input
|
{$i18n.t('Made by OpenWebUI Community')}
|
||||||
id="documents-import-input"
|
</div>
|
||||||
bind:this={toolsImportInputElement}
|
|
||||||
bind:files={importFiles}
|
|
||||||
type="file"
|
|
||||||
accept=".json"
|
|
||||||
hidden
|
|
||||||
on:change={() => {
|
|
||||||
console.log(importFiles);
|
|
||||||
showConfirm = true;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<button
|
<a
|
||||||
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-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
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"
|
||||||
on:click={() => {
|
href="https://openwebui.com/#open-webui-community"
|
||||||
toolsImportInputElement.click();
|
target="_blank"
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Import Tools')}</div>
|
|
||||||
|
|
||||||
<div class=" self-center">
|
<div class=" self-center">
|
||||||
<svg
|
<div class=" font-semibold line-clamp-1">{$i18n.t('Discover a tool')}</div>
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<div class=" text-sm line-clamp-1">
|
||||||
viewBox="0 0 16 16"
|
{$i18n.t('Discover, download, and explore custom tools')}
|
||||||
fill="currentColor"
|
</div>
|
||||||
class="w-4 h-4"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 9.5a.75.75 0 0 1-.75-.75V8.06l-.72.72a.75.75 0 0 1-1.06-1.06l2-2a.75.75 0 0 1 1.06 0l2 2a.75.75 0 1 1-1.06 1.06l-.72-.72v2.69a.75.75 0 0 1-.75.75Z"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
</div>
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
<div>
|
||||||
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-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
<div>
|
||||||
on:click={async () => {
|
<ChevronRight />
|
||||||
const _tools = await exportTools(localStorage.token).catch((error) => {
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<DeleteConfirmDialog
|
||||||
|
bind:show={showDeleteConfirm}
|
||||||
|
title={$i18n.t('Delete tool?')}
|
||||||
|
on:confirm={() => {
|
||||||
|
deleteHandler(selectedTool);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class=" text-sm text-gray-500">
|
||||||
|
{$i18n.t('This will delete')} <span class=" font-semibold">{selectedTool.name}</span>.
|
||||||
|
</div>
|
||||||
|
</DeleteConfirmDialog>
|
||||||
|
|
||||||
|
<ValvesModal bind:show={showValvesModal} type="tool" id={selectedTool?.id ?? null} />
|
||||||
|
<ManifestModal bind:show={showManifestModal} manifest={selectedTool?.meta?.manifest ?? {}} />
|
||||||
|
|
||||||
|
<ConfirmDialog
|
||||||
|
bind:show={showConfirm}
|
||||||
|
on:confirm={() => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = async (event) => {
|
||||||
|
const _tools = JSON.parse(event.target.result);
|
||||||
|
console.log(_tools);
|
||||||
|
|
||||||
|
for (const tool of _tools) {
|
||||||
|
const res = await createNewTool(localStorage.token, tool).catch((error) => {
|
||||||
toast.error(error);
|
toast.error(error);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (_tools) {
|
toast.success($i18n.t('Tool imported successfully'));
|
||||||
let blob = new Blob([JSON.stringify(_tools)], {
|
tools.set(await getTools(localStorage.token));
|
||||||
type: 'application/json'
|
};
|
||||||
});
|
|
||||||
saveAs(blob, `tools-export-${Date.now()}.json`);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Tools')}</div>
|
|
||||||
|
|
||||||
<div class=" self-center">
|
reader.readAsText(importFiles[0]);
|
||||||
<svg
|
}}
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
>
|
||||||
viewBox="0 0 16 16"
|
<div class="text-sm text-gray-500">
|
||||||
fill="currentColor"
|
<div class=" bg-yellow-500/20 text-yellow-700 dark:text-yellow-200 rounded-lg px-4 py-3">
|
||||||
class="w-4 h-4"
|
<div>{$i18n.t('Please carefully review the following warnings:')}</div>
|
||||||
>
|
|
||||||
<path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if $config?.features.enable_community_sharing}
|
<ul class=" mt-1 list-disc pl-4 text-xs">
|
||||||
<div class=" my-16">
|
<li>
|
||||||
<div class=" text-lg font-semibold mb-0.5 line-clamp-1">
|
{$i18n.t('Tools have a function calling system that allows arbitrary code execution')}.
|
||||||
{$i18n.t('Made by OpenWebUI Community')}
|
</li>
|
||||||
</div>
|
<li>{$i18n.t('Do not install tools from sources you do not fully trust.')}</li>
|
||||||
|
</ul>
|
||||||
<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"
|
|
||||||
href="https://openwebui.com/#open-webui-community"
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
<div class=" self-center">
|
|
||||||
<div class=" font-semibold line-clamp-1">{$i18n.t('Discover a tool')}</div>
|
|
||||||
<div class=" text-sm line-clamp-1">
|
|
||||||
{$i18n.t('Discover, download, and explore custom tools')}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div class="my-3">
|
||||||
<div>
|
{$i18n.t(
|
||||||
<ChevronRight />
|
'I acknowledge that I have read and I understand the implications of my action. I am aware of the risks associated with executing arbitrary code and I have verified the trustworthiness of the source.'
|
||||||
</div>
|
)}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</div>
|
||||||
|
</ConfirmDialog>
|
||||||
|
{:else}
|
||||||
|
<div class="w-full h-full flex justify-center items-center">
|
||||||
|
<Spinner />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<DeleteConfirmDialog
|
|
||||||
bind:show={showDeleteConfirm}
|
|
||||||
title={$i18n.t('Delete tool?')}
|
|
||||||
on:confirm={() => {
|
|
||||||
deleteHandler(selectedTool);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class=" text-sm text-gray-500">
|
|
||||||
{$i18n.t('This will delete')} <span class=" font-semibold">{selectedTool.name}</span>.
|
|
||||||
</div>
|
|
||||||
</DeleteConfirmDialog>
|
|
||||||
|
|
||||||
<ValvesModal bind:show={showValvesModal} type="tool" id={selectedTool?.id ?? null} />
|
|
||||||
<ManifestModal bind:show={showManifestModal} manifest={selectedTool?.meta?.manifest ?? {}} />
|
|
||||||
|
|
||||||
<ConfirmDialog
|
|
||||||
bind:show={showConfirm}
|
|
||||||
on:confirm={() => {
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = async (event) => {
|
|
||||||
const _tools = JSON.parse(event.target.result);
|
|
||||||
console.log(_tools);
|
|
||||||
|
|
||||||
for (const tool of _tools) {
|
|
||||||
const res = await createNewTool(localStorage.token, tool).catch((error) => {
|
|
||||||
toast.error(error);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toast.success($i18n.t('Tool imported successfully'));
|
|
||||||
tools.set(await getTools(localStorage.token));
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.readAsText(importFiles[0]);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class="text-sm text-gray-500">
|
|
||||||
<div class=" bg-yellow-500/20 text-yellow-700 dark:text-yellow-200 rounded-lg px-4 py-3">
|
|
||||||
<div>{$i18n.t('Please carefully review the following warnings:')}</div>
|
|
||||||
|
|
||||||
<ul class=" mt-1 list-disc pl-4 text-xs">
|
|
||||||
<li>
|
|
||||||
{$i18n.t('Tools have a function calling system that allows arbitrary code execution')}.
|
|
||||||
</li>
|
|
||||||
<li>{$i18n.t('Do not install tools from sources you do not fully trust.')}</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="my-3">
|
|
||||||
{$i18n.t(
|
|
||||||
'I acknowledge that I have read and I understand the implications of my action. I am aware of the risks associated with executing arbitrary code and I have verified the trustworthiness of the source.'
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ConfirmDialog>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user