Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
c8f44b73
Commit
c8f44b73
authored
Aug 02, 2024
by
Timothy J. Baek
Browse files
refac: user valves save handler
parent
bf6b149b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
12 deletions
+37
-12
src/lib/components/chat/Chat.svelte
src/lib/components/chat/Chat.svelte
+0
-4
src/lib/components/chat/ChatControls.svelte
src/lib/components/chat/ChatControls.svelte
+0
-4
src/lib/components/chat/Controls/Controls.svelte
src/lib/components/chat/Controls/Controls.svelte
+0
-1
src/lib/components/chat/Controls/Valves.svelte
src/lib/components/chat/Controls/Valves.svelte
+21
-1
src/lib/components/common/Valves.svelte
src/lib/components/common/Valves.svelte
+16
-2
No files found.
src/lib/components/chat/Chat.svelte
View file @
c8f44b73
...
@@ -109,7 +109,6 @@
...
@@ -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 @@
...
@@ -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 @@
...
@@ -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 @@
...
@@ -1639,7 +1636,6 @@
bind:show={showControls}
bind:show={showControls}
bind:chatFiles
bind:chatFiles
bind:params
bind:params
bind:valves
/>
/>
</div>
</div>
{/if}
{/if}
src/lib/components/chat/ChatControls.svelte
View file @
c8f44b73
...
@@ -9,9 +9,7 @@
...
@@ -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 @@
...
@@ -50,7 +48,6 @@
}}
}}
{models}
{models}
bind:chatFiles
bind:chatFiles
bind:valves
bind:params
bind:params
/>
/>
</div>
</div>
...
@@ -66,7 +63,6 @@
...
@@ -66,7 +63,6 @@
}}
}}
{models}
{models}
bind:chatFiles
bind:chatFiles
bind:valves
bind:params
bind:params
/>
/>
</div>
</div>
...
...
src/lib/components/chat/Controls/Controls.svelte
View file @
c8f44b73
...
@@ -12,7 +12,6 @@
...
@@ -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>
...
...
src/lib/components/chat/Controls/Valves.svelte
View file @
c8f44b73
...
@@ -31,6 +31,20 @@
...
@@ -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 @@
...
@@ -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}
...
...
src/lib/components/common/Valves.svelte
View file @
c8f44b73
<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 @@
...
@@ -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 @@
...
@@ -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 @@
...
@@ -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 @@
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment