This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-15 18:52:12 -04:00
1 parent 6abee5cc3c
commit b3255a3656
10 files changed
+1242 -2107

No files matched your search

+203 -440
View File
@@ -14,6 +14,7 @@
import Spinner from '$lib/components/common/Spinner.svelte'; import Spinner from '$lib/components/common/Spinner.svelte';
import SensitiveInput from '$lib/components/common/SensitiveInput.svelte'; import SensitiveInput from '$lib/components/common/SensitiveInput.svelte';
import Switch from '$lib/components/common/Switch.svelte';
import TTSVoiceInput from '$lib/components/workspace/Models/TTSVoiceInput.svelte'; import TTSVoiceInput from '$lib/components/workspace/Models/TTSVoiceInput.svelte';
import { TTS_RESPONSE_SPLIT } from '$lib/types'; import { TTS_RESPONSE_SPLIT } from '$lib/types';
@@ -22,6 +23,9 @@
import type { i18n as i18nType } from 'i18next'; import type { i18n as i18nType } from 'i18next';
import Textarea from '$lib/components/common/Textarea.svelte'; import Textarea from '$lib/components/common/Textarea.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 i18n = getContext<Writable<i18nType>>('i18n'); const i18n = getContext<Writable<i18nType>>('i18n');
@@ -74,6 +78,12 @@
let voices: SpeechSynthesisVoice[] = []; let voices: SpeechSynthesisVoice[] = [];
let providerVoices: Voice[] = []; let providerVoices: Voice[] = [];
let models: Awaited<ReturnType<typeof _getModels>>['models'] = []; let models: Awaited<ReturnType<typeof _getModels>>['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 =
'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 linkedHelpClass =
'text-[0.6875rem] text-gray-400 dark:text-gray-600 [&_a]:text-gray-600 [&_a]:hover:underline dark:[&_a]:text-gray-300';
const getModels = async () => { const getModels = async () => {
if (TTS_ENGINE === '') { if (TTS_ENGINE === '') {
@@ -237,36 +247,11 @@
<h2 class="text-sm font-medium text-gray-900 dark:text-white mb-4">{$i18n.t('Audio')}</h2> <h2 class="text-sm font-medium text-gray-900 dark:text-white mb-4">{$i18n.t('Audio')}</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="flex flex-col gap-3"> <AdminSettingSection title={$i18n.t('Speech-to-Text')} first>
<div> <AdminSettingRow
<div class=" mb-2 text-xs text-gray-400 dark:text-gray-600"> label={$i18n.t('Speech-to-Text Engine')}
{$i18n.t('Speech-to-Text')} description={$i18n.t('Choose the transcription provider used for audio input.')}
</div> >
{#if STT_ENGINE !== 'web'}
<div class="mb-2">
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('Supported MIME Types')}
</div>
<div class="flex w-full">
<div class="flex-1">
<input
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={STT_SUPPORTED_CONTENT_TYPES}
placeholder={$i18n.t(
'e.g., audio/wav,audio/mpeg,video/* (leave blank for defaults)'
)}
/>
</div>
</div>
</div>
{/if}
<div class="mb-2 py-0.5 flex w-full justify-between">
<div class=" self-center text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('Speech-to-Text Engine')}
</div>
<div class="flex items-center relative">
<SettingsSelect bind:value={STT_ENGINE} placeholder={$i18n.t('Select an engine')}> <SettingsSelect bind:value={STT_ENGINE} placeholder={$i18n.t('Select an engine')}>
<option value="">{$i18n.t('Whisper (Local)')}</option> <option value="">{$i18n.t('Whisper (Local)')}</option>
<option value="openai">{$i18n.t('OpenAI')}</option> <option value="openai">{$i18n.t('OpenAI')}</option>
@@ -275,261 +260,192 @@
<option value="azure">{$i18n.t('Azure AI Speech')}</option> <option value="azure">{$i18n.t('Azure AI Speech')}</option>
<option value="mistral">{$i18n.t('MistralAI')}</option> <option value="mistral">{$i18n.t('MistralAI')}</option>
</SettingsSelect> </SettingsSelect>
</div> </AdminSettingRow>
</div>
{#if STT_ENGINE !== 'web'}
<AdminSettingField
label={$i18n.t('Supported MIME Types')}
description={$i18n.t('Comma-separated audio or video MIME types accepted for upload.')}
>
<input
class={inputClass}
bind:value={STT_SUPPORTED_CONTENT_TYPES}
placeholder={$i18n.t('e.g., audio/wav,audio/mpeg,video/* (leave blank for defaults)')}
/>
</AdminSettingField>
{/if}
{#if STT_ENGINE === 'openai'} {#if STT_ENGINE === 'openai'}
<div> <div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
<div class="mt-1 flex gap-2 mb-1"> <AdminSettingField label={$i18n.t('API Base URL')}>
<input <input
class="flex-1 w-full border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300" class={inputClass}
placeholder={$i18n.t('API Base URL')} placeholder={$i18n.t('API Base URL')}
bind:value={STT_OPENAI_API_BASE_URL} bind:value={STT_OPENAI_API_BASE_URL}
required required
/> />
</AdminSettingField>
<AdminSettingField label={$i18n.t('API Key')}>
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
placeholder={$i18n.t('API Key')} placeholder={$i18n.t('API Key')}
bind:value={STT_OPENAI_API_KEY} bind:value={STT_OPENAI_API_KEY}
/> />
</div> </AdminSettingField>
</div> </div>
<div class="mb-2 py-0.5 flex w-full justify-between"> <AdminSettingRow
<div class=" self-center text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Request Format')}
{$i18n.t('Request Format')} description={$i18n.t('Select how audio is sent to the OpenAI-compatible endpoint.')}
</div> >
<div class="flex items-center relative">
<SettingsSelect bind:value={STT_OPENAI_API_REQUEST_FORMAT}> <SettingsSelect bind:value={STT_OPENAI_API_REQUEST_FORMAT}>
<option value="multipart">{$i18n.t('Multipart Upload')}</option> <option value="multipart">{$i18n.t('Multipart Upload')}</option>
<option value="json">{$i18n.t('JSON Base64')}</option> <option value="json">{$i18n.t('JSON Base64')}</option>
</SettingsSelect> </SettingsSelect>
</div> </AdminSettingRow>
</div>
<div> <AdminSettingField label={$i18n.t('STT Model')}>
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('STT Model')}
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
list="model-list" list="stt-openai-model-list"
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" class={inputClass}
bind:value={STT_MODEL} bind:value={STT_MODEL}
placeholder={$i18n.t('Select a model')} placeholder={$i18n.t('Select a model')}
/> />
<datalist id="stt-openai-model-list">
<datalist id="model-list"> <option value="whisper-1"></option>
<option value="whisper-1" />
</datalist> </datalist>
</div> </AdminSettingField>
</div>
</div>
{:else if STT_ENGINE === 'deepgram'} {:else if STT_ENGINE === 'deepgram'}
<div> <AdminSettingField label={$i18n.t('API Key')}>
<div class="mt-1 flex gap-2 mb-1">
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
placeholder={$i18n.t('API Key')} placeholder={$i18n.t('API Key')}
bind:value={STT_DEEPGRAM_API_KEY} bind:value={STT_DEEPGRAM_API_KEY}
/> />
</div> </AdminSettingField>
</div>
<div> <AdminSettingField
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('STT Model')}
{$i18n.t('STT Model')} description={$i18n.t('Leave model field empty to use the default model.')}
</div> >
<div class="flex w-full">
<div class="flex-1">
<input <input
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" class={inputClass}
bind:value={STT_MODEL} bind:value={STT_MODEL}
placeholder={$i18n.t('Select a model (optional)')} placeholder={$i18n.t('Select a model (optional)')}
/> />
</div> <div class="mt-1 {linkedHelpClass}">
</div> <a href="https://developers.deepgram.com/docs/models" target="_blank">
<div class="mt-2 mb-1 text-xs text-gray-400 dark:text-gray-500">
{$i18n.t('Leave model field empty to use the default model.')}
<a
class=" hover:underline dark:text-gray-200 text-gray-800"
href="https://developers.deepgram.com/docs/models"
target="_blank"
>
{$i18n.t('Click here to see available models.')} {$i18n.t('Click here to see available models.')}
</a> </a>
</div> </div>
</div> </AdminSettingField>
{:else if STT_ENGINE === 'azure'} {:else if STT_ENGINE === 'azure'}
<div> <AdminSettingField label={$i18n.t('API Key')}>
<div class="mt-1 flex gap-2 mb-1">
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
placeholder={$i18n.t('API Key')} placeholder={$i18n.t('API Key')}
bind:value={STT_AZURE_API_KEY} bind:value={STT_AZURE_API_KEY}
required required
/> />
</div> </AdminSettingField>
<div> <div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400"> <AdminSettingField label={$i18n.t('Azure Region')}>
{$i18n.t('Azure Region')}
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
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" class={inputClass}
bind:value={STT_AZURE_REGION} bind:value={STT_AZURE_REGION}
placeholder={$i18n.t('e.g., westus (leave blank for eastus)')} placeholder={$i18n.t('e.g., westus (leave blank for eastus)')}
/> />
</div> </AdminSettingField>
</div> <AdminSettingField label={$i18n.t('Language Locales')}>
</div>
<div>
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('Language Locales')}
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
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" class={inputClass}
bind:value={STT_AZURE_LOCALES} bind:value={STT_AZURE_LOCALES}
placeholder={$i18n.t('e.g., en-US,ja-JP (leave blank for auto-detect)')} placeholder={$i18n.t('e.g., en-US,ja-JP (leave blank for auto-detect)')}
/> />
</div> </AdminSettingField>
</div> <AdminSettingField label={$i18n.t('Endpoint URL')}>
</div>
<div>
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('Endpoint URL')}
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
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" class={inputClass}
bind:value={STT_AZURE_BASE_URL} bind:value={STT_AZURE_BASE_URL}
placeholder={$i18n.t('(leave blank for to use commercial endpoint)')} placeholder={$i18n.t('(leave blank for to use commercial endpoint)')}
/> />
</div> </AdminSettingField>
</div> <AdminSettingField label={$i18n.t('Max Speakers')}>
</div>
<div>
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('Max Speakers')}
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
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" class={inputClass}
bind:value={STT_AZURE_MAX_SPEAKERS} bind:value={STT_AZURE_MAX_SPEAKERS}
placeholder={$i18n.t('e.g., 3, 4, 5 (leave blank for default)')} placeholder={$i18n.t('e.g., 3, 4, 5 (leave blank for default)')}
/> />
</div> </AdminSettingField>
</div>
</div>
</div> </div>
{:else if STT_ENGINE === 'mistral'} {:else if STT_ENGINE === 'mistral'}
<div> <div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
<div class="mt-1 flex gap-2 mb-1"> <AdminSettingField label={$i18n.t('API Base URL')}>
<input <input
class="flex-1 w-full border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300" class={inputClass}
placeholder={$i18n.t('API Base URL')} placeholder={$i18n.t('API Base URL')}
bind:value={STT_MISTRAL_API_BASE_URL} bind:value={STT_MISTRAL_API_BASE_URL}
required required
/> />
</AdminSettingField>
<AdminSettingField label={$i18n.t('API Key')}>
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
placeholder={$i18n.t('API Key')} placeholder={$i18n.t('API Key')}
bind:value={STT_MISTRAL_API_KEY} bind:value={STT_MISTRAL_API_KEY}
/> />
</div> </AdminSettingField>
</div> </div>
<div> <AdminSettingField
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('STT Model')}
{$i18n.t('STT Model')} description={$i18n.t('Leave empty to use the default model (voxtral-mini-latest).')}
</div>
<div class="flex w-full">
<div class="flex-1">
<input
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={STT_MODEL}
placeholder="voxtral-mini-latest"
/>
</div>
</div>
<div class="mt-2 mb-1 text-xs text-gray-400 dark:text-gray-500">
{$i18n.t('Leave empty to use the default model (voxtral-mini-latest).')}
<a
class=" hover:underline dark:text-gray-200 text-gray-800"
href="https://docs.mistral.ai/capabilities/audio_transcription"
target="_blank"
> >
<input class={inputClass} bind:value={STT_MODEL} placeholder="voxtral-mini-latest" />
<div class="mt-1 {linkedHelpClass}">
<a href="https://docs.mistral.ai/capabilities/audio_transcription" target="_blank">
{$i18n.t('Learn more about Voxtral transcription.')} {$i18n.t('Learn more about Voxtral transcription.')}
</a> </a>
</div> </div>
</div> </AdminSettingField>
<div> <AdminSettingRow
<div class="flex items-center justify-between mb-2"> label={$i18n.t('Use Chat Completions API')}
<div class="text-xs text-gray-600 dark:text-gray-400"> description={$i18n.t(
{$i18n.t('Use Chat Completions API')}
</div>
<label class="relative inline-flex items-center cursor-pointer">
<input
type="checkbox"
bind:checked={STT_MISTRAL_USE_CHAT_COMPLETIONS}
class="sr-only peer"
/>
<div
class="w-9 h-5 bg-gray-200 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"
></div>
</label>
</div>
<div class="text-xs text-gray-400 dark:text-gray-500">
{$i18n.t(
'Use /v1/chat/completions endpoint instead of /v1/audio/transcriptions for potentially better accuracy.' 'Use /v1/chat/completions endpoint instead of /v1/audio/transcriptions for potentially better accuracy.'
)} )}
</div> >
</div> <Switch bind:state={STT_MISTRAL_USE_CHAT_COMPLETIONS} />
</AdminSettingRow>
{:else if STT_ENGINE === ''} {:else if STT_ENGINE === ''}
<div> <AdminSettingField
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('STT Model')}
{$i18n.t('STT Model')} description={$i18n.t('Open WebUI uses faster-whisper internally.')}
</div> >
<div class="flex w-full gap-2">
<div class="flex w-full">
<div class="flex-1 mr-2">
<input <input
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" class={inputClass}
placeholder={$i18n.t('Set whisper model')} placeholder={$i18n.t('Set whisper model')}
bind:value={STT_WHISPER_MODEL} bind:value={STT_WHISPER_MODEL}
/> />
</div>
<button <button
class="px-2.5 hover:bg-black/5 text-gray-800 dark:hover:bg-white/5 dark:text-gray-100 rounded-lg transition" class="flex h-7 w-7 shrink-0 items-center justify-center rounded-lg 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"
type="button"
on:click={() => { on:click={() => {
sttModelUpdateHandler(); sttModelUpdateHandler();
}} }}
disabled={STT_WHISPER_MODEL_LOADING} disabled={STT_WHISPER_MODEL_LOADING}
aria-label={$i18n.t('Update model')}
> >
{#if STT_WHISPER_MODEL_LOADING} {#if STT_WHISPER_MODEL_LOADING}
<div class="self-center">
<Spinner /> <Spinner />
</div>
{:else} {:else}
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16" viewBox="0 0 16 16"
fill="currentColor" fill="currentColor"
class="w-4 h-4" class="size-4"
> >
<path <path
d="M8.75 2.75a.75.75 0 0 0-1.5 0v5.69L5.03 6.22a.75.75 0 0 0-1.06 1.06l3.5 3.5a.75.75 0 0 0 1.06 0l3.5-3.5a.75.75 0 0 0-1.06-1.06L8.75 8.44V2.75Z" d="M8.75 2.75a.75.75 0 0 0-1.5 0v5.69L5.03 6.22a.75.75 0 0 0-1.06 1.06l3.5 3.5a.75.75 0 0 0 1.06 0l3.5-3.5a.75.75 0 0 0-1.06-1.06L8.75 8.44V2.75Z"
@@ -541,34 +457,22 @@
{/if} {/if}
</button> </button>
</div> </div>
<div class="mt-1 {linkedHelpClass}">
<div class="mt-2 mb-1 text-xs text-gray-400 dark:text-gray-500"> <a href="https://github.com/SYSTRAN/faster-whisper" target="_blank">
{$i18n.t(`Open WebUI uses faster-whisper internally.`)}
<a
class=" hover:underline dark:text-gray-200 text-gray-800"
href="https://github.com/SYSTRAN/faster-whisper"
target="_blank"
>
{$i18n.t( {$i18n.t(
`Click here to learn more about faster-whisper and see the available models.` 'Click here to learn more about faster-whisper and see the available models.'
)} )}
</a> </a>
</div> </div>
</div> </AdminSettingField>
{/if} {/if}
</div> </AdminSettingSection>
<div> <AdminSettingSection title={$i18n.t('Text-to-Speech')}>
<div class=" mb-2 text-xs text-gray-400 dark:text-gray-600"> <AdminSettingRow
{$i18n.t('Text-to-Speech')} label={$i18n.t('Text-to-Speech Engine')}
</div> description={$i18n.t('Choose the speech provider used for assistant audio output.')}
>
<div class="mb-2 py-0.5 flex w-full justify-between">
<div class=" self-center text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('Text-to-Speech Engine')}
</div>
<div class="flex items-center relative">
<SettingsSelect <SettingsSelect
bind:value={TTS_ENGINE} bind:value={TTS_ENGINE}
placeholder={$i18n.t('Select a mode')} placeholder={$i18n.t('Select a mode')}
@@ -577,10 +481,12 @@
await getVoices(); await getVoices();
await getModels(); await getModels();
if (e.target?.value === 'openai') { const value = (e.currentTarget as HTMLSelectElement).value;
if (value === 'openai') {
TTS_VOICE = 'alloy'; TTS_VOICE = 'alloy';
TTS_MODEL = 'tts-1'; TTS_MODEL = 'tts-1';
} else if (e.target?.value === 'mistral') { } else if (value === 'mistral') {
TTS_VOICE = ''; TTS_VOICE = '';
TTS_MODEL = 'voxtral-mini-tts-2603'; TTS_MODEL = 'voxtral-mini-tts-2603';
} else { } else {
@@ -596,105 +502,83 @@
<option value="azure">{$i18n.t('Azure AI Speech')}</option> <option value="azure">{$i18n.t('Azure AI Speech')}</option>
<option value="mistral">{$i18n.t('MistralAI')}</option> <option value="mistral">{$i18n.t('MistralAI')}</option>
</SettingsSelect> </SettingsSelect>
</div> </AdminSettingRow>
</div>
{#if TTS_ENGINE === 'openai'} {#if TTS_ENGINE === 'openai'}
<div> <div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
<div class="mt-1 flex gap-2 mb-1"> <AdminSettingField label={$i18n.t('API Base URL')}>
<input <input
class="flex-1 w-full border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300" class={inputClass}
placeholder={$i18n.t('API Base URL')} placeholder={$i18n.t('API Base URL')}
bind:value={TTS_OPENAI_API_BASE_URL} bind:value={TTS_OPENAI_API_BASE_URL}
required required
/> />
</AdminSettingField>
<AdminSettingField label={$i18n.t('API Key')}>
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
placeholder={$i18n.t('API Key')} placeholder={$i18n.t('API Key')}
bind:value={TTS_OPENAI_API_KEY} bind:value={TTS_OPENAI_API_KEY}
/> />
</div> </AdminSettingField>
</div> </div>
{:else if TTS_ENGINE === 'elevenlabs'} {:else if TTS_ENGINE === 'elevenlabs'}
<div> <AdminSettingField label={$i18n.t('API Key')}>
<div class="mt-1 flex gap-2 mb-1">
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
placeholder={$i18n.t('API Key')} placeholder={$i18n.t('API Key')}
bind:value={TTS_API_KEY} bind:value={TTS_API_KEY}
required required
/> />
</div> </AdminSettingField>
</div>
{:else if TTS_ENGINE === 'azure'} {:else if TTS_ENGINE === 'azure'}
<div> <AdminSettingField label={$i18n.t('API Key')}>
<div class="mt-1 flex gap-2 mb-1">
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
placeholder={$i18n.t('API Key')} placeholder={$i18n.t('API Key')}
bind:value={TTS_API_KEY} bind:value={TTS_API_KEY}
required required
/> />
</div> </AdminSettingField>
<div> <div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400"> <AdminSettingField label={$i18n.t('Azure Region')}>
{$i18n.t('Azure Region')}
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
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" class={inputClass}
bind:value={TTS_AZURE_SPEECH_REGION} bind:value={TTS_AZURE_SPEECH_REGION}
placeholder={$i18n.t('e.g., westus (leave blank for eastus)')} placeholder={$i18n.t('e.g., westus (leave blank for eastus)')}
/> />
</div> </AdminSettingField>
</div> <AdminSettingField label={$i18n.t('Endpoint URL')}>
</div>
<div>
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('Endpoint URL')}
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
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" class={inputClass}
bind:value={TTS_AZURE_SPEECH_BASE_URL} bind:value={TTS_AZURE_SPEECH_BASE_URL}
placeholder={$i18n.t('(leave blank for to use commercial endpoint)')} placeholder={$i18n.t('(leave blank for to use commercial endpoint)')}
/> />
</div> </AdminSettingField>
</div>
</div>
</div> </div>
{:else if TTS_ENGINE === 'mistral'} {:else if TTS_ENGINE === 'mistral'}
<div> <div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
<div class="mt-1 flex gap-2 mb-1"> <AdminSettingField label={$i18n.t('API Base URL')}>
<input <input
class="flex-1 w-full border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300" class={inputClass}
placeholder={$i18n.t('API Base URL')} placeholder={$i18n.t('API Base URL')}
bind:value={TTS_MISTRAL_API_BASE_URL} bind:value={TTS_MISTRAL_API_BASE_URL}
required required
/> />
</AdminSettingField>
<AdminSettingField label={$i18n.t('API Key')}>
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
placeholder={$i18n.t('API Key')} placeholder={$i18n.t('API Key')}
bind:value={TTS_MISTRAL_API_KEY} bind:value={TTS_MISTRAL_API_KEY}
/> />
</div> </AdminSettingField>
</div> </div>
{/if} {/if}
<div class="mb-2">
{#if TTS_ENGINE === ''} {#if TTS_ENGINE === ''}
<div> <AdminSettingField label={$i18n.t('TTS Voice')}>
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('TTS Voice')}
</div>
<div class="flex w-full">
<div class="flex-1">
<SettingsSelect bind:value={TTS_VOICE} className="w-full"> <SettingsSelect bind:value={TTS_VOICE} className="w-full">
<option value="" selected={TTS_VOICE !== ''}>{$i18n.t('Default')}</option> <option value="" selected={TTS_VOICE !== ''}>{$i18n.t('Default')}</option>
{#each voices as voice} {#each voices as voice}
@@ -705,253 +589,132 @@
> >
{/each} {/each}
</SettingsSelect> </SettingsSelect>
</div> </AdminSettingField>
</div>
</div>
{:else if TTS_ENGINE === 'transformers'} {:else if TTS_ENGINE === 'transformers'}
<div> <AdminSettingField
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('TTS Model')}
{$i18n.t('TTS Model')} description={$i18n.t('Open WebUI uses SpeechT5 and CMU Arctic speaker embeddings.')}
</div> >
<div class="flex w-full">
<div class="flex-1">
<input <input
list="model-list" list="tts-transformers-model-list"
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" class={inputClass}
bind:value={TTS_MODEL} bind:value={TTS_MODEL}
placeholder={$i18n.t('CMU ARCTIC speaker embedding name')} placeholder={$i18n.t('CMU ARCTIC speaker embedding name')}
/> />
<datalist id="tts-transformers-model-list">
<datalist id="model-list"> <option value="tts-1"></option>
<option value="tts-1" />
</datalist> </datalist>
</div> <div class="mt-1 {linkedHelpClass}">
</div> {$i18n.t('To learn more about SpeechT5,')}
<div class="mt-2 mb-1 text-xs text-gray-400 dark:text-gray-500"> <a href="https://github.com/microsoft/SpeechT5" target="_blank">
{$i18n.t(`Open WebUI uses SpeechT5 and CMU Arctic speaker embeddings.`)} {$i18n.t('click here')}.
To learn more about SpeechT5,
<a
class=" hover:underline dark:text-gray-200 text-gray-800"
href="https://github.com/microsoft/SpeechT5"
target="_blank"
>
{$i18n.t(`click here`, {
name: 'SpeechT5'
})}.
</a> </a>
To see the available CMU Arctic speaker embeddings, {$i18n.t('To see the available CMU Arctic speaker embeddings,')}
<a <a href="https://huggingface.co/datasets/Matthijs/cmu-arctic-xvectors" target="_blank">
class=" hover:underline dark:text-gray-200 text-gray-800" {$i18n.t('click here')}.
href="https://huggingface.co/datasets/Matthijs/cmu-arctic-xvectors"
target="_blank"
>
{$i18n.t(`click here`)}.
</a> </a>
</div> </div>
</div> </AdminSettingField>
{:else if TTS_ENGINE === 'openai'} {:else if TTS_ENGINE === 'openai'}
<div class=" flex gap-2"> <div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
<div class="w-full"> <AdminSettingField label={$i18n.t('TTS Voice')}>
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('TTS Voice')}
</div>
<div class="flex w-full">
<div class="flex-1">
<TTSVoiceInput <TTSVoiceInput
bind:value={TTS_VOICE} bind:value={TTS_VOICE}
voices={providerVoices} voices={providerVoices}
placeholder={$i18n.t('Select a voice')} placeholder={$i18n.t('Select a voice')}
className="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" className={inputClass}
/> />
</div> </AdminSettingField>
</div> <AdminSettingField label={$i18n.t('TTS Model')}>
</div>
<div class="w-full">
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('TTS Model')}
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
list="tts-model-list" list="tts-model-list"
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" class={inputClass}
bind:value={TTS_MODEL} bind:value={TTS_MODEL}
placeholder={$i18n.t('Select a model')} placeholder={$i18n.t('Select a model')}
/> />
</AdminSettingField>
<datalist id="tts-model-list">
{#each models as model}
<option value={model.id} class="bg-gray-50 dark:bg-gray-700" />
{/each}
</datalist>
</div> </div>
</div> <AdminSettingField
</div> label={$i18n.t('Additional Parameters')}
</div> description={$i18n.t(
'Enter additional OpenAI-compatible TTS request parameters as JSON.'
<div class="mt-2 mb-1 text-xs text-gray-400 dark:text-gray-500"> )}
<div class="w-full"> >
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('Additional Parameters')}
</div>
<div class="flex w-full">
<div class="flex-1">
<Textarea <Textarea
className="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" className={textareaClass}
bind:value={TTS_OPENAI_PARAMS} bind:value={TTS_OPENAI_PARAMS}
placeholder={$i18n.t('Enter additional parameters in JSON format')} placeholder={$i18n.t('Enter additional parameters in JSON format')}
minSize={100}
/> />
</div> </AdminSettingField>
</div> {:else if TTS_ENGINE === 'elevenlabs' || TTS_ENGINE === 'mistral'}
</div> <div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
</div> <AdminSettingField label={$i18n.t('TTS Voice')}>
{:else if TTS_ENGINE === 'elevenlabs'}
<div class=" flex gap-2">
<div class="w-full">
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('TTS Voice')}
</div>
<div class="flex w-full">
<div class="flex-1">
<TTSVoiceInput <TTSVoiceInput
bind:value={TTS_VOICE} bind:value={TTS_VOICE}
voices={providerVoices} voices={providerVoices}
placeholder={$i18n.t('Select a voice')} placeholder={$i18n.t('Select a voice')}
className="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" className={inputClass}
/> />
</div> </AdminSettingField>
</div> <AdminSettingField label={$i18n.t('TTS Model')}>
</div>
<div class="w-full">
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('TTS Model')}
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
list="tts-model-list" list="tts-model-list"
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" class={inputClass}
bind:value={TTS_MODEL} bind:value={TTS_MODEL}
placeholder={$i18n.t('Select a model')} placeholder={$i18n.t('Select a model')}
/> />
</AdminSettingField>
<datalist id="tts-model-list">
{#each models as model}
<option value={model.id} class="bg-gray-50 dark:bg-gray-700" />
{/each}
</datalist>
</div>
</div>
</div>
</div> </div>
{:else if TTS_ENGINE === 'azure'} {:else if TTS_ENGINE === 'azure'}
<div class=" flex gap-2"> <div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
<div class="w-full"> <AdminSettingField label={$i18n.t('TTS Voice')}>
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('TTS Voice')}
</div>
<div class="flex w-full">
<div class="flex-1">
<TTSVoiceInput <TTSVoiceInput
bind:value={TTS_VOICE} bind:value={TTS_VOICE}
voices={providerVoices} voices={providerVoices}
placeholder={$i18n.t('Select a voice')} placeholder={$i18n.t('Select a voice')}
className="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" className={inputClass}
/> />
</div> </AdminSettingField>
</div> <AdminSettingField label={$i18n.t('Output format')}>
</div> <input
<div class="w-full"> class={inputClass}
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400"> bind:value={TTS_AZURE_SPEECH_OUTPUT_FORMAT}
{$i18n.t('Output format')} placeholder={$i18n.t('Select an output format')}
/>
<div class="mt-1 {linkedHelpClass}">
<a <a
href="https://learn.microsoft.com/en-us/azure/ai-services/speech-service/rest-text-to-speech?tabs=streaming#audio-outputs" href="https://learn.microsoft.com/en-us/azure/ai-services/speech-service/rest-text-to-speech?tabs=streaming#audio-outputs"
target="_blank" target="_blank"
> >
<small>{$i18n.t('Available list')}</small> {$i18n.t('Available list')}
</a> </a>
</div> </div>
<div class="flex w-full"> </AdminSettingField>
<div class="flex-1">
<input
list="tts-model-list"
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={TTS_AZURE_SPEECH_OUTPUT_FORMAT}
placeholder={$i18n.t('Select an output format')}
/>
</div> </div>
</div> {/if}
</div>
</div>
{:else if TTS_ENGINE === 'mistral'}
<div class=" flex gap-2">
<div class="w-full">
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('TTS Voice')}
</div>
<div class="flex w-full">
<div class="flex-1">
<TTSVoiceInput
bind:value={TTS_VOICE}
voices={providerVoices}
placeholder={$i18n.t('Select a voice')}
className="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"
/>
</div>
</div>
</div>
<div class="w-full">
<div class=" mb-1.5 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('TTS Model')}
</div>
<div class="flex w-full">
<div class="flex-1">
<input
list="tts-model-list"
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={TTS_MODEL}
placeholder={$i18n.t('Select a model')}
/>
<datalist id="tts-model-list"> <datalist id="tts-model-list">
{#each models as model} {#each models as model}
<option value={model.id} class="bg-gray-50 dark:bg-gray-700" /> <option value={model.id} class="bg-gray-50 dark:bg-gray-700"></option>
{/each} {/each}
</datalist> </datalist>
</div>
</div>
</div>
</div>
{/if}
</div>
<div class="pt-0.5 flex w-full justify-between"> <AdminSettingRow
<div class="self-center text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Response Splitting')}
{$i18n.t('Response splitting')} description={$i18n.t(
</div> "Control how message text is split for TTS requests. 'Punctuation' splits into sentences, 'paragraphs' splits into paragraphs, and 'none' keeps the message as a single string."
<div class="flex items-center relative"> )}
>
<SettingsSelect <SettingsSelect
aria-label={$i18n.t('Select how to split message text for TTS requests')} aria-label={$i18n.t('Select how to split message text for TTS requests')}
bind:value={TTS_SPLIT_ON} bind:value={TTS_SPLIT_ON}
> >
{#each Object.values(TTS_RESPONSE_SPLIT) as split} {#each Object.values(TTS_RESPONSE_SPLIT) as split}
<option value={split} <option value={split}>{$i18n.t(split.charAt(0).toUpperCase() + split.slice(1))}</option>
>{$i18n.t(split.charAt(0).toUpperCase() + split.slice(1))}</option
>
{/each} {/each}
</SettingsSelect> </SettingsSelect>
</div> </AdminSettingRow>
</div> </AdminSettingSection>
<div class="mt-2 mb-1 text-xs text-gray-400 dark:text-gray-500">
{$i18n.t(
"Control how message text is split for TTS requests. 'Punctuation' splits into sentences, 'paragraphs' splits into paragraphs, and 'none' keeps the message as a single string."
)}
</div>
</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">
<button <button
@@ -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')}
description={$i18n.t('Maximum runtime in seconds before execution is stopped.')}
>
<input <input
class={inlineInputClass} class={inputClass}
type="number" type="number"
bind:value={config.CODE_EXECUTION_JUPYTER_TIMEOUT} bind:value={config.CODE_EXECUTION_JUPYTER_TIMEOUT}
placeholder={$i18n.t('e.g. 60')} placeholder={$i18n.t('e.g. 60')}
autocomplete="off" autocomplete="off"
/> />
</Tooltip> </AdminSettingField>
</AdminSettingRow>
{/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,23 +233,25 @@
</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')}
description={$i18n.t('Maximum runtime in seconds before execution is stopped.')}
>
<input <input
class={inlineInputClass} class={inputClass}
type="number" type="number"
bind:value={config.CODE_INTERPRETER_JUPYTER_TIMEOUT} bind:value={config.CODE_INTERPRETER_JUPYTER_TIMEOUT}
placeholder={$i18n.t('e.g. 60')} placeholder={$i18n.t('e.g. 60')}
autocomplete="off" autocomplete="off"
/> />
</Tooltip> </AdminSettingField>
</AdminSettingRow>
{/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 <Textarea
className={textareaClass} className={textareaClass}
@@ -240,7 +260,6 @@
'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> </AdminSettingField>
{/if} {/if}
</AdminSettingSection> </AdminSettingSection>
File diff suppressed because it is too large. Load diff
+184 -451
View File
@@ -20,6 +20,10 @@
import Textarea from '$lib/components/common/Textarea.svelte'; import Textarea from '$lib/components/common/Textarea.svelte';
import CodeEditorModal from '$lib/components/common/CodeEditorModal.svelte'; import CodeEditorModal from '$lib/components/common/CodeEditorModal.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();
const i18n = getContext('i18n'); const i18n = getContext('i18n');
@@ -28,6 +32,10 @@
let models = null; let models = null;
let config = null; let config = null;
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 =
'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';
let showComfyUIWorkflowEditor = false; let showComfyUIWorkflowEditor = false;
let REQUIRED_WORKFLOW_NODES = [ let REQUIRED_WORKFLOW_NODES = [
@@ -294,39 +302,38 @@
<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}
<div> <div class="flex flex-col">
<div class="mb-5"> <AdminSettingSection first>
<div class="mb-2.5"> <AdminSettingRow
<div class="flex w-full justify-between items-center"> label={$i18n.t('Image Generation')}
<div class="text-xs pr-2"> description={$i18n.t('Allow users to generate images from prompts.')}
<div class=""> >
{$i18n.t('Image Generation')}
</div>
</div>
<Switch bind:state={config.ENABLE_IMAGE_GENERATION} /> <Switch bind:state={config.ENABLE_IMAGE_GENERATION} />
</div> </AdminSettingRow>
</div> </AdminSettingSection>
</div>
<div class="mb-5"> <AdminSettingSection title={$i18n.t('Create Image')}>
<div class=" mb-2 text-xs text-gray-400 dark:text-gray-600"> <AdminSettingRow
{$i18n.t('Create Image')} label={$i18n.t('Image Generation Engine')}
</div> description={$i18n.t('Choose the provider used for image generation.')}
>
<SettingsSelect
bind:value={config.IMAGE_GENERATION_ENGINE}
placeholder={$i18n.t('Select Engine')}
>
<option value="openai">{$i18n.t('Default (Open AI)')}</option>
<option value="comfyui">{$i18n.t('ComfyUI')}</option>
<option value="automatic1111">{$i18n.t('Automatic1111')}</option>
<option value="gemini">{$i18n.t('Gemini')}</option>
</SettingsSelect>
</AdminSettingRow>
{#if config.ENABLE_IMAGE_GENERATION} {#if config.ENABLE_IMAGE_GENERATION}
<div class="mb-2.5"> <div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
<div class="flex w-full justify-between items-center"> <AdminSettingField label={$i18n.t('Model')}>
<div class="text-xs pr-2">
<div class="shrink-0">
{$i18n.t('Model')}
</div>
</div>
<Tooltip content={$i18n.t('Enter Model ID')} placement="top-start">
<input <input
list="model-list" list="model-list"
class=" text-right text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300 max-w-full w-52" class={inputClass}
bind:value={config.IMAGE_GENERATION_MODEL} bind:value={config.IMAGE_GENERATION_MODEL}
placeholder={$i18n.t('Select a model')} placeholder={$i18n.t('Select a model')}
required required
@@ -337,186 +344,92 @@
<option value={model.id}>{model.name}</option> <option value={model.id}>{model.name}</option>
{/each} {/each}
</datalist> </datalist>
</Tooltip> </AdminSettingField>
</div>
</div>
<div class="mb-2.5"> <AdminSettingField label={$i18n.t('Image Size')}>
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2">
<div class="shrink-0">
{$i18n.t('Image Size')}
</div>
</div>
<Tooltip content={$i18n.t('Enter Image Size (e.g. 512x512)')} placement="top-start">
<input <input
class=" text-right text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300 max-w-full w-52" class={inputClass}
placeholder={$i18n.t('Enter Image Size (e.g. 512x512)')} placeholder={$i18n.t('Enter Image Size (e.g. 512x512)')}
bind:value={config.IMAGE_SIZE} bind:value={config.IMAGE_SIZE}
/> />
</Tooltip> </AdminSettingField>
</div>
</div>
{#if ['comfyui', 'automatic1111', ''].includes(config?.IMAGE_GENERATION_ENGINE)} {#if ['comfyui', 'automatic1111', ''].includes(config?.IMAGE_GENERATION_ENGINE)}
<div class="mb-2.5"> <AdminSettingField label={$i18n.t('Steps')}>
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2">
<div class="">
{$i18n.t('Steps')}
</div>
</div>
<Tooltip
content={$i18n.t('Enter Number of Steps (e.g. 50)')}
placement="top-start"
>
<input <input
class=" text-right text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300" class={inputClass}
placeholder={$i18n.t('Enter Number of Steps (e.g. 50)')} placeholder={$i18n.t('Enter Number of Steps (e.g. 50)')}
bind:value={config.IMAGE_STEPS} bind:value={config.IMAGE_STEPS}
required required
/> />
</Tooltip> </AdminSettingField>
</div>
</div>
{/if} {/if}
<div class="mb-2.5">
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2">
<div class="">
{$i18n.t('Image Prompt Generation')}
</div>
</div> </div>
<Switch bind:state={config.ENABLE_IMAGE_PROMPT_GENERATION} /> <AdminSettingRow
</div> label={$i18n.t('Image Prompt Generation')}
</div> description={$i18n.t('Generate an image prompt before sending the request.')}
{/if}
<div class="mb-2.5">
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2">
<div class="">
{$i18n.t('Image Generation Engine')}
</div>
</div>
<SettingsSelect
bind:value={config.IMAGE_GENERATION_ENGINE}
placeholder={$i18n.t('Select Engine')}
> >
<option value="openai">{$i18n.t('Default (Open AI)')}</option> <Switch bind:state={config.ENABLE_IMAGE_PROMPT_GENERATION} />
<option value="comfyui">{$i18n.t('ComfyUI')}</option> </AdminSettingRow>
<option value="automatic1111">{$i18n.t('Automatic1111')}</option> {/if}
<option value="gemini">{$i18n.t('Gemini')}</option>
</SettingsSelect>
</div>
</div>
{#if config?.IMAGE_GENERATION_ENGINE === 'openai'} {#if config?.IMAGE_GENERATION_ENGINE === 'openai'}
<div class="mb-2.5"> <div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
<div class="flex w-full justify-between items-center"> <AdminSettingField label={$i18n.t('API Base URL')}>
<div class="text-xs pr-2 shrink-0">
<div class="">
{$i18n.t('OpenAI API Base URL')}
</div>
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
class="w-full text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300 text-right" class={inputClass}
placeholder={$i18n.t('API Base URL')} placeholder={$i18n.t('API Base URL')}
bind:value={config.IMAGES_OPENAI_API_BASE_URL} bind:value={config.IMAGES_OPENAI_API_BASE_URL}
/> />
</div> </AdminSettingField>
</div>
</div>
</div>
<div class="mb-2.5"> <AdminSettingField label={$i18n.t('API Key')}>
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2 shrink-0">
<div class="">
{$i18n.t('OpenAI API Key')}
</div>
</div>
<div class="flex w-full">
<div class="flex-1">
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
inputClassName="text-right w-full"
placeholder={$i18n.t('API Key')} placeholder={$i18n.t('API Key')}
bind:value={config.IMAGES_OPENAI_API_KEY} bind:value={config.IMAGES_OPENAI_API_KEY}
required={false} required={false}
/> />
</div> </AdminSettingField>
</div>
</div>
</div> </div>
<div class="mb-2.5"> <AdminSettingField label={$i18n.t('API Version')}>
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2 shrink-0">
<div class="">
{$i18n.t('OpenAI API Version')}
</div>
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
class="w-full text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300 text-right" class={inputClass}
placeholder={$i18n.t('API Version')} placeholder={$i18n.t('API Version')}
bind:value={config.IMAGES_OPENAI_API_VERSION} bind:value={config.IMAGES_OPENAI_API_VERSION}
/> />
</div> </AdminSettingField>
</div>
</div>
</div>
<div class="mb-2.5"> <AdminSettingField
<div class="flex w-full justify-between items-center"> label={$i18n.t('Additional Parameters')}
<div class="text-xs pr-2 shrink-0"> description={$i18n.t(
<div class=""> 'Send extra JSON parameters with each image generation request.'
{$i18n.t('Additional Parameters')} )}
</div> >
</div>
</div>
<div class="mt-1.5 flex w-full">
<div class="flex-1 mr-2">
<Textarea <Textarea
className="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" className={textareaClass}
bind:value={config.IMAGES_OPENAI_API_PARAMS} bind:value={config.IMAGES_OPENAI_API_PARAMS}
placeholder={$i18n.t('Enter additional parameters in JSON format')} placeholder={$i18n.t('Enter additional parameters in JSON format')}
minSize={100} minSize={100}
/> />
</div> </AdminSettingField>
</div>
</div>
{:else if (config?.IMAGE_GENERATION_ENGINE ?? 'automatic1111') === 'automatic1111'} {:else if (config?.IMAGE_GENERATION_ENGINE ?? 'automatic1111') === 'automatic1111'}
<div class="mb-2.5"> <AdminSettingField
<div class="flex w-full justify-between items-center"> label={$i18n.t('Base URL')}
<div class="text-xs pr-2 shrink-0"> description={$i18n.t(
<div class=""> 'Connect to a stable-diffusion-webui server running with the `--api` flag.'
{$i18n.t('AUTOMATIC1111 Base URL')} )}
</div> >
</div> <div class="flex w-full gap-2">
<div class="flex w-full">
<div class="flex-1 mr-2">
<input <input
class="w-full text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300 text-right" class={inputClass}
placeholder={$i18n.t('Enter URL (e.g. http://127.0.0.1:7860/)')} placeholder={$i18n.t('Enter URL (e.g. http://127.0.0.1:7860/)')}
bind:value={config.AUTOMATIC1111_BASE_URL} bind:value={config.AUTOMATIC1111_BASE_URL}
/> />
</div>
<button <button
class=" transition" class="shrink-0 text-gray-400 transition-colors hover:text-gray-900 dark:text-gray-600 dark:hover:text-white"
type="button" type="button"
aria-label="verify connection" aria-label="verify connection"
on:click={async () => { on:click={async () => {
@@ -545,93 +458,44 @@
</svg> </svg>
</button> </button>
</div> </div>
</div> </AdminSettingField>
<div class="mt-1 text-xs text-gray-400 dark:text-gray-500"> <AdminSettingField
{$i18n.t('Include `--api` flag when running stable-diffusion-webui')} label={$i18n.t('API Auth String')}
<a description={$i18n.t('Provide the --api-auth username and password when required.')}
class=" text-gray-300 font-normal"
href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/3734"
target="_blank"
> >
{$i18n.t('(e.g. `sh webui.sh --api`)')}
</a>
</div>
</div>
<div class="mb-2.5">
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2 shrink-0">
<div class="">
{$i18n.t('AUTOMATIC1111 Api Auth String')}
</div>
</div>
<div class="flex w-full">
<div class="flex-1">
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
inputClassName="text-right w-full"
placeholder={$i18n.t('Enter api auth string (e.g. username:password)')} placeholder={$i18n.t('Enter api auth string (e.g. username:password)')}
bind:value={config.AUTOMATIC1111_API_AUTH} bind:value={config.AUTOMATIC1111_API_AUTH}
required={false} required={false}
/> />
</div> </AdminSettingField>
</div>
</div>
<div class="mt-1 text-xs text-gray-400 dark:text-gray-500"> <AdminSettingField
{$i18n.t('Include `--api-auth` flag when running stable-diffusion-webui')} label={$i18n.t('Additional Parameters')}
<a description={$i18n.t('Send extra JSON parameters with each AUTOMATIC1111 request.')}
class=" text-gray-300 font-normal"
href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/13993"
target="_blank"
> >
{$i18n
.t('(e.g. `sh webui.sh --api --api-auth username_password`)')
.replace('_', ':')}
</a>
</div>
</div>
<div class="mb-2.5">
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2 shrink-0">
<div class="">
{$i18n.t('Additional Parameters')}
</div>
</div>
</div>
<div class="mt-1.5 flex w-full">
<div class="flex-1 mr-2">
<Textarea <Textarea
className="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" className={textareaClass}
bind:value={config.AUTOMATIC1111_PARAMS} bind:value={config.AUTOMATIC1111_PARAMS}
placeholder={$i18n.t('Enter additional parameters in JSON format')} placeholder={$i18n.t('Enter additional parameters in JSON format')}
minSize={100} minSize={100}
/> />
</div> </AdminSettingField>
</div>
</div>
{:else if config?.IMAGE_GENERATION_ENGINE === 'comfyui'} {:else if config?.IMAGE_GENERATION_ENGINE === 'comfyui'}
<div class="mb-2.5"> <AdminSettingField
<div class="flex w-full justify-between items-center"> label={$i18n.t('Base URL')}
<div class="text-xs pr-2 shrink-0"> description={$i18n.t('Connect to the ComfyUI server used for generation.')}
<div class=""> >
{$i18n.t('ComfyUI Base URL')} <div class="flex w-full gap-2">
</div>
</div>
<div class="flex w-full">
<div class="flex-1 mr-2">
<input <input
class="w-full text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300 text-right" class={inputClass}
placeholder={$i18n.t('Enter URL (e.g. http://127.0.0.1:7860/)')} placeholder={$i18n.t('Enter URL (e.g. http://127.0.0.1:7860/)')}
bind:value={config.COMFYUI_BASE_URL} bind:value={config.COMFYUI_BASE_URL}
/> />
</div>
<button <button
class=" rounded-lg transition" class="shrink-0 text-gray-400 transition-colors hover:text-gray-900 dark:text-gray-600 dark:hover:text-white"
type="button" type="button"
aria-label="verify connection" aria-label="verify connection"
on:click={async () => { on:click={async () => {
@@ -660,32 +524,21 @@
</svg> </svg>
</button> </button>
</div> </div>
</div> </AdminSettingField>
</div>
<div class="mb-2.5"> <AdminSettingField
<div class="flex w-full justify-between items-center"> label={$i18n.t('API Key')}
<div class="text-xs pr-2 shrink-0"> description={$i18n.t('Use an API key when your ComfyUI server requires one.')}
<div class=""> >
{$i18n.t('ComfyUI API Key')}
</div>
</div>
<div class="flex w-full">
<div class="flex-1">
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
inputClassName="text-right w-full"
placeholder={$i18n.t('sk-1234')} placeholder={$i18n.t('sk-1234')}
bind:value={config.COMFYUI_API_KEY} bind:value={config.COMFYUI_API_KEY}
required={false} required={false}
/> />
</div> </AdminSettingField>
</div>
</div>
</div>
<div class="mb-2.5"> <div>
<input <input
id="upload-comfyui-workflow-input" id="upload-comfyui-workflow-input"
hidden hidden
@@ -703,18 +556,16 @@
reader.readAsText(file); reader.readAsText(file);
}} }}
/> />
<div class="flex w-full justify-between items-center"> <AdminSettingRow
<div class="text-xs pr-2 shrink-0"> label={$i18n.t('ComfyUI Workflow')}
<div class=""> description={$i18n.t(
{$i18n.t('ComfyUI Workflow')} 'Upload a workflow.json file exported as API format from ComfyUI.'
</div> )}
</div> >
<div class="flex items-center justify-end gap-2">
<div class="flex w-full">
<div class="flex-1 mr-2 justify-end flex gap-1">
{#if config.COMFYUI_WORKFLOW} {#if config.COMFYUI_WORKFLOW}
<button <button
class="text-xs text-gray-700 dark:text-gray-400 underline" class="text-xs text-gray-500 transition-colors hover:text-gray-900 hover:underline dark:text-gray-500 dark:hover:text-white"
type="button" type="button"
aria-label={$i18n.t('Edit workflow.json content')} aria-label={$i18n.t('Edit workflow.json content')}
on:click={() => { on:click={() => {
@@ -728,7 +579,7 @@
<Tooltip content={$i18n.t('Click here to upload a workflow.json file.')}> <Tooltip content={$i18n.t('Click here to upload a workflow.json file.')}>
<button <button
class="text-xs text-gray-700 dark:text-gray-400 underline" class="text-xs text-gray-500 transition-colors hover:text-gray-900 hover:underline dark:text-gray-500 dark:hover:text-white"
type="button" type="button"
aria-label={$i18n.t('Click here to upload a workflow.json file.')} aria-label={$i18n.t('Click here to upload a workflow.json file.')}
on:click={() => { on:click={() => {
@@ -739,10 +590,9 @@
</button> </button>
</Tooltip> </Tooltip>
</div> </div>
</div> </AdminSettingRow>
</div>
<div class="mt-1 text-xs text-gray-400 dark:text-gray-500"> <div>
<CodeEditorModal <CodeEditorModal
bind:show={showComfyUIWorkflowEditor} bind:show={showComfyUIWorkflowEditor}
value={config.COMFYUI_WORKFLOW} value={config.COMFYUI_WORKFLOW}
@@ -762,7 +612,6 @@
required required
/> />
{/if} --> {/if} -->
{$i18n.t('Make sure to export a workflow.json file as API format from ComfyUI.')}
</div> </div>
</div> </div>
@@ -822,56 +671,33 @@
</div> </div>
{/if} {/if}
{:else if config?.IMAGE_GENERATION_ENGINE === 'gemini'} {:else if config?.IMAGE_GENERATION_ENGINE === 'gemini'}
<div class="mb-2.5"> <AdminSettingField
<div class="flex w-full justify-between items-center"> label={$i18n.t('Base URL')}
<div class="text-xs pr-2 shrink-0"> description={$i18n.t('Override the Gemini image generation endpoint.')}
<div class=""> >
{$i18n.t('Gemini Base URL')}
</div>
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
class="w-full text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300 text-right" class={inputClass}
placeholder={$i18n.t('API Base URL')} placeholder={$i18n.t('API Base URL')}
bind:value={config.IMAGES_GEMINI_API_BASE_URL} bind:value={config.IMAGES_GEMINI_API_BASE_URL}
/> />
</div> </AdminSettingField>
</div>
</div>
</div>
<div class="mb-2.5"> <AdminSettingField
<div class="flex w-full justify-between items-center"> label={$i18n.t('API Key')}
<div class="text-xs pr-2 shrink-0"> description={$i18n.t('Use a Gemini API key for image generation.')}
<div class=""> >
{$i18n.t('Gemini API Key')}
</div>
</div>
<div class="flex w-full">
<div class="flex-1">
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
inputClassName="text-right w-full"
placeholder={$i18n.t('API Key')} placeholder={$i18n.t('API Key')}
bind:value={config.IMAGES_GEMINI_API_KEY} bind:value={config.IMAGES_GEMINI_API_KEY}
required={true} required={true}
/> />
</div> </AdminSettingField>
</div>
</div>
</div>
<div class="mb-2.5">
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2">
<div class="">
{$i18n.t('Gemini Endpoint Method')}
</div>
</div>
<AdminSettingRow
label={$i18n.t('Gemini Endpoint Method')}
description={$i18n.t('Select the Gemini endpoint method to call.')}
>
<SettingsSelect <SettingsSelect
bind:value={config.IMAGES_GEMINI_ENDPOINT_METHOD} bind:value={config.IMAGES_GEMINI_ENDPOINT_METHOD}
placeholder={$i18n.t('Select Method')} placeholder={$i18n.t('Select Method')}
@@ -879,41 +705,38 @@
<option value="predict">predict</option> <option value="predict">predict</option>
<option value="generateContent">generateContent</option> <option value="generateContent">generateContent</option>
</SettingsSelect> </SettingsSelect>
</div> </AdminSettingRow>
</div>
{/if} {/if}
</div> </AdminSettingSection>
<div class="mb-5">
<div class=" mb-2 text-xs text-gray-400 dark:text-gray-600">
{$i18n.t('Edit Image')}
</div>
<div class="mb-2.5">
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2">
<div class="">
{$i18n.t('Image Edit')}
</div>
</div>
<AdminSettingSection title={$i18n.t('Edit Image')}>
<AdminSettingRow
label={$i18n.t('Image Edit')}
description={$i18n.t('Allow users to edit existing images.')}
>
<Switch bind:state={config.ENABLE_IMAGE_EDIT} /> <Switch bind:state={config.ENABLE_IMAGE_EDIT} />
</div> </AdminSettingRow>
</div>
<AdminSettingRow
label={$i18n.t('Image Edit Engine')}
description={$i18n.t('Choose the provider used for image edits.')}
>
<SettingsSelect
bind:value={config.IMAGE_EDIT_ENGINE}
placeholder={$i18n.t('Select Engine')}
>
<option value="openai">{$i18n.t('Default (Open AI)')}</option>
<option value="comfyui">{$i18n.t('ComfyUI')}</option>
<option value="gemini">{$i18n.t('Gemini')}</option>
</SettingsSelect>
</AdminSettingRow>
{#if config?.ENABLE_IMAGE_GENERATION && config?.ENABLE_IMAGE_EDIT} {#if config?.ENABLE_IMAGE_GENERATION && config?.ENABLE_IMAGE_EDIT}
<div class="mb-2.5"> <div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
<div class="flex w-full justify-between items-center"> <AdminSettingField label={$i18n.t('Model')}>
<div class="text-xs pr-2">
<div class="shrink-0">
{$i18n.t('Model')}
</div>
</div>
<Tooltip content={$i18n.t('Enter Model ID')} placement="top-start">
<input <input
list="model-list" list="model-list"
class="text-right text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300 max-w-full w-52" class={inputClass}
bind:value={config.IMAGE_EDIT_MODEL} bind:value={config.IMAGE_EDIT_MODEL}
placeholder={$i18n.t('Select a model')} placeholder={$i18n.t('Select a model')}
/> />
@@ -923,129 +746,58 @@
<option value={model.id}>{model.name}</option> <option value={model.id}>{model.name}</option>
{/each} {/each}
</datalist> </datalist>
</Tooltip> </AdminSettingField>
</div>
</div>
<div class="mb-2.5"> <AdminSettingField label={$i18n.t('Image Size')}>
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2">
<div class="shrink-0">
{$i18n.t('Image Size')}
</div>
</div>
<Tooltip content={$i18n.t('Enter Image Size (e.g. 512x512)')} placement="top-start">
<input <input
class="text-right text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300 max-w-full w-52" class={inputClass}
placeholder={$i18n.t('Enter Image Size (e.g. 512x512)')} placeholder={$i18n.t('Enter Image Size (e.g. 512x512)')}
bind:value={config.IMAGE_EDIT_SIZE} bind:value={config.IMAGE_EDIT_SIZE}
/> />
</Tooltip> </AdminSettingField>
</div>
</div> </div>
{/if} {/if}
<div class="mb-2.5">
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2">
<div class="">
{$i18n.t('Image Edit Engine')}
</div>
</div>
<SettingsSelect
bind:value={config.IMAGE_EDIT_ENGINE}
placeholder={$i18n.t('Select Engine')}
>
<option value="openai">{$i18n.t('Default (Open AI)')}</option>
<option value="comfyui">{$i18n.t('ComfyUI')}</option>
<option value="gemini">{$i18n.t('Gemini')}</option>
</SettingsSelect>
</div>
</div>
{#if config?.IMAGE_EDIT_ENGINE === 'openai'} {#if config?.IMAGE_EDIT_ENGINE === 'openai'}
<div class="mb-2.5"> <div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
<div class="flex w-full justify-between items-center"> <AdminSettingField label={$i18n.t('API Base URL')}>
<div class="text-xs pr-2 shrink-0">
<div class="">
{$i18n.t('OpenAI API Base URL')}
</div>
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
class="w-full text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300 text-right" class={inputClass}
placeholder={$i18n.t('API Base URL')} placeholder={$i18n.t('API Base URL')}
bind:value={config.IMAGES_EDIT_OPENAI_API_BASE_URL} bind:value={config.IMAGES_EDIT_OPENAI_API_BASE_URL}
/> />
</div> </AdminSettingField>
</div>
</div>
</div>
<div class="mb-2.5"> <AdminSettingField label={$i18n.t('API Key')}>
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2 shrink-0">
<div class="">
{$i18n.t('OpenAI API Key')}
</div>
</div>
<div class="flex w-full">
<div class="flex-1">
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
inputClassName="text-right w-full"
placeholder={$i18n.t('API Key')} placeholder={$i18n.t('API Key')}
bind:value={config.IMAGES_EDIT_OPENAI_API_KEY} bind:value={config.IMAGES_EDIT_OPENAI_API_KEY}
required={false} required={false}
/> />
</div> </AdminSettingField>
</div>
</div>
</div> </div>
<div class="mb-2.5"> <AdminSettingField label={$i18n.t('API Version')}>
<div class="flex w-full justify-between items-center">
<div class="text-xs pr-2 shrink-0">
<div class="">
{$i18n.t('OpenAI API Version')}
</div>
</div>
<div class="flex w-full">
<div class="flex-1">
<input <input
class="w-full text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300 text-right" class={inputClass}
placeholder={$i18n.t('API Version')} placeholder={$i18n.t('API Version')}
bind:value={config.IMAGES_EDIT_OPENAI_API_VERSION} bind:value={config.IMAGES_EDIT_OPENAI_API_VERSION}
/> />
</div> </AdminSettingField>
</div>
</div>
</div>
{:else if config?.IMAGE_EDIT_ENGINE === 'comfyui'} {:else if config?.IMAGE_EDIT_ENGINE === 'comfyui'}
<div class="mb-2.5"> <AdminSettingField
<div class="flex w-full justify-between items-center"> label={$i18n.t('Base URL')}
<div class="text-xs pr-2 shrink-0"> description={$i18n.t('Connect to the ComfyUI server used for image edits.')}
<div class=""> >
{$i18n.t('ComfyUI Base URL')} <div class="flex w-full gap-2">
</div>
</div>
<div class="flex w-full">
<div class="flex-1 mr-2">
<input <input
class="w-full text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300 text-right" class={inputClass}
placeholder={$i18n.t('Enter URL (e.g. http://127.0.0.1:7860/)')} placeholder={$i18n.t('Enter URL (e.g. http://127.0.0.1:7860/)')}
bind:value={config.IMAGES_EDIT_COMFYUI_BASE_URL} bind:value={config.IMAGES_EDIT_COMFYUI_BASE_URL}
/> />
</div>
<button <button
class=" transition" class="shrink-0 text-gray-400 transition-colors hover:text-gray-900 dark:text-gray-600 dark:hover:text-white"
type="button" type="button"
aria-label="verify connection" aria-label="verify connection"
on:click={async () => { on:click={async () => {
@@ -1074,32 +826,21 @@
</svg> </svg>
</button> </button>
</div> </div>
</div> </AdminSettingField>
</div>
<div class="mb-2.5"> <AdminSettingField
<div class="flex w-full justify-between items-center"> label={$i18n.t('API Key')}
<div class="text-xs pr-2 shrink-0"> description={$i18n.t('Use an API key when your ComfyUI server requires one.')}
<div class=""> >
{$i18n.t('ComfyUI API Key')}
</div>
</div>
<div class="flex w-full">
<div class="flex-1">
<SensitiveInput <SensitiveInput
variant="settings" variant="settings"
inputClassName="text-right w-full"
placeholder={$i18n.t('sk-1234')} placeholder={$i18n.t('sk-1234')}
bind:value={config.IMAGES_EDIT_COMFYUI_API_KEY} bind:value={config.IMAGES_EDIT_COMFYUI_API_KEY}
required={false} required={false}
/> />
</div> </AdminSettingField>
</div>
</div>
</div>
<div class="mb-2.5"> <div>
<input <input
id="upload-comfyui-edit-workflow-input" id="upload-comfyui-edit-workflow-input"
hidden hidden
@@ -1117,18 +858,14 @@
reader.readAsText(file); reader.readAsText(file);
}} }}
/> />
<div class="flex w-full justify-between items-center"> <AdminSettingRow
<div class="text-xs pr-2 shrink-0"> label={$i18n.t('ComfyUI Workflow')}
<div class=""> description={$i18n.t('Upload a workflow.json file exported as API format from ComfyUI.')}
{$i18n.t('ComfyUI Workflow')} >
</div> <div class="flex items-center justify-end gap-2">
</div>
<div class="flex w-full">
<div class="flex-1 mr-2 justify-end flex gap-1">
{#if config.IMAGES_EDIT_COMFYUI_WORKFLOW} {#if config.IMAGES_EDIT_COMFYUI_WORKFLOW}
<button <button
class="text-xs text-gray-700 dark:text-gray-400 underline" class="text-xs text-gray-500 transition-colors hover:text-gray-900 hover:underline dark:text-gray-500 dark:hover:text-white"
type="button" type="button"
aria-label={$i18n.t('Edit workflow.json content')} aria-label={$i18n.t('Edit workflow.json content')}
on:click={() => { on:click={() => {
@@ -1142,7 +879,7 @@
<Tooltip content={$i18n.t('Click here to upload a workflow.json file.')}> <Tooltip content={$i18n.t('Click here to upload a workflow.json file.')}>
<button <button
class="text-xs text-gray-700 dark:text-gray-400 underline" class="text-xs text-gray-500 transition-colors hover:text-gray-900 hover:underline dark:text-gray-500 dark:hover:text-white"
type="button" type="button"
aria-label={$i18n.t('Click here to upload a workflow.json file.')} aria-label={$i18n.t('Click here to upload a workflow.json file.')}
on:click={() => { on:click={() => {
@@ -1153,10 +890,8 @@
</button> </button>
</Tooltip> </Tooltip>
</div> </div>
</div> </AdminSettingRow>
</div>
<div class="mt-1 text-xs text-gray-400 dark:text-gray-500">
<CodeEditorModal <CodeEditorModal
bind:show={showComfyUIEditWorkflowEditor} bind:show={showComfyUIEditWorkflowEditor}
value={config.IMAGES_EDIT_COMFYUI_WORKFLOW} value={config.IMAGES_EDIT_COMFYUI_WORKFLOW}
@@ -1168,8 +903,6 @@
console.log('Saved'); console.log('Saved');
}} }}
/> />
{$i18n.t('Make sure to export a workflow.json file as API format from ComfyUI.')}
</div>
</div> </div>
{#if config.IMAGES_EDIT_COMFYUI_WORKFLOW} {#if config.IMAGES_EDIT_COMFYUI_WORKFLOW}
@@ -1270,7 +1003,7 @@
</div> </div>
</div> </div>
{/if} {/if}
</div> </AdminSettingSection>
</div> </div>
{/if} {/if}
</div> </div>
+142 -228
View File
@@ -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 = [];
} }
}; };
@@ -114,50 +119,31 @@
</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">
<div class=" mb-2 font-normal flex items-center"> {$i18n.t(
<div class=" text-xs mr-1">{$i18n.t('Task Model')}</div> 'Choose fallback models for background tasks. Current Model follows the active chat model.'
<Tooltip
content={$i18n.t(
'A task model is used when performing tasks such as generating titles for chats and web search queries'
)} )}
> </div>
<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>
</div> </div>
<div class=" mb-2.5 flex w-full gap-2"> <div class="grid w-full grid-cols-1 gap-2.5 sm:grid-cols-2">
<div class="flex-1"> <AdminSettingField label={$i18n.t('Local Task Model')}>
<div class=" text-xs mb-1">{$i18n.t('Local Task Model')}</div>
<SettingsSelect <SettingsSelect
bind:value={taskConfig.TASK_MODEL} bind:value={taskConfig.TASK_MODEL}
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) { if (taskConfig.TASK_MODEL) {
const model = models.find((m) => m.id === taskConfig.TASK_MODEL); const model = modelOptions.find((m: any) => m.id === taskConfig.TASK_MODEL);
if (model) { if (model) {
if ( if (
model?.access_grants && model?.access_grants &&
!model.access_grants.some( !model.access_grants.some(
(g) => (g: any) =>
g.principal_type === 'user' && g.principal_type === 'user' &&
g.principal_id === '*' && g.principal_id === '*' &&
g.permission === 'read' g.permission === 'read'
@@ -178,29 +164,30 @@
}} }}
> >
<option value="" selected>{$i18n.t('Current Model')}</option> <option value="" selected>{$i18n.t('Current Model')}</option>
{#each models as model} {#each modelOptions 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>
</div> </AdminSettingField>
<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 = models.find((m) => m.id === taskConfig.TASK_MODEL_EXTERNAL); const model = modelOptions.find(
(m: any) => m.id === taskConfig.TASK_MODEL_EXTERNAL
);
if (model) { if (model) {
if ( if (
model?.access_grants && model?.access_grants &&
!model.access_grants.some( !model.access_grants.some(
(g) => (g: any) =>
g.principal_type === 'user' && g.principal_type === 'user' &&
g.principal_id === '*' && g.principal_id === '*' &&
g.permission === 'read' g.permission === 'read'
@@ -221,73 +208,64 @@
}} }}
> >
<option value="" selected>{$i18n.t('Current Model')}</option> <option value="" selected>{$i18n.t('Current Model')}</option>
{#each models as model} {#each modelOptions 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>
<Tooltip
content={$i18n.t(
'Older messages are summarized when estimated context exceeds this token limit.' 'Older messages are summarized when estimated context exceeds this token limit.'
)} )}
placement="top-start"
> >
<input <input
type="number" type="number"
min="1" min="1"
step="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" class={inputClass}
bind:value={chatConfig.CONTEXT_COMPACTION_TOKEN_THRESHOLD} bind:value={chatConfig.CONTEXT_COMPACTION_TOKEN_THRESHOLD}
/> />
</Tooltip> </AdminSettingField>
</div>
<div class="mb-2.5"> <AdminSettingField
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">{$i18n.t('Token Cap')}</div> label={$i18n.t('Token Cap')}
description={$i18n.t(
<Tooltip
content={$i18n.t(
'Model-specific context compaction thresholds cannot exceed this token limit.' 'Model-specific context compaction thresholds cannot exceed this token limit.'
)} )}
placement="top-start"
> >
<input <input
type="number" type="number"
min="1" min="1"
step="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" class={inputClass}
bind:value={chatConfig.CONTEXT_COMPACTION_TOKEN_CAP} bind:value={chatConfig.CONTEXT_COMPACTION_TOKEN_CAP}
/> />
</Tooltip> </AdminSettingField>
</div>
<div class="mb-2.5"> <AdminSettingField
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Context Compaction Prompt')}
{$i18n.t('Context Compaction Prompt')} description={$i18n.t(
</div> 'Controls how older messages are rewritten into a running summary.'
)}
<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}
@@ -296,8 +274,7 @@
'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> <div class="mt-1 text-[0.6875rem] text-gray-400 dark:text-gray-600">
<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,26 +282,22 @@
<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>
<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}
@@ -333,27 +306,20 @@
'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} {/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>
<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}
@@ -362,27 +328,20 @@
'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} {/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>
<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}
@@ -391,27 +350,20 @@
'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} {/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 <Textarea
className={textareaClass} className={textareaClass}
@@ -420,80 +372,59 @@
'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} {/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('Retrieval Query Generation')} description={$i18n.t('Rewrite user requests for knowledge retrieval.')}
</div> >
<Switch bind:state={taskConfig.ENABLE_RETRIEVAL_QUERY_GENERATION} /> <Switch bind:state={taskConfig.ENABLE_RETRIEVAL_QUERY_GENERATION} />
</div> </AdminSettingRow>
<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>
<AdminSettingRow
label={$i18n.t('Web Search Query Generation')}
description={$i18n.t('Rewrite user requests into web-search queries.')}
>
<Switch bind:state={taskConfig.ENABLE_SEARCH_QUERY_GENERATION} /> <Switch bind:state={taskConfig.ENABLE_SEARCH_QUERY_GENERATION} />
</div> </AdminSettingRow>
<div class="mb-2.5"> <AdminSettingField
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Query Generation Prompt')}
{$i18n.t('Query Generation Prompt')} description={$i18n.t('Shared prompt for retrieval and web-search query rewriting.')}
</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.QUERY_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>
<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('Autocomplete Generation')}
{$i18n.t('Autocomplete Generation')} description={$i18n.t('Suggest completions while users type chat messages.')}
</div> >
<Tooltip content={$i18n.t('Enable autocomplete generation for chat messages')}>
<Switch bind:state={taskConfig.ENABLE_AUTOCOMPLETE_GENERATION} /> <Switch bind:state={taskConfig.ENABLE_AUTOCOMPLETE_GENERATION} />
</Tooltip> </AdminSettingRow>
</div>
{#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>
<Tooltip
content={$i18n.t('Character limit for autocomplete generation input')}
placement="top-start"
> >
<input <input
class="w-full outline-hidden bg-transparent" type="number"
min="-1"
step="1"
class={inputClass}
bind:value={taskConfig.AUTOCOMPLETE_GENERATION_INPUT_MAX_LENGTH} bind:value={taskConfig.AUTOCOMPLETE_GENERATION_INPUT_MAX_LENGTH}
placeholder={$i18n.t('-1 for no limit, or a positive integer for a specific limit')} placeholder={$i18n.t('-1 for no limit, or a positive integer for a specific limit')}
/> />
</Tooltip> </AdminSettingField>
</div>
<div class="mb-2.5">
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('Autocomplete Generation Prompt')}
</div>
<Tooltip <AdminSettingField
content={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')} label={$i18n.t('Autocomplete Generation Prompt')}
placement="top-start" description={$i18n.t('Guides inline completions while users type a message.')}
> >
<Textarea <Textarea
className={textareaClass} className={textareaClass}
@@ -502,48 +433,31 @@
'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} {/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>
<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.IMAGE_PROMPT_GENERATION_PROMPT_TEMPLATE} bind:value={taskConfig.IMAGE_PROMPT_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>
<div class="mb-2.5"> <AdminSettingField
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Tools Function Calling Prompt')}
{$i18n.t('Tools Function Calling Prompt')} description={$i18n.t('Guides how the assistant formats tool and function calls.')}
</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.TOOLS_FUNCTION_CALLING_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'
)}
/> />
</Tooltip> </AdminSettingField>
</div> </AdminSettingSection>
</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}
</AdminSettingSection>
{:else} {:else}
<AdminSettingSection title={$i18n.t('Pipelines')}>
<div class={mutedMessageClass}>{$i18n.t('Pipelines Not Detected')}</div> <div class={mutedMessageClass}>{$i18n.t('Pipelines Not Detected')}</div>
</AdminSettingSection>
{/if} {/if}
{:else} {:else}
<div class="flex justify-center py-4"> <div class="flex justify-center py-4">
<Spinner className="size-4" /> <Spinner className="size-4" />
</div> </div>
{/if} {/if}
</div>
{:else} {:else}
<AdminSettingSection title={$i18n.t('Source')} first>
<div class={mutedMessageClass}>{$i18n.t('Pipelines Not Detected')}</div> <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">
+102 -152
View File
@@ -9,8 +9,11 @@
import Tooltip from '$lib/components/common/Tooltip.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 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 i18n = getContext('i18n'); const i18n: any = getContext('i18n');
export let saveHandler: Function; export let saveHandler: Function;
@@ -47,7 +50,9 @@
]; ];
let webLoaderEngines = ['playwright', 'firecrawl', 'tavily', 'microsoft_web_iq', 'external']; let webLoaderEngines = ['playwright', 'firecrawl', 'tavily', 'microsoft_web_iq', 'external'];
let webConfig = null; let webConfig: any = null;
const inputClass =
'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 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';
@@ -58,8 +63,8 @@
webConfig.WEB_SEARCH_DOMAIN_FILTER_LIST webConfig.WEB_SEARCH_DOMAIN_FILTER_LIST
) { ) {
webConfig.WEB_SEARCH_DOMAIN_FILTER_LIST = webConfig.WEB_SEARCH_DOMAIN_FILTER_LIST.split(',') webConfig.WEB_SEARCH_DOMAIN_FILTER_LIST = webConfig.WEB_SEARCH_DOMAIN_FILTER_LIST.split(',')
.map((domain) => domain.trim()) .map((domain: string) => domain.trim())
.filter((domain) => domain.length > 0); .filter((domain: string) => domain.length > 0);
} else if (!Array.isArray(webConfig.WEB_SEARCH_DOMAIN_FILTER_LIST)) { } else if (!Array.isArray(webConfig.WEB_SEARCH_DOMAIN_FILTER_LIST)) {
webConfig.WEB_SEARCH_DOMAIN_FILTER_LIST = []; webConfig.WEB_SEARCH_DOMAIN_FILTER_LIST = [];
} }
@@ -70,8 +75,8 @@
webConfig.YOUTUBE_LOADER_LANGUAGE webConfig.YOUTUBE_LOADER_LANGUAGE
) { ) {
webConfig.YOUTUBE_LOADER_LANGUAGE = webConfig.YOUTUBE_LOADER_LANGUAGE.split(',') webConfig.YOUTUBE_LOADER_LANGUAGE = webConfig.YOUTUBE_LOADER_LANGUAGE.split(',')
.map((lang) => lang.trim()) .map((lang: string) => lang.trim())
.filter((lang) => lang.length > 0); .filter((lang: string) => lang.length > 0);
} else if (!Array.isArray(webConfig.YOUTUBE_LOADER_LANGUAGE)) { } else if (!Array.isArray(webConfig.YOUTUBE_LOADER_LANGUAGE)) {
webConfig.YOUTUBE_LOADER_LANGUAGE = []; webConfig.YOUTUBE_LOADER_LANGUAGE = [];
} }
@@ -157,33 +162,26 @@
<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 webConfig} {#if webConfig}
<div class=""> <AdminSettingSection first title={$i18n.t('Search')}>
<div class="mb-5"> <AdminSettingRow
<div class=" mb-2.5 flex w-full justify-between"> label={$i18n.t('Web Search')}
<div class=" self-center text-xs text-gray-600 dark:text-gray-400"> description={$i18n.t('Allow users to search the web from chats.')}
{$i18n.t('Web Search')} >
</div>
<div class="flex items-center relative">
<Switch bind:state={webConfig.ENABLE_WEB_SEARCH} /> <Switch bind:state={webConfig.ENABLE_WEB_SEARCH} />
</div> </AdminSettingRow>
</div>
<div class="mb-2.5 flex w-full justify-between"> <AdminSettingRow
<div class="self-center text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Web Search Confirmation')}
{$i18n.t('Web Search Confirmation')} description={$i18n.t('Require users to confirm before using Web Search.')}
</div> >
<div class="flex items-center relative">
<Tooltip content={$i18n.t('Require users to confirm before using Web Search.')}>
<Switch bind:state={webConfig.ENABLE_WEB_SEARCH_CONFIRMATION} /> <Switch bind:state={webConfig.ENABLE_WEB_SEARCH_CONFIRMATION} />
</Tooltip> </AdminSettingRow>
</div>
</div>
{#if webConfig.ENABLE_WEB_SEARCH_CONFIRMATION} {#if webConfig.ENABLE_WEB_SEARCH_CONFIRMATION}
<div class="mb-2.5"> <AdminSettingField
<div class="self-center text-xs text-gray-600 dark:text-gray-400 mb-2"> label={$i18n.t('Web Search Confirmation Content')}
{$i18n.t('Web Search Confirmation Content')} description={$i18n.t('Message shown before web search runs.')}
</div> >
<Textarea <Textarea
className={textareaClass} className={textareaClass}
placeholder={$i18n.t( placeholder={$i18n.t(
@@ -191,14 +189,13 @@
)} )}
bind:value={webConfig.WEB_SEARCH_CONFIRMATION_CONTENT} bind:value={webConfig.WEB_SEARCH_CONFIRMATION_CONTENT}
/> />
</div> </AdminSettingField>
{/if} {/if}
<div class=" mb-2.5 flex w-full justify-between"> <AdminSettingRow
<div class=" self-center text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Web Search Engine')}
{$i18n.t('Web Search Engine')} description={$i18n.t('Choose the provider used for web search queries.')}
</div> >
<div class="flex items-center relative">
<SettingsSelect <SettingsSelect
bind:value={webConfig.WEB_SEARCH_ENGINE} bind:value={webConfig.WEB_SEARCH_ENGINE}
placeholder={$i18n.t('Select a engine')} placeholder={$i18n.t('Select a engine')}
@@ -215,8 +212,7 @@
{/if} {/if}
{/each} {/each}
</SettingsSelect> </SettingsSelect>
</div> </AdminSettingRow>
</div>
{#if webConfig.WEB_SEARCH_ENGINE !== ''} {#if webConfig.WEB_SEARCH_ENGINE !== ''}
{#if webConfig.WEB_SEARCH_ENGINE === 'ollama_cloud'} {#if webConfig.WEB_SEARCH_ENGINE === 'ollama_cloud'}
@@ -1040,7 +1036,10 @@
{/if} {/if}
{#if webConfig.ENABLE_WEB_SEARCH} {#if webConfig.ENABLE_WEB_SEARCH}
<div class="mb-2.5 flex w-full flex-col"> <AdminSettingField
label={$i18n.t('Search Limits')}
description={$i18n.t('Control result volume and parallel search requests.')}
>
<div class="flex gap-2"> <div class="flex gap-2">
<div class="w-full"> <div class="w-full">
<div class=" self-center text-xs text-gray-600 dark:text-gray-400 mb-1"> <div class=" self-center text-xs text-gray-600 dark:text-gray-400 mb-1">
@@ -1076,106 +1075,68 @@
/> />
</div> </div>
</div> </div>
</div> </AdminSettingField>
<div class="mb-2.5 w-full"> <AdminSettingField
<div class=" self-center text-xs text-gray-600 dark:text-gray-400 mb-1"> label={$i18n.t('Fetch URL Content Length Limit')}
<Tooltip description={$i18n.t(
content={$i18n.t(
'Maximum characters to return from fetched URLs. Leave empty for no limit.' 'Maximum characters to return from fetched URLs. Leave empty for no limit.'
)} )}
placement="top-start"
> >
{$i18n.t('Fetch URL Content Length Limit')}
</Tooltip>
</div>
<input <input
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" class={inputClass}
placeholder={$i18n.t('No limit')} placeholder={$i18n.t('No limit')}
bind:value={webConfig.WEB_FETCH_MAX_CONTENT_LENGTH} bind:value={webConfig.WEB_FETCH_MAX_CONTENT_LENGTH}
type="number" type="number"
min="0" min="0"
/> />
</div> </AdminSettingField>
<div class="mb-2.5 flex w-full flex-col">
<div class=" text-xs text-gray-600 dark:text-gray-400 mb-1">
{$i18n.t('Domain Filter List')}
</div>
<AdminSettingField
label={$i18n.t('Domain Filter List')}
description={$i18n.t('Restrict or exclude domains using a comma-separated list.')}
>
<input <input
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" class={inputClass}
placeholder={$i18n.t( placeholder={$i18n.t(
'Enter domains separated by commas (e.g., example.com,site.org,!excludedsite.com)' 'Enter domains separated by commas (e.g., example.com,site.org,!excludedsite.com)'
)} )}
bind:value={webConfig.WEB_SEARCH_DOMAIN_FILTER_LIST} bind:value={webConfig.WEB_SEARCH_DOMAIN_FILTER_LIST}
/> />
</div> </AdminSettingField>
{/if} {/if}
<div class=" mb-2.5 flex w-full justify-between"> <AdminSettingRow
<div class=" self-center text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Bypass Embedding and Retrieval')}
<Tooltip content={$i18n.t('Full Context Mode')} placement="top-start"> description={webConfig.BYPASS_WEB_SEARCH_EMBEDDING_AND_RETRIEVAL
{$i18n.t('Bypass Embedding and Retrieval')} ? $i18n.t('Inject the entire content as context for comprehensive processing.')
</Tooltip> : $i18n.t('Use segmented retrieval for focused and relevant content extraction.')}
</div>
<div class="flex items-center relative">
<Tooltip
content={webConfig.BYPASS_WEB_SEARCH_EMBEDDING_AND_RETRIEVAL
? $i18n.t(
'Inject the entire content as context for comprehensive processing, this is recommended for complex queries.'
)
: $i18n.t(
'Default to segmented retrieval for focused and relevant content extraction, this is recommended for most cases.'
)}
> >
<Switch bind:state={webConfig.BYPASS_WEB_SEARCH_EMBEDDING_AND_RETRIEVAL} /> <Switch bind:state={webConfig.BYPASS_WEB_SEARCH_EMBEDDING_AND_RETRIEVAL} />
</Tooltip> </AdminSettingRow>
</div>
</div>
<div class=" mb-2.5 flex w-full justify-between"> <AdminSettingRow
<div class=" self-center text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Bypass Web Loader')}
<Tooltip content={$i18n.t('Bypass Web Loader')} placement="top-start"> description={$i18n.t('Use search results without fetching page contents.')}
{$i18n.t('Bypass Web Loader')} >
</Tooltip>
</div>
<div class="flex items-center relative">
<Tooltip content={''}>
<Switch bind:state={webConfig.BYPASS_WEB_SEARCH_WEB_LOADER} /> <Switch bind:state={webConfig.BYPASS_WEB_SEARCH_WEB_LOADER} />
</Tooltip> </AdminSettingRow>
</div>
</div>
<div class=" mb-2.5 flex w-full justify-between"> <AdminSettingRow
<div class=" self-center text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Trust Proxy Environment')}
{$i18n.t('Trust Proxy Environment')} description={webConfig.WEB_SEARCH_TRUST_ENV
</div> ? $i18n.t('Use proxy environment variables to fetch page contents.')
<div class="flex items-center relative"> : $i18n.t('Fetch page contents without proxy environment variables.')}
<Tooltip
content={webConfig.WEB_SEARCH_TRUST_ENV
? $i18n.t(
'Use proxy designated by http_proxy and https_proxy environment variables to fetch page contents.'
)
: $i18n.t('Use no proxy to fetch page contents.')}
> >
<Switch bind:state={webConfig.WEB_SEARCH_TRUST_ENV} /> <Switch bind:state={webConfig.WEB_SEARCH_TRUST_ENV} />
</Tooltip> </AdminSettingRow>
</div> </AdminSettingSection>
</div>
</div>
<div class="mb-5"> <AdminSettingSection title={$i18n.t('Loader')}>
<div class=" mb-2 text-xs text-gray-400 dark:text-gray-600"> <AdminSettingRow
{$i18n.t('Loader')} label={$i18n.t('Web Loader Engine')}
</div> description={$i18n.t('Choose how web result pages are fetched and read.')}
>
<div class=" mb-2.5 flex w-full justify-between">
<div class=" self-center text-xs text-gray-600 dark:text-gray-400">
{$i18n.t('Web Loader Engine')}
</div>
<div class="flex items-center relative">
<SettingsSelect <SettingsSelect
bind:value={webConfig.WEB_LOADER_ENGINE} bind:value={webConfig.WEB_LOADER_ENGINE}
placeholder={$i18n.t('Select a engine')} placeholder={$i18n.t('Select a engine')}
@@ -1185,31 +1146,26 @@
<option value={engine}>{engine}</option> <option value={engine}>{engine}</option>
{/each} {/each}
</SettingsSelect> </SettingsSelect>
</div> </AdminSettingRow>
</div>
{#if webConfig.WEB_LOADER_ENGINE === '' || webConfig.WEB_LOADER_ENGINE === 'safe_web'} {#if webConfig.WEB_LOADER_ENGINE === '' || webConfig.WEB_LOADER_ENGINE === 'safe_web'}
<div class=" mb-2.5 flex w-full justify-between"> <AdminSettingField
<div class=" self-center text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Timeout')}
{$i18n.t('Timeout')} description={$i18n.t('Maximum time to wait while loading web content.')}
</div> >
<div class="flex items-center relative">
<input <input
class="flex-1 w-full text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300" class={inputClass}
placeholder={$i18n.t('Timeout')} placeholder={$i18n.t('Timeout')}
bind:value={webConfig.WEB_LOADER_TIMEOUT} bind:value={webConfig.WEB_LOADER_TIMEOUT}
/> />
</div> </AdminSettingField>
</div>
<div class=" mb-2.5 flex w-full justify-between"> <AdminSettingRow
<div class=" self-center text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Verify SSL Certificate')}
{$i18n.t('Verify SSL Certificate')} description={$i18n.t('Validate SSL certificates when fetching web content.')}
</div> >
<div class="flex items-center relative">
<Switch bind:state={webConfig.ENABLE_WEB_LOADER_SSL_VERIFICATION} /> <Switch bind:state={webConfig.ENABLE_WEB_LOADER_SSL_VERIFICATION} />
</div> </AdminSettingRow>
</div>
{:else if webConfig.WEB_LOADER_ENGINE === 'playwright'} {:else if webConfig.WEB_LOADER_ENGINE === 'playwright'}
<div class="mb-2.5 flex w-full flex-col"> <div class="mb-2.5 flex w-full flex-col">
<div> <div>
@@ -1395,50 +1351,44 @@
</div> </div>
{/if} {/if}
<div class="mb-2.5 w-full"> <AdminSettingField
<div class=" self-center text-xs text-gray-600 dark:text-gray-400 mb-1"> label={$i18n.t('Concurrent Requests')}
{$i18n.t('Concurrent Requests')} description={$i18n.t('Limit parallel web loader requests.')}
</div> >
<input <input
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" class={inputClass}
placeholder={$i18n.t('Concurrent Requests')} placeholder={$i18n.t('Concurrent Requests')}
bind:value={webConfig.WEB_LOADER_CONCURRENT_REQUESTS} bind:value={webConfig.WEB_LOADER_CONCURRENT_REQUESTS}
required required
/> />
</div> </AdminSettingField>
<div class=" mb-2.5 flex w-full justify-between"> <AdminSettingField
<div class=" self-center text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Youtube Language')}
{$i18n.t('Youtube Language')} description={$i18n.t('Preferred transcript language codes, separated by commas.')}
</div> >
<div class="flex items-center relative">
<input <input
class="flex-1 w-full rounded-lg text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300" class={inputClass}
type="text" type="text"
placeholder={$i18n.t('Enter language codes')} placeholder={$i18n.t('Enter language codes')}
bind:value={webConfig.YOUTUBE_LOADER_LANGUAGE} bind:value={webConfig.YOUTUBE_LOADER_LANGUAGE}
autocomplete="off" autocomplete="off"
/> />
</div> </AdminSettingField>
</div>
<div class=" mb-2.5 flex flex-col w-full justify-between"> <AdminSettingField
<div class=" mb-1 text-xs text-gray-600 dark:text-gray-400"> label={$i18n.t('Youtube Proxy URL')}
{$i18n.t('Youtube Proxy URL')} description={$i18n.t('Proxy URL used for Youtube loader requests.')}
</div> >
<div class="flex items-center relative">
<input <input
class="flex-1 w-full rounded-lg text-xs border border-gray-100/50 !bg-gray-50/40 outline-hidden dark:border-white/[0.04] dark:!bg-white/[0.03] dark:text-gray-300" class={inputClass}
type="text" type="text"
placeholder={$i18n.t('Enter proxy URL (e.g. https://user:password@host:port)')} placeholder={$i18n.t('Enter proxy URL (e.g. https://user:password@host:port)')}
bind:value={webConfig.YOUTUBE_LOADER_PROXY_URL} bind:value={webConfig.YOUTUBE_LOADER_PROXY_URL}
autocomplete="off" autocomplete="off"
/> />
</div> </AdminSettingField>
</div> </AdminSettingSection>
</div>
</div>
{/if} {/if}
</div> </div>
<div class="flex justify-end pt-6 text-sm font-normal"> <div class="flex justify-end pt-6 text-sm font-normal">
@@ -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>
+16 -26
View File
@@ -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
+11 -13
View File
@@ -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>