Skip to content

Commit 53cf93f

Browse files
authored
Merge branch 'main' into sample/september-samples
2 parents 557ddf9 + 2ded410 commit 53cf93f

16 files changed

+37
-32
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ async function countTokens(
2424
projectId = GOOGLE_CLOUD_PROJECT,
2525
location = GOOGLE_CLOUD_LOCATION
2626
) {
27-
const ai = new GoogleGenAI({
27+
const client = new GoogleGenAI({
2828
vertexai: true,
2929
project: projectId,
3030
location: location,
3131
httpOptions: {apiVersion: 'v1'},
3232
});
3333

34-
const response = await ai.models.computeTokens({
34+
const response = await client.models.computeTokens({
3535
model: 'gemini-2.5-flash',
3636
contents: "What's the longest word in the English language?",
3737
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ async function countTokens(
2424
projectId = GOOGLE_CLOUD_PROJECT,
2525
location = GOOGLE_CLOUD_LOCATION
2626
) {
27-
const ai = new GoogleGenAI({
27+
const client = new GoogleGenAI({
2828
vertexai: true,
2929
project: projectId,
3030
location: location,
3131
httpOptions: {apiVersion: 'v1'},
3232
});
3333

34-
const response = await ai.models.generateContent({
34+
const response = await client.models.generateContent({
3535
model: 'gemini-2.5-flash',
3636
contents: 'Why is the sky blue?',
3737
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function countTokens(
2424
projectId = GOOGLE_CLOUD_PROJECT,
2525
location = GOOGLE_CLOUD_LOCATION
2626
) {
27-
const ai = new GoogleGenAI({
27+
const client = new GoogleGenAI({
2828
vertexai: true,
2929
project: projectId,
3030
location: location,
@@ -37,7 +37,7 @@ async function countTokens(
3737
},
3838
};
3939

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ async function countTokens(
2424
projectId = GOOGLE_CLOUD_PROJECT,
2525
location = GOOGLE_CLOUD_LOCATION
2626
) {
27-
const ai = new GoogleGenAI({
27+
const client = new GoogleGenAI({
2828
vertexai: true,
2929
project: projectId,
3030
location: location,
3131
});
3232

33-
const response = await ai.models.countTokens({
33+
const response = await client.models.countTokens({
3434
model: 'gemini-2.5-flash',
3535
contents: 'What is the highest mountain in Africa?',
3636
});

genai/test/imggen-mmflash-with-txt.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,20 @@ const {assert} = require('chai');
1818
const {describe, it} = require('mocha');
1919

2020
const projectId = process.env.CAIP_PROJECT_ID;
21+
const location = 'global';
22+
2123
const sample = require('../image-generation/imggen-mmflash-with-txt.js');
2224
const {delay} = require('./util');
2325

2426
describe('imggen-mmflash-with-txt', async () => {
2527
it('should generate images from a text prompt', async function () {
2628
this.timeout(180000);
27-
this.retries(4);
29+
this.retries(5);
2830
await delay(this.test);
29-
const generatedFileNames = await sample.generateImage(projectId);
31+
const generatedFileNames = await sample.generateContent(
32+
projectId,
33+
location
34+
);
3035
assert(generatedFileNames.length > 0);
3136
});
3237
});

genai/text-generation/textgen-code-with-pdf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function generateText(
2424
projectId = GOOGLE_CLOUD_PROJECT,
2525
location = GOOGLE_CLOUD_LOCATION
2626
) {
27-
const ai = new GoogleGenAI({
27+
const client = new GoogleGenAI({
2828
vertexai: true,
2929
project: projectId,
3030
location: location,
@@ -46,7 +46,7 @@ async function generateText(
4646
},
4747
];
4848

49-
const response = await ai.models.generateContent({
49+
const response = await client.models.generateContent({
5050
model: 'gemini-2.5-flash',
5151
contents: contents,
5252
});

genai/text-generation/textgen-sys-instr-with-txt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function generateContent(
2424
projectId = GOOGLE_CLOUD_PROJECT,
2525
location = GOOGLE_CLOUD_LOCATION
2626
) {
27-
const ai = new GoogleGenAI({
27+
const client = new GoogleGenAI({
2828
vertexai: true,
2929
project: projectId,
3030
location: location,
@@ -35,7 +35,7 @@ async function generateContent(
3535
Answer:
3636
`;
3737

38-
const response = await ai.models.generateContent({
38+
const response = await client.models.generateContent({
3939
model: 'gemini-2.5-flash',
4040
contents: prompt,
4141
config: {

genai/text-generation/textgen-with-multi-img.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function generateContent(
2424
projectId = GOOGLE_CLOUD_PROJECT,
2525
location = GOOGLE_CLOUD_LOCATION
2626
) {
27-
const ai = new GoogleGenAI({
27+
const client = new GoogleGenAI({
2828
vertexai: true,
2929
project: projectId,
3030
location: location,
@@ -44,7 +44,7 @@ async function generateContent(
4444
},
4545
};
4646

47-
const response = await ai.models.generateContent({
47+
const response = await client.models.generateContent({
4848
model: 'gemini-2.5-flash',
4949
contents: [
5050
image1,

genai/text-generation/textgen-with-multi-local-img.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async function generateContent(
3232
imagePath1,
3333
imagePath2
3434
) {
35-
const ai = new GoogleGenAI({
35+
const client = new GoogleGenAI({
3636
vertexai: true,
3737
project: projectId,
3838
location: location,
@@ -42,7 +42,7 @@ async function generateContent(
4242
const image1 = loadImageAsBase64(imagePath1);
4343
const image2 = loadImageAsBase64(imagePath2);
4444

45-
const response = await ai.models.generateContent({
45+
const response = await client.models.generateContent({
4646
model: 'gemini-2.5-flash',
4747
contents: [
4848
{

genai/text-generation/textgen-with-txt-img.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function generateContent(
2424
projectId = GOOGLE_CLOUD_PROJECT,
2525
location = GOOGLE_CLOUD_LOCATION
2626
) {
27-
const ai = new GoogleGenAI({
27+
const client = new GoogleGenAI({
2828
vertexai: true,
2929
project: projectId,
3030
location: location,
@@ -37,7 +37,7 @@ async function generateContent(
3737
},
3838
};
3939

40-
const response = await ai.models.generateContent({
40+
const response = await client.models.generateContent({
4141
model: 'gemini-2.5-flash',
4242
contents: [image, 'What is shown in this image?'],
4343
});

0 commit comments

Comments
 (0)