File size: 501 Bytes
b5430db
 
 
 
 
5ce247d
a5904e1
b5430db
 
a5904e1
b5430db
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
export function checkFilename(filename: string) {
	if (
		!filename.endsWith('.safetensors') &&
		!filename.endsWith('.json') &&
		!filename.endsWith('.gguf') &&
        !filename.endsWith('.txt') &&
        !filename.endsWith('.model') &&
		!filename.endsWith('/')
	) {
		throw new Error('Files must have a .safetensors, .txt, .model, .gguf or .json extension');
	}

	const split = filename.split('/');

	if (split.length > 2) {
		throw new Error('Files must be only one level deep, not more');
	}
}