2024-06-09 08:44:08 +00:00
|
|
|
<script lang="ts">
|
2025-05-24 22:17:51 +00:00
|
|
|
import fileSaver from 'file-saver';
|
|
|
|
|
const { saveAs } = fileSaver;
|
|
|
|
|
|
2024-06-09 09:39:18 +00:00
|
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
|
import { toast } from 'svelte-sonner';
|
|
|
|
|
|
2025-05-10 18:43:53 +00:00
|
|
|
import { getBackendConfig, getModels, getTaskConfig, updateTaskConfig } from '$lib/apis';
|
2024-06-09 08:44:08 +00:00
|
|
|
import { setDefaultPromptSuggestions } from '$lib/apis/configs';
|
2025-05-10 18:43:53 +00:00
|
|
|
import { config, settings, user } from '$lib/stores';
|
2024-06-09 08:44:08 +00:00
|
|
|
import { createEventDispatcher, onMount, getContext } from 'svelte';
|
2024-06-09 09:39:18 +00:00
|
|
|
|
|
|
|
|
import { banners as _banners } from '$lib/stores';
|
|
|
|
|
import type { Banner } from '$lib/types';
|
|
|
|
|
|
2025-05-22 22:02:11 +00:00
|
|
|
import { getBaseModels } from '$lib/apis/models';
|
2024-06-09 09:39:18 +00:00
|
|
|
import { getBanners, setBanners } from '$lib/apis/configs';
|
|
|
|
|
|
2024-06-09 08:44:08 +00:00
|
|
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
2024-06-09 09:39:18 +00:00
|
|
|
import Switch from '$lib/components/common/Switch.svelte';
|
2024-10-20 06:17:47 +00:00
|
|
|
import Textarea from '$lib/components/common/Textarea.svelte';
|
2025-05-10 18:43:53 +00:00
|
|
|
import Spinner from '$lib/components/common/Spinner.svelte';
|
2025-05-22 22:02:11 +00:00
|
|
|
import Banners from './Interface/Banners.svelte';
|
2024-06-09 09:39:18 +00:00
|
|
|
|
2024-06-09 08:44:08 +00:00
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
|
|
|
|
|
const i18n = getContext('i18n');
|
|
|
|
|
|
2024-06-09 22:00:38 +00:00
|
|
|
let taskConfig = {
|
|
|
|
|
TASK_MODEL: '',
|
|
|
|
|
TASK_MODEL_EXTERNAL: '',
|
2025-02-13 15:28:39 +00:00
|
|
|
ENABLE_TITLE_GENERATION: true,
|
2024-06-09 22:00:38 +00:00
|
|
|
TITLE_GENERATION_PROMPT_TEMPLATE: '',
|
2025-06-03 14:07:29 +00:00
|
|
|
ENABLE_FOLLOW_UP_GENERATION: true,
|
|
|
|
|
FOLLOW_UP_GENERATION_PROMPT_TEMPLATE: '',
|
2025-01-16 08:06:37 +00:00
|
|
|
IMAGE_PROMPT_GENERATION_PROMPT_TEMPLATE: '',
|
2024-12-01 02:30:59 +00:00
|
|
|
ENABLE_AUTOCOMPLETE_GENERATION: true,
|
|
|
|
|
AUTOCOMPLETE_GENERATION_INPUT_MAX_LENGTH: -1,
|
2024-10-25 07:05:04 +00:00
|
|
|
TAGS_GENERATION_PROMPT_TEMPLATE: '',
|
2024-11-06 02:32:08 +00:00
|
|
|
ENABLE_TAGS_GENERATION: true,
|
2024-11-19 10:24:32 +00:00
|
|
|
ENABLE_SEARCH_QUERY_GENERATION: true,
|
|
|
|
|
ENABLE_RETRIEVAL_QUERY_GENERATION: true,
|
2025-02-02 05:01:06 +00:00
|
|
|
QUERY_GENERATION_PROMPT_TEMPLATE: '',
|
|
|
|
|
TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE: ''
|
2024-06-09 22:00:38 +00:00
|
|
|
};
|
2024-06-09 09:39:18 +00:00
|
|
|
|
2024-06-09 08:44:08 +00:00
|
|
|
let promptSuggestions = [];
|
2024-06-09 09:39:18 +00:00
|
|
|
let banners: Banner[] = [];
|
2024-06-09 08:44:08 +00:00
|
|
|
|
|
|
|
|
const updateInterfaceHandler = async () => {
|
2024-06-09 22:00:38 +00:00
|
|
|
taskConfig = await updateTaskConfig(localStorage.token, taskConfig);
|
|
|
|
|
|
2025-05-23 14:22:57 +00:00
|
|
|
promptSuggestions = promptSuggestions.filter((p) => p.content !== '');
|
2024-06-09 08:44:08 +00:00
|
|
|
promptSuggestions = await setDefaultPromptSuggestions(localStorage.token, promptSuggestions);
|
2024-06-09 09:39:18 +00:00
|
|
|
await updateBanners();
|
2024-06-09 22:00:38 +00:00
|
|
|
|
2024-06-09 08:44:08 +00:00
|
|
|
await config.set(await getBackendConfig());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onMount(async () => {
|
2025-05-10 18:43:53 +00:00
|
|
|
await init();
|
2024-06-09 22:00:38 +00:00
|
|
|
taskConfig = await getTaskConfig(localStorage.token);
|
2024-06-09 08:44:08 +00:00
|
|
|
|
2025-02-19 04:07:59 +00:00
|
|
|
promptSuggestions = $config?.default_prompt_suggestions ?? [];
|
2024-06-09 09:39:18 +00:00
|
|
|
banners = await getBanners(localStorage.token);
|
2024-06-09 08:44:08 +00:00
|
|
|
});
|
2024-06-09 09:39:18 +00:00
|
|
|
|
|
|
|
|
const updateBanners = async () => {
|
|
|
|
|
_banners.set(await setBanners(localStorage.token, banners));
|
|
|
|
|
};
|
2025-05-10 18:43:53 +00:00
|
|
|
|
|
|
|
|
let workspaceModels = null;
|
|
|
|
|
let baseModels = null;
|
|
|
|
|
|
|
|
|
|
let models = null;
|
|
|
|
|
|
|
|
|
|
const init = async () => {
|
|
|
|
|
workspaceModels = await getBaseModels(localStorage.token);
|
2025-05-19 01:12:53 +00:00
|
|
|
baseModels = await getModels(localStorage.token, null, false);
|
2025-05-10 18:43:53 +00:00
|
|
|
|
|
|
|
|
models = baseModels.map((m) => {
|
|
|
|
|
const workspaceModel = workspaceModels.find((wm) => wm.id === m.id);
|
|
|
|
|
|
|
|
|
|
if (workspaceModel) {
|
|
|
|
|
return {
|
|
|
|
|
...m,
|
|
|
|
|
...workspaceModel
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
|
|
|
|
...m,
|
|
|
|
|
id: m.id,
|
|
|
|
|
name: m.name,
|
|
|
|
|
|
|
|
|
|
is_active: true
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2025-05-15 19:53:07 +00:00
|
|
|
console.debug('models', models);
|
2025-05-10 18:43:53 +00:00
|
|
|
};
|
2024-06-09 08:44:08 +00:00
|
|
|
</script>
|
|
|
|
|
|
2025-05-10 18:43:53 +00:00
|
|
|
{#if models !== null && taskConfig}
|
2024-11-26 22:14:26 +00:00
|
|
|
<form
|
|
|
|
|
class="flex flex-col h-full justify-between space-y-3 text-sm"
|
|
|
|
|
on:submit|preventDefault={() => {
|
|
|
|
|
updateInterfaceHandler();
|
|
|
|
|
dispatch('save');
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div class=" overflow-y-scroll scrollbar-hidden h-full pr-1.5">
|
2025-02-16 03:50:40 +00:00
|
|
|
<div class="mb-3.5">
|
|
|
|
|
<div class=" mb-2.5 text-base font-medium">{$i18n.t('Tasks')}</div>
|
|
|
|
|
|
|
|
|
|
<hr class=" border-gray-100 dark:border-gray-850 my-2" />
|
|
|
|
|
|
2025-05-16 21:47:48 +00:00
|
|
|
<div class=" mb-2 font-medium flex items-center">
|
|
|
|
|
<div class=" text-xs mr-1">{$i18n.t('Task Model')}</div>
|
2024-11-26 22:14:26 +00:00
|
|
|
<Tooltip
|
|
|
|
|
content={$i18n.t(
|
|
|
|
|
'A task model is used when performing tasks such as generating titles for chats and web search queries'
|
|
|
|
|
)}
|
2024-06-09 08:44:08 +00:00
|
|
|
>
|
2024-11-26 22:14:26 +00:00
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
fill="none"
|
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
|
stroke-width="1.5"
|
|
|
|
|
stroke="currentColor"
|
|
|
|
|
class="size-3.5"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
stroke-linecap="round"
|
|
|
|
|
stroke-linejoin="round"
|
|
|
|
|
d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</Tooltip>
|
2024-06-09 08:44:08 +00:00
|
|
|
</div>
|
2025-02-16 03:50:40 +00:00
|
|
|
|
|
|
|
|
<div class=" mb-2.5 flex w-full gap-2">
|
2024-11-26 22:14:26 +00:00
|
|
|
<div class="flex-1">
|
2025-05-16 21:47:48 +00:00
|
|
|
<div class=" text-xs mb-1">{$i18n.t('Local Task Model')}</div>
|
2024-11-26 22:14:26 +00:00
|
|
|
<select
|
2025-02-16 03:27:25 +00:00
|
|
|
class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-hidden"
|
2024-11-26 22:14:26 +00:00
|
|
|
bind:value={taskConfig.TASK_MODEL}
|
|
|
|
|
placeholder={$i18n.t('Select a model')}
|
2025-05-10 18:43:53 +00:00
|
|
|
on:change={() => {
|
|
|
|
|
if (taskConfig.TASK_MODEL) {
|
|
|
|
|
const model = models.find((m) => m.id === taskConfig.TASK_MODEL);
|
|
|
|
|
if (model) {
|
|
|
|
|
if (model?.access_control !== null) {
|
|
|
|
|
toast.error(
|
|
|
|
|
$i18n.t(
|
|
|
|
|
'This model is not publicly available. Please select another model.'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
taskConfig.TASK_MODEL = model.id;
|
|
|
|
|
} else {
|
|
|
|
|
taskConfig.TASK_MODEL = '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}}
|
2024-11-26 22:14:26 +00:00
|
|
|
>
|
|
|
|
|
<option value="" selected>{$i18n.t('Current Model')}</option>
|
2025-05-19 01:12:53 +00:00
|
|
|
{#each models as model}
|
2024-11-26 22:14:26 +00:00
|
|
|
<option value={model.id} class="bg-gray-100 dark:bg-gray-700">
|
|
|
|
|
{model.name}
|
2025-05-19 01:12:53 +00:00
|
|
|
{model?.connection_type === 'local' ? `(${$i18n.t('Local')})` : ''}
|
2024-11-26 22:14:26 +00:00
|
|
|
</option>
|
|
|
|
|
{/each}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
2024-10-20 04:27:10 +00:00
|
|
|
|
2024-11-26 22:14:26 +00:00
|
|
|
<div class="flex-1">
|
2025-05-16 21:47:48 +00:00
|
|
|
<div class=" text-xs mb-1">{$i18n.t('External Task Model')}</div>
|
2024-11-26 22:14:26 +00:00
|
|
|
<select
|
2025-02-16 03:27:25 +00:00
|
|
|
class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-hidden"
|
2024-11-26 22:14:26 +00:00
|
|
|
bind:value={taskConfig.TASK_MODEL_EXTERNAL}
|
|
|
|
|
placeholder={$i18n.t('Select a model')}
|
2025-05-10 18:43:53 +00:00
|
|
|
on:change={() => {
|
|
|
|
|
if (taskConfig.TASK_MODEL_EXTERNAL) {
|
|
|
|
|
const model = models.find((m) => m.id === taskConfig.TASK_MODEL_EXTERNAL);
|
|
|
|
|
if (model) {
|
|
|
|
|
if (model?.access_control !== null) {
|
|
|
|
|
toast.error(
|
|
|
|
|
$i18n.t(
|
|
|
|
|
'This model is not publicly available. Please select another model.'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
taskConfig.TASK_MODEL_EXTERNAL = model.id;
|
|
|
|
|
} else {
|
|
|
|
|
taskConfig.TASK_MODEL_EXTERNAL = '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}}
|
2024-11-26 22:14:26 +00:00
|
|
|
>
|
|
|
|
|
<option value="" selected>{$i18n.t('Current Model')}</option>
|
2025-05-10 18:43:53 +00:00
|
|
|
{#each models as model}
|
2024-11-26 22:14:26 +00:00
|
|
|
<option value={model.id} class="bg-gray-100 dark:bg-gray-700">
|
|
|
|
|
{model.name}
|
2025-05-19 01:12:53 +00:00
|
|
|
{model?.connection_type === 'local' ? `(${$i18n.t('Local')})` : ''}
|
2024-11-26 22:14:26 +00:00
|
|
|
</option>
|
|
|
|
|
{/each}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
2024-11-06 02:32:08 +00:00
|
|
|
</div>
|
|
|
|
|
|
2025-02-16 03:50:40 +00:00
|
|
|
<div class="mb-2.5 flex w-full items-center justify-between">
|
2025-02-13 15:28:39 +00:00
|
|
|
<div class=" self-center text-xs font-medium">
|
|
|
|
|
{$i18n.t('Title Generation')}
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-02-14 06:54:45 +00:00
|
|
|
<Switch bind:state={taskConfig.ENABLE_TITLE_GENERATION} />
|
2024-11-06 02:32:08 +00:00
|
|
|
</div>
|
|
|
|
|
|
2025-02-13 15:28:39 +00:00
|
|
|
{#if taskConfig.ENABLE_TITLE_GENERATION}
|
2025-02-16 03:50:40 +00:00
|
|
|
<div class="mb-2.5">
|
|
|
|
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Title Generation Prompt')}</div>
|
2025-02-13 15:28:39 +00:00
|
|
|
|
|
|
|
|
<Tooltip
|
|
|
|
|
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
|
|
|
|
placement="top-start"
|
|
|
|
|
>
|
|
|
|
|
<Textarea
|
|
|
|
|
bind:value={taskConfig.TITLE_GENERATION_PROMPT_TEMPLATE}
|
|
|
|
|
placeholder={$i18n.t(
|
|
|
|
|
'Leave empty to use the default prompt, or enter a custom prompt'
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2025-06-03 14:07:29 +00:00
|
|
|
<div class="mb-2.5 flex w-full items-center justify-between">
|
|
|
|
|
<div class=" self-center text-xs font-medium">
|
|
|
|
|
{$i18n.t('Follow Up Generation')}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Switch bind:state={taskConfig.ENABLE_FOLLOW_UP_GENERATION} />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{#if taskConfig.ENABLE_FOLLOW_UP_GENERATION}
|
|
|
|
|
<div class="mb-2.5">
|
|
|
|
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Follow Up Generation Prompt')}</div>
|
|
|
|
|
|
|
|
|
|
<Tooltip
|
|
|
|
|
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
|
|
|
|
placement="top-start"
|
|
|
|
|
>
|
|
|
|
|
<Textarea
|
|
|
|
|
bind:value={taskConfig.FOLLOW_UP_GENERATION_PROMPT_TEMPLATE}
|
|
|
|
|
placeholder={$i18n.t(
|
|
|
|
|
'Leave empty to use the default prompt, or enter a custom prompt'
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2025-02-16 03:50:40 +00:00
|
|
|
<div class="mb-2.5 flex w-full items-center justify-between">
|
2024-12-01 02:30:59 +00:00
|
|
|
<div class=" self-center text-xs font-medium">
|
|
|
|
|
{$i18n.t('Tags Generation')}
|
2024-11-26 22:14:26 +00:00
|
|
|
</div>
|
2024-09-07 03:50:29 +00:00
|
|
|
|
2024-11-26 22:14:26 +00:00
|
|
|
<Switch bind:state={taskConfig.ENABLE_TAGS_GENERATION} />
|
2024-11-19 10:24:32 +00:00
|
|
|
</div>
|
|
|
|
|
|
2024-11-26 22:14:26 +00:00
|
|
|
{#if taskConfig.ENABLE_TAGS_GENERATION}
|
2025-02-16 03:50:40 +00:00
|
|
|
<div class="mb-2.5">
|
|
|
|
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Tags Generation Prompt')}</div>
|
2024-11-19 10:24:32 +00:00
|
|
|
|
2024-11-26 22:14:26 +00:00
|
|
|
<Tooltip
|
|
|
|
|
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
|
|
|
|
placement="top-start"
|
|
|
|
|
>
|
|
|
|
|
<Textarea
|
|
|
|
|
bind:value={taskConfig.TAGS_GENERATION_PROMPT_TEMPLATE}
|
|
|
|
|
placeholder={$i18n.t(
|
|
|
|
|
'Leave empty to use the default prompt, or enter a custom prompt'
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2024-09-07 03:50:29 +00:00
|
|
|
|
2025-02-16 03:50:40 +00:00
|
|
|
<div class="mb-2.5 flex w-full items-center justify-between">
|
2024-11-26 22:14:26 +00:00
|
|
|
<div class=" self-center text-xs font-medium">
|
2024-12-01 02:30:59 +00:00
|
|
|
{$i18n.t('Retrieval Query Generation')}
|
2024-11-26 22:14:26 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Switch bind:state={taskConfig.ENABLE_RETRIEVAL_QUERY_GENERATION} />
|
|
|
|
|
</div>
|
2024-06-09 08:44:08 +00:00
|
|
|
|
2025-02-16 03:50:40 +00:00
|
|
|
<div class="mb-2.5 flex w-full items-center justify-between">
|
2024-11-26 22:14:26 +00:00
|
|
|
<div class=" self-center text-xs font-medium">
|
2024-12-01 02:30:59 +00:00
|
|
|
{$i18n.t('Web Search Query Generation')}
|
2024-11-26 22:14:26 +00:00
|
|
|
</div>
|
2024-06-09 09:39:18 +00:00
|
|
|
|
2024-11-26 22:14:26 +00:00
|
|
|
<Switch bind:state={taskConfig.ENABLE_SEARCH_QUERY_GENERATION} />
|
2024-06-09 09:39:18 +00:00
|
|
|
</div>
|
|
|
|
|
|
2025-02-16 03:50:40 +00:00
|
|
|
<div class="mb-2.5">
|
|
|
|
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Query Generation Prompt')}</div>
|
2024-11-26 22:14:26 +00:00
|
|
|
|
|
|
|
|
<Tooltip
|
|
|
|
|
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
|
|
|
|
placement="top-start"
|
2024-06-09 09:39:18 +00:00
|
|
|
>
|
2024-11-26 22:14:26 +00:00
|
|
|
<Textarea
|
|
|
|
|
bind:value={taskConfig.QUERY_GENERATION_PROMPT_TEMPLATE}
|
|
|
|
|
placeholder={$i18n.t(
|
|
|
|
|
'Leave empty to use the default prompt, or enter a custom prompt'
|
|
|
|
|
)}
|
2024-06-09 09:39:18 +00:00
|
|
|
/>
|
2024-11-26 22:14:26 +00:00
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
2024-06-09 09:39:18 +00:00
|
|
|
|
2025-02-16 03:50:40 +00:00
|
|
|
<div class="mb-2.5 flex w-full items-center justify-between">
|
|
|
|
|
<div class=" self-center text-xs font-medium">
|
|
|
|
|
{$i18n.t('Autocomplete Generation')}
|
|
|
|
|
</div>
|
2025-02-02 05:01:06 +00:00
|
|
|
|
2025-02-16 03:50:40 +00:00
|
|
|
<Tooltip content={$i18n.t('Enable autocomplete generation for chat messages')}>
|
|
|
|
|
<Switch bind:state={taskConfig.ENABLE_AUTOCOMPLETE_GENERATION} />
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
2024-06-09 08:44:08 +00:00
|
|
|
|
2025-02-16 03:50:40 +00:00
|
|
|
{#if taskConfig.ENABLE_AUTOCOMPLETE_GENERATION}
|
|
|
|
|
<div class="mb-2.5">
|
|
|
|
|
<div class=" mb-1 text-xs font-medium">
|
|
|
|
|
{$i18n.t('Autocomplete Generation Input Max Length')}
|
|
|
|
|
</div>
|
2024-06-09 08:44:08 +00:00
|
|
|
|
2025-02-16 03:50:40 +00:00
|
|
|
<Tooltip
|
|
|
|
|
content={$i18n.t('Character limit for autocomplete generation input')}
|
|
|
|
|
placement="top-start"
|
2024-06-09 08:44:08 +00:00
|
|
|
>
|
2025-02-16 03:50:40 +00:00
|
|
|
<input
|
|
|
|
|
class="w-full outline-hidden bg-transparent"
|
|
|
|
|
bind:value={taskConfig.AUTOCOMPLETE_GENERATION_INPUT_MAX_LENGTH}
|
|
|
|
|
placeholder={$i18n.t('-1 for no limit, or a positive integer for a specific limit')}
|
2024-06-09 08:44:08 +00:00
|
|
|
/>
|
2025-02-16 03:50:40 +00:00
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
<div class="mb-2.5">
|
|
|
|
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Image Prompt Generation Prompt')}</div>
|
|
|
|
|
|
|
|
|
|
<Tooltip
|
|
|
|
|
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
|
|
|
|
placement="top-start"
|
|
|
|
|
>
|
|
|
|
|
<Textarea
|
|
|
|
|
bind:value={taskConfig.IMAGE_PROMPT_GENERATION_PROMPT_TEMPLATE}
|
|
|
|
|
placeholder={$i18n.t(
|
|
|
|
|
'Leave empty to use the default prompt, or enter a custom prompt'
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</Tooltip>
|
2024-06-09 08:44:08 +00:00
|
|
|
</div>
|
|
|
|
|
|
2025-02-16 03:50:40 +00:00
|
|
|
<div class="mb-2.5">
|
|
|
|
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Tools Function Calling Prompt')}</div>
|
2024-06-09 08:44:08 +00:00
|
|
|
|
2025-02-16 03:50:40 +00:00
|
|
|
<Tooltip
|
|
|
|
|
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
|
|
|
|
placement="top-start"
|
|
|
|
|
>
|
|
|
|
|
<Textarea
|
|
|
|
|
bind:value={taskConfig.TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE}
|
|
|
|
|
placeholder={$i18n.t(
|
|
|
|
|
'Leave empty to use the default prompt, or enter a custom prompt'
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</Tooltip>
|
2024-06-09 08:44:08 +00:00
|
|
|
</div>
|
2024-11-26 22:14:26 +00:00
|
|
|
</div>
|
|
|
|
|
|
2025-02-16 03:50:40 +00:00
|
|
|
<div class="mb-3.5">
|
|
|
|
|
<div class=" mb-2.5 text-base font-medium">{$i18n.t('UI')}</div>
|
|
|
|
|
|
|
|
|
|
<hr class=" border-gray-100 dark:border-gray-850 my-2" />
|
|
|
|
|
|
2025-05-22 22:02:11 +00:00
|
|
|
<div class="mb-2.5">
|
2025-07-02 09:59:14 +00:00
|
|
|
<div class="flex w-full justify-between">
|
2025-07-02 09:48:18 +00:00
|
|
|
<div class=" self-center text-xs">
|
2025-02-16 03:50:40 +00:00
|
|
|
{$i18n.t('Banners')}
|
2024-11-26 22:14:26 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<button
|
2025-02-16 03:27:25 +00:00
|
|
|
class="p-1 px-3 text-xs flex rounded-sm transition"
|
2024-11-26 22:14:26 +00:00
|
|
|
type="button"
|
|
|
|
|
on:click={() => {
|
2025-02-16 03:50:40 +00:00
|
|
|
if (banners.length === 0 || banners.at(-1).content !== '') {
|
|
|
|
|
banners = [
|
|
|
|
|
...banners,
|
|
|
|
|
{
|
|
|
|
|
id: uuidv4(),
|
|
|
|
|
type: '',
|
|
|
|
|
title: '',
|
|
|
|
|
content: '',
|
|
|
|
|
dismissible: true,
|
|
|
|
|
timestamp: Math.floor(Date.now() / 1000)
|
|
|
|
|
}
|
|
|
|
|
];
|
2024-11-26 22:14:26 +00:00
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
viewBox="0 0 20 20"
|
|
|
|
|
fill="currentColor"
|
|
|
|
|
class="w-4 h-4"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
d="M10.75 4.75a.75.75 0 00-1.5 0v4.5h-4.5a.75.75 0 000 1.5h4.5v4.5a.75.75 0 001.5 0v-4.5h4.5a.75.75 0 000-1.5h-4.5v-4.5z"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-05-22 22:02:11 +00:00
|
|
|
<Banners bind:banners />
|
2025-02-16 03:50:40 +00:00
|
|
|
</div>
|
2024-11-26 22:14:26 +00:00
|
|
|
|
2025-04-01 03:32:12 +00:00
|
|
|
{#if $user?.role === 'admin'}
|
2025-02-16 03:50:40 +00:00
|
|
|
<div class=" space-y-3">
|
|
|
|
|
<div class="flex w-full justify-between mb-2">
|
2025-07-02 09:48:18 +00:00
|
|
|
<div class=" self-center text-xs">
|
2025-02-16 03:50:40 +00:00
|
|
|
{$i18n.t('Default Prompt Suggestions')}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
class="p-1 px-3 text-xs flex rounded-sm transition"
|
|
|
|
|
type="button"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
if (promptSuggestions.length === 0 || promptSuggestions.at(-1).content !== '') {
|
|
|
|
|
promptSuggestions = [...promptSuggestions, { content: '', title: ['', ''] }];
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
viewBox="0 0 20 20"
|
|
|
|
|
fill="currentColor"
|
|
|
|
|
class="w-4 h-4"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
d="M10.75 4.75a.75.75 0 00-1.5 0v4.5h-4.5a.75.75 0 000 1.5h4.5v4.5a.75.75 0 001.5 0v-4.5h4.5a.75.75 0 000-1.5h-4.5v-4.5z"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
2024-11-26 22:14:26 +00:00
|
|
|
</div>
|
2025-02-16 03:50:40 +00:00
|
|
|
<div class="grid lg:grid-cols-2 flex-col gap-1.5">
|
|
|
|
|
{#each promptSuggestions as prompt, promptIdx}
|
|
|
|
|
<div
|
|
|
|
|
class=" flex border border-gray-100 dark:border-none dark:bg-gray-850 rounded-xl py-1.5"
|
|
|
|
|
>
|
|
|
|
|
<div class="flex flex-col flex-1 pl-1">
|
|
|
|
|
<div class="flex border-b border-gray-100 dark:border-gray-850 w-full">
|
|
|
|
|
<input
|
|
|
|
|
class="px-3 py-1.5 text-xs w-full bg-transparent outline-hidden border-r border-gray-100 dark:border-gray-850"
|
|
|
|
|
placeholder={$i18n.t('Title (e.g. Tell me a fun fact)')}
|
|
|
|
|
bind:value={prompt.title[0]}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<input
|
|
|
|
|
class="px-3 py-1.5 text-xs w-full bg-transparent outline-hidden border-r border-gray-100 dark:border-gray-850"
|
|
|
|
|
placeholder={$i18n.t('Subtitle (e.g. about the Roman Empire)')}
|
|
|
|
|
bind:value={prompt.title[1]}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<textarea
|
|
|
|
|
class="px-3 py-1.5 text-xs w-full bg-transparent outline-hidden border-r border-gray-100 dark:border-gray-850 resize-none"
|
|
|
|
|
placeholder={$i18n.t(
|
|
|
|
|
'Prompt (e.g. Tell me a fun fact about the Roman Empire)'
|
|
|
|
|
)}
|
|
|
|
|
rows="3"
|
|
|
|
|
bind:value={prompt.content}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
class="px-3"
|
|
|
|
|
type="button"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
promptSuggestions.splice(promptIdx, 1);
|
|
|
|
|
promptSuggestions = promptSuggestions;
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
viewBox="0 0 20 20"
|
|
|
|
|
fill="currentColor"
|
|
|
|
|
class="w-4 h-4"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{#if promptSuggestions.length > 0}
|
|
|
|
|
<div class="text-xs text-left w-full mt-2">
|
|
|
|
|
{$i18n.t('Adjusting these settings will apply changes universally to all users.')}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2025-05-24 22:17:51 +00:00
|
|
|
|
|
|
|
|
<div class="flex items-center justify-end space-x-2 mt-2">
|
|
|
|
|
<input
|
|
|
|
|
id="prompt-suggestions-import-input"
|
|
|
|
|
type="file"
|
|
|
|
|
accept=".json"
|
|
|
|
|
hidden
|
|
|
|
|
on:change={(e) => {
|
|
|
|
|
const files = e.target.files;
|
|
|
|
|
if (!files || files.length === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(files);
|
|
|
|
|
|
|
|
|
|
let reader = new FileReader();
|
|
|
|
|
reader.onload = async (event) => {
|
2025-05-24 22:21:03 +00:00
|
|
|
try {
|
|
|
|
|
let suggestions = JSON.parse(event.target.result);
|
|
|
|
|
|
|
|
|
|
suggestions = suggestions.map((s) => {
|
|
|
|
|
if (typeof s.title === 'string') {
|
|
|
|
|
s.title = [s.title, ''];
|
|
|
|
|
} else if (!Array.isArray(s.title)) {
|
|
|
|
|
s.title = ['', ''];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
promptSuggestions = [...promptSuggestions, ...suggestions];
|
|
|
|
|
} catch (error) {
|
|
|
|
|
toast.error($i18n.t('Invalid JSON file'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-05-24 22:17:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
reader.readAsText(files[0]);
|
2025-05-24 22:21:03 +00:00
|
|
|
|
|
|
|
|
e.target.value = ''; // Reset the input value
|
2025-05-24 22:17:51 +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-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
2025-05-24 22:21:03 +00:00
|
|
|
type="button"
|
2025-05-24 22:17:51 +00:00
|
|
|
on:click={() => {
|
|
|
|
|
const input = document.getElementById('prompt-suggestions-import-input');
|
|
|
|
|
if (input) {
|
|
|
|
|
input.click();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div class=" self-center mr-2 font-medium line-clamp-1">
|
|
|
|
|
{$i18n.t('Import Prompt Suggestions')}
|
|
|
|
|
</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>
|
|
|
|
|
|
|
|
|
|
{#if promptSuggestions.length}
|
|
|
|
|
<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"
|
2025-05-24 22:21:03 +00:00
|
|
|
type="button"
|
2025-05-24 22:17:51 +00:00
|
|
|
on:click={async () => {
|
|
|
|
|
let blob = new Blob([JSON.stringify(promptSuggestions)], {
|
|
|
|
|
type: 'application/json'
|
|
|
|
|
});
|
|
|
|
|
saveAs(blob, `prompt-suggestions-export-${Date.now()}.json`);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div class=" self-center mr-2 font-medium line-clamp-1">
|
|
|
|
|
{$i18n.t('Export Prompt Suggestions')} ({promptSuggestions.length})
|
|
|
|
|
</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>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
2025-02-16 03:50:40 +00:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
2024-11-26 22:14:26 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="flex justify-end text-sm font-medium">
|
|
|
|
|
<button
|
|
|
|
|
class="px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-full"
|
|
|
|
|
type="submit"
|
|
|
|
|
>
|
|
|
|
|
{$i18n.t('Save')}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
2025-05-10 18:43:53 +00:00
|
|
|
{:else}
|
|
|
|
|
<div class=" h-full w-full flex justify-center items-center">
|
2025-06-27 12:15:16 +00:00
|
|
|
<Spinner className="size-5" />
|
2025-05-10 18:43:53 +00:00
|
|
|
</div>
|
2024-11-26 22:14:26 +00:00
|
|
|
{/if}
|