-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow patching selectively window.ai even when window.ai natively available #4
Comments
In terms of individually choosing the APIs, this is a transient thing until Chrome takes them out of the origin trial. I'm hoping that they'll reach some level of stability soon, but I think this is something to come back and look at depending on what the final set of APIs looks like. What I have added, is a setting in the extensions settings to always override There should already be enough stuff exposed from a developer standpoint to pick and choose which API to use.
This means a developer should be able to do something like this to pick and choose which API's they want to use: function getBrowserAI () {
// Always get the browsers AI, regardless of the user's preference in AiBrow
const ai = window.ai && window.ai.aibrow === true
? window.ai.aibrow.browserAI
: window.ai
if (!window.ai) {
// Eventually this check wont be needed as all browsers support window.ai
throw new Error('Your browser doesn\'t support window.ai')
}
return ai
}
function getAiBrow () {
if (!window.aibrow) {
// Send user to the download page
throw new Error('AiBrow is not installed')
}
return window.aibrow
}
const browserAI = getBrowserAI()
const aibrowAI = getAiBrow()
// Both can be then used interchangeably as needed
await browserAI.summarizer.create()
await aibrowAI.summarizer.create()
// Or you can fallback as needed
const writer = browserAI.writer || aibrowAI.writer || throw new Error('Writer is not supported')
await writer.create() |
Thanks for sharing ideas how to pick and choose specific feature from each AI implementation. I will try this approach.
Is this override feature part if 1.2.0 or 1.2.1 ? I cannot find in 1.2.0 I was trying yesterday, to override globally within app, specific features but I understand they are r |
It's 1.2.1. We submitted it to the Chrome store yesterday but are still awaiting approval and publish :) |
Version 1.2.1 is now published live on the Chrome store. |
I'm guessing from the logs you were toggling it on and off and then trying the setting on the page. After changing the setting, you'll need to reload any tabs where you want to test it because the content-scripts and runtime's already setup with the setting that were available on navigation |
Other behaviour I noted is, when I have |
Thanks, I've tightened this up so it should be more reliable. It will go out in a release next week - version 1.2.2 |
b.t.w |
lets say browser natively support
window.ai.writer
,window.ai.rewriter
,window.ai.summarizer
etc because either user enabled them viachrome://flags/
or website addedorigin-trials
for them, today aibrow only polyfill all features or nothing.It would be nice if developers or users can be able to choose selective models from aibrow and others from native chrome AI models. for example I like to use only
window.ai.writer
,window.ai.rewriter
polyfilled by aibrow and rest from browser native models.Ask:
nativeAI
vsaibrow
for writer, rewriter, summarizer, languageModel, languageDetector and translator usecases individually via Extensions settings pagenativeAI
vsaibrow
for writer, rewriter, summarizer, languageModel, languageDetector and translator usecases individually via APIThe text was updated successfully, but these errors were encountered: