Open obovoid opened 2 weeks ago
I have the exact problem with DEV 130.0.6669.2, it was working on 127~129.
I used your code to try, but the result showed undefined.
I have the exact problem with DEV 130.0.6669.2, it was working on 127~129.
I used your code to try, but the result showed undefined.
It's only undefined because you are just defining the functions. To use the AI with my code you would need to define the model:
const model = await createAISession(); await model.prompt("Your request");
I had to manually check for updates and this sealed the deal ... the state was "after-download"
in my case which gave me a good enough hint to check that thing ... I wonder if components will get a "check updates on IDLE" at some point so that these keep being updated without manual intervention from the users.
@obovoid out of curiosity ... where did you find these details and where could we find more details around the API? 🤔 Thanks
FWIWI this is how I would instead provide a helper ... not too different but at least it provides a solution in non-updated cases 😇
async function createAISession() {
try {
const { ai: { assistant } } = globalThis;
if ((await assistant.capabilities()).available === 'readily')
return await assistant.create();
throw new Error(`chrome://components/ "Optimization Guide On Device Model" update required`);
}
catch (error) {
throw error;
}
}
Only for Canary Version: 130.0.6679.0 or above (check chrome://version)
As the title says, createTextSession is no longer valid in the newest canary version.
The new way to create a session is now:
To get the ready state of the ai you would do:
and lastly, before doing anything with the ai check if ai is a property to avoid errors:
A full example of how I would recommend the AI features here:
with this, the AI should be fully initialized and usable