tylermullen commited on
Commit
f37c00e
·
verified ·
1 Parent(s): 9772eed

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +6 -0
index.js CHANGED
@@ -129,6 +129,12 @@ function requireSignIn() {
129
  * cache.
130
  */
131
  async function pipeStreamAndReportProgress(readableStream, writableStream) {
 
 
 
 
 
 
132
  // Effectively "await responseStream.pipeTo(writeStream)", but with progress
133
  // reporting.
134
  const reader = readableStream.getReader();
 
129
  * cache.
130
  */
131
  async function pipeStreamAndReportProgress(readableStream, writableStream) {
132
+ // Alert the user if browser expects caching to run out of memory.
133
+ const cacheEstimate = await navigator.storage.estimate();
134
+ if (modelSize > (cacheEstimate.quota - cacheEstimate.usage)) {
135
+ alert(`The browser reports it does not have enough space in cache for this model. Ensure you are not running in incognito mode, or else try to free up some space. Model size: ${modelSize}. Cache quota: ${cacheEstimate.quota}. Cache usage: ${cacheEstimate.usage}.`);
136
+ }
137
+
138
  // Effectively "await responseStream.pipeTo(writeStream)", but with progress
139
  // reporting.
140
  const reader = readableStream.getReader();