File size: 1,046 Bytes
3b86586
7357f85
1778c9e
5acf3a4
3b86586
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5acf3a4
1979653
 
 
 
 
 
3b86586
1979653
 
 
 
 
5acf3a4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import type { Provider } from "$lib/types.js";
import type { PageLoad } from "./$types.js";
import type { ApiModelsResponse } from "./api/models/+server.js";

export type RouterData = {
	object: string;
	data: Datum[];
};

type Datum = {
	id: string;
	// eslint-disable-next-line @typescript-eslint/no-explicit-any
	object: any;
	created: number;
	owned_by: string;
	providers: ProviderElement[];
};

type ProviderElement = {
	provider: Provider;
	// eslint-disable-next-line @typescript-eslint/no-explicit-any
	status: any;
	context_length?: number;
	pricing?: Pricing;
	supports_tools?: boolean;
	supports_structured_output?: boolean;
};

type Pricing = {
	input: number;
	output: number;
};

export const load: PageLoad = async ({ fetch }) => {
	const [modelsRes, routerRes] = await Promise.all([
		fetch("/api/models"),
		fetch("https://router.huggingface.co/v1/models"),
	]);

	const models: ApiModelsResponse = await modelsRes.json();
	const routerData = (await routerRes.json()) as RouterData;

	return {
		...models,
		routerData,
	};
};