Prompt API
The destroy() method of the LanguageModel interface releases the resources assigned to the LanguageModel instance it is called on and stops any further activity on it. Any ongoing and subsequent method calls made on the LanguageModel will reject with an AbortError.
It makes sense to destroy LanguageModel objects if they are no longer being used, as they tie up significant resources in their handling.
Syntax
destroy()
Parameters
None.
Return value
None (undefined).
Exceptions
NotAllowedErrorDOMException- : Thrown if usage of the method is blocked by a Permissions-Policy/language-model Permissions-Policy.
Examples
Basic destroy() usage
const session = await LanguageModel.create({
expectedInputs: [{ type: "text", languages: ["en"] }],
expectedOutputs: [{ type: "text", languages: ["en"] }],
});
// ...
session.destroy();
See also Using the Prompt API > Canceling operations and destroying instances.
Specifications
Browser compatibility
See also
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
