Skip to content

Commit

Permalink
small clarification
Browse files Browse the repository at this point in the history
  • Loading branch information
ngxson committed Dec 1, 2024
1 parent 658fafd commit 88a9cdb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

/src/multi-thread
/src/single-thread
/src/workers-code/generated.ts

*.md
*.mdx
Expand Down
10 changes: 10 additions & 0 deletions guides/intro-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ await model.remove();
const blobs = await model.open();
const wllama = new Wllama(CONFIG_PATHS);
await wllama.loadModel(blobs);

// Alternatively, you can also pass directly model URL like in v1.x
// This will automatically download the model to cache
await wllama.loadModelFromUrl('https://example.com/model.gguf');
```

Key features of `ModelManager`:
Expand Down Expand Up @@ -94,3 +98,9 @@ const wllama = new Wllama(CONFIG_PATHS, {
As mentioned earlier, some options are moved to `Wllama` constructor, including:
- `parallelDownloads`
- `allowOffline`

### Other changes

- `Wllama.downloadModel` is removed. Please use `ModelManager.downloadModel` instead
- Added `CacheManager.download` function. You may need to implement it if you're using your own implementation of `CacheManager`
- `loadModelFromUrl` won't check if cached model is up-to-date. You may need to manually call `Model.refresh()` to re-download the model.
2 changes: 1 addition & 1 deletion src/cache-manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DownloadProgressCallback } from './model-manager';
import { createWorker, isSafari, isSafariMobile } from './utils';
import { createWorker, isSafariMobile } from './utils';
import { OPFS_UTILS_WORKER_CODE } from './workers-code/generated';

const PREFIX_METADATA = '__metadata__';
Expand Down
1 change: 1 addition & 0 deletions src/model-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ test('download with abort signal', async () => {
setTimeout(() => controller.abort(), 10);
await downloadPromise.catch(console.error);
await expect(downloadPromise).rejects.toThrow('aborted');
expect((await manager.getModels()).length).toBe(0);
});

test('model validation status for new model', async () => {
Expand Down
Loading

0 comments on commit 88a9cdb

Please sign in to comment.