mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-03 18:17:56 -05:00
refac
This commit is contained in:
1 parent
85c59d65a8
commit
bfb7122c88
9 files changed
+95
-42
No files matched your search
@@ -347,7 +347,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-wrap items-center justify-between mb-3 gap-x-4 gap-y-2">
|
||||
<div class="flex flex-wrap items-center justify-between mb-1 gap-x-4 gap-y-2">
|
||||
<h2 class="text-sm font-normal text-base-900 dark:text-base-0 shrink-0">
|
||||
{$i18n.t('Analytics')}
|
||||
</h2>
|
||||
|
||||
@@ -230,7 +230,7 @@
|
||||
<form class="flex h-full flex-col justify-between text-sm" on:submit|preventDefault={submitHandler}>
|
||||
<div class="flex-1 min-h-0 overflow-y-auto scrollbar-hover pr-1.5">
|
||||
{#if ENABLE_OPENAI_API !== null && ENABLE_OLLAMA_API !== null && connectionsConfig !== null}
|
||||
<AdminSettingSection first>
|
||||
<AdminSettingSection title={$i18n.t('settings.admin.connections.title')} first>
|
||||
<AdminSettingRow label={$i18n.t('settings.admin.connections.openaiApi.label')} let:labelId>
|
||||
<Switch
|
||||
bind:state={ENABLE_OPENAI_API}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
type EventWebhookTarget
|
||||
} from '$lib/apis';
|
||||
import Modal from '$lib/components/common/Modal.svelte';
|
||||
import AdminSettingSection from './AdminSettingSection.svelte';
|
||||
import Switch from '$lib/components/common/Switch.svelte';
|
||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
||||
import ConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
|
||||
@@ -695,11 +696,7 @@
|
||||
}}
|
||||
/>
|
||||
|
||||
<div class="mt-5">
|
||||
<div class="mb-2 text-xs text-base-500 dark:text-base-400">
|
||||
{$i18n.t('settings.admin.general.events.events.label')}
|
||||
</div>
|
||||
|
||||
<AdminSettingSection title={$i18n.t('settings.admin.general.events.events.label')}>
|
||||
<div class="flex flex-col w-full justify-between gap-2.5">
|
||||
<div class="flex w-full items-start justify-between gap-4">
|
||||
<div class="min-w-0">
|
||||
@@ -775,4 +772,4 @@
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</AdminSettingSection>
|
||||
@@ -99,7 +99,7 @@
|
||||
>
|
||||
<div class="flex-1 min-h-0 overflow-y-auto scrollbar-hover pr-1.5">
|
||||
{#if adminConfig !== null}
|
||||
<AdminSettingSection first>
|
||||
<AdminSettingSection title={$i18n.t('settings.admin.general.title')} first>
|
||||
<div class="flex items-start justify-between gap-4">
|
||||
<div class="min-w-0 text-xs">
|
||||
<div class="text-base-800 dark:text-base-200">
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
<div class="flex-1 min-h-0 overflow-y-auto scrollbar-hover pr-1.5">
|
||||
{#if config}
|
||||
<div class="flex flex-col">
|
||||
<AdminSettingSection first>
|
||||
<AdminSettingSection title={$i18n.t('Images')} first>
|
||||
<AdminSettingRow
|
||||
label={$i18n.t('settings.admin.images.imageGeneration.label')}
|
||||
description={$i18n.t('settings.admin.images.imageGeneration.description')}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import AdminSettingField from './AdminSettingField.svelte';
|
||||
import AdminSettingRow from './AdminSettingRow.svelte';
|
||||
import AdminSettingSaveButton from './AdminSettingSaveButton.svelte';
|
||||
import AdminSettingSection from './AdminSettingSection.svelte';
|
||||
import { getChangedKeys } from '$lib/utils';
|
||||
import { getContext, onMount, tick } from 'svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
@@ -96,7 +97,7 @@
|
||||
{#if loading}
|
||||
<div class="flex justify-center py-8"><Spinner className="size-5" /></div>
|
||||
{:else}
|
||||
<div class="flex flex-col gap-2.5">
|
||||
<AdminSettingSection title={$i18n.t('settings.admin.subagents.title')} first>
|
||||
<AdminSettingRow
|
||||
label={$i18n.t('settings.admin.subagents.enableSubAgents.label')}
|
||||
description={$i18n.t(
|
||||
@@ -194,7 +195,7 @@
|
||||
/>
|
||||
</AdminSettingField>
|
||||
{/if}
|
||||
</div>
|
||||
</AdminSettingSection>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
}}
|
||||
>
|
||||
<div class="flex-1 min-h-0 overflow-y-auto scrollbar-hover pr-1.5">
|
||||
<AdminSettingSection first>
|
||||
<AdminSettingSection title={$i18n.t('Model')} first>
|
||||
<div>
|
||||
<div class="mb-2">
|
||||
<div class="text-xs text-base-800 dark:text-base-200">
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
import UserSettingRow from '../UserSettingRow.svelte';
|
||||
import Switch from '$lib/components/common/Switch.svelte';
|
||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
||||
import XMark from '$lib/components/icons/XMark.svelte';
|
||||
import Plus from '$lib/components/icons/Plus.svelte';
|
||||
import TTSVoiceInput from '$lib/components/workspace/Models/TTSVoiceInput.svelte';
|
||||
import type { i18n as i18nType } from 'i18next';
|
||||
import { getContext } from 'svelte';
|
||||
@@ -27,6 +29,7 @@
|
||||
key: string;
|
||||
label: string;
|
||||
tip: string;
|
||||
placeholder?: string;
|
||||
kind: 'number' | 'bool' | 'text';
|
||||
initial: unknown;
|
||||
min?: number;
|
||||
@@ -134,6 +137,7 @@
|
||||
},
|
||||
{
|
||||
key: 'seed',
|
||||
placeholder: $i18n.t('Enter Seed'),
|
||||
label: $i18n.t('settings.personal.general.parameters.seed.label'),
|
||||
tip: $i18n.t('settings.personal.general.parameters.seed.description'),
|
||||
kind: 'number',
|
||||
@@ -144,6 +148,7 @@
|
||||
},
|
||||
{
|
||||
key: 'stop',
|
||||
placeholder: $i18n.t('Enter stop sequence'),
|
||||
label: $i18n.t('settings.personal.general.parameters.stopSequence.label'),
|
||||
tip: $i18n.t('settings.personal.general.parameters.stopSequence.description'),
|
||||
kind: 'text',
|
||||
@@ -151,6 +156,7 @@
|
||||
},
|
||||
{
|
||||
key: 'reasoning_effort',
|
||||
placeholder: $i18n.t('Enter reasoning effort'),
|
||||
label: $i18n.t('settings.personal.general.parameters.reasoningEffort.label'),
|
||||
tip: $i18n.t('settings.personal.general.parameters.reasoningEffort.description'),
|
||||
kind: 'text',
|
||||
@@ -159,6 +165,9 @@
|
||||
},
|
||||
{
|
||||
key: 'logit_bias',
|
||||
placeholder: $i18n.t(
|
||||
'Enter comma-separated "token:bias_value" pairs (example: 5432:100, 413:-100)'
|
||||
),
|
||||
label: $i18n.t('settings.personal.general.parameters.logitBias.label'),
|
||||
tip: $i18n.t(
|
||||
'Boosting or penalizing specific tokens for constrained responses. Bias values will be clamped between -100 and 100 (inclusive). (Default: none)'
|
||||
@@ -242,6 +251,7 @@
|
||||
},
|
||||
{
|
||||
key: 'think',
|
||||
placeholder: $i18n.t("e.g. 'low', 'medium', 'high'"),
|
||||
label: $i18n.t('settings.personal.general.parameters.think.label'),
|
||||
tip: $i18n.t('settings.personal.general.parameters.ollama.description'),
|
||||
kind: 'text',
|
||||
@@ -251,6 +261,7 @@
|
||||
},
|
||||
{
|
||||
key: 'format',
|
||||
placeholder: $i18n.t('e.g. "json" or a JSON schema'),
|
||||
label: $i18n.t('settings.personal.general.parameters.format.label'),
|
||||
tip: $i18n.t('The format to return a response in. Format can be json or a JSON schema.'),
|
||||
kind: 'text',
|
||||
@@ -355,6 +366,7 @@
|
||||
},
|
||||
{
|
||||
key: 'keep_alive',
|
||||
placeholder: $i18n.t("e.g. '30s','10m'. Valid time units are 's', 'm', 'h'."),
|
||||
label: $i18n.t('settings.personal.general.parameters.keepAlive.label'),
|
||||
tip: $i18n.t(
|
||||
'This option controls how long the model will stay loaded into memory following the request (default: 5m)'
|
||||
@@ -497,6 +509,25 @@
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
{#snippet removableRow(label: string, tip: string, mono: boolean, onRemove: () => void)}
|
||||
<Tooltip content={tip} placement="top-start" className="inline-tooltip">
|
||||
<UserSettingRow
|
||||
className="w-full py-0.5"
|
||||
labelClassName={tip ? rowLabelClass : 'self-center font-normal'}
|
||||
>
|
||||
<span slot="label" class={mono ? 'font-mono' : ''}>{label}</span>
|
||||
<button
|
||||
class="flex shrink-0 rounded-sm p-1 text-base-400 transition hover:text-base-700 dark:text-base-500 dark:hover:text-base-300"
|
||||
type="button"
|
||||
aria-label={`${$i18n.t('Remove')} ${label}`}
|
||||
on:click={onRemove}
|
||||
>
|
||||
<XMark className="size-3" strokeWidth="2" />
|
||||
</button>
|
||||
</UserSettingRow>
|
||||
</Tooltip>
|
||||
{/snippet}
|
||||
|
||||
{#snippet defaultRow(label: string, tip: string, value: string, onClick: () => void)}
|
||||
<Tooltip content={tip} placement="top-start" className="inline-tooltip">
|
||||
<UserSettingRow let:labelId className="w-full py-0.5" labelClassName={rowLabelClass}>
|
||||
@@ -579,6 +610,7 @@
|
||||
type="number"
|
||||
min="1"
|
||||
step="1"
|
||||
placeholder={$i18n.t('Enter token threshold')}
|
||||
aria-label={$i18n.t(
|
||||
'settings.personal.general.parameters.contextCompactionThreshold.label'
|
||||
)}
|
||||
@@ -667,9 +699,7 @@
|
||||
<!-- Model parameters that are set. Custom resets to Default, which removes the row. -->
|
||||
{#each setParams as param (param.key)}
|
||||
<div>
|
||||
{@render defaultRow(labelOf(param), param.tip, $i18n.t('Custom'), () =>
|
||||
setParam(param.key, null)
|
||||
)}
|
||||
{@render removableRow(labelOf(param), param.tip, false, () => setParam(param.key, null))}
|
||||
{#if param.kind === 'bool'}
|
||||
<UserSettingRow let:labelId className="mt-1">
|
||||
<span slot="label">
|
||||
@@ -693,6 +723,7 @@
|
||||
type="number"
|
||||
min={param.min}
|
||||
step={param.step ?? 'any'}
|
||||
placeholder={param.placeholder ?? labelOf(param)}
|
||||
aria-label={labelOf(param)}
|
||||
value={params[param.key]}
|
||||
on:change={(event) => setNumber(param.key, event)}
|
||||
@@ -702,7 +733,8 @@
|
||||
{:else if param.suggestions}
|
||||
<div
|
||||
class="flex mt-0.5 text-sm"
|
||||
on:focusout={() => setParam(param.key, toValue(param.key, `${params[param.key] ?? ''}`))}
|
||||
on:focusout={(event) =>
|
||||
setParam(param.key, toValue(param.key, (event.target as HTMLInputElement).value))}
|
||||
>
|
||||
<TTSVoiceInput
|
||||
limit={null}
|
||||
@@ -710,9 +742,10 @@
|
||||
showDescription
|
||||
popupClassName="max-w-[calc(100vw-1rem)] max-h-64 rounded-xl border border-base-200 bg-base-0 p-1 shadow-lg dark:border-base-800 dark:bg-base-850"
|
||||
id={`${pickerId}-${param.key}`}
|
||||
bind:value={params[param.key]}
|
||||
value={`${params[param.key] ?? ''}`}
|
||||
voices={suggestionItems(param.suggestions)}
|
||||
placeholder={labelOf(param)}
|
||||
on:select={(event) => setParam(param.key, toValue(param.key, event.detail.id))}
|
||||
placeholder={param.placeholder ?? labelOf(param)}
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
@@ -721,6 +754,7 @@
|
||||
class={inputClass}
|
||||
type="text"
|
||||
autocomplete="off"
|
||||
placeholder={param.placeholder ?? labelOf(param)}
|
||||
aria-label={labelOf(param)}
|
||||
value={params[param.key]}
|
||||
on:change={(event) =>
|
||||
@@ -734,34 +768,44 @@
|
||||
{#each customParams as name (name)}
|
||||
{@const options = customSuggestions[name] ?? []}
|
||||
<div>
|
||||
<UserSettingRow
|
||||
let:labelId
|
||||
className="w-full py-0.5"
|
||||
labelClassName="self-center font-normal"
|
||||
>
|
||||
<span slot="label" class="font-mono">{name}</span>
|
||||
<button
|
||||
id={`${labelId}-control`}
|
||||
class={buttonClass}
|
||||
type="button"
|
||||
on:click={() => {
|
||||
const { [name]: _, ...rest } = params.custom_params;
|
||||
setCustom(rest);
|
||||
}}
|
||||
{@render removableRow(name, '', true, () => {
|
||||
const { [name]: _, ...rest } = params.custom_params;
|
||||
setCustom(rest);
|
||||
})}
|
||||
{#if options.length === 2 && options.includes('true') && options.includes('false')}
|
||||
<!-- Saved as text, as the old free-text field did. -->
|
||||
<UserSettingRow let:labelId className="mt-1">
|
||||
<span slot="label">
|
||||
{`${params.custom_params[name]}` === 'true' ? $i18n.t('Enabled') : $i18n.t('Disabled')}
|
||||
</span>
|
||||
<div class=" pr-2">
|
||||
<Switch
|
||||
ariaLabelledbyId={labelId}
|
||||
state={`${params.custom_params[name]}` === 'true'}
|
||||
on:change={(event) =>
|
||||
setCustom({ ...params.custom_params, [name]: event.detail ? 'true' : 'false' })}
|
||||
ariaLabel={name}
|
||||
/>
|
||||
</div>
|
||||
</UserSettingRow>
|
||||
{:else if options.length}
|
||||
<div
|
||||
class="flex mt-0.5 text-sm"
|
||||
on:focusout={(event) =>
|
||||
setCustom({
|
||||
...params.custom_params,
|
||||
[name]: (event.target as HTMLInputElement).value
|
||||
})}
|
||||
>
|
||||
<span class="ml-2 self-center">{$i18n.t('Remove')}</span>
|
||||
</button>
|
||||
</UserSettingRow>
|
||||
{#if options.length}
|
||||
<div class="flex mt-0.5 text-sm" on:focusout={() => setCustom({ ...params.custom_params })}>
|
||||
<TTSVoiceInput
|
||||
limit={null}
|
||||
minWidth={384}
|
||||
showDescription
|
||||
popupClassName="max-w-[calc(100vw-1rem)] max-h-64 rounded-xl border border-base-200 bg-base-0 p-1 shadow-lg dark:border-base-800 dark:bg-base-850"
|
||||
id={`${pickerId}-custom-${name}`}
|
||||
bind:value={params.custom_params[name]}
|
||||
value={customText(name)}
|
||||
voices={suggestionItems(options)}
|
||||
on:select={(event) => setCustom({ ...params.custom_params, [name]: event.detail.id })}
|
||||
placeholder={$i18n.t('Custom Parameter Value')}
|
||||
/>
|
||||
</div>
|
||||
@@ -771,6 +815,7 @@
|
||||
class={inputClass}
|
||||
type="text"
|
||||
autocomplete="off"
|
||||
placeholder={$i18n.t('Custom Parameter Value')}
|
||||
aria-label={name}
|
||||
value={customText(name)}
|
||||
on:change={(event) =>
|
||||
@@ -783,7 +828,7 @@
|
||||
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="flex items-center py-0.5"
|
||||
class="flex items-center gap-2 py-0.5"
|
||||
on:keydown={(event) => {
|
||||
// Enter on typed text adds it; picking a suggestion is handled by on:select.
|
||||
if (event.key === 'Enter' && newName.trim()) {
|
||||
@@ -803,5 +848,14 @@
|
||||
placeholder={$i18n.t('Add parameter')}
|
||||
on:select={(event) => addParam(event.detail.id)}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="flex shrink-0 rounded-sm p-1 text-base-400 transition hover:text-base-700 disabled:opacity-40 dark:text-base-500 dark:hover:text-base-300"
|
||||
aria-label={$i18n.t('Add parameter')}
|
||||
disabled={!newName.trim()}
|
||||
on:click={() => addParam(newName)}
|
||||
>
|
||||
<Plus className="size-3" strokeWidth="2" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import UserSettingRow from './UserSettingRow.svelte';
|
||||
import UserSettingSection from './UserSettingSection.svelte';
|
||||
import { canUseNotificationTargets } from '$lib/utils/settings-access';
|
||||
import { getContext, onMount } from 'svelte';
|
||||
import {
|
||||
@@ -213,7 +214,7 @@
|
||||
|
||||
<div id="tab-notifications" class="flex h-full flex-col text-sm">
|
||||
<div class="flex-1 min-h-0 w-full overflow-y-auto scrollbar-hover pr-1.5">
|
||||
<div class="flex flex-col gap-2.5">
|
||||
<UserSettingSection title={$i18n.t('settings.personal.notifications.title')} first>
|
||||
<UserSettingRow let:labelId>
|
||||
<span slot="label">
|
||||
{$i18n.t('settings.personal.notifications.browserNotifications.label')}
|
||||
@@ -402,7 +403,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</UserSettingSection>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in new issue
Block a user