Download src/startup.js from ProCreations/minicpm5-2b-webgpu: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/spaces/ProCreations/minicpm5-2b-webgpu/resolve/main/src/startup.js
- Command line
-
hf download hf://spaces/ProCreations/minicpm5-2b-webgpu/src/startup.js
-
curl -L -o startup.js https://huggingface.co/spaces/ProCreations/minicpm5-2b-webgpu/resolve/main/src/startup.js
1.17 kB
| // Runtime worker errors can be logged without rejecting loadModel(). Bound that | |
| // wait and terminate the worker on cancellation, timeout, or a reported failure. | |
| export function startRuntime(start,{signal,stop,timeoutMs=120000,onFailure=()=>{}}){ | |
| return new Promise((resolve,reject)=>{ | |
| let settled=false,started=false,timer; | |
| const cleanup=()=>{clearTimeout(timer);signal?.removeEventListener('abort',abort);onFailure(null);}; | |
| const fail=error=>{if(settled)return;settled=true;cleanup();Promise.resolve().then(stop).catch(()=>{});reject(error);}; | |
| const abort=()=>fail(signal.reason||new DOMException('Loading canceled','AbortError')); | |
| onFailure(fail); | |
| if(signal?.aborted){abort();return;} | |
| signal?.addEventListener('abort',abort,{once:true}); | |
| timer=setTimeout(()=>fail(new Error('GPU setup did not finish within two minutes. Your downloaded weights are still available in this tab; retry setup or choose a smaller context.')),timeoutMs); | |
| Promise.resolve().then(()=>{if(settled)return;started=true;return start();}).then(value=>{if(settled){if(started)Promise.resolve().then(stop).catch(()=>{});return;}settled=true;cleanup();resolve(value);},fail); | |
| }); | |
| } | |