File size: 785 Bytes
7764421
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { HF_ACCESS_TOKEN, MODELS } from "$env/static/private";
import { z } from "zod";

export const models = z
	.array(
		z.union([
			z.string().min(1),
			z.object({
				name: z.string().min(1),
				displayName: z.string().min(1).optional(),
				endpoints: z
					.array(
						z.object({
							url: z.string().url(),
							authorization: z.string().min(1).default(`Bearer ${HF_ACCESS_TOKEN}`),
							weight: z.number().int().positive().default(1),
						})
					)
					.optional(),
			}),
		])
	)
	.parse(JSON.parse(MODELS));

export const modelNames: Array<{ name: string; displayName: string }> = models.map((m) =>
	typeof m === "string"
		? { name: m, displayName: m }
		: { name: m.name, displayName: m.displayName ?? m.name }
);
export const defaultModel = modelNames[0];