Skip to content

Commit 2f056ff

Browse files
Update Geminin nano samples (#1347)
* Link to latest articles * Add systemprompt to prompt sample to provide better guidance on simple prompts such as 'hello'. * Limit default topK to 3 (the default is currently set too high, this will change). * Fix setup instructions in the readmes.
1 parent fc7c4b3 commit 2f056ff

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# On-device Summarization with Gemini Nano
22

3-
This sample demonstrates how to use the experimental Summarization API in Chrome. To learn more about the API and how to sign-up for the preview, head over to [Built-in AI on developer.chrome.com](https://developer.chrome.com/docs/ai/built-in).
3+
This sample demonstrates how to use the experimental Summarization API in Chrome. To learn more about the API and how to sign-up for the preview, head over to the [summarizer guide on developer.chrome.com](https://developer.chrome.com/docs/ai/summarizer-api).
44

55
## Overview
66

@@ -9,8 +9,12 @@ The extension summarizes the content of the currently open tab. It uses Mozilla'
99
## Running this extension
1010

1111
1. Clone this repository
12-
2. Run `npm install` in this folder to install all dependencies.
13-
3. Run `npm run build` to bundle the content script .
14-
4. Load the 'dist' directory in Chrome as an [unpacked extension](https://developer.chrome.com/docs/extensions/mv3/getstarted/development-basics/#load-unpacked).
15-
5. Click the extension icon to open the summary side panel.
16-
6. Open any web page, the page's content summary will automatically be displayed in the side panel.
12+
1. Run `npm install` in this folder to install all dependencies.
13+
1. Run `npm run build` to build the extension.
14+
1. Load the newly created `dist` directory in Chrome as an [unpacked extension](https://developer.chrome.com/docs/extensions/get-started/tutorial/hello-world#load-unpacked).
15+
1. Click the extension icon to open the summary side panel.
16+
1. Open any web page, the page's content summary will automatically be displayed in the side panel.
17+
18+
## Creating your own extension
19+
20+
If you use this sample as the foundation for your own extension, be sure to update the `"trial_tokens"` field [with your own origin trial token](https://developer.chrome.com/docs/web-platform/origin-trials#extensions) and to remove the `"key"` field in `manifest.json`.
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# On-device AI with Gemini Nano
22

3-
This sample demonstrates how to use the experimental Gemini Nano API available in the context of an origin trial in Chrome with Chrome Extensions. To learn more about the API and how to sign-up for the origin trial, head over to [Built-in AI on developer.chrome.com](https://developer.chrome.com/docs/ai/built-in).
3+
This sample demonstrates how to use the experimental Gemini Nano API available in the context of an origin trial in Chrome with Chrome Extensions. To learn more about the API and how to sign-up for the origin trial, head over to [Built-in AI on developer.chrome.com](https://developer.chrome.com/docs/extensions/ai/prompt-api).
44

55
## Overview
66

@@ -9,13 +9,12 @@ The extension provides a chat interface using the Prompt API with Chrome's built
99
## Running this extension
1010

1111
1. Clone this repository.
12-
1. Launch Chrome with the following flag, which makes sure the origin trial token in `manifest.json` is accepted by the browser. This won't be necessary once the origin trial is live.
13-
14-
`--origin-trial-public-key=dRCs+TocuKkocNKa0AtZ4awrt9XKH2SQCI6o4FY6BNA=`
15-
1. Load this directory in Chrome as an [unpacked extension](https://developer.chrome.com/docs/extensions/mv3/getstarted/development-basics/#load-unpacked).
12+
1. Run `npm install` in the project directory.
13+
1. Run `npm run build` in the project directory to build the extension.
14+
1. Load the newly created `dist` directory in Chrome as an [unpacked extension](https://developer.chrome.com/docs/extensions/get-started/tutorial/hello-world#load-unpacked).
1615
1. Click the extension icon.
1716
1. Interact with the Prompt API in the sidebar.
1817

1918
## Creating your own extension
2019

21-
If you use this sample as the foundation for your own extension, be sure to update the `"trial_tokens"` field [with your own origin trial token](https://developer.chrome.com/docs/web-platform/origin-trials?hl=en#extensions) and to remove the `"key"` field in `manifest.json`.
20+
If you use this sample as the foundation for your own extension, be sure to update the `"trial_tokens"` field [with your own origin trial token](https://developer.chrome.com/docs/web-platform/origin-trials#extensions) and to remove the `"key"` field in `manifest.json`.

functional-samples/ai.gemini-on-device/sidepanel/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,17 @@ async function initDefaults() {
5151
return;
5252
}
5353
sliderTemperature.value = defaults.defaultTemperature;
54-
// sliderTemperature.max = defaults.maxTemperature;
5554
// Pending https://issues.chromium.org/issues/367771112.
56-
sliderTopK.value = defaults.defaultTopK;
55+
// sliderTemperature.max = defaults.maxTemperature;
56+
if (defaults.defaultTopK > 3) {
57+
// limit default topK to 3
58+
sliderTopK.value = 3;
59+
labelTopK.textContent = 3;
60+
} else {
61+
sliderTopK.value = defaults.defaultTopK;
62+
labelTopK.textContent = defaults.defaultTopK;
63+
}
5764
sliderTopK.max = defaults.maxTopK;
58-
labelTopK.textContent = defaults.defaultTopK;
5965
labelTemperature.textContent = defaults.defaultTemperature;
6066
}
6167

@@ -92,6 +98,7 @@ buttonPrompt.addEventListener('click', async () => {
9298
showLoading();
9399
try {
94100
const params = {
101+
systemPrompt: 'You are a helpful and friendly assistant.',
95102
temperature: sliderTemperature.value,
96103
topK: sliderTopK.value
97104
};

0 commit comments

Comments
 (0)