char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
61328e6a9
char/aliceai-t5-moe
1const logs = []; 2const fmt = ( value ) => { 3if ( typeof value === 'string' ) return value ; 4try { 5return JSON . stringify ( value ); 6} catch { 7return String ( value ); 8} 9}; 10const capture = 11( level , prefix ) => 12( ...args ) => { 13logs . push ( prefix + args . map ( fmt ). join ( ' ' )); 14}; 15console . log = capture ( 'log' , '' ); 16console . info = capture ( 'info' , '' ); 17console . debug = capture ( 'debug' , '' ); 18console . warn = capture ( 'warn' , 'warn: ' ); 19console . error = capture ( 'error' , 'error: ' ); 20self . onmessage = async ( event ) => { 21const reply = { logs, result :null , error :null }; 22try { 23const AsyncFunction = Object . getPrototypeOf ( async function () {}). constructor ; 24// The prelude bundled ahead of this shim defines self.nerdamer, 25// passed into the execution scope as the `nerdamer` parameter. 26const value = await new AsyncFunction ( 'nerdamer' , event . data . code )( self . nerdamer ); 27if ( value !== undefined ) reply . result = fmt ( value ); 28} catch ( err ) { 29reply . error = err instanceof Error ?err . stack || err . message :String ( err ); 30} 31self . postMessage ( reply ); 32};