AICreateMonitor
(m: EventTarget) => voidA function which is passed an event target allowing it to monitor the creation progress. The monitor is normally updated when the model needs to be downloaded.
The downloadprogress event
loaded number
The number of bytes downloaded so far
total number
The total number of bytes to download
model string
The id of the model that's being downloaded
Usage
window.ai.languageModel.create({
monitor: (m) => {
m.addEventListener('downloadprogress', ({ loaded, total, model }) => {
console.log(`${model} = `${Math.round(loaded / total * 100)}`)
})
}
})window.ai.languageModel.create({
monitor: (m: EventTarget) => {
m.addEventListener('downloadprogress', ({ loaded, total, model }) => {
console.log(`${model} = `${Math.round(loaded / total * 100)}`)
})
}
})Last updated