Spaces:
Running
Running
Update index.js
Browse files
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();
|