mirror of
https://github.com/open-webui/open-webui
synced 2025-04-23 15:55:23 +00:00
refac: user valves save handler
This commit is contained in:
parent
bf6b149b8b
commit
c8f44b73f1
@ -109,7 +109,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
let params = {};
|
let params = {};
|
||||||
let valves = {};
|
|
||||||
|
|
||||||
$: if (history.currentId !== null) {
|
$: if (history.currentId !== null) {
|
||||||
let _messages = [];
|
let _messages = [];
|
||||||
@ -812,7 +811,6 @@
|
|||||||
keep_alive: $settings.keepAlive ?? undefined,
|
keep_alive: $settings.keepAlive ?? undefined,
|
||||||
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
|
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
|
||||||
files: files.length > 0 ? files : undefined,
|
files: files.length > 0 ? files : undefined,
|
||||||
...(Object.keys(valves).length ? { valves } : {}),
|
|
||||||
session_id: $socket?.id,
|
session_id: $socket?.id,
|
||||||
chat_id: $chatId,
|
chat_id: $chatId,
|
||||||
id: responseMessageId
|
id: responseMessageId
|
||||||
@ -1112,7 +1110,6 @@
|
|||||||
max_tokens: params?.max_tokens ?? $settings?.params?.max_tokens ?? undefined,
|
max_tokens: params?.max_tokens ?? $settings?.params?.max_tokens ?? undefined,
|
||||||
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
|
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
|
||||||
files: files.length > 0 ? files : undefined,
|
files: files.length > 0 ? files : undefined,
|
||||||
...(Object.keys(valves).length ? { valves } : {}),
|
|
||||||
session_id: $socket?.id,
|
session_id: $socket?.id,
|
||||||
chat_id: $chatId,
|
chat_id: $chatId,
|
||||||
id: responseMessageId
|
id: responseMessageId
|
||||||
@ -1639,7 +1636,6 @@
|
|||||||
bind:show={showControls}
|
bind:show={showControls}
|
||||||
bind:chatFiles
|
bind:chatFiles
|
||||||
bind:params
|
bind:params
|
||||||
bind:valves
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -9,9 +9,7 @@
|
|||||||
export let models = [];
|
export let models = [];
|
||||||
|
|
||||||
export let chatId = null;
|
export let chatId = null;
|
||||||
|
|
||||||
export let chatFiles = [];
|
export let chatFiles = [];
|
||||||
export let valves = {};
|
|
||||||
export let params = {};
|
export let params = {};
|
||||||
|
|
||||||
let largeScreen = false;
|
let largeScreen = false;
|
||||||
@ -50,7 +48,6 @@
|
|||||||
}}
|
}}
|
||||||
{models}
|
{models}
|
||||||
bind:chatFiles
|
bind:chatFiles
|
||||||
bind:valves
|
|
||||||
bind:params
|
bind:params
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -66,7 +63,6 @@
|
|||||||
}}
|
}}
|
||||||
{models}
|
{models}
|
||||||
bind:chatFiles
|
bind:chatFiles
|
||||||
bind:valves
|
|
||||||
bind:params
|
bind:params
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
export let models = [];
|
export let models = [];
|
||||||
|
|
||||||
export let chatFiles = [];
|
export let chatFiles = [];
|
||||||
export let valves = {};
|
|
||||||
export let params = {};
|
export let params = {};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -31,6 +31,20 @@
|
|||||||
let valvesSpec = null;
|
let valvesSpec = null;
|
||||||
let valves = {};
|
let valves = {};
|
||||||
|
|
||||||
|
let debounceTimer;
|
||||||
|
|
||||||
|
const debounceSubmitHandler = async () => {
|
||||||
|
// debounce 1 second
|
||||||
|
if (debounceTimer) {
|
||||||
|
clearTimeout(debounceTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set a new timer
|
||||||
|
debounceTimer = setTimeout(() => {
|
||||||
|
submitHandler();
|
||||||
|
}, 1000); // 1 second debounce
|
||||||
|
};
|
||||||
|
|
||||||
const getUserValves = async () => {
|
const getUserValves = async () => {
|
||||||
loading = true;
|
loading = true;
|
||||||
if (tab === 'tools') {
|
if (tab === 'tools') {
|
||||||
@ -157,7 +171,13 @@
|
|||||||
|
|
||||||
<div class="my-2 text-xs">
|
<div class="my-2 text-xs">
|
||||||
{#if !loading}
|
{#if !loading}
|
||||||
<Valves {valvesSpec} bind:valves />
|
<Valves
|
||||||
|
{valvesSpec}
|
||||||
|
bind:valves
|
||||||
|
on:change={() => {
|
||||||
|
debounceSubmitHandler();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<Spinner className="size-5" />
|
<Spinner className="size-5" />
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import { onMount, getContext } from 'svelte';
|
import { onMount, getContext, createEventDispatcher } from 'svelte';
|
||||||
|
const dispatch = createEventDispatcher();
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
import Switch from './Switch.svelte';
|
import Switch from './Switch.svelte';
|
||||||
@ -28,6 +29,8 @@
|
|||||||
(valves[property] ?? null) === null
|
(valves[property] ?? null) === null
|
||||||
? valvesSpec.properties[property]?.default ?? ''
|
? valvesSpec.properties[property]?.default ?? ''
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
dispatch('change');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#if (valves[property] ?? null) === null}
|
{#if (valves[property] ?? null) === null}
|
||||||
@ -52,6 +55,9 @@
|
|||||||
<select
|
<select
|
||||||
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none border border-gray-100 dark:border-gray-800"
|
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none border border-gray-100 dark:border-gray-800"
|
||||||
bind:value={valves[property]}
|
bind:value={valves[property]}
|
||||||
|
on:change={() => {
|
||||||
|
dispatch('change');
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{#each valvesSpec.properties[property].enum as option}
|
{#each valvesSpec.properties[property].enum as option}
|
||||||
<option value={option} selected={option === valves[property]}>
|
<option value={option} selected={option === valves[property]}>
|
||||||
@ -66,7 +72,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class=" pr-2">
|
<div class=" pr-2">
|
||||||
<Switch bind:state={valves[property]} />
|
<Switch
|
||||||
|
bind:state={valves[property]}
|
||||||
|
on:change={() => {
|
||||||
|
dispatch('change');
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
@ -77,6 +88,9 @@
|
|||||||
bind:value={valves[property]}
|
bind:value={valves[property]}
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
required
|
required
|
||||||
|
on:change={() => {
|
||||||
|
dispatch('change');
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user