API updates on Chrome on-device AI (Nov 2024)
This article is an update for the previous articles below:
https://calvin.my/posts/on-device-generative-ai-with-gemini-nano
https://calvin.my/posts/on-device-generative-ai-with-gemini-nano-part-2
https://calvin.my/posts/api-updates-on-chrome-on-device-ai
Updates in November 2024
- Package Name "ai.assistant" is changed to "ai.languageModel". This change avoids confusion with Google Assistant.
- The API now supports more than 1024 input tokens.
Updated sample code
async askAi(prompt) {
const {available, defaultTopK } = await ai.languageModel.capabilities();
if (available !== "no") {
const systemPrompt = "You are a helpful assistant.";
const session = await ai.languageModel.create({
systemPrompt: systemPrompt,
temperature: 0,
topK: defaultTopK
});
const stream = session.promptStreaming(prompt);
for await (const chunk of stream) {
this.outputTarget.textContent = chunk;
}
session.destroy();
} else {
this.outputTarget.textContent = "Error! On-device AI is not available on your browser."
}
}
AI Summary
gpt-4o-2024-08-06
2024-11-30 17:29:18
In November 2024, Chrome's on-device AI updates include changing the package name from "ai.assistant" to "ai.languageModel" to prevent confusion with Google Assistant. Additionally, the API now supports more than 1024 input tokens, enhancing its capabilities.
Chrome On-device AI
2024-12-06 18:28:07
Share Article