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
2fd2f792
Commit
2fd2f792
authored
Apr 20, 2024
by
Timothy J. Baek
Browse files
refac
parent
93bd20b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
33 deletions
+3
-33
src/lib/components/chat/SettingsModal.svelte
src/lib/components/chat/SettingsModal.svelte
+2
-30
src/lib/utils/index.ts
src/lib/utils/index.ts
+1
-3
No files found.
src/lib/components/chat/SettingsModal.svelte
View file @
2fd2f792
...
...
@@ -3,9 +3,7 @@
import { toast } from 'svelte-sonner';
import { models, settings, user } from '$lib/stores';
import { getOllamaModels } from '$lib/apis/ollama';
import { getOpenAIModels } from '$lib/apis/openai';
import { getLiteLLMModels } from '$lib/apis/litellm';
import { getModels } from '$lib/utils';
import Modal from '../common/Modal.svelte';
import Account from './Settings/Account.svelte';
...
...
@@ -25,37 +23,11 @@
const saveSettings = async (updated) => {
console.log(updated);
await settings.set({ ...$settings, ...updated });
await models.set(await getModels());
await models.set(await getModels(
localStorage.token
));
localStorage.setItem('settings', JSON.stringify($settings));
};
let selectedTab = 'general';
const getModels = async () => {
let models = await Promise.all([
await getOllamaModels(localStorage.token).catch((error) => {
console.log(error);
return null;
}),
await getOpenAIModels(localStorage.token).catch((error) => {
console.log(error);
return null;
}),
await getLiteLLMModels(localStorage.token).catch((error) => {
console.log(error);
return null;
})
]);
models = models
.filter((models) => models)
.reduce((a, e, i, arr) => a.concat(e, ...(i < arr.length - 1 ? [{ name: 'hr' }] : [])), []);
// models.push(...(ollamaModels ? [{ name: 'hr' }, ...ollamaModels] : []));
// models.push(...(openAIModels ? [{ name: 'hr' }, ...openAIModels] : []));
// models.push(...(liteLLMModels ? [{ name: 'hr' }, ...liteLLMModels] : []));
return models;
};
</script>
<Modal bind:show>
...
...
src/lib/utils/index.ts
View file @
2fd2f792
...
...
@@ -20,9 +20,7 @@ export const getModels = async (token: string) => {
})
]);
models
=
models
.
filter
((
models
)
=>
models
)
.
reduce
((
a
,
e
,
i
,
arr
)
=>
a
.
concat
(
e
,
...(
i
<
arr
.
length
-
1
?
[{
name
:
'
hr
'
}]
:
[])),
[]);
models
=
models
.
filter
((
models
)
=>
models
).
reduce
((
a
,
e
,
i
,
arr
)
=>
a
.
concat
(
e
),
[]);
return
models
;
};
...
...
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