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
dfde45d3
Commit
dfde45d3
authored
Jan 02, 2024
by
Timothy J. Baek
Browse files
feat: set default models globally
parent
5719bcad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
src/lib/apis/configs/index.ts
src/lib/apis/configs/index.ts
+1
-1
src/lib/components/chat/ModelSelector.svelte
src/lib/components/chat/ModelSelector.svelte
+8
-2
No files found.
src/lib/apis/configs/index.ts
View file @
dfde45d3
...
...
@@ -4,7 +4,7 @@ export const setDefaultModels = async (token: string, models: string) => {
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/configs/default/models`
,
{
method
:
'
GE
T
'
,
method
:
'
POS
T
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
token
}
`
...
...
src/lib/components/chat/ModelSelector.svelte
View file @
dfde45d3
<script lang="ts">
import { models, showSettings, settings } from '$lib/stores';
import { setDefaultModels } from '$lib/apis/configs';
import { models, showSettings, settings, user } from '$lib/stores';
import { onMount, tick } from 'svelte';
import toast from 'svelte-french-toast';
export let selectedModels = [''];
export let disabled = false;
const saveDefaultModel = () => {
const saveDefaultModel =
async
() => {
const hasEmptyModel = selectedModels.filter((it) => it === '');
if (hasEmptyModel.length) {
toast.error('Choose a model before saving...');
...
...
@@ -14,6 +15,11 @@
}
settings.set({ ...$settings, models: selectedModels });
localStorage.setItem('settings', JSON.stringify($settings));
if ($user.role === 'admin') {
console.log('admin');
await setDefaultModels(localStorage.token, selectedModels.join(','));
}
toast.success('Default model updated');
};
...
...
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