-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Gemini API sample * Simplify configuration and fix response formatting * Update wording for gemini nano sample
- Loading branch information
1 parent
2dd50d5
commit 005f7ca
Showing
15 changed files
with
595 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ node_modules | |
# Temporary directory for debugging extension samples | ||
_debug | ||
_metadata | ||
*.swp # vim temp files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# On-device AI with Gemini Nano | ||
|
||
This sample demonstrates how to use the Gemini Cloud API in a Chrome Extension. | ||
|
||
## Overview | ||
|
||
The extension provides a chat interface for the Gemini API. To learn more about the API head over to [https://ai.google.dev/](https://ai.google.dev/). | ||
|
||
## Running this extension | ||
|
||
1. Clone this repository. | ||
2. Download the Gemini API client by running: | ||
```sh | ||
npm install | ||
``` | ||
3. [Retrieve an API key](https://ai.google.dev/gemini-api/docs/api-key) and update [functional-samples/ai.gemini-in-the-cloud/sidepanel/index.js](functional-samples/ai.gemini-in-the-cloud/sidepanel/index.js) (only for testing). | ||
4. Compile the JS bundle for the sidepanel implementation by running: | ||
```sh | ||
npm run build | ||
``` | ||
5. Load this directory in Chrome as an [unpacked extension](https://developer.chrome.com/docs/extensions/mv3/getstarted/development-basics/#load-unpacked). | ||
6. Click the extension icon. | ||
7. Interact with the prompt API in the sidebar. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
chrome.sidePanel | ||
.setPanelBehavior({ openPanelOnActionClick: true }) | ||
.catch((error) => console.error(error)); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "Google Gemini Demo", | ||
"version": "0.1", | ||
"manifest_version": 3, | ||
"description": "Try the Gemini Models.", | ||
"background": { | ||
"service_worker": "background.js" | ||
}, | ||
"permissions": ["sidePanel"], | ||
"side_panel": { | ||
"default_path": "sidepanel/index.html" | ||
}, | ||
"action": { | ||
"default_icon": { | ||
"16": "images/icon16.png", | ||
"32": "images/icon32.png", | ||
"48": "images/icon48.png", | ||
"128": "images/icon128.png" | ||
}, | ||
"default_title": "Open Chat Interface" | ||
} | ||
} |
288 changes: 288 additions & 0 deletions
288
functional-samples/ai.gemini-in-the-cloud/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "Chrome Extensions Gemini Demo", | ||
"version": "1.0", | ||
"scripts": { | ||
"build": "rollup sidepanel/index.js --file dist/sidepanel.bundle.js --format iife" | ||
}, | ||
"private": true, | ||
"devDependencies": { | ||
"@google/generative-ai": "0.15.0", | ||
"rollup": "4.19.0" | ||
} | ||
} |
Oops, something went wrong.