open-webui/src/routes/+page.server.ts
2023-10-18 02:59:00 -07:00

26 lines
539 B
TypeScript

import { ENDPOINT } from '$lib/contants';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ url }) => {
const models = await fetch(`${ENDPOINT}/api/tags`, {
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((error) => {
console.log(error);
return null;
});
return {
models: models?.models ?? [],
ENDPOINT: ENDPOINT
};
};