Skip to content

Commit 2ded410

Browse files
GuinersGuiners
andauthored
feat(genai): bump sdk version (#4185)
* client naming update * updating sdk version � * update package.json * update package.json * sample update * sample update * sample update * model update --------- Co-authored-by: Guiners <[email protected]>
1 parent 5a10894 commit 2ded410

18 files changed

+41
-37
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/image-generation/imggen-mmflash-with-txt.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ async function generateContent(
2626
projectId = GOOGLE_CLOUD_PROJECT,
2727
location = GOOGLE_CLOUD_LOCATION
2828
) {
29-
const ai = new GoogleGenAI({
29+
const client = new GoogleGenAI({
3030
vertexai: true,
3131
project: projectId,
3232
location: location,
3333
});
3434

35-
const response = await ai.models.generateContentStream({
36-
model: 'gemini-2.0-flash-exp',
35+
const response = await client.models.generateContentStream({
36+
model: 'gemini-2.5-flash-image',
3737
contents:
3838
'Generate an image of the Eiffel tower with fireworks in the background.',
3939
config: {

genai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"test": "c8 mocha -p -j 2 --timeout 2400000 test/*.test.js test/**/*.test.js"
1414
},
1515
"dependencies": {
16-
"@google/genai": "1.12.0",
16+
"@google/genai": "1.20.0",
1717
"axios": "^1.6.2",
1818
"luxon": "^3.7.1",
1919
"supertest": "^7.0.0"

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +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(10);
29+
this.retries(5);
2830
await delay(this.test);
29-
const generatedFileNames = await sample.generateContent(projectId);
30-
assert(Array.isArray(generatedFileNames));
31+
const generatedFileNames = await sample.generateContent(
32+
projectId,
33+
location
34+
);
3135
assert(generatedFileNames.length > 0);
3236
});
3337
});

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,

0 commit comments

Comments
 (0)