okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
aff3a132f
main
1import type { NativeFamily , NativeSize } from './native' ; 2import { tr } from './i18n' ; 3import { nvfp4Version } from './native-names' ; 4export interface CatalogVersion extends NativeSize { sourceFamily :string ; edition :string ; images :boolean } 5export interface CatalogModel extends Omit < NativeFamily , 'sizes' >{ sizes :CatalogVersion []} 6export function nativeVersionLabel ( model :string ){ const nv = nvfp4Version ( model ); if ( nv ) return tr ( nv . name ); return tr (({ Q2_0 :'Fastest' , IQ2_XS :'Compact' , IQ3_XXS :'Balanced' , IQ3_S :'High quality' , IQ1_M :'Coding' , 'Gyro-S' :'Smallest' , 'Gyro-M' :'Small memory' } as Record < string , string >)[ model ] ?? model );} 7export const catalogVersionLabel = ( version :CatalogVersion ) => { const label = nativeVersionLabel ( version . model ); return [ tr ( version . edition ), label === version . model && version . edition ?'' :label ]. filter ( Boolean ). join ( ' · ' );}; 8/** 9* Models whose picture files Load fetches by itself (strata_control/pictures.py): the Flash-Next GGUF families, which share the original's reader (Swift has its own file). 10* NVFP4 packs and Qwen3.6 keep the installer for their pictures. With these the Load of a model that is on this computer never runs the installer again just 11* because the picture files are missing. 12*/ 13export const PICTURE_FETCH_FAMILIES = [ 'qwen' , 'coder' , 'unsloth' , 'gyro' , 'swift' ]; 14export const fetchesPictures = ( version :{ sourceFamily ?:string } | undefined , packaged :boolean | undefined ) => !! version && packaged === true && PICTURE_FETCH_FAMILIES . includes ( version . sourceFamily ?? '' ); 15/** The one line that says how a version differs from its neighbours (the three NVFP4 versions); empty for the rest. */ 16export const versionNote = ( model :string ) => { const nv = nvfp4Version ( model ); return nv ?tr ( nv . note ) :'' ;}; 17/** Display groups are distinct from the engine's installation family IDs. */ 18export function nativeCatalogModels ( families :NativeFamily []) :CatalogModel []{ 19if ( ! families . length ) return []; 20const groups :CatalogModel [] = [{ family :'qwen3.8' , title :'Qwen3.8-Flash-Next' , about :'' , experimental :false , images :false , sizes :[]},{ family :'qwen3.6' , title :'Qwen3.6-35B-A3B' , about :'' , experimental :false , images :false , sizes :[]}]; 21for ( const family of families ){ 22if ( family . feed ){ groups . push ({ family :family . family , title :family . title , about :family . about ?? '' , experimental :false , images :family . images , available :family . available , unavailable_reason :family . unavailable_reason , feed :true , sizes :family . sizes . map ( size => ({ ...size , sourceFamily :family . family , edition :'' , images :family . images }))}); continue ;} 23const target = /qwen3[._-]?6|35b[-_]?a3b / i . test ( family . title + ' ' + family . family ) ?groups [ 1 ] :[ 'qwen' , 'swift' , 'coder' , 'unsloth' , 'gyro' ]. includes ( family . family ) || /qwen3[._-]?8|flash.next / i . test ( family . title ) ?groups [ 0 ] :undefined ; 24if ( ! target ) continue ; 25const edition = target === groups [ 0 ] ?({ swift :'Swift 1.5' , coder :'Coder' , unsloth :'Unsloth' , gyro :'Gyro' } as Record < string , string >)[ family . family ] ?? '' :'' ; 26target . images ||= family . images ; 27target . sizes . push ( ...family . sizes . map ( size => ({ ...size , sourceFamily :family . family , edition, images :family . images }))); 28} 29return groups ; 30} 31 32/** Where the first-run model step starts: a version already on this computer and ready (the recommended one if it is among them), else the catalog's recommendation. Null when neither is in the list (the caller then keeps its own fallback). */ 33export function startingChoice ( families :CatalogModel [], readyIds :string [], pick ?:{ family ?:string | null ; model ?:string | null } | null ) :{ family :string ; size :string } | null { 34const ready = new Set ( readyIds ); 35const recommended = pick ?. family && pick . model ?families . flatMap ( f => f . sizes . filter ( s => s . model === pick . model && ( s . sourceFamily === pick . family || f . family === pick . family )). map ( s => ({ family :f . family , size :s . id }))) :[]; 36const have = recommended . find ( r => ready . has ( r . size )) ?? families . flatMap ( f => f . sizes . filter ( s => ready . has ( s . id )). map ( s => ({ family :f . family , size :s . id })))[ 0 ]; 37return have ?? recommended [ 0 ] ?? null ; 38}