Commit b2c8f90
wasm: streaming tokens + IndexedDB model cache
Two UX improvements:
1. **Streaming**: switched from quant_ask (returns full string) to
quant_generate with on_token callback. Each token is sent to JS
via js_on_token as it's generated, so the user sees text appear
in real time instead of waiting for the full response.
2. **Model caching**: downloaded GGUF is stored in IndexedDB after
first download. On page refresh, the "Try Demo" button shows
"Load cached SmolLM2-135M (instant)" and loads from local storage
instead of re-downloading 135 MB from HuggingFace.
Flow: first visit → download → cache → load
refresh → check cache → instant load
NOTE: streaming requires WASM rebuild (emcc) to take effect — the
current quant.wasm binary still uses the old quant_ask path. The JS
side is ready; the C change will apply on next `bash wasm/build.sh`.
The IndexedDB caching is pure JS and works immediately.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 6089212 commit b2c8f90
2 files changed
+72
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
138 | 172 | | |
139 | 173 | | |
140 | 174 | | |
| |||
164 | 198 | | |
165 | 199 | | |
166 | 200 | | |
167 | | - | |
| 201 | + | |
168 | 202 | | |
169 | 203 | | |
170 | 204 | | |
171 | 205 | | |
172 | | - | |
173 | | - | |
174 | 206 | | |
175 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
176 | 222 | | |
177 | 223 | | |
178 | 224 | | |
| |||
191 | 237 | | |
192 | 238 | | |
193 | 239 | | |
194 | | - | |
| 240 | + | |
195 | 241 | | |
196 | 242 | | |
197 | 243 | | |
198 | | - | |
199 | 244 | | |
200 | 245 | | |
201 | 246 | | |
202 | 247 | | |
203 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
204 | 253 | | |
205 | 254 | | |
206 | 255 | | |
| |||
210 | 259 | | |
211 | 260 | | |
212 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
213 | 274 | | |
214 | 275 | | |
215 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
118 | | - | |
| 116 | + | |
| 117 | + | |
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 121 | + | |
126 | 122 | | |
127 | | - | |
128 | 123 | | |
129 | | - | |
130 | 124 | | |
131 | | - | |
| 125 | + | |
| 126 | + | |
132 | 127 | | |
133 | 128 | | |
134 | 129 | | |
| |||
0 commit comments