dduf-check / src /lib /check-filename.ts
marcsun13's picture
marcsun13 HF staff
add .model extension for spiece.model file from tokenizer
8d73152 verified
raw
history blame contribute delete
503 Bytes
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, .gguf or .json or .model extension');
}
const split = filename.split('/');
if (split.length > 2) {
throw new Error('Files must be only one level deep, not more');
}
}