forked from open-webui/open-webui
fix: pull model from selector
This commit is contained in:
parent
c19ea89a1d
commit
302bd11b33
2 changed files with 42 additions and 14 deletions
|
@ -1,5 +1,31 @@
|
|||
import { v4 as uuidv4 } from 'uuid';
|
||||
import sha256 from 'js-sha256';
|
||||
import { getOllamaModels } from '$lib/apis/ollama';
|
||||
import { getOpenAIModels } from '$lib/apis/openai';
|
||||
import { getLiteLLMModels } from '$lib/apis/litellm';
|
||||
|
||||
export const getModels = async (token: string) => {
|
||||
let models = await Promise.all([
|
||||
await getOllamaModels(token).catch((error) => {
|
||||
console.log(error);
|
||||
return null;
|
||||
}),
|
||||
await getOpenAIModels(token).catch((error) => {
|
||||
console.log(error);
|
||||
return null;
|
||||
}),
|
||||
await getLiteLLMModels(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' }] : [])), []);
|
||||
|
||||
return models;
|
||||
};
|
||||
|
||||
//////////////////////////
|
||||
// Helper functions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue