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
downloadprogress eventloaded number
numberThe number of bytes downloaded so far
total number
numberThe total number of bytes to download
model string
stringThe 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