You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Cache] Support IndexedDB, add useIndexedDBCache in AppConfig (#352)
Add `AppConfig.useIndexedDBCache` to optionally use IndexedDBCache
rather than the default Cache API.
Also add `examples/cache-usage` to demonstrate the usage of the two
caches and cache utils such as deleting a model from cache.
---------
Co-authored-by: Charlie Ruan <[email protected]>
Copy file name to clipboardExpand all lines: examples/README.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,9 @@ These examples demonstrate various capabilities via WebLLM's OpenAI-like API.
27
27
28
28
#### Others
29
29
-[logit-processor](logit-processor): while `logit_bias` is supported, we additionally support stateful logit processing where users can specify their own rules. We also expose low-level API `forwardTokensAndSample()`.
30
+
-[cache-usage](cache-usage): demonstrates how WebLLM supports both the [Cache API](https://developer.mozilla.org/en-US/docs/Web/API/Cache) and [IndexedDB cache](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API), and
31
+
users can pick with `appConfig.useIndexedDBCache`. Also demonstrates various cache utils such as checking
32
+
whether a model is cached, deleting a model's weights from cache, deleting a model library wasm from cache, etc.
WebLLM supports both the Cache API and IndexedDB, which you can specify via `AppConfig.useIndexedDBCache`.
4
+
This folder provides an example on how Cache and IndexedDB Cache are used in WebLLM. We also
5
+
demonstrate the utility cache functions such as deleting models, checking if models are in cache, etc.
6
+
7
+
For more information about the two caches, see: https://developer.mozilla.org/en-US/docs/Web/API/Storage_API/Storage_quotas_and_eviction_criteria#what_technologies_store_data_in_the_browser.
8
+
9
+
To inspect the downloaded artifacts in your browser, open up developer console, go to application,
10
+
and you will find the artifacts under either `IndexedDB` or `Cache storage`.
11
+
12
+
13
+
To run the exapmle, you can do the following steps under this folder
14
+
15
+
```bash
16
+
npm install
17
+
npm start
18
+
```
19
+
20
+
Note if you would like to hack WebLLM core package.
21
+
You can change web-llm dependencies as `"file:../.."`, and follow the build from source
22
+
instruction in the project to build webllm locally. This option is only recommended
0 commit comments