Skip to content

Instantly share code, notes, and snippets.

@thangman22
Created August 29, 2025 03:22
Show Gist options
  • Select an option

  • Save thangman22/ae50cfd3443f3e2b824a54e0ff97b693 to your computer and use it in GitHub Desktop.

Select an option

Save thangman22/ae50cfd3443f3e2b824a54e0ff97b693 to your computer and use it in GitHub Desktop.
// Check availability first
const availability = await LanguageModel.availability({
})
// Create session with monitoring
const session = await LanguageModel.create({
temperature: 0.7,
monitor(m) {
m.addEventListener('downloadprogress', (e) => {
console.log(`Downloaded ${e.loaded * 100}%`)
})
}
})
// Use regular API for complete response
const result = await session.prompt(prompt)
// Clean up when done
session.destroy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment