AiBrow
  • Welcome
  • AiBrow web API
    • Getting started
    • Feature comparison
  • AiBrow Extension
    • Getting started
    • Web polyfill
    • Helping users install the AiBrow extension
    • Remove the on-device helper or models
  • Examples
    • CoreModel API
    • Embedding API
    • LanguageDetector API
    • LanguageModel API
    • Rewriter API
    • Summarizer API
    • Translator API
    • Writer API
    • Using different models
    • Model download feedback
    • Getting JSON output
  • API Reference
    • AI
      • AiBrowAI
      • BrowserAI
      • WebAI
    • AiBrow
      • CoreModelFactory
        • CoreModel
        • CoreModelCapabilities
      • EmbeddingFactory
        • Embedding
        • EmbeddingCapabilities
      • LanguageDetectorFactory
        • LanguageDetector
        • LanguageDectectorCapabilities
      • LanguageModelFactory
        • LanguageModel
        • LanguageModelCapabilities
      • RewriterFactory
        • Rewriter
        • RewriterCapabilities
      • SummarizerFactory
        • Summarizer
        • SummarizerCapabilities
      • TranslatorFactory
        • Translator
        • TranslatorCapabilities
      • WriterFactory
        • Writer
        • WriterCapabilities
    • Types
      • AICapabilityAvailability
      • AICapabilityGpuEngine
      • AICreateMonitor
      • AILanguageDetectorDetectResult
      • AIRewriterFormat
      • AIRewriterLength
      • AIRewriterTone
      • AISummarizerFormat
      • AISummarizerLength
      • AISummarizerType
      • AIWriterFormat
      • AIWriterLength
      • AIWriterTone
      • AIModelDtype
    • Models
Powered by GitBook
On this page
  • The downloadprogress event
  • Usage
  1. API Reference
  2. Types

AICreateMonitor

(m: EventTarget) => void

A 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)}`)
    })
  }
})
PreviousAICapabilityGpuEngineNextAILanguageDetectorDetectResult

Last updated 6 months ago