by lolinder · 2y ago · 0 comments
Leave it to Vercel to announce `window.ai` on Google's behalf by showing off their own abstraction but not the actual Chrome API.
Here's a blog post from a few days ago that shows how the actual `window.ai` API works [0]. The code is extremely simple and really shouldn't need a wrapper:
const model = await window.ai.createTextSession();
const result = await model.prompt("What do you think is the meaning of life?");
[0] https://afficone.com/blog/window-ai-new-chrome-feature-api/Overview: https://developer.chrome.com/docs/ai/built-in
Sign-up: https://docs.google.com/forms/d/e/1FAIpQLSfZXeiwj9KO9jMctffH...
Yes, wrapping stuff to give a different developer experience contributes to new ideas, and can evolve into something more.
It’s nice insofar with very little abstraction, runtime, and bundle size overhead, you can easily switch between models without having to learn a new API.