()
| 22 | } |
| 23 | |
| 24 | async function loadWebLLMModule() { |
| 25 | if (modulePromise) return modulePromise; |
| 26 | |
| 27 | modulePromise = (async () => { |
| 28 | const globalModule = resolveWebLLMGlobal(); |
| 29 | if (globalModule) return globalModule; |
| 30 | if (loaderOverride) { |
| 31 | const loaded = await loaderOverride(); |
| 32 | return loaded?.default || loaded; |
| 33 | } |
| 34 | if (!modulePath) { |
| 35 | throw new Error('WebLLM module path is not configured.'); |
| 36 | } |
| 37 | const baseUrl = typeof document !== 'undefined' ? (document.baseURI || window.location.href) : import.meta.url; |
| 38 | const moduleUrl = new URL(modulePath, baseUrl).toString(); |
| 39 | const imported = await import(moduleUrl); |
| 40 | return imported?.default || imported; |
| 41 | })(); |
| 42 | |
| 43 | return modulePromise; |
| 44 | } |
| 45 | |
| 46 | function extractModelList(webllmModule) { |
| 47 | if (!webllmModule) return []; |
no test coverage detected