CautionThis hook relies on the experimental Window AI (Summarizer) API.
ImportantAlways call the destroy() method when the component unmounts or the summarizer is no longer needed to free up browser-side AI model resources and memory.
TipUse checkAvailability() before calling create() to handle cases where the model needs to be downloaded before use.
This hook interacts with local AI models provided by modern browsers (like Chrome's Gemini Nano integration). It allows checking if a summarization model is available, downloading it if necessary, and performing efficient, privacy-focused text summarization without sending data to a cloud server.
| Name | Type | Description |
|---|---|---|
| cancel | () => void | Aborts any ongoing summarization or creation task. |
| checkAvailability | (opts={}) => Promise<SummarizerAvailability> | Checks if the AI model is 'available', 'unavailable', or 'downloadable'. |
| create | (opts={}) => Promise<void> | Instantiates the Summarizer model with specific options (type, length, format). |
| destroy | () => void | Cleans up the model instance and releases browser resources. |
| isAbortError | (error: unknown) => boolean | Checks if the provided error is an AbortError. |
| isSupported | boolean | true if the browser supports the window.Summarizer API. |
| summarize | (text: string) => Promise<string> | Asynchronously processes the input text and returns a summary. |