Did something change in prompt API?

252 views
Skip to first unread message

Vinayak Nigam

unread,
Nov 29, 2024, 11:33:26 PM11/29/24
to Chrome Built-in AI Early Preview Program Discussions
I have been working with prompt API for a the last few days and it was working perfectly but today it is giving an error:
```
Error: TypeError: Cannot read properties of undefined (reading 'languageModel')
Context
popup/chat.html
```

and this is the concerned code where this error is coming:
```
 const { available } =
        await chrome.aiOriginTrial.languageModel.capabilities();
      if (available !== "readily") {
        throw new Error("Gemini Nano model is not readily available");
      }

      const session = await chrome.aiOriginTrial.languageModel.create({
        systemPrompt: "You are a helpful and friendly assistant.",
        topK: 6,
        temperature: 1,
      });
```

I did not change any code since yesterday and I checked from the 
https://developer.chrome.com/docs/extensions/ai/prompt-api#streaming_output and its the same code Can anyone tell me what I am doing wrong? Thank you for answering

Vinayak Nigam

unread,
Nov 29, 2024, 11:53:58 PM11/29/24
to Chrome Built-in AI Early Preview Program Discussions, Vinayak Nigam
So i changed the code and it is working:
const { available } =
        // @ts-ignore
        await self.ai.languageModel.capabilities();
      if (available !== "readily") {
        throw new Error("Gemini Nano model is not readily available");
      }

      // @ts-ignore
      const session = await self.ai.languageModel.create({
        systemPrompt: "You are a helpful and friendly assistant.",
        topK: 6,
        temperature: 1,
      });
without even the origin Trial, is this intended?
and is using originTrial compulsory for this challenge?

Thomas Steiner

unread,
Nov 30, 2024, 1:10:50 AM11/30/24
to Vinayak Nigam, Chrome Built-in AI Early Preview Program Discussions
Hi Vinayak,

If you're accessing the Prompt API from an extension context, you need to use the chrome.aiOriginTrial.* entry point. Else, you need to use self.ai.*. Both give access to the same model, but from different contexts, Chrome Extension or web app directly. Only the Chrome Extension context can be used by real users if you submit your extension to the Chrome Web Store with an origin token. All other use is purely local on your own browser. 

Cheers,
Tom

--
You received this message because you are subscribed to the Google Groups "Chrome Built-in AI Early Preview Program Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chrome-ai-dev-previe...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/chrome-ai-dev-preview-discuss/b0b2d6c3-104a-44e9-b830-c5ece006d233n%40chromium.org.

Vinayak Nigam

unread,
Nov 30, 2024, 1:49:22 AM11/30/24
to Chrome Built-in AI Early Preview Program Discussions, Thomas Steiner, Chrome Built-in AI Early Preview Program Discussions, Vinayak Nigam
Hey Thomas, 
Thanks for the quick reply
I am making an extension but the thing is I'm trying to use "chrome.aiOriginTrial." but it is not working and showing that:

```
Error: TypeError: Cannot read properties of undefined (reading 'languageModel')
```

It was perfectly working yesterday but now it is not working.

Thomas Steiner

unread,
Nov 30, 2024, 2:03:15 AM11/30/24
to Vinayak Nigam, Chrome Built-in AI Early Preview Program Discussions, Thomas Steiner
Most likely the model got deleted again after having been downloaded before because you ran out of free disk space (it requires 22+GB).
Message has been deleted

Thomas Steiner

unread,
Nov 30, 2024, 4:28:40 AM11/30/24
to Vinayak Nigam, Sebastian Benz, Chrome Built-in AI Early Preview Program Discussions, Thomas Steiner
Might be a bug in Canary. Maybe wait for the next version. @Sebastian Benz is the extension expert and might know more. 

On Sat, Nov 30, 2024, 09:48 Vinayak Nigam <myself....@gmail.com> wrote:
I also suspected that at first but I have around 66 GB free on disk and also I can easily use prompt API here on this website https://chrome.dev/web-ai-demos/prompt-api-playground/. So the browser(dev one) supports it and can run it. it's just the extension where the problem is happening. Thats why Im very confused on what is happening.

Sebastian Benz

unread,
Nov 30, 2024, 4:41:43 AM11/30/24
to Thomas Steiner, Vinayak Nigam, Chrome Built-in AI Early Preview Program Discussions
Hey Vinayak,

did you define a fixed key in your manifest.json? Otherwise it's generated automatically based on the extension's path on the file system. If you move the location, it gets a new key (which might've happened in your case) and you need to get a new origin trial token.

Sebastian

Dr. Sebastian Benz

Developer Relations Engineer


Google Germany GmbH

Erika-Mann-Straße 33

80636 München


Geschäftsführer: Paul Manicle, Liana Sebastian

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg


Diese E-Mail ist vertraulich. Falls Sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde. 

     

This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.


Thomas Steiner

unread,
Nov 30, 2024, 4:47:30 AM11/30/24
to Sebastian Benz, Thomas Steiner, Vinayak Nigam, Chrome Built-in AI Early Preview Program Discussions

Vinayak Nigam

unread,
Nov 30, 2024, 11:51:36 AM11/30/24
to Chrome Built-in AI Early Preview Program Discussions, Sebastian Benz, Vinayak Nigam, Chrome Built-in AI Early Preview Program Discussions
Hey Sebastian,
Although I did double check if the extension ID is the same on the Origin trial page as my actual one(It was). I even removed my registration and got a new key and pasted it but still it didn't work. I did explore for key in the manifest from here and tried following the steps but it said to upload my extension `.zip ` on Chrome Web Store Developer but To do that I have to pay $5 or maybe I'm doing something wrong? idk I'm very confused
Screenshot 2024-11-30 221457.png

Thomas Steiner

unread,
Nov 30, 2024, 5:59:37 PM11/30/24
to Vinayak Nigam, Chrome Built-in AI Early Preview Program Discussions, Sebastian Benz
Yes, to upload an extension (even without publishing) you need to be a developer, which requires a one-time $5 payment. Sorry, I don't think there's a way around this. 

Cheers,
Tom

Vinayak Nigam

unread,
Dec 1, 2024, 12:26:58 AM12/1/24
to Chrome Built-in AI Early Preview Program Discussions, Thomas Steiner, Chrome Built-in AI Early Preview Program Discussions, Sebastian Benz, Vinayak Nigam

Hey Sebastian and Thomas,
I registered on the Chrome Developer Dashboard and indeed the prompt API is working now :)
Thank you so much to both of you for your quick responses and resolution of the issue

Cheers,
Vinayak

Thomas Steiner

unread,
Dec 1, 2024, 12:30:43 AM12/1/24
to Vinayak Nigam, Chrome Built-in AI Early Preview Program Discussions, Thomas Steiner, Sebastian Benz
Glad you got it working!
Reply all
Reply to author
Forward
0 new messages