Allow connect Flutter Web to using the local Gemini API of Chrome by making use of interoperability between Dart and JavaScript.
🚧🚩This package is proof of concept, it is not recommended to use it in a production environment and should only be used on the Web platform.
Tested on | MacOs | iOS | Windows | Android | Linux |
---|---|---|---|---|---|
Work | Yes | * | * | * | * |
Add the following lines to your project dependencies
chrome_ai_api:
git: https://github.com/yeikel16/chrome_ai_api.git
Run
flutter pub get
-
Make sure than you have install Chrome Canary in you machine and complate every steps from Built-in AI Early Preview Program setup guide.
The session status be one of the following:
- "readily": the model is available on-device and so creating will happen quickly
- "after-download": the model is not available on-device, but the device is capable, so creating the session will start the download process (which can take a while).
- "no": the model is not available for this device.
Since the Gemeni API currently has no way of knowing the download progress (issue #4) of the model, you will have to monitor your network activity. The model weighs around 1.37 GB.
-
Run example: Option A: The easy wahy is copy the URL after run the example project into Chrome Canary version. The normal version of Chrome not work beacause the Gemini API is only aviable in Chrome Dev channel (or Canary channel). Option B: Compile the example and launch a web server (for example,
python -m http.server 8000
, or by using the dhttpd package), and open the/build/web
directory and opemlocalhost:8000
in your Chrome Canary browser.
final chromeAiApi = ChromeAiApi();
You can see the full example here.
If you want to report a problem or would like to add a new feature, feel free to open an issue on GitHub. Pull requests are also welcome.