This repository contains tools and examples for experimenting with Gemini Nano in the Chrome browser. As of July 16, 2024, this project requires Chrome Dev or Chrome Canary (version 127 or higher).
- Install Chrome Dev or Chrome Canary (version 127 or higher).
- Enable the following Chrome flags:
- Set
chrome://flags/#prompt-api-for-gemini-nano
to "Enabled" - Set
chrome://flags/#optimization-guide-on-device-model
to "Enabled BypassPrefRequirement"
- Set
- Reload the browser.
- Go to
chrome://components
and click "Check for Update" on "Optimization Guide On Device Model".
Note: It may take some time after the initial installation for the model to download and become available on your device.
To verify that everything is working correctly:
- Open the browser console:
- Windows/Linux:
Shift + CTRL + J
- macOS:
Option + ⌘ + J
- Windows/Linux:
- Run the following code:
await ai.canCreateTextSession()
- You should see:
'readily'
- If you see other ouput you can navigate to
chrome://components
, look for "Optimization Guide on Device Mode" and click "Check for update". It might take some time for browser to download and enable the model, I left the browser for around an hour to do it's thing ;).
nano.html
: Simple page to interact with the Gemini Nano modelnano-stream.html
: Page to interact with the model using streaming responsesnano-explain/
: Chrome extension for quick explanations using Gemini Nano
You can use nano.html
or nano-stream.html
to start interacting with the model:
- Download the HTML file to your local drive.
- Open it with Chrome (version 127 or higher).
- These pages work offline, allowing you to interact with Gemini Nano locally.
See the Nano Explain Extension section for installation instructions.
- Clone this repository or download it as a ZIP file.
- Open Chrome and go to
chrome://extensions/
- Enable "Developer mode" in the top right corner.
- Click "Load unpacked" and select the
nano-explain
directory from this repository.
- Select any text on a webpage.
- Right-click to open the context menu.
- Choose "Nano Explain" from the context menu.
- An alert will appear with a simplified explanation of the selected text.
Feel free to modify the extension code or HTML files to suit your needs. The main files are:
nano-explain/background.js
: Contains the core logic for the extension.nano-explain/manifest.json
: Defines the extension's properties and permissions.nano.html
andnano-stream.html
: Provide interfaces for interacting with Gemini Nano.
For a visual guide on setting up and using this project, check out our YouTube tutorial: [Placeholder for link]
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the terms of the Apache License 2.0. See the LICENSE
file for more details.