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
bf6b149b
Commit
bf6b149b
authored
Aug 02, 2024
by
Timothy J. Baek
Browse files
refac: user valves
parent
f334c834
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
75 deletions
+16
-75
src/lib/components/chat/Controls/Controls.svelte
src/lib/components/chat/Controls/Controls.svelte
+6
-10
src/lib/components/chat/Controls/Valves.svelte
src/lib/components/chat/Controls/Valves.svelte
+8
-31
src/lib/components/chat/SettingsModal.svelte
src/lib/components/chat/SettingsModal.svelte
+0
-32
src/lib/components/common/Valves.svelte
src/lib/components/common/Valves.svelte
+2
-2
No files found.
src/lib/components/chat/Controls/Controls.svelte
View file @
bf6b149b
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
import XMark from '$lib/components/icons/XMark.svelte';
import XMark from '$lib/components/icons/XMark.svelte';
import AdvancedParams from '../Settings/Advanced/AdvancedParams.svelte';
import AdvancedParams from '../Settings/Advanced/AdvancedParams.svelte';
import Valves from '$lib/components/c
ommon
/Valves.svelte';
import Valves from '$lib/components/c
hat/Controls
/Valves.svelte';
import FileItem from '$lib/components/common/FileItem.svelte';
import FileItem from '$lib/components/common/FileItem.svelte';
import Collapsible from '$lib/components/common/Collapsible.svelte';
import Collapsible from '$lib/components/common/Collapsible.svelte';
...
@@ -55,17 +55,13 @@
...
@@ -55,17 +55,13 @@
<hr class="my-2 border-gray-100 dark:border-gray-800" />
<hr class="my-2 border-gray-100 dark:border-gray-800" />
{/if}
{/if}
{#if models.length === 1 && models[0]?.pipe?.valves_spec}
<Collapsible title={$i18n.t('Valves')}>
<div>
<div class="text-sm mt-1.5" slot="content">
<div class=" font-medium">{$i18n.t('Valves')}</div>
<Valves />
<div>
<Valves valvesSpec={models[0]?.pipe?.valves_spec} bind:valves />
</div>
</div>
</div>
</Collapsible>
<hr class="my-2 border-gray-100 dark:border-gray-800" />
<hr class="my-2 border-gray-100 dark:border-gray-800" />
{/if}
<Collapsible title={$i18n.t('System Prompt')} open={true}>
<Collapsible title={$i18n.t('System Prompt')} open={true}>
<div class=" mt-1.5" slot="content">
<div class=" mt-1.5" slot="content">
...
...
src/lib/components/chat/
Setting
s/Valves.svelte
→
src/lib/components/chat/
Control
s/Valves.svelte
View file @
bf6b149b
...
@@ -15,18 +15,14 @@
...
@@ -15,18 +15,14 @@
updateUserValvesById as updateFunctionUserValvesById
updateUserValvesById as updateFunctionUserValvesById
} from '$lib/apis/functions';
} from '$lib/apis/functions';
import ManageModal from './Personalization/ManageModal.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
import Spinner from '$lib/components/common/Spinner.svelte';
import Spinner from '$lib/components/common/Spinner.svelte';
import Switch from '$lib/components/common/Switch.svelte';
import Valves from '$lib/components/common/Valves.svelte';
import Valves from '$lib/components/common/Valves.svelte';
const dispatch = createEventDispatcher();
const dispatch = createEventDispatcher();
const i18n = getContext('i18n');
const i18n = getContext('i18n');
export let saveSettings: Function;
let tab = 'tools';
let tab = 'tools';
let selectedId = '';
let selectedId = '';
...
@@ -112,18 +108,12 @@
...
@@ -112,18 +108,12 @@
dispatch('save');
dispatch('save');
}}
}}
>
>
<div class="flex flex-col pr-1.5 overflow-y-scroll max-h-[25rem]">
<div class="flex flex-col">
<div>
<div class="space-y-1">
<div class="flex items-center justify-between mb-2">
<div class="flex gap-2">
<Tooltip content="">
<div class="flex-1">
<div class="text-sm font-medium">
{$i18n.t('Manage Valves')}
</div>
</Tooltip>
<div class=" self-end">
<select
<select
class="
dark:bg-gray-900 w-fit pr-8
rounded text-xs bg-transparent outline-none
text-right
"
class="
w-full
rounded text-xs
py-2 px-1
bg-transparent outline-none"
bind:value={tab}
bind:value={tab}
placeholder="Select"
placeholder="Select"
>
>
...
@@ -131,14 +121,10 @@
...
@@ -131,14 +121,10 @@
<option value="functions">{$i18n.t('Functions')}</option>
<option value="functions">{$i18n.t('Functions')}</option>
</select>
</select>
</div>
</div>
</div>
</div>
<div class="space-y-1">
<div class="flex gap-2">
<div class="flex-1">
<div class="flex-1">
<select
<select
class="w-full rounded
-lg
py-2 px-
4
text-
sm dark:text-gray-300 dark:
bg-
g
ra
y-850
outline-none"
class="w-full rounded py-2 px-
1
text-
xs
bg-
t
ra
nsparent
outline-none"
bind:value={selectedId}
bind:value={selectedId}
on:change={async () => {
on:change={async () => {
await tick();
await tick();
...
@@ -167,9 +153,9 @@
...
@@ -167,9 +153,9 @@
</div>
</div>
{#if selectedId}
{#if selectedId}
<hr class="dark:border-gray-800 my-
3
w-full" />
<hr class="dark:border-gray-800 my-
1
w-full" />
<div>
<div
class="my-2 text-xs"
>
{#if !loading}
{#if !loading}
<Valves {valvesSpec} bind:valves />
<Valves {valvesSpec} bind:valves />
{:else}
{:else}
...
@@ -178,13 +164,4 @@
...
@@ -178,13 +164,4 @@
</div>
</div>
{/if}
{/if}
</div>
</div>
<div class="flex justify-end text-sm font-medium">
<button
class=" px-4 py-2 bg-emerald-700 hover:bg-emerald-800 text-gray-100 transition rounded-lg"
type="submit"
>
{$i18n.t('Save')}
</button>
</div>
</form>
</form>
src/lib/components/chat/SettingsModal.svelte
View file @
bf6b149b
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
import Chats from './Settings/Chats.svelte';
import Chats from './Settings/Chats.svelte';
import User from '../icons/User.svelte';
import User from '../icons/User.svelte';
import Personalization from './Settings/Personalization.svelte';
import Personalization from './Settings/Personalization.svelte';
import Valves from './Settings/Valves.svelte';
const i18n = getContext('i18n');
const i18n = getContext('i18n');
...
@@ -188,30 +187,6 @@
...
@@ -188,30 +187,6 @@
<div class=" self-center">{$i18n.t('Audio')}</div>
<div class=" self-center">{$i18n.t('Audio')}</div>
</button>
</button>
<button
class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
'valves'
? 'bg-gray-200 dark:bg-gray-800'
: ' hover:bg-gray-100 dark:hover:bg-gray-850'}"
on:click={() => {
selectedTab = 'valves';
}}
>
<div class=" self-center mr-2">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
class="size-4"
>
<path
d="M18.75 12.75h1.5a.75.75 0 0 0 0-1.5h-1.5a.75.75 0 0 0 0 1.5ZM12 6a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 12 6ZM12 18a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 12 18ZM3.75 6.75h1.5a.75.75 0 1 0 0-1.5h-1.5a.75.75 0 0 0 0 1.5ZM5.25 18.75h-1.5a.75.75 0 0 1 0-1.5h1.5a.75.75 0 0 1 0 1.5ZM3 12a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 3 12ZM9 3.75a2.25 2.25 0 1 0 0 4.5 2.25 2.25 0 0 0 0-4.5ZM12.75 12a2.25 2.25 0 1 1 4.5 0 2.25 2.25 0 0 1-4.5 0ZM9 15.75a2.25 2.25 0 1 0 0 4.5 2.25 2.25 0 0 0 0-4.5Z"
/>
</svg>
</div>
<div class=" self-center">{$i18n.t('Valves')}</div>
</button>
<button
<button
class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
'chats'
'chats'
...
@@ -349,13 +324,6 @@
...
@@ -349,13 +324,6 @@
toast.success($i18n.t('Settings saved successfully!'));
toast.success($i18n.t('Settings saved successfully!'));
}}
}}
/>
/>
{:else if selectedTab === 'valves'}
<Valves
{saveSettings}
on:save={() => {
toast.success($i18n.t('Settings saved successfully!'));
}}
/>
{:else if selectedTab === 'chats'}
{:else if selectedTab === 'chats'}
<Chats {saveSettings} />
<Chats {saveSettings} />
{:else if selectedTab === 'account'}
{:else if selectedTab === 'account'}
...
...
src/lib/components/common/Valves.svelte
View file @
bf6b149b
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
export let valves = {};
export let valves = {};
</script>
</script>
{#if valvesSpec}
{#if valvesSpec
&& Object.keys(valvesSpec?.properties ?? {}).length
}
{#each Object.keys(valvesSpec.properties) as property, idx}
{#each Object.keys(valvesSpec.properties) as property, idx}
<div class=" py-0.5 w-full justify-between">
<div class=" py-0.5 w-full justify-between">
<div class="flex w-full justify-between">
<div class="flex w-full justify-between">
...
@@ -91,5 +91,5 @@
...
@@ -91,5 +91,5 @@
</div>
</div>
{/each}
{/each}
{:else}
{:else}
<div class="text-s
m
">No valves</div>
<div class="text-
x
s">No valves</div>
{/if}
{/if}
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