feat: unified /models endpoint

This commit is contained in:
Timothy J. Baek
2024-05-24 01:40:48 -07:00
parent 4d57e08b38
commit 110ed67468
16 changed files with 166 additions and 170 deletions

View File

@@ -1,27 +1,17 @@
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';
import { getModels } from '$lib/apis';
export const getAllModels = async (token: string) => {
let models = await Promise.all([
getOllamaModels(token).catch((error) => {
console.log(error);
return null;
}),
getOpenAIModels(token).catch((error) => {
console.log(error);
return null;
}),
getLiteLLMModels(token).catch((error) => {
console.log(error);
return null;
})
]);
let models = await getModels(token).catch((error) => {
console.log(error);
return null;
});
models = models.filter((models) => models).reduce((a, e, i, arr) => a.concat(e), []);
console.log(models);
return models;
};