refac: base models endpoint

This commit is contained in:
Timothy Jaeryang Baek
2024-11-15 19:14:24 -08:00
parent 7e78889e33
commit 19c98b74fa
3 changed files with 19 additions and 8 deletions

View File

@@ -1,9 +1,10 @@
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
export const getModels = async (token: string = '') => {
export const getModels = async (token: string = '', base: boolean = false) => {
let error = null;
const res = await fetch(`${WEBUI_BASE_URL}/api/models`, {
const res = await fetch(`${WEBUI_BASE_URL}/api/models${
base ? '/base' : ''
}`, {
method: 'GET',
headers: {
Accept: 'application/json',
@@ -16,17 +17,17 @@ export const getModels = async (token: string = '') => {
return res.json();
})
.catch((err) => {
console.log(err);
error = err;
console.log(err);
return null;
});
if (error) {
throw error;
}
let models = res?.data ?? [];
models = models
.filter((models) => models)
// Sort the models

View File

@@ -43,7 +43,7 @@
const init = async () => {
const workspaceModels = await getBaseModels(localStorage.token);
const allModels = await getModels(localStorage.token);
const allModels = await getModels(localStorage.token, true);
models = allModels
.filter((m) => !(m?.preset ?? false))