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
Additionally, the summarizer/writer/rewriter objects themselves have a `destroy()` method. Calling this method will:
220
+
Additionally, the summarizer/writer/rewriter objects themselves have a `destroy()` method, which is a convenience method with equivalent behavior for cases where the summarizer/writer/rewriter object has already been created.
221
221
222
-
* Abort any ongoing downloads or loading process for the model.
223
-
* Reject any ongoing one-shot operations (`summarize()`, `write()`, or `rewrite()`) with a `"AbortError"``DOMException`.
224
-
* Error any `ReadableStream`s returned by the streaming operations with a `"AbortError"``DOMException`.
222
+
Destroying a summarizer/writer/rewriter will:
223
+
224
+
* Reject any ongoing one-shot operations (`summarize()`, `write()`, or `rewrite()`).
225
+
* Error any `ReadableStream`s returned by the streaming operations.
225
226
* And, most importantly, allow the user agent to unload the machine learning models from memory. (If no other APIs are using them.)
226
227
227
-
This method is mainly used as a mechanism to free up the memory used by the language model without waiting for garbage collection, since models can be quite large.
228
+
Allowing such destruction provides a way to free up the memory used by the language model without waiting for garbage collection, since models can be quite large.
229
+
230
+
Aborting the creation process will reject the promise returned by `create()`, and will also stop signaling any ongoing download progress. (The browser may then abort the downloads, or may continue them. Either way, no further `downloadprogress` events will be fired.)
231
+
232
+
In all cases, the exception used for rejecting promises or erroring `ReadableStream`s will be an `"AbortError"``DOMException`, or the given abort reason.
0 commit comments