Skip to content

Commit 1b76cca

Browse files
authored
Merge branch 'main' into sample/thinking
2 parents 6780e2a + 40758cc commit 1b76cca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+529
-142
lines changed

.github/workflows/ai-platform-snippets.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
id: npm-cache-dir
6363
shell: bash
6464
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
65-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
65+
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4
6666
id: npm-cache
6767
with:
6868
path: ${{ steps.npm-cache-dir.outputs.dir }}

.github/workflows/dialogflow-cx.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
id: npm-cache-dir
6363
shell: bash
6464
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
65-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
65+
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4
6666
id: npm-cache
6767
with:
6868
path: ${{ steps.npm-cache-dir.outputs.dir }}

.github/workflows/functions-slack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
id: npm-cache-dir
6363
shell: bash
6464
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
65-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
65+
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4
6666
id: npm-cache
6767
with:
6868
path: ${{ steps.npm-cache-dir.outputs.dir }}

.github/workflows/iam-deny.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
id: npm-cache-dir
6161
shell: bash
6262
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
63-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
63+
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4
6464
id: npm-cache
6565
with:
6666
path: ${{ steps.npm-cache-dir.outputs.dir }}

.github/workflows/storagetransfer.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
id: npm-cache-dir
6666
shell: bash
6767
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
68-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
68+
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4
6969
id: npm-cache
7070
with:
7171
path: ${{ steps.npm-cache-dir.outputs.dir }}

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
id: npm-cache-dir
4848
shell: bash
4949
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
50-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
50+
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4
5151
id: npm-cache
5252
with:
5353
path: ${{ steps.npm-cache-dir.outputs.dir }}

genai/controlled-generation/ctrlgen-with-enum-schema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async function generateContent(
3636
};
3737

3838
const response = await ai.models.generateContent({
39-
model: 'gemini-2.0-flash',
39+
model: 'gemini-2.5-flash',
4040
contents: 'What type of instrument is an oboe?',
4141
config: {
4242
responseMimeType: 'text/x.enum',
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
// [START googlegenaisdk_counttoken_compute_with_txt]
18+
const {GoogleGenAI} = require('@google/genai');
19+
20+
const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT;
21+
const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global';
22+
23+
async function countTokens(
24+
projectId = GOOGLE_CLOUD_PROJECT,
25+
location = GOOGLE_CLOUD_LOCATION
26+
) {
27+
const ai = new GoogleGenAI({
28+
vertexai: true,
29+
project: projectId,
30+
location: location,
31+
httpOptions: {apiVersion: 'v1'},
32+
});
33+
34+
const response = await ai.models.computeTokens({
35+
model: 'gemini-2.5-flash',
36+
contents: "What's the longest word in the English language?",
37+
});
38+
39+
console.log(response);
40+
41+
return response.tokensInfo;
42+
}
43+
// [END googlegenaisdk_counttoken_compute_with_txt]
44+
45+
module.exports = {
46+
countTokens,
47+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
// [START googlegenaisdk_counttoken_resp_with_txt]
18+
const {GoogleGenAI} = require('@google/genai');
19+
20+
const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT;
21+
const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global';
22+
23+
async function countTokens(
24+
projectId = GOOGLE_CLOUD_PROJECT,
25+
location = GOOGLE_CLOUD_LOCATION
26+
) {
27+
const ai = new GoogleGenAI({
28+
vertexai: true,
29+
project: projectId,
30+
location: location,
31+
httpOptions: {apiVersion: 'v1'},
32+
});
33+
34+
const response = await ai.models.generateContent({
35+
model: 'gemini-2.5-flash',
36+
contents: 'Why is the sky blue?',
37+
});
38+
39+
console.log(response.usageMetadata);
40+
41+
return response.usageMetadata;
42+
}
43+
// [END googlegenaisdk_counttoken_resp_with_txt]
44+
45+
module.exports = {
46+
countTokens,
47+
};

genai/count-tokens/counttoken-with-txt-vid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async function countTokens(
3838
};
3939

4040
const response = await ai.models.countTokens({
41-
model: 'gemini-2.0-flash',
41+
model: 'gemini-2.5-flash',
4242
contents: [video, 'Provide a description of the video.'],
4343
});
4444

0 commit comments

Comments
 (0)