refac: move functions (plugin) to admin panel

This commit is contained in:
Timothy Jaeryang Baek 2024-11-14 18:32:23 -08:00
parent 0cf1969adc
commit 947444949a
9 changed files with 25 additions and 38 deletions

View File

@ -5,7 +5,6 @@
import { WEBUI_NAME, config, functions, models } from '$lib/stores';
import { onMount, getContext, tick } from 'svelte';
import { createNewPrompt, deletePromptByCommand, getPrompts } from '$lib/apis/prompts';
import { goto } from '$app/navigation';
import {
@ -25,8 +24,8 @@
import FunctionMenu from './Functions/FunctionMenu.svelte';
import EllipsisHorizontal from '../icons/EllipsisHorizontal.svelte';
import Switch from '../common/Switch.svelte';
import ValvesModal from './common/ValvesModal.svelte';
import ManifestModal from './common/ManifestModal.svelte';
import ValvesModal from '../workspace/common/ValvesModal.svelte';
import ManifestModal from '../workspace/common/ManifestModal.svelte';
import Heart from '../icons/Heart.svelte';
import DeleteConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
import GarbageBin from '../icons/GarbageBin.svelte';
@ -98,7 +97,7 @@
id: `${_function.id}_clone`,
name: `${_function.name} (Clone)`
});
goto('/workspace/functions/create');
goto('/admin/functions/create');
}
};
@ -210,7 +209,7 @@
<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/functions/create"
href="/admin/functions/create"
>
<Plus className="size-3.5" />
</a>
@ -225,7 +224,7 @@
>
<a
class=" flex flex-1 space-x-3.5 cursor-pointer w-full"
href={`/workspace/functions/edit?id=${encodeURIComponent(func.id)}`}
href={`/admin/functions/edit?id=${encodeURIComponent(func.id)}`}
>
<div class="flex items-center text-left">
<div class=" flex-1 self-center pl-1">
@ -322,7 +321,7 @@
<FunctionMenu
{func}
editHandler={() => {
goto(`/workspace/functions/edit?id=${encodeURIComponent(func.id)}`);
goto(`/admin/functions/edit?id=${encodeURIComponent(func.id)}`);
}}
shareHandler={() => {
shareHandler(func);

View File

@ -305,7 +305,7 @@ class Pipe:
<button
class="w-full text-left text-sm py-1.5 px-1 rounded-lg dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-gray-850"
on:click={() => {
goto('/workspace/functions');
goto('/admin/functions');
}}
type="button"
>

View File

@ -323,12 +323,6 @@
{/each}
</div>
<div class=" text-gray-500 text-xs mt-1 mb-2">
{$i18n.t(
'Admins have access to all tools at all times; users need tools assigned per model in the workspace.'
)}
</div>
<div class=" flex justify-end w-full mb-2">
<div class="flex space-x-2">
<input

View File

@ -65,6 +65,13 @@
href="/admin/evaluations">{$i18n.t('Evaluations')}</a
>
<a
class="min-w-fit rounded-full p-1.5 {$page.url.pathname.includes('/admin/functions')
? ''
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"
href="/admin/functions">{$i18n.t('Functions')}</a
>
<a
class="min-w-fit rounded-full p-1.5 {$page.url.pathname.includes('/admin/settings')
? ''

View File

@ -3,7 +3,7 @@
import { functions } from '$lib/stores';
import { getFunctions } from '$lib/apis/functions';
import Functions from '$lib/components/workspace/Functions.svelte';
import Functions from '$lib/components/admin/Functions.svelte';
onMount(async () => {
await Promise.all([

View File

@ -5,7 +5,7 @@
import { functions, models } from '$lib/stores';
import { createNewFunction, getFunctions } from '$lib/apis/functions';
import FunctionEditor from '$lib/components/workspace/Functions/FunctionEditor.svelte';
import FunctionEditor from '$lib/components/admin/Functions/FunctionEditor.svelte';
import { getModels } from '$lib/apis';
import { compareVersion, extractFrontmatter } from '$lib/utils';
import { WEBUI_VERSION } from '$lib/constants';

View File

@ -7,7 +7,7 @@
import { functions, models } from '$lib/stores';
import { updateFunctionById, getFunctions, getFunctionById } from '$lib/apis/functions';
import FunctionEditor from '$lib/components/workspace/Functions/FunctionEditor.svelte';
import FunctionEditor from '$lib/components/admin/Functions/FunctionEditor.svelte';
import Spinner from '$lib/components/common/Spinner.svelte';
import { getModels } from '$lib/apis';
import { compareVersion, extractFrontmatter } from '$lib/utils';

View File

@ -82,7 +82,6 @@
href="/workspace/prompts">{$i18n.t('Prompts')}</a
>
{#if $user?.role === 'admin'}
<a
class="min-w-fit rounded-full p-1.5 {$page.url.pathname.includes('/workspace/tools')
? ''
@ -91,18 +90,6 @@
>
{$i18n.t('Tools')}
</a>
<a
class="min-w-fit rounded-full p-1.5 {$page.url.pathname.includes(
'/workspace/functions'
)
? ''
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"
href="/workspace/functions"
>
{$i18n.t('Functions')}
</a>
{/if}
</div>
</div>