char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
92d1bb0c9
char/aliceai-t5-moe
1/** 2* Type-safe configuration helpers 3* 4* Provides utilities for safely accessing and modifying configuration objects 5* with dynamic keys while maintaining TypeScript type safety. 6*/ 7 8/** 9* Type-safe helper to access config properties dynamically 10* Provides better type safety than direct casting to Record 11*/ 12export function setConfigValue < T extends SettingsConfigType > ( 13config :T , 14key :string , 15value :unknown 16) :void { 17if ( key in config ) { 18( config as Record < string , unknown >)[ key ] = value ; 19} 20} 21 22/** 23* Type-safe helper to get config values dynamically 24*/ 25export function getConfigValue < T extends SettingsConfigType > ( 26config :T , 27key :string 28) :string | number | boolean | undefined { 29const value = ( config as Record < string , unknown >)[ key ]; 30 31return value as string | number | boolean | undefined ; 32} 33 34/** 35* Convert a SettingsConfigType to a ParameterRecord for specific keys 36* Useful for parameter synchronization operations 37*/ 38export function configToParameterRecord < T extends SettingsConfigType > ( 39config :T , 40keys :string [] 41) :Record < string , string | number | boolean > { 42const record :Record < string , string | number | boolean > = {}; 43 44for ( const key of keys ) { 45const value = getConfigValue ( config , key ); 46 47if ( value !== undefined ) { 48record [ key ] = value ; 49} 50} 51 52return record ; 53}