Add Chrome AI as a Provider for our text generation Features #819
+448
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
Chrome is experimenting with adding built-in AI to their browser. The model they include is fairly lightweight and doesn't give quite as good results as larger models, but since it's built-in, there's no cost and all data stays private (also allows easy testing of some AI features without having to sign up for something).
At the moment, this feature is still being worked on and is only available in Chrome Canary, so there's a chance this never releases publicly or it may change quite a bit before the public release.
This PR integrates this browser AI API into our Title Generation, Excerpt Generation and Content Resizing Features. Because this API is 100% javascript, the way we integrate is a little unique compared to our other Providers:
How to test the Change
chrome://flags/#optimization-guide-on-device-model
and select Enabled BypassPerfRequirementchrome://flags/#prompt-api-for-gemini-nano
and select Enabled(await ai.languageModel.capabilities()).available;
in the consoleawait ai.languageModel.create();
in the console. This will likely fail but it’s intendedchrome://components
Optimization Guide On Device Model
present with a version greater or equal to 2024.5.21.1031. If there is no version listed, click on Check for update to force the download(await ai.languageModel.capabilities()).available;
in the console. If this returns “readily”, then you are all setChangelog Entry
Credits
Props @dkotter, @jeffpaul, @iamdharmesh, @faisal-alvi
Checklist: