refac
This commit is contained in:
1 parent
6abee5cc3c
commit
b3255a3656
10 files changed
+3529
-4394
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import SensitiveInput from '$lib/components/common/SensitiveInput.svelte';
|
import SensitiveInput from '$lib/components/common/SensitiveInput.svelte';
|
||||||
|
|
||||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
|
||||||
import Textarea from '$lib/components/common/Textarea.svelte';
|
import Textarea from '$lib/components/common/Textarea.svelte';
|
||||||
import Switch from '$lib/components/common/Switch.svelte';
|
import Switch from '$lib/components/common/Switch.svelte';
|
||||||
import AdminSettingField from './AdminSettingField.svelte';
|
import AdminSettingField from './AdminSettingField.svelte';
|
||||||
@@ -23,8 +22,6 @@
|
|||||||
'w-full h-7 rounded-lg border border-gray-100/50 bg-gray-50/40 px-2 text-xs text-gray-700 outline-hidden transition-colors placeholder:text-gray-300 focus:border-blue-400 dark:border-white/[0.04] dark:bg-white/[0.03] dark:text-gray-300 dark:placeholder:text-gray-700 dark:focus:border-blue-500';
|
'w-full h-7 rounded-lg border border-gray-100/50 bg-gray-50/40 px-2 text-xs text-gray-700 outline-hidden transition-colors placeholder:text-gray-300 focus:border-blue-400 dark:border-white/[0.04] dark:bg-white/[0.03] dark:text-gray-300 dark:placeholder:text-gray-700 dark:focus:border-blue-500';
|
||||||
const textareaClass =
|
const textareaClass =
|
||||||
'w-full rounded-lg border border-gray-100/50 bg-gray-50/40 px-2 py-1.5 text-xs text-gray-700 outline-hidden transition-colors placeholder:text-gray-300 focus:border-blue-400 dark:border-white/[0.04] dark:bg-white/[0.03] dark:text-gray-300 dark:placeholder:text-gray-700 dark:focus:border-blue-500';
|
'w-full rounded-lg border border-gray-100/50 bg-gray-50/40 px-2 py-1.5 text-xs text-gray-700 outline-hidden transition-colors placeholder:text-gray-300 focus:border-blue-400 dark:border-white/[0.04] dark:bg-white/[0.03] dark:text-gray-300 dark:placeholder:text-gray-700 dark:focus:border-blue-500';
|
||||||
const inlineInputClass =
|
|
||||||
'w-fit h-7 rounded-lg border border-transparent bg-transparent px-2 text-xs text-gray-600 outline-hidden transition-colors hover:bg-black/5 focus:border-blue-400 dark:text-gray-400 dark:hover:bg-white/5 dark:focus:border-blue-500';
|
|
||||||
|
|
||||||
const submitHandler = async () => {
|
const submitHandler = async () => {
|
||||||
const res = await setCodeExecutionConfig(localStorage.token, config);
|
const res = await setCodeExecutionConfig(localStorage.token, config);
|
||||||
@@ -52,8 +49,11 @@
|
|||||||
|
|
||||||
<div class="flex-1 min-h-0 overflow-y-auto scrollbar-hover pr-1.5">
|
<div class="flex-1 min-h-0 overflow-y-auto scrollbar-hover pr-1.5">
|
||||||
{#if config}
|
{#if config}
|
||||||
<AdminSettingSection first>
|
<AdminSettingSection title={$i18n.t('Code Execution')} first>
|
||||||
<AdminSettingRow label={$i18n.t('Enable Code Execution')}>
|
<AdminSettingRow
|
||||||
|
label={$i18n.t('Enable Code Execution')}
|
||||||
|
description={$i18n.t('Allow models to run generated code and return execution results.')}
|
||||||
|
>
|
||||||
<Switch bind:state={config.ENABLE_CODE_EXECUTION} />
|
<Switch bind:state={config.ENABLE_CODE_EXECUTION} />
|
||||||
</AdminSettingRow>
|
</AdminSettingRow>
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
? $i18n.t(
|
? $i18n.t(
|
||||||
'Warning: Jupyter execution enables arbitrary code execution, posing severe security risks—proceed with extreme caution.'
|
'Warning: Jupyter execution enables arbitrary code execution, posing severe security risks—proceed with extreme caution.'
|
||||||
)
|
)
|
||||||
: ''}
|
: $i18n.t('Choose the runtime used for generated code blocks.')}
|
||||||
>
|
>
|
||||||
<SettingsSelect
|
<SettingsSelect
|
||||||
bind:value={config.CODE_EXECUTION_ENGINE}
|
bind:value={config.CODE_EXECUTION_ENGINE}
|
||||||
@@ -79,7 +79,10 @@
|
|||||||
</AdminSettingRow>
|
</AdminSettingRow>
|
||||||
|
|
||||||
{#if config.CODE_EXECUTION_ENGINE === 'jupyter'}
|
{#if config.CODE_EXECUTION_ENGINE === 'jupyter'}
|
||||||
<AdminSettingField label={$i18n.t('Jupyter URL')}>
|
<AdminSettingField
|
||||||
|
label={$i18n.t('Jupyter URL')}
|
||||||
|
description={$i18n.t('Connect code execution to a Jupyter server endpoint.')}
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
class={inputClass}
|
class={inputClass}
|
||||||
type="text"
|
type="text"
|
||||||
@@ -89,7 +92,10 @@
|
|||||||
/>
|
/>
|
||||||
</AdminSettingField>
|
</AdminSettingField>
|
||||||
|
|
||||||
<AdminSettingRow label={$i18n.t('Jupyter Auth')}>
|
<AdminSettingRow
|
||||||
|
label={$i18n.t('Jupyter Auth')}
|
||||||
|
description={$i18n.t('Select how Open WebUI authenticates with the Jupyter server.')}
|
||||||
|
>
|
||||||
<SettingsSelect
|
<SettingsSelect
|
||||||
bind:value={config.CODE_EXECUTION_JUPYTER_AUTH}
|
bind:value={config.CODE_EXECUTION_JUPYTER_AUTH}
|
||||||
placeholder={$i18n.t('Select an auth method')}
|
placeholder={$i18n.t('Select an auth method')}
|
||||||
@@ -105,6 +111,7 @@
|
|||||||
label={config.CODE_EXECUTION_JUPYTER_AUTH === 'password'
|
label={config.CODE_EXECUTION_JUPYTER_AUTH === 'password'
|
||||||
? $i18n.t('Jupyter Password')
|
? $i18n.t('Jupyter Password')
|
||||||
: $i18n.t('Jupyter Token')}
|
: $i18n.t('Jupyter Token')}
|
||||||
|
description={$i18n.t('Credentials used to authenticate with the Jupyter server.')}
|
||||||
>
|
>
|
||||||
{#if config.CODE_EXECUTION_JUPYTER_AUTH === 'password'}
|
{#if config.CODE_EXECUTION_JUPYTER_AUTH === 'password'}
|
||||||
<SensitiveInput
|
<SensitiveInput
|
||||||
@@ -126,23 +133,27 @@
|
|||||||
</AdminSettingField>
|
</AdminSettingField>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<AdminSettingRow label={$i18n.t('Code Execution Timeout')}>
|
<AdminSettingField
|
||||||
<Tooltip content={$i18n.t('Enter timeout in seconds')}>
|
label={$i18n.t('Code Execution Timeout')}
|
||||||
<input
|
description={$i18n.t('Maximum runtime in seconds before execution is stopped.')}
|
||||||
class={inlineInputClass}
|
>
|
||||||
type="number"
|
<input
|
||||||
bind:value={config.CODE_EXECUTION_JUPYTER_TIMEOUT}
|
class={inputClass}
|
||||||
placeholder={$i18n.t('e.g. 60')}
|
type="number"
|
||||||
autocomplete="off"
|
bind:value={config.CODE_EXECUTION_JUPYTER_TIMEOUT}
|
||||||
/>
|
placeholder={$i18n.t('e.g. 60')}
|
||||||
</Tooltip>
|
autocomplete="off"
|
||||||
</AdminSettingRow>
|
/>
|
||||||
|
</AdminSettingField>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</AdminSettingSection>
|
</AdminSettingSection>
|
||||||
|
|
||||||
<AdminSettingSection title={$i18n.t('Code Interpreter')}>
|
<AdminSettingSection title={$i18n.t('Code Interpreter')}>
|
||||||
<AdminSettingRow label={$i18n.t('Enable Code Interpreter')}>
|
<AdminSettingRow
|
||||||
|
label={$i18n.t('Enable Code Interpreter')}
|
||||||
|
description={$i18n.t('Allow models to use the code interpreter tool during chats.')}
|
||||||
|
>
|
||||||
<Switch bind:state={config.ENABLE_CODE_INTERPRETER} />
|
<Switch bind:state={config.ENABLE_CODE_INTERPRETER} />
|
||||||
</AdminSettingRow>
|
</AdminSettingRow>
|
||||||
|
|
||||||
@@ -153,7 +164,7 @@
|
|||||||
? $i18n.t(
|
? $i18n.t(
|
||||||
'Warning: Jupyter execution enables arbitrary code execution, posing severe security risks—proceed with extreme caution.'
|
'Warning: Jupyter execution enables arbitrary code execution, posing severe security risks—proceed with extreme caution.'
|
||||||
)
|
)
|
||||||
: ''}
|
: $i18n.t('Choose the runtime used by the code interpreter tool.')}
|
||||||
>
|
>
|
||||||
<SettingsSelect
|
<SettingsSelect
|
||||||
bind:value={config.CODE_INTERPRETER_ENGINE}
|
bind:value={config.CODE_INTERPRETER_ENGINE}
|
||||||
@@ -168,7 +179,10 @@
|
|||||||
</AdminSettingRow>
|
</AdminSettingRow>
|
||||||
|
|
||||||
{#if config.CODE_INTERPRETER_ENGINE === 'jupyter'}
|
{#if config.CODE_INTERPRETER_ENGINE === 'jupyter'}
|
||||||
<AdminSettingField label={$i18n.t('Jupyter URL')}>
|
<AdminSettingField
|
||||||
|
label={$i18n.t('Jupyter URL')}
|
||||||
|
description={$i18n.t('Connect code interpreter to a Jupyter server endpoint.')}
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
class={inputClass}
|
class={inputClass}
|
||||||
type="text"
|
type="text"
|
||||||
@@ -178,7 +192,10 @@
|
|||||||
/>
|
/>
|
||||||
</AdminSettingField>
|
</AdminSettingField>
|
||||||
|
|
||||||
<AdminSettingRow label={$i18n.t('Jupyter Auth')}>
|
<AdminSettingRow
|
||||||
|
label={$i18n.t('Jupyter Auth')}
|
||||||
|
description={$i18n.t('Select how Open WebUI authenticates with the Jupyter server.')}
|
||||||
|
>
|
||||||
<SettingsSelect
|
<SettingsSelect
|
||||||
bind:value={config.CODE_INTERPRETER_JUPYTER_AUTH}
|
bind:value={config.CODE_INTERPRETER_JUPYTER_AUTH}
|
||||||
placeholder={$i18n.t('Select an auth method')}
|
placeholder={$i18n.t('Select an auth method')}
|
||||||
@@ -194,6 +211,7 @@
|
|||||||
label={config.CODE_INTERPRETER_JUPYTER_AUTH === 'password'
|
label={config.CODE_INTERPRETER_JUPYTER_AUTH === 'password'
|
||||||
? $i18n.t('Jupyter Password')
|
? $i18n.t('Jupyter Password')
|
||||||
: $i18n.t('Jupyter Token')}
|
: $i18n.t('Jupyter Token')}
|
||||||
|
description={$i18n.t('Credentials used to authenticate with the Jupyter server.')}
|
||||||
>
|
>
|
||||||
{#if config.CODE_INTERPRETER_JUPYTER_AUTH === 'password'}
|
{#if config.CODE_INTERPRETER_JUPYTER_AUTH === 'password'}
|
||||||
<SensitiveInput
|
<SensitiveInput
|
||||||
@@ -215,32 +233,33 @@
|
|||||||
</AdminSettingField>
|
</AdminSettingField>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<AdminSettingRow label={$i18n.t('Code Execution Timeout')}>
|
<AdminSettingField
|
||||||
<Tooltip content={$i18n.t('Enter timeout in seconds')}>
|
label={$i18n.t('Code Execution Timeout')}
|
||||||
<input
|
description={$i18n.t('Maximum runtime in seconds before execution is stopped.')}
|
||||||
class={inlineInputClass}
|
>
|
||||||
type="number"
|
<input
|
||||||
bind:value={config.CODE_INTERPRETER_JUPYTER_TIMEOUT}
|
class={inputClass}
|
||||||
placeholder={$i18n.t('e.g. 60')}
|
type="number"
|
||||||
autocomplete="off"
|
bind:value={config.CODE_INTERPRETER_JUPYTER_TIMEOUT}
|
||||||
/>
|
placeholder={$i18n.t('e.g. 60')}
|
||||||
</Tooltip>
|
autocomplete="off"
|
||||||
</AdminSettingRow>
|
/>
|
||||||
|
</AdminSettingField>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<AdminSettingField label={$i18n.t('Code Interpreter Prompt Template')}>
|
<AdminSettingField
|
||||||
<Tooltip
|
label={$i18n.t('Code Interpreter Prompt Template')}
|
||||||
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
description={$i18n.t(
|
||||||
placement="top-start"
|
'Leave empty to use the default prompt, or enter a custom prompt.'
|
||||||
>
|
)}
|
||||||
<Textarea
|
>
|
||||||
className={textareaClass}
|
<Textarea
|
||||||
bind:value={config.CODE_INTERPRETER_PROMPT_TEMPLATE}
|
className={textareaClass}
|
||||||
placeholder={$i18n.t(
|
bind:value={config.CODE_INTERPRETER_PROMPT_TEMPLATE}
|
||||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
placeholder={$i18n.t(
|
||||||
)}
|
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||||
/>
|
)}
|
||||||
</Tooltip>
|
/>
|
||||||
</AdminSettingField>
|
</AdminSettingField>
|
||||||
{/if}
|
{/if}
|
||||||
</AdminSettingSection>
|
</AdminSettingSection>
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,17 +1,18 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getModels, getTaskConfig, updateTaskConfig } from '$lib/apis';
|
import { getModels, getTaskConfig, updateTaskConfig } from '$lib/apis';
|
||||||
import { getChatConfig, updateChatConfig } from '$lib/apis/chats';
|
import { getChatConfig, updateChatConfig } from '$lib/apis/chats';
|
||||||
import { config, settings } from '$lib/stores';
|
|
||||||
import { createEventDispatcher, onMount, getContext } from 'svelte';
|
import { createEventDispatcher, onMount, getContext } from 'svelte';
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
|
|
||||||
import { getBaseModels } from '$lib/apis/models';
|
import { getBaseModels } from '$lib/apis/models';
|
||||||
|
|
||||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
|
||||||
import Switch from '$lib/components/common/Switch.svelte';
|
import Switch from '$lib/components/common/Switch.svelte';
|
||||||
import Textarea from '$lib/components/common/Textarea.svelte';
|
import Textarea from '$lib/components/common/Textarea.svelte';
|
||||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||||
import SettingsSelect from '$lib/components/common/SettingsSelect.svelte';
|
import SettingsSelect from '$lib/components/common/SettingsSelect.svelte';
|
||||||
|
import AdminSettingField from './AdminSettingField.svelte';
|
||||||
|
import AdminSettingRow from './AdminSettingRow.svelte';
|
||||||
|
import AdminSettingSection from './AdminSettingSection.svelte';
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
@@ -52,10 +53,13 @@
|
|||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
let workspaceModels = null;
|
let workspaceModels: any[] = [];
|
||||||
let baseModels = null;
|
let baseModels: any[] = [];
|
||||||
|
|
||||||
let models = null;
|
let models: any[] | null = null;
|
||||||
|
$: modelOptions = models ?? [];
|
||||||
|
const inputClass =
|
||||||
|
'w-full h-7 rounded-lg border border-gray-100/50 bg-gray-50/40 px-2 text-xs text-gray-700 outline-hidden transition-colors placeholder:text-gray-300 focus:border-blue-400 dark:border-white/[0.04] dark:bg-white/[0.03] dark:text-gray-300 dark:placeholder:text-gray-700 dark:focus:border-blue-500';
|
||||||
const textareaClass =
|
const textareaClass =
|
||||||
'w-full rounded-lg border border-gray-100/50 bg-gray-50/40 px-2 py-1.5 text-xs text-gray-700 outline-hidden transition-colors placeholder:text-gray-300 focus:border-blue-400 dark:border-white/[0.04] dark:bg-white/[0.03] dark:text-gray-300 dark:placeholder:text-gray-700 dark:focus:border-blue-500';
|
'w-full rounded-lg border border-gray-100/50 bg-gray-50/40 px-2 py-1.5 text-xs text-gray-700 outline-hidden transition-colors placeholder:text-gray-300 focus:border-blue-400 dark:border-white/[0.04] dark:bg-white/[0.03] dark:text-gray-300 dark:placeholder:text-gray-700 dark:focus:border-blue-500';
|
||||||
|
|
||||||
@@ -69,8 +73,8 @@
|
|||||||
workspaceModels = await getBaseModels(localStorage.token);
|
workspaceModels = await getBaseModels(localStorage.token);
|
||||||
baseModels = await getModels(localStorage.token, null, false);
|
baseModels = await getModels(localStorage.token, null, false);
|
||||||
|
|
||||||
models = baseModels.map((m) => {
|
models = baseModels.map((m: any) => {
|
||||||
const workspaceModel = workspaceModels.find((wm) => wm.id === m.id);
|
const workspaceModel = workspaceModels.find((wm: any) => wm.id === m.id);
|
||||||
|
|
||||||
if (workspaceModel) {
|
if (workspaceModel) {
|
||||||
return {
|
return {
|
||||||
@@ -90,8 +94,9 @@
|
|||||||
|
|
||||||
console.debug('models', models);
|
console.debug('models', models);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
const error = err as { detail?: string; message?: string };
|
||||||
console.error('Failed to initialize Interface settings:', err);
|
console.error('Failed to initialize Interface settings:', err);
|
||||||
toast.error(err?.detail ?? err?.message ?? $i18n.t('Failed to load Interface settings'));
|
toast.error(error?.detail ?? error?.message ?? $i18n.t('Failed to load Interface settings'));
|
||||||
models = [];
|
models = [];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -113,191 +118,163 @@
|
|||||||
{$i18n.t('Interface')}
|
{$i18n.t('Interface')}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<div class=" flex-1 min-h-0 overflow-y-auto scrollbar-hover pr-1.5">
|
<div class="flex-1 min-h-0 overflow-y-auto scrollbar-hover pr-1.5">
|
||||||
<div class="mb-5">
|
<AdminSettingSection title={$i18n.t('Tasks')} first>
|
||||||
<div class=" mb-2 text-xs text-gray-400 dark:text-gray-600">
|
<div>
|
||||||
{$i18n.t('Tasks')}
|
<div class="mb-2">
|
||||||
</div>
|
<div class="text-xs text-gray-600 dark:text-gray-400">{$i18n.t('Task Model')}</div>
|
||||||
|
<div class="mt-1.5 text-[0.6875rem] text-gray-400 dark:text-gray-600">
|
||||||
|
{$i18n.t(
|
||||||
|
'Choose fallback models for background tasks. Current Model follows the active chat model.'
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class=" mb-2 font-normal flex items-center">
|
<div class="grid w-full grid-cols-1 gap-2.5 sm:grid-cols-2">
|
||||||
<div class=" text-xs mr-1">{$i18n.t('Task Model')}</div>
|
<AdminSettingField label={$i18n.t('Local Task Model')}>
|
||||||
<Tooltip
|
<SettingsSelect
|
||||||
content={$i18n.t(
|
bind:value={taskConfig.TASK_MODEL}
|
||||||
'A task model is used when performing tasks such as generating titles for chats and web search queries'
|
className="w-full"
|
||||||
)}
|
placeholder={$i18n.t('Select a model')}
|
||||||
>
|
on:change={() => {
|
||||||
<svg
|
if (taskConfig.TASK_MODEL) {
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
const model = modelOptions.find((m: any) => m.id === taskConfig.TASK_MODEL);
|
||||||
fill="none"
|
if (model) {
|
||||||
viewBox="0 0 24 24"
|
if (
|
||||||
stroke-width="1.5"
|
model?.access_grants &&
|
||||||
stroke="currentColor"
|
!model.access_grants.some(
|
||||||
class="size-3.5"
|
(g: any) =>
|
||||||
>
|
g.principal_type === 'user' &&
|
||||||
<path
|
g.principal_id === '*' &&
|
||||||
stroke-linecap="round"
|
g.permission === 'read'
|
||||||
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>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class=" mb-2.5 flex w-full gap-2">
|
|
||||||
<div class="flex-1">
|
|
||||||
<div class=" text-xs mb-1">{$i18n.t('Local Task Model')}</div>
|
|
||||||
<SettingsSelect
|
|
||||||
bind:value={taskConfig.TASK_MODEL}
|
|
||||||
className="w-full"
|
|
||||||
placeholder={$i18n.t('Select a model')}
|
|
||||||
on:change={() => {
|
|
||||||
if (taskConfig.TASK_MODEL) {
|
|
||||||
const model = models.find((m) => m.id === taskConfig.TASK_MODEL);
|
|
||||||
if (model) {
|
|
||||||
if (
|
|
||||||
model?.access_grants &&
|
|
||||||
!model.access_grants.some(
|
|
||||||
(g) =>
|
|
||||||
g.principal_type === 'user' &&
|
|
||||||
g.principal_id === '*' &&
|
|
||||||
g.permission === 'read'
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
toast.error(
|
|
||||||
$i18n.t(
|
|
||||||
'This model is not publicly available. Please select another model.'
|
|
||||||
)
|
)
|
||||||
);
|
) {
|
||||||
|
toast.error(
|
||||||
|
$i18n.t(
|
||||||
|
'This model is not publicly available. Please select another model.'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
taskConfig.TASK_MODEL = model.id;
|
||||||
|
} else {
|
||||||
|
taskConfig.TASK_MODEL = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
taskConfig.TASK_MODEL = model.id;
|
|
||||||
} else {
|
|
||||||
taskConfig.TASK_MODEL = '';
|
|
||||||
}
|
}
|
||||||
}
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<option value="" selected>{$i18n.t('Current Model')}</option>
|
||||||
<option value="" selected>{$i18n.t('Current Model')}</option>
|
{#each modelOptions as model}
|
||||||
{#each models as model}
|
<option value={model.id} class="bg-gray-100 dark:bg-gray-700">
|
||||||
<option value={model.id} class="bg-gray-100 dark:bg-gray-700">
|
{model.name}
|
||||||
{model.name}
|
{model?.connection_type === 'local' ? `(${$i18n.t('Local')})` : ''}
|
||||||
{model?.connection_type === 'local' ? `(${$i18n.t('Local')})` : ''}
|
</option>
|
||||||
</option>
|
{/each}
|
||||||
{/each}
|
</SettingsSelect>
|
||||||
</SettingsSelect>
|
</AdminSettingField>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex-1">
|
<AdminSettingField label={$i18n.t('External Task Model')}>
|
||||||
<div class=" text-xs mb-1">{$i18n.t('External Task Model')}</div>
|
<SettingsSelect
|
||||||
<SettingsSelect
|
bind:value={taskConfig.TASK_MODEL_EXTERNAL}
|
||||||
bind:value={taskConfig.TASK_MODEL_EXTERNAL}
|
className="w-full"
|
||||||
className="w-full"
|
placeholder={$i18n.t('Select a model')}
|
||||||
placeholder={$i18n.t('Select a model')}
|
on:change={() => {
|
||||||
on:change={() => {
|
if (taskConfig.TASK_MODEL_EXTERNAL) {
|
||||||
if (taskConfig.TASK_MODEL_EXTERNAL) {
|
const model = modelOptions.find(
|
||||||
const model = models.find((m) => m.id === taskConfig.TASK_MODEL_EXTERNAL);
|
(m: any) => m.id === taskConfig.TASK_MODEL_EXTERNAL
|
||||||
if (model) {
|
);
|
||||||
if (
|
if (model) {
|
||||||
model?.access_grants &&
|
if (
|
||||||
!model.access_grants.some(
|
model?.access_grants &&
|
||||||
(g) =>
|
!model.access_grants.some(
|
||||||
g.principal_type === 'user' &&
|
(g: any) =>
|
||||||
g.principal_id === '*' &&
|
g.principal_type === 'user' &&
|
||||||
g.permission === 'read'
|
g.principal_id === '*' &&
|
||||||
)
|
g.permission === 'read'
|
||||||
) {
|
|
||||||
toast.error(
|
|
||||||
$i18n.t(
|
|
||||||
'This model is not publicly available. Please select another model.'
|
|
||||||
)
|
)
|
||||||
);
|
) {
|
||||||
}
|
toast.error(
|
||||||
|
$i18n.t(
|
||||||
|
'This model is not publicly available. Please select another model.'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
taskConfig.TASK_MODEL_EXTERNAL = model.id;
|
taskConfig.TASK_MODEL_EXTERNAL = model.id;
|
||||||
} else {
|
} else {
|
||||||
taskConfig.TASK_MODEL_EXTERNAL = '';
|
taskConfig.TASK_MODEL_EXTERNAL = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<option value="" selected>{$i18n.t('Current Model')}</option>
|
||||||
<option value="" selected>{$i18n.t('Current Model')}</option>
|
{#each modelOptions as model}
|
||||||
{#each models as model}
|
<option value={model.id} class="bg-gray-100 dark:bg-gray-700">
|
||||||
<option value={model.id} class="bg-gray-100 dark:bg-gray-700">
|
{model.name}
|
||||||
{model.name}
|
{model?.connection_type === 'local' ? `(${$i18n.t('Local')})` : ''}
|
||||||
{model?.connection_type === 'local' ? `(${$i18n.t('Local')})` : ''}
|
</option>
|
||||||
</option>
|
{/each}
|
||||||
{/each}
|
</SettingsSelect>
|
||||||
</SettingsSelect>
|
</AdminSettingField>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</AdminSettingSection>
|
||||||
|
|
||||||
<div class="mb-2.5 flex w-full items-center justify-between">
|
<AdminSettingSection title={$i18n.t('Chat')}>
|
||||||
<div class=" self-center text-xs text-gray-600 dark:text-gray-400">
|
<AdminSettingRow
|
||||||
{$i18n.t('Context Compaction')}
|
label={$i18n.t('Context Compaction')}
|
||||||
</div>
|
description={$i18n.t(
|
||||||
|
'Summarize older chat history when the conversation context grows large.'
|
||||||
|
)}
|
||||||
|
>
|
||||||
<Switch bind:state={chatConfig.ENABLE_CONTEXT_COMPACTION} />
|
<Switch bind:state={chatConfig.ENABLE_CONTEXT_COMPACTION} />
|
||||||
</div>
|
</AdminSettingRow>
|
||||||
|
|
||||||
{#if chatConfig.ENABLE_CONTEXT_COMPACTION}
|
{#if chatConfig.ENABLE_CONTEXT_COMPACTION}
|
||||||
<div class="mb-2.5">
|
<AdminSettingField
|
||||||
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">
|
label={$i18n.t('Token Threshold')}
|
||||||
{$i18n.t('Token Threshold')}
|
description={$i18n.t(
|
||||||
</div>
|
'Older messages are summarized when estimated context exceeds this token limit.'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
min="1"
|
||||||
|
step="1"
|
||||||
|
class={inputClass}
|
||||||
|
bind:value={chatConfig.CONTEXT_COMPACTION_TOKEN_THRESHOLD}
|
||||||
|
/>
|
||||||
|
</AdminSettingField>
|
||||||
|
|
||||||
<Tooltip
|
<AdminSettingField
|
||||||
content={$i18n.t(
|
label={$i18n.t('Token Cap')}
|
||||||
'Older messages are summarized when estimated context exceeds this token limit.'
|
description={$i18n.t(
|
||||||
|
'Model-specific context compaction thresholds cannot exceed this token limit.'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
min="1"
|
||||||
|
step="1"
|
||||||
|
class={inputClass}
|
||||||
|
bind:value={chatConfig.CONTEXT_COMPACTION_TOKEN_CAP}
|
||||||
|
/>
|
||||||
|
</AdminSettingField>
|
||||||
|
|
||||||
|
<AdminSettingField
|
||||||
|
label={$i18n.t('Context Compaction Prompt')}
|
||||||
|
description={$i18n.t(
|
||||||
|
'Controls how older messages are rewritten into a running summary.'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Textarea
|
||||||
|
className={textareaClass}
|
||||||
|
bind:value={chatConfig.CONTEXT_COMPACTION_PROMPT_TEMPLATE}
|
||||||
|
placeholder={$i18n.t(
|
||||||
|
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||||
)}
|
)}
|
||||||
placement="top-start"
|
/>
|
||||||
>
|
<div class="mt-1 text-[0.6875rem] text-gray-400 dark:text-gray-600">
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
min="1"
|
|
||||||
step="1"
|
|
||||||
class="w-full rounded-lg border border-gray-100/50 bg-gray-50/40 px-2 py-1.5 text-xs text-gray-700 outline-hidden transition-colors focus:border-blue-400 dark:border-white/[0.04] dark:bg-white/[0.03] dark:text-gray-300 dark:focus:border-blue-500"
|
|
||||||
bind:value={chatConfig.CONTEXT_COMPACTION_TOKEN_THRESHOLD}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-2.5">
|
|
||||||
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">{$i18n.t('Token Cap')}</div>
|
|
||||||
|
|
||||||
<Tooltip
|
|
||||||
content={$i18n.t(
|
|
||||||
'Model-specific context compaction thresholds cannot exceed this token limit.'
|
|
||||||
)}
|
|
||||||
placement="top-start"
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
min="1"
|
|
||||||
step="1"
|
|
||||||
class="w-full rounded-lg border border-gray-100/50 bg-gray-50/40 px-2 py-1.5 text-xs text-gray-700 outline-hidden transition-colors focus:border-blue-400 dark:border-white/[0.04] dark:bg-white/[0.03] dark:text-gray-300 dark:focus:border-blue-500"
|
|
||||||
bind:value={chatConfig.CONTEXT_COMPACTION_TOKEN_CAP}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-2.5">
|
|
||||||
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">
|
|
||||||
{$i18n.t('Context Compaction Prompt')}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Tooltip
|
|
||||||
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
|
||||||
placement="top-start"
|
|
||||||
>
|
|
||||||
<Textarea
|
|
||||||
className={textareaClass}
|
|
||||||
bind:value={chatConfig.CONTEXT_COMPACTION_PROMPT_TEMPLATE}
|
|
||||||
placeholder={$i18n.t(
|
|
||||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
<div class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
|
||||||
{$i18n.t('Available variables')}:
|
{$i18n.t('Available variables')}:
|
||||||
<code>{'{{PREVIOUS_SUMMARY}}'}</code>,
|
<code>{'{{PREVIOUS_SUMMARY}}'}</code>,
|
||||||
<code>{'{{COMPACTED_MESSAGES}}'}</code>,
|
<code>{'{{COMPACTED_MESSAGES}}'}</code>,
|
||||||
@@ -305,245 +282,182 @@
|
|||||||
<code>{'{{MESSAGES}}'}</code>,
|
<code>{'{{MESSAGES}}'}</code>,
|
||||||
<code>{'{{CURRENT_DATE}}'}</code>
|
<code>{'{{CURRENT_DATE}}'}</code>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</AdminSettingField>
|
||||||
{/if}
|
{/if}
|
||||||
|
</AdminSettingSection>
|
||||||
|
|
||||||
<div class="mb-2.5 flex w-full items-center justify-between">
|
<AdminSettingSection title={$i18n.t('Generation')}>
|
||||||
<div class=" self-center text-xs text-gray-600 dark:text-gray-400">
|
<AdminSettingRow
|
||||||
{$i18n.t('Title Generation')}
|
label={$i18n.t('Title Generation')}
|
||||||
</div>
|
description={$i18n.t('Allow automatic names for new chats.')}
|
||||||
|
>
|
||||||
<Switch bind:state={taskConfig.ENABLE_TITLE_GENERATION} />
|
<Switch bind:state={taskConfig.ENABLE_TITLE_GENERATION} />
|
||||||
</div>
|
</AdminSettingRow>
|
||||||
|
|
||||||
{#if taskConfig.ENABLE_TITLE_GENERATION}
|
{#if taskConfig.ENABLE_TITLE_GENERATION}
|
||||||
<div class="mb-2.5">
|
<AdminSettingField
|
||||||
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">
|
label={$i18n.t('Title Generation Prompt')}
|
||||||
{$i18n.t('Title Generation Prompt')}
|
description={$i18n.t('Shapes the short label generated for each chat.')}
|
||||||
</div>
|
>
|
||||||
|
<Textarea
|
||||||
<Tooltip
|
className={textareaClass}
|
||||||
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
bind:value={taskConfig.TITLE_GENERATION_PROMPT_TEMPLATE}
|
||||||
placement="top-start"
|
placeholder={$i18n.t(
|
||||||
>
|
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||||
<Textarea
|
)}
|
||||||
className={textareaClass}
|
/>
|
||||||
bind:value={taskConfig.TITLE_GENERATION_PROMPT_TEMPLATE}
|
</AdminSettingField>
|
||||||
placeholder={$i18n.t(
|
|
||||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="mb-2.5 flex w-full items-center justify-between">
|
<AdminSettingRow
|
||||||
<div class=" self-center text-xs text-gray-600 dark:text-gray-400">
|
label={$i18n.t('Voice Mode Prompt')}
|
||||||
{$i18n.t('Voice Mode Prompt')}
|
description={$i18n.t('Apply voice-specific instructions while voice mode is active.')}
|
||||||
</div>
|
>
|
||||||
|
|
||||||
<Switch bind:state={taskConfig.ENABLE_VOICE_MODE_PROMPT} />
|
<Switch bind:state={taskConfig.ENABLE_VOICE_MODE_PROMPT} />
|
||||||
</div>
|
</AdminSettingRow>
|
||||||
|
|
||||||
{#if taskConfig.ENABLE_VOICE_MODE_PROMPT}
|
{#if taskConfig.ENABLE_VOICE_MODE_PROMPT}
|
||||||
<div class="mb-2.5">
|
<AdminSettingField
|
||||||
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">
|
label={$i18n.t('Prompt Template')}
|
||||||
{$i18n.t('Prompt Template')}
|
description={$i18n.t('Defines the behavior used for spoken conversations.')}
|
||||||
</div>
|
>
|
||||||
|
<Textarea
|
||||||
<Tooltip
|
className={textareaClass}
|
||||||
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
bind:value={taskConfig.VOICE_MODE_PROMPT_TEMPLATE}
|
||||||
placement="top-start"
|
placeholder={$i18n.t(
|
||||||
>
|
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||||
<Textarea
|
)}
|
||||||
className={textareaClass}
|
/>
|
||||||
bind:value={taskConfig.VOICE_MODE_PROMPT_TEMPLATE}
|
</AdminSettingField>
|
||||||
placeholder={$i18n.t(
|
|
||||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="mb-2.5 flex w-full items-center justify-between">
|
<AdminSettingRow
|
||||||
<div class=" self-center text-xs text-gray-600 dark:text-gray-400">
|
label={$i18n.t('Follow Up Generation')}
|
||||||
{$i18n.t('Follow Up Generation')}
|
description={$i18n.t('Show suggested next questions after assistant responses.')}
|
||||||
</div>
|
>
|
||||||
|
|
||||||
<Switch bind:state={taskConfig.ENABLE_FOLLOW_UP_GENERATION} />
|
<Switch bind:state={taskConfig.ENABLE_FOLLOW_UP_GENERATION} />
|
||||||
</div>
|
</AdminSettingRow>
|
||||||
|
|
||||||
{#if taskConfig.ENABLE_FOLLOW_UP_GENERATION}
|
{#if taskConfig.ENABLE_FOLLOW_UP_GENERATION}
|
||||||
<div class="mb-2.5">
|
<AdminSettingField
|
||||||
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">
|
label={$i18n.t('Follow Up Generation Prompt')}
|
||||||
{$i18n.t('Follow Up Generation Prompt')}
|
description={$i18n.t('Guides the suggestions shown after an assistant response.')}
|
||||||
</div>
|
>
|
||||||
|
<Textarea
|
||||||
<Tooltip
|
className={textareaClass}
|
||||||
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
bind:value={taskConfig.FOLLOW_UP_GENERATION_PROMPT_TEMPLATE}
|
||||||
placement="top-start"
|
placeholder={$i18n.t(
|
||||||
>
|
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||||
<Textarea
|
)}
|
||||||
className={textareaClass}
|
/>
|
||||||
bind:value={taskConfig.FOLLOW_UP_GENERATION_PROMPT_TEMPLATE}
|
</AdminSettingField>
|
||||||
placeholder={$i18n.t(
|
|
||||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="mb-2.5 flex w-full items-center justify-between">
|
<AdminSettingRow
|
||||||
<div class=" self-center text-xs text-gray-600 dark:text-gray-400">
|
label={$i18n.t('Tags Generation')}
|
||||||
{$i18n.t('Tags Generation')}
|
description={$i18n.t('Create chat tags from conversation content.')}
|
||||||
</div>
|
>
|
||||||
|
|
||||||
<Switch bind:state={taskConfig.ENABLE_TAGS_GENERATION} />
|
<Switch bind:state={taskConfig.ENABLE_TAGS_GENERATION} />
|
||||||
</div>
|
</AdminSettingRow>
|
||||||
|
|
||||||
{#if taskConfig.ENABLE_TAGS_GENERATION}
|
{#if taskConfig.ENABLE_TAGS_GENERATION}
|
||||||
<div class="mb-2.5">
|
<AdminSettingField
|
||||||
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">
|
label={$i18n.t('Tags Generation Prompt')}
|
||||||
{$i18n.t('Tags Generation Prompt')}
|
description={$i18n.t('Controls how chat tags are inferred.')}
|
||||||
</div>
|
|
||||||
|
|
||||||
<Tooltip
|
|
||||||
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
|
||||||
placement="top-start"
|
|
||||||
>
|
|
||||||
<Textarea
|
|
||||||
className={textareaClass}
|
|
||||||
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}
|
|
||||||
|
|
||||||
<div class="mb-2.5 flex w-full items-center justify-between">
|
|
||||||
<div class=" self-center text-xs text-gray-600 dark:text-gray-400">
|
|
||||||
{$i18n.t('Retrieval Query Generation')}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Switch bind:state={taskConfig.ENABLE_RETRIEVAL_QUERY_GENERATION} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-2.5 flex w-full items-center justify-between">
|
|
||||||
<div class=" self-center text-xs text-gray-600 dark:text-gray-400">
|
|
||||||
{$i18n.t('Web Search Query Generation')}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Switch bind:state={taskConfig.ENABLE_SEARCH_QUERY_GENERATION} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-2.5">
|
|
||||||
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">
|
|
||||||
{$i18n.t('Query Generation Prompt')}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Tooltip
|
|
||||||
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
|
||||||
placement="top-start"
|
|
||||||
>
|
>
|
||||||
<Textarea
|
<Textarea
|
||||||
className={textareaClass}
|
className={textareaClass}
|
||||||
bind:value={taskConfig.QUERY_GENERATION_PROMPT_TEMPLATE}
|
bind:value={taskConfig.TAGS_GENERATION_PROMPT_TEMPLATE}
|
||||||
placeholder={$i18n.t(
|
placeholder={$i18n.t(
|
||||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</AdminSettingField>
|
||||||
</div>
|
{/if}
|
||||||
|
|
||||||
<div class="mb-2.5 flex w-full items-center justify-between">
|
<AdminSettingRow
|
||||||
<div class=" self-center text-xs text-gray-600 dark:text-gray-400">
|
label={$i18n.t('Retrieval Query Generation')}
|
||||||
{$i18n.t('Autocomplete Generation')}
|
description={$i18n.t('Rewrite user requests for knowledge retrieval.')}
|
||||||
</div>
|
>
|
||||||
|
<Switch bind:state={taskConfig.ENABLE_RETRIEVAL_QUERY_GENERATION} />
|
||||||
|
</AdminSettingRow>
|
||||||
|
|
||||||
<Tooltip content={$i18n.t('Enable autocomplete generation for chat messages')}>
|
<AdminSettingRow
|
||||||
<Switch bind:state={taskConfig.ENABLE_AUTOCOMPLETE_GENERATION} />
|
label={$i18n.t('Web Search Query Generation')}
|
||||||
</Tooltip>
|
description={$i18n.t('Rewrite user requests into web-search queries.')}
|
||||||
</div>
|
>
|
||||||
|
<Switch bind:state={taskConfig.ENABLE_SEARCH_QUERY_GENERATION} />
|
||||||
|
</AdminSettingRow>
|
||||||
|
|
||||||
|
<AdminSettingField
|
||||||
|
label={$i18n.t('Query Generation Prompt')}
|
||||||
|
description={$i18n.t('Shared prompt for retrieval and web-search query rewriting.')}
|
||||||
|
>
|
||||||
|
<Textarea
|
||||||
|
className={textareaClass}
|
||||||
|
bind:value={taskConfig.QUERY_GENERATION_PROMPT_TEMPLATE}
|
||||||
|
placeholder={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
||||||
|
/>
|
||||||
|
</AdminSettingField>
|
||||||
|
|
||||||
|
<AdminSettingRow
|
||||||
|
label={$i18n.t('Autocomplete Generation')}
|
||||||
|
description={$i18n.t('Suggest completions while users type chat messages.')}
|
||||||
|
>
|
||||||
|
<Switch bind:state={taskConfig.ENABLE_AUTOCOMPLETE_GENERATION} />
|
||||||
|
</AdminSettingRow>
|
||||||
|
|
||||||
{#if taskConfig.ENABLE_AUTOCOMPLETE_GENERATION}
|
{#if taskConfig.ENABLE_AUTOCOMPLETE_GENERATION}
|
||||||
<div class="mb-2.5">
|
<AdminSettingField
|
||||||
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">
|
label={$i18n.t('Autocomplete Generation Input Max Length')}
|
||||||
{$i18n.t('Autocomplete Generation Input Max Length')}
|
description={$i18n.t('Limit how much draft text is sent for suggestion generation.')}
|
||||||
</div>
|
>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
min="-1"
|
||||||
|
step="1"
|
||||||
|
class={inputClass}
|
||||||
|
bind:value={taskConfig.AUTOCOMPLETE_GENERATION_INPUT_MAX_LENGTH}
|
||||||
|
placeholder={$i18n.t('-1 for no limit, or a positive integer for a specific limit')}
|
||||||
|
/>
|
||||||
|
</AdminSettingField>
|
||||||
|
|
||||||
<Tooltip
|
<AdminSettingField
|
||||||
content={$i18n.t('Character limit for autocomplete generation input')}
|
label={$i18n.t('Autocomplete Generation Prompt')}
|
||||||
placement="top-start"
|
description={$i18n.t('Guides inline completions while users type a message.')}
|
||||||
>
|
>
|
||||||
<input
|
<Textarea
|
||||||
class="w-full outline-hidden bg-transparent"
|
className={textareaClass}
|
||||||
bind:value={taskConfig.AUTOCOMPLETE_GENERATION_INPUT_MAX_LENGTH}
|
bind:value={taskConfig.AUTOCOMPLETE_GENERATION_PROMPT_TEMPLATE}
|
||||||
placeholder={$i18n.t('-1 for no limit, or a positive integer for a specific limit')}
|
placeholder={$i18n.t(
|
||||||
/>
|
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||||
</Tooltip>
|
)}
|
||||||
</div>
|
/>
|
||||||
<div class="mb-2.5">
|
</AdminSettingField>
|
||||||
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">
|
|
||||||
{$i18n.t('Autocomplete Generation Prompt')}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Tooltip
|
|
||||||
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
|
||||||
placement="top-start"
|
|
||||||
>
|
|
||||||
<Textarea
|
|
||||||
className={textareaClass}
|
|
||||||
bind:value={taskConfig.AUTOCOMPLETE_GENERATION_PROMPT_TEMPLATE}
|
|
||||||
placeholder={$i18n.t(
|
|
||||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="mb-2.5">
|
<AdminSettingField
|
||||||
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">
|
label={$i18n.t('Image Prompt Generation Prompt')}
|
||||||
{$i18n.t('Image Prompt Generation Prompt')}
|
description={$i18n.t('Rewrites user intent into an image-generation prompt.')}
|
||||||
</div>
|
>
|
||||||
|
<Textarea
|
||||||
|
className={textareaClass}
|
||||||
|
bind:value={taskConfig.IMAGE_PROMPT_GENERATION_PROMPT_TEMPLATE}
|
||||||
|
placeholder={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
||||||
|
/>
|
||||||
|
</AdminSettingField>
|
||||||
|
|
||||||
<Tooltip
|
<AdminSettingField
|
||||||
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
label={$i18n.t('Tools Function Calling Prompt')}
|
||||||
placement="top-start"
|
description={$i18n.t('Guides how the assistant formats tool and function calls.')}
|
||||||
>
|
>
|
||||||
<Textarea
|
<Textarea
|
||||||
className={textareaClass}
|
className={textareaClass}
|
||||||
bind:value={taskConfig.IMAGE_PROMPT_GENERATION_PROMPT_TEMPLATE}
|
bind:value={taskConfig.TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE}
|
||||||
placeholder={$i18n.t(
|
placeholder={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
||||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
/>
|
||||||
)}
|
</AdminSettingField>
|
||||||
/>
|
</AdminSettingSection>
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-2.5">
|
|
||||||
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">
|
|
||||||
{$i18n.t('Tools Function Calling Prompt')}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Tooltip
|
|
||||||
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
|
||||||
placement="top-start"
|
|
||||||
>
|
|
||||||
<Textarea
|
|
||||||
className={textareaClass}
|
|
||||||
bind:value={taskConfig.TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE}
|
|
||||||
placeholder={$i18n.t(
|
|
||||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex justify-end pt-6 text-sm font-normal">
|
<div class="flex justify-end pt-6 text-sm font-normal">
|
||||||
@@ -556,7 +470,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{:else}
|
{:else}
|
||||||
<div class=" h-full w-full flex justify-center items-center">
|
<div class="flex h-full w-full items-center justify-center">
|
||||||
<Spinner className="size-5" />
|
<Spinner className="size-5" />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
import Switch from '$lib/components/common/Switch.svelte';
|
import Switch from '$lib/components/common/Switch.svelte';
|
||||||
import AdminSettingField from './AdminSettingField.svelte';
|
import AdminSettingField from './AdminSettingField.svelte';
|
||||||
import AdminSettingRow from './AdminSettingRow.svelte';
|
import AdminSettingRow from './AdminSettingRow.svelte';
|
||||||
|
import AdminSettingSection from './AdminSettingSection.svelte';
|
||||||
import SettingsSelect from '$lib/components/common/SettingsSelect.svelte';
|
import SettingsSelect from '$lib/components/common/SettingsSelect.svelte';
|
||||||
|
|
||||||
const i18n: Writable<i18nType> = getContext('i18n');
|
const i18n: Writable<i18nType> = getContext('i18n');
|
||||||
@@ -38,24 +39,27 @@
|
|||||||
|
|
||||||
let valves: any = null;
|
let valves: any = null;
|
||||||
let valves_spec: any = null;
|
let valves_spec: any = null;
|
||||||
let selectedPipelineIdx: number | null = null;
|
let selectedPipelineIdx = 0;
|
||||||
|
|
||||||
let pipelineDownloadUrl = '';
|
let pipelineDownloadUrl = '';
|
||||||
const inputClass =
|
const inputClass =
|
||||||
'w-full h-7 rounded-lg border border-gray-100/50 bg-gray-50/40 px-2 text-xs text-gray-700 outline-hidden transition-colors placeholder:text-gray-300 focus:border-blue-400 dark:border-white/[0.04] dark:bg-white/[0.03] dark:text-gray-300 dark:placeholder:text-gray-700 dark:focus:border-blue-500';
|
'w-full h-7 rounded-lg border border-gray-100/50 bg-gray-50/40 px-2 text-xs text-gray-700 outline-hidden transition-colors placeholder:text-gray-300 focus:border-blue-400 dark:border-white/[0.04] dark:bg-white/[0.03] dark:text-gray-300 dark:placeholder:text-gray-700 dark:focus:border-blue-500';
|
||||||
const actionButtonClass =
|
const actionButtonClass =
|
||||||
'rounded-lg px-2 py-1 text-xs text-gray-500 transition-colors hover:bg-black/5 hover:text-gray-900 disabled:opacity-50 dark:text-gray-500 dark:hover:bg-white/5 dark:hover:text-white';
|
'shrink-0 text-xs text-gray-500 transition-colors hover:text-gray-900 disabled:opacity-50 dark:text-gray-500 dark:hover:text-white';
|
||||||
const iconButtonClass =
|
|
||||||
'flex size-7 items-center justify-center rounded-lg text-gray-400 transition-colors hover:bg-black/5 hover:text-gray-900 disabled:opacity-50 dark:text-gray-600 dark:hover:bg-white/5 dark:hover:text-white';
|
|
||||||
const mutedMessageClass = 'text-xs text-gray-400 dark:text-gray-600';
|
const mutedMessageClass = 'text-xs text-gray-400 dark:text-gray-600';
|
||||||
|
|
||||||
const updateHandler = async () => {
|
const updateHandler = async () => {
|
||||||
|
if (!pipelines) {
|
||||||
|
toast.error($i18n.t('No valves to update'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const pipeline = pipelines[selectedPipelineIdx];
|
const pipeline = pipelines[selectedPipelineIdx];
|
||||||
|
|
||||||
if (pipeline && (pipeline?.valves ?? false)) {
|
if (pipeline && (pipeline?.valves ?? false)) {
|
||||||
for (const property in valves_spec.properties) {
|
for (const property in valves_spec.properties) {
|
||||||
if (valves_spec.properties[property]?.type === 'array') {
|
if (valves_spec.properties[property]?.type === 'array') {
|
||||||
valves[property] = (valves[property] ?? '').split(',').map((v) => v.trim());
|
valves[property] = (valves[property] ?? '').split(',').map((v: string) => v.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +90,11 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getValves = async (idx) => {
|
const getValves = async (idx: number) => {
|
||||||
|
if (!pipelines?.[idx]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
valves = null;
|
valves = null;
|
||||||
valves_spec = null;
|
valves_spec = null;
|
||||||
|
|
||||||
@@ -113,11 +121,12 @@
|
|||||||
valves = null;
|
valves = null;
|
||||||
valves_spec = null;
|
valves_spec = null;
|
||||||
|
|
||||||
if (PIPELINES_LIST.length > 0) {
|
if ((PIPELINES_LIST ?? []).length > 0) {
|
||||||
console.debug(selectedPipelinesUrlIdx);
|
console.debug(selectedPipelinesUrlIdx);
|
||||||
pipelines = await getPipelines(localStorage.token, selectedPipelinesUrlIdx);
|
const loadedPipelines = await getPipelines(localStorage.token, selectedPipelinesUrlIdx);
|
||||||
|
pipelines = loadedPipelines;
|
||||||
|
|
||||||
if (pipelines.length > 0) {
|
if (loadedPipelines.length > 0) {
|
||||||
selectedPipelineIdx = 0;
|
selectedPipelineIdx = 0;
|
||||||
await getValves(selectedPipelineIdx);
|
await getValves(selectedPipelineIdx);
|
||||||
}
|
}
|
||||||
@@ -186,19 +195,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
pipelineFiles = null;
|
pipelineFiles = null;
|
||||||
const pipelineUploadInputElement = document.getElementById('pipelines-upload-input');
|
const pipelineUploadInputElement = document.getElementById(
|
||||||
|
'pipelines-upload-input'
|
||||||
|
) as HTMLInputElement | null;
|
||||||
|
|
||||||
if (pipelineUploadInputElement) {
|
if (pipelineUploadInputElement) {
|
||||||
pipelineUploadInputElement.value = null;
|
pipelineUploadInputElement.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
uploading = false;
|
uploading = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deletePipelineHandler = async () => {
|
const deletePipelineHandler = async () => {
|
||||||
|
const pipeline = pipelines?.[selectedPipelineIdx];
|
||||||
|
if (!pipeline) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const res = await deletePipeline(
|
const res = await deletePipeline(
|
||||||
localStorage.token,
|
localStorage.token,
|
||||||
pipelines[selectedPipelineIdx].id,
|
pipeline.id,
|
||||||
selectedPipelinesUrlIdx
|
selectedPipelinesUrlIdx
|
||||||
).catch((error) => {
|
).catch((error) => {
|
||||||
toast.error(`${error}`);
|
toast.error(`${error}`);
|
||||||
@@ -223,8 +239,9 @@
|
|||||||
PIPELINES_LIST = await getPipelinesList(localStorage.token);
|
PIPELINES_LIST = await getPipelinesList(localStorage.token);
|
||||||
console.log(PIPELINES_LIST);
|
console.log(PIPELINES_LIST);
|
||||||
|
|
||||||
if (PIPELINES_LIST.length > 0) {
|
const pipelinesList = PIPELINES_LIST ?? [];
|
||||||
selectedPipelinesUrlIdx = PIPELINES_LIST[0]['idx'].toString();
|
if (pipelinesList.length > 0) {
|
||||||
|
selectedPipelinesUrlIdx = pipelinesList[0]['idx'].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
await setPipelines();
|
await setPipelines();
|
||||||
@@ -250,8 +267,11 @@
|
|||||||
hidden
|
hidden
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="flex flex-col gap-2.5">
|
<AdminSettingSection title={$i18n.t('Source')} first>
|
||||||
<AdminSettingField label={$i18n.t('Pipeline URL')}>
|
<AdminSettingField
|
||||||
|
label={$i18n.t('Pipeline URL')}
|
||||||
|
description={$i18n.t('Select the Pipelines server to manage.')}
|
||||||
|
>
|
||||||
<SettingsSelect
|
<SettingsSelect
|
||||||
bind:value={selectedPipelinesUrlIdx}
|
bind:value={selectedPipelinesUrlIdx}
|
||||||
className="w-full"
|
className="w-full"
|
||||||
@@ -273,7 +293,10 @@
|
|||||||
</SettingsSelect>
|
</SettingsSelect>
|
||||||
</AdminSettingField>
|
</AdminSettingField>
|
||||||
|
|
||||||
<AdminSettingField label={$i18n.t('Upload Pipeline')}>
|
<AdminSettingField
|
||||||
|
label={$i18n.t('Upload Pipeline')}
|
||||||
|
description={$i18n.t('Upload a local Python pipeline file to the selected server.')}
|
||||||
|
>
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<button
|
<button
|
||||||
class="h-7 flex-1 rounded-lg border border-dashed border-gray-100/50 bg-transparent px-2 text-left text-xs text-gray-500 transition-colors hover:bg-black/5 hover:text-gray-900 dark:border-white/[0.04] dark:text-gray-500 dark:hover:bg-white/5 dark:hover:text-white"
|
class="h-7 flex-1 rounded-lg border border-dashed border-gray-100/50 bg-transparent px-2 text-left text-xs text-gray-500 transition-colors hover:bg-black/5 hover:text-gray-900 dark:border-white/[0.04] dark:text-gray-500 dark:hover:bg-white/5 dark:hover:text-white"
|
||||||
@@ -324,10 +347,15 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</AdminSettingField>
|
</AdminSettingField>
|
||||||
|
</AdminSettingSection>
|
||||||
|
|
||||||
{#if pipelines !== null}
|
{#if pipelines !== null}
|
||||||
{#if pipelines.length > 0}
|
{#if pipelines.length > 0}
|
||||||
<AdminSettingField label={$i18n.t('Pipeline')}>
|
<AdminSettingSection title={$i18n.t('Pipelines')}>
|
||||||
|
<AdminSettingField
|
||||||
|
label={$i18n.t('Pipeline')}
|
||||||
|
description={$i18n.t('Select an installed pipeline to configure or remove.')}
|
||||||
|
>
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<SettingsSelect
|
<SettingsSelect
|
||||||
bind:value={selectedPipelineIdx}
|
bind:value={selectedPipelineIdx}
|
||||||
@@ -356,12 +384,17 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</AdminSettingField>
|
</AdminSettingField>
|
||||||
|
</AdminSettingSection>
|
||||||
|
|
||||||
|
<AdminSettingSection title={$i18n.t('Valves')}>
|
||||||
{#if pipelines[selectedPipelineIdx ?? 0]?.valves}
|
{#if pipelines[selectedPipelineIdx ?? 0]?.valves}
|
||||||
{#if valves}
|
{#if valves && valves_spec}
|
||||||
{#each Object.keys(valves_spec.properties) as property}
|
{#each Object.keys(valves_spec.properties) as property}
|
||||||
<div>
|
<div>
|
||||||
<AdminSettingRow label={valves_spec.properties[property].title}>
|
<AdminSettingRow
|
||||||
|
label={valves_spec.properties[property].title}
|
||||||
|
description={valves_spec.properties[property]?.description ?? ''}
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
class={actionButtonClass}
|
class={actionButtonClass}
|
||||||
type="button"
|
type="button"
|
||||||
@@ -407,22 +440,28 @@
|
|||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
{:else}
|
{:else}
|
||||||
<Spinner className="size-5" />
|
<div class="flex justify-center py-2">
|
||||||
|
<Spinner className="size-4" />
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
<div class={mutedMessageClass}>{$i18n.t('No valves')}</div>
|
<div class={mutedMessageClass}>{$i18n.t('No valves')}</div>
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
</AdminSettingSection>
|
||||||
<div class={mutedMessageClass}>{$i18n.t('Pipelines Not Detected')}</div>
|
|
||||||
{/if}
|
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex justify-center py-4">
|
<AdminSettingSection title={$i18n.t('Pipelines')}>
|
||||||
<Spinner className="size-4" />
|
<div class={mutedMessageClass}>{$i18n.t('Pipelines Not Detected')}</div>
|
||||||
</div>
|
</AdminSettingSection>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
{:else}
|
||||||
|
<div class="flex justify-center py-4">
|
||||||
|
<Spinner className="size-4" />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
<div class={mutedMessageClass}>{$i18n.t('Pipelines Not Detected')}</div>
|
<AdminSettingSection title={$i18n.t('Source')} first>
|
||||||
|
<div class={mutedMessageClass}>{$i18n.t('Pipelines Not Detected')}</div>
|
||||||
|
</AdminSettingSection>
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex justify-center h-full">
|
<div class="flex justify-center h-full">
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -154,7 +154,7 @@
|
|||||||
<div class="text-xs text-gray-400 dark:text-gray-500">
|
<div class="text-xs text-gray-400 dark:text-gray-500">
|
||||||
{$i18n.t('Created by')}
|
{$i18n.t('Created by')}
|
||||||
<a class="text-gray-500 dark:text-gray-400" href="https://github.com/tjbck" target="_blank"
|
<a class="text-gray-500 dark:text-gray-400" href="https://github.com/tjbck" target="_blank"
|
||||||
>Timothy J. Baek</a
|
>Tim J. Baek</a
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</UserSettingSection>
|
</UserSettingSection>
|
||||||
|
|||||||
@@ -41,8 +41,6 @@
|
|||||||
let playbackRate = 1;
|
let playbackRate = 1;
|
||||||
const inputClass =
|
const inputClass =
|
||||||
'h-7 w-full rounded-lg border border-gray-100/50 bg-gray-50/40 px-2 text-xs text-gray-700 outline-hidden transition-colors placeholder:text-gray-300 focus:border-blue-400 dark:border-white/[0.04] dark:bg-white/[0.03] dark:text-gray-300 dark:placeholder:text-gray-700 dark:focus:border-blue-500';
|
'h-7 w-full rounded-lg border border-gray-100/50 bg-gray-50/40 px-2 text-xs text-gray-700 outline-hidden transition-colors placeholder:text-gray-300 focus:border-blue-400 dark:border-white/[0.04] dark:bg-white/[0.03] dark:text-gray-300 dark:placeholder:text-gray-700 dark:focus:border-blue-500';
|
||||||
const actionButtonClass =
|
|
||||||
'text-xs text-gray-500 transition-colors hover:text-gray-900 dark:text-gray-500 dark:hover:text-white';
|
|
||||||
|
|
||||||
const getVoices = async () => {
|
const getVoices = async () => {
|
||||||
if (TTSEngine === 'browser-kokoro') {
|
if (TTSEngine === 'browser-kokoro') {
|
||||||
@@ -80,13 +78,13 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleResponseAutoPlayback = async () => {
|
const setResponseAutoPlayback = async (enabled: boolean) => {
|
||||||
responseAutoPlayback = !responseAutoPlayback;
|
responseAutoPlayback = enabled;
|
||||||
saveSettings({ responseAutoPlayback: responseAutoPlayback });
|
saveSettings({ responseAutoPlayback: responseAutoPlayback });
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleSpeechAutoSend = async () => {
|
const setSpeechAutoSend = async (enabled: boolean) => {
|
||||||
speechAutoSend = !speechAutoSend;
|
speechAutoSend = enabled;
|
||||||
saveSettings({ speechAutoSend: speechAutoSend });
|
saveSettings({ speechAutoSend: speechAutoSend });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -231,17 +229,13 @@
|
|||||||
'Send transcribed voice input immediately after speech recognition finishes.'
|
'Send transcribed voice input immediately after speech recognition finishes.'
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<button
|
<Switch
|
||||||
class={actionButtonClass}
|
state={speechAutoSend}
|
||||||
on:click={() => {
|
ariaLabel={$i18n.t('Instant Auto-Send After Voice Transcription')}
|
||||||
toggleSpeechAutoSend();
|
on:change={(event) => {
|
||||||
|
setSpeechAutoSend(event.detail);
|
||||||
}}
|
}}
|
||||||
type="button"
|
/>
|
||||||
role="switch"
|
|
||||||
aria-checked={speechAutoSend}
|
|
||||||
>
|
|
||||||
{speechAutoSend === true ? $i18n.t('On') : $i18n.t('Off')}
|
|
||||||
</button>
|
|
||||||
</UserSettingRow>
|
</UserSettingRow>
|
||||||
</UserSettingSection>
|
</UserSettingSection>
|
||||||
|
|
||||||
@@ -283,17 +277,13 @@
|
|||||||
label={$i18n.t('Auto-Playback Response')}
|
label={$i18n.t('Auto-Playback Response')}
|
||||||
description={$i18n.t('Play assistant responses aloud automatically.')}
|
description={$i18n.t('Play assistant responses aloud automatically.')}
|
||||||
>
|
>
|
||||||
<button
|
<Switch
|
||||||
class={actionButtonClass}
|
state={responseAutoPlayback}
|
||||||
on:click={() => {
|
ariaLabel={$i18n.t('Auto-Playback Response')}
|
||||||
toggleResponseAutoPlayback();
|
on:change={(event) => {
|
||||||
|
setResponseAutoPlayback(event.detail);
|
||||||
}}
|
}}
|
||||||
type="button"
|
/>
|
||||||
role="switch"
|
|
||||||
aria-checked={responseAutoPlayback}
|
|
||||||
>
|
|
||||||
{responseAutoPlayback === true ? $i18n.t('On') : $i18n.t('Off')}
|
|
||||||
</button>
|
|
||||||
</UserSettingRow>
|
</UserSettingRow>
|
||||||
|
|
||||||
<UserSettingRow
|
<UserSettingRow
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
import UserSettingRow from './UserSettingRow.svelte';
|
import UserSettingRow from './UserSettingRow.svelte';
|
||||||
import UserSettingSection from './UserSettingSection.svelte';
|
import UserSettingSection from './UserSettingSection.svelte';
|
||||||
import SettingsSelect from '$lib/components/common/SettingsSelect.svelte';
|
import SettingsSelect from '$lib/components/common/SettingsSelect.svelte';
|
||||||
|
import Switch from '$lib/components/common/Switch.svelte';
|
||||||
export let saveSettings: Function;
|
export let saveSettings: Function;
|
||||||
export let getModels: Function;
|
export let getModels: Function;
|
||||||
|
|
||||||
@@ -33,13 +34,14 @@
|
|||||||
const actionButtonClass =
|
const actionButtonClass =
|
||||||
'text-xs text-gray-500 transition-colors hover:text-gray-900 dark:text-gray-500 dark:hover:text-white';
|
'text-xs text-gray-500 transition-colors hover:text-gray-900 dark:text-gray-500 dark:hover:text-white';
|
||||||
|
|
||||||
const toggleNotification = async () => {
|
const setNotificationEnabled = async (enabled: boolean) => {
|
||||||
const permission = await Notification.requestPermission();
|
const permission = enabled ? await Notification.requestPermission() : 'granted';
|
||||||
|
|
||||||
if (permission === 'granted') {
|
if (permission === 'granted') {
|
||||||
notificationEnabled = !notificationEnabled;
|
notificationEnabled = enabled;
|
||||||
saveSettings({ notificationEnabled: notificationEnabled });
|
saveSettings({ notificationEnabled: notificationEnabled });
|
||||||
} else {
|
} else {
|
||||||
|
notificationEnabled = false;
|
||||||
toast.error(
|
toast.error(
|
||||||
$i18n.t(
|
$i18n.t(
|
||||||
'Response notifications cannot be activated as the website permissions have been denied. Please visit your browser settings to grant the necessary access.'
|
'Response notifications cannot be activated as the website permissions have been denied. Please visit your browser settings to grant the necessary access.'
|
||||||
@@ -273,17 +275,13 @@
|
|||||||
label={$i18n.t('Notifications')}
|
label={$i18n.t('Notifications')}
|
||||||
description={$i18n.t('Allow browser notifications for completed responses.')}
|
description={$i18n.t('Allow browser notifications for completed responses.')}
|
||||||
>
|
>
|
||||||
<button
|
<Switch
|
||||||
class={actionButtonClass}
|
state={notificationEnabled}
|
||||||
on:click={() => {
|
ariaLabel={$i18n.t('Notifications')}
|
||||||
toggleNotification();
|
on:change={(event) => {
|
||||||
|
setNotificationEnabled(event.detail);
|
||||||
}}
|
}}
|
||||||
type="button"
|
/>
|
||||||
role="switch"
|
|
||||||
aria-checked={notificationEnabled}
|
|
||||||
>
|
|
||||||
{notificationEnabled === true ? $i18n.t('On') : $i18n.t('Off')}
|
|
||||||
</button>
|
|
||||||
</UserSettingRow>
|
</UserSettingRow>
|
||||||
</UserSettingSection>
|
</UserSettingSection>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user