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
Copy file name to clipboardExpand all lines: README.md
+13-5Lines changed: 13 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -179,15 +179,23 @@ or by calling `destroy()` on the session:
179
179
stopButton.onclick= () =>session.destroy();
180
180
```
181
181
182
-
Destroying a session will:
182
+
Destroying a session will have the following effects:
183
183
184
-
*Abort any ongoing downloads or loading process for the language model.
184
+
*If done before the promise returned by `create()` is settled:
185
185
186
-
* Reject any ongoing calls to `prompt()` with an `"AbortError"``DOMException` (or the given abort reason).
186
+
* Stop signaling any ongoing download progress for the language model. (The browser may also abort the download, or may continue it. Either way, no further `downloadprogress` events will fire.)
187
187
188
-
* Error any `ReadableStream`s returned by `promptStreaming()`with an `"AbortError"``DOMException` (or the given abort reason).
188
+
* Reject the `create()`promise.
189
189
190
-
* And, most importantly, allow the user agent to unload the language model from memory. (If no other APIs or sessions are using it.)
190
+
* Otherwise:
191
+
192
+
* Reject any ongoing calls to `prompt()`.
193
+
194
+
* Error any `ReadableStream`s returned by `promptStreaming()`.
195
+
196
+
* Most importantly, destroying the session allows the user agent to unload the language model from memory, if no other APIs or sessions are using it.
197
+
198
+
In all cases the exception used for rejecting promises or erroring `ReadableStream`s will be an `"AbortError"``DOMException`, or the given abort reason.
191
199
192
200
The ability to manually destroy a session allows applications to free up memory without waiting for garbage collection, which can be useful since language models can be quite large.
0 commit comments