In v2.0, the Wllama constructor has been simplified. You no longer need to provide .js files in the configuration paths; you only need to specify the *.wasm files for each thread configuration.
Standard Configuration
Provide a mapping of thread types to their corresponding .wasm files:
const CONFIG_PATHS = {
'single-thread/wllama.wasm': '../../esm/single-thread/wllama.wasm',
'multi-thread/wllama.wasm' : '../../esm/multi-thread/wllama.wasm',
};
const wllama = new Wllama(CONFIG_PATHS);
Using CDN (Not recommended for production)
If you cannot embed WASM files in your project, you can use the provided CDN helper:
import WasmFromCDN from '@wllama/wllama/esm/wasm-from-cdn.js';
const wllama = new Wllama(WasmFromCDN);
Constructor Options
The constructor accepts an optional second parameter of type WllamaConfig. Note that many options previously passed to loadModelFromUrl (like parallelDownloads and allowOffline) have moved here.
const CONFIG_PATHS = {
'single-thread/wllama.wasm': '../../esm/single-thread/wllama.wasm',
'multi-thread/wllama.wasm' : '../../esm/multi-thread/wllama.wasm',
};
const wllama = new Wllama(CONFIG_PATHS, {
parallelDownloads: 5, // maximum concurrent downloads
allowOffline: false, // whether to allow offline model loading
});