File size: 518 Bytes
b2ecf7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import type { WidgetProps } from "$lib/components/InferenceWidget/shared/types.js";
import type { Load } from "@sveltejs/kit";

export const load: Load = async ({ params, fetch }): Promise<{ model?: WidgetProps["model"]; message?: string }> => {
	const url = `https://huggingface.co/api/models/${params.model}`;
	try {
		const model = await (await fetch(url)).json();
		return {
			model,
		};
	} catch {
		// todo: throw error() instead
		return {
			message: `Model ${params.model} not found (probably)`,
		};
	}
};