char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
92d1bb0c9
char/aliceai-t5-moe
1import { isValidModelName , normalizeModelName } from '$lib/utils/model-names' ; 2import { describe , expect , it } from 'vitest' ; 3 4describe ( 'normalizeModelName' , () => { 5it ( 'preserves Hugging Face org/model format (single slash)' , () => { 6// Single slash is treated as Hugging Face format and preserved 7expect ( normalizeModelName ( 'meta-llama/Llama-3.1-8B' )). toBe ( 'meta-llama/Llama-3.1-8B' ); 8expect ( normalizeModelName ( 'models/model-name-1' )). toBe ( 'models/model-name-1' ); 9}); 10 11it ( 'extracts filename from multi-segment paths' , () => { 12// Multiple slashes -> extract just the filename 13expect ( normalizeModelName ( 'path/to/model/model-name-2' )). toBe ( 'model-name-2' ); 14expect ( normalizeModelName ( '/absolute/path/to/model' )). toBe ( 'model' ); 15}); 16 17it ( 'extracts filename from backslash paths' , () => { 18expect ( normalizeModelName ( 'C\\Models\\model-name-1' )). toBe ( 'model-name-1' ); 19expect ( normalizeModelName ( 'path\\to\\model\\model-name-2' )). toBe ( 'model-name-2' ); 20}); 21 22it ( 'handles mixed path separators' , () => { 23expect ( normalizeModelName ( 'path/to\\model/model-name-2' )). toBe ( 'model-name-2' ); 24}); 25 26it ( 'returns simple names as-is' , () => { 27expect ( normalizeModelName ( 'simple-model' )). toBe ( 'simple-model' ); 28expect ( normalizeModelName ( 'model-name-2' )). toBe ( 'model-name-2' ); 29}); 30 31it ( 'trims whitespace' , () => { 32expect ( normalizeModelName ( ' model-name ' )). toBe ( 'model-name' ); 33}); 34 35it ( 'returns empty string for empty input' , () => { 36expect ( normalizeModelName ( '' )). toBe ( '' ); 37expect ( normalizeModelName ( ' ' )). toBe ( '' ); 38}); 39}); 40 41describe ( 'isValidModelName' , () => { 42it ( 'returns true for valid names' , () => { 43expect ( isValidModelName ( 'model' )). toBe ( true ); 44expect ( isValidModelName ( 'path/to/model.bin' )). toBe ( true ); 45}); 46 47it ( 'returns false for empty values' , () => { 48expect ( isValidModelName ( '' )). toBe ( false ); 49expect ( isValidModelName ( ' ' )). toBe ( false ); 50}); 51});