Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions genai/count-tokens/counttoken-compute-with-txt.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ async function countTokens(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
httpOptions: {apiVersion: 'v1'},
});

const response = await ai.models.computeTokens({
const response = await client.models.computeTokens({
model: 'gemini-2.5-flash',
contents: "What's the longest word in the English language?",
});
Expand Down
4 changes: 2 additions & 2 deletions genai/count-tokens/counttoken-resp-with-txt.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ async function countTokens(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
httpOptions: {apiVersion: 'v1'},
});

const response = await ai.models.generateContent({
const response = await client.models.generateContent({
model: 'gemini-2.5-flash',
contents: 'Why is the sky blue?',
});
Expand Down
4 changes: 2 additions & 2 deletions genai/count-tokens/counttoken-with-txt-vid.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function countTokens(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
Expand All @@ -37,7 +37,7 @@ async function countTokens(
},
};

const response = await ai.models.countTokens({
const response = await client.models.countTokens({
model: 'gemini-2.5-flash',
contents: [video, 'Provide a description of the video.'],
});
Expand Down
4 changes: 2 additions & 2 deletions genai/count-tokens/counttoken-with-txt.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ async function countTokens(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
});

const response = await ai.models.countTokens({
const response = await client.models.countTokens({
model: 'gemini-2.5-flash',
contents: 'What is the highest mountain in Africa?',
});
Expand Down
6 changes: 3 additions & 3 deletions genai/image-generation/imggen-mmflash-with-txt.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ async function generateContent(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
});

const response = await ai.models.generateContentStream({
model: 'gemini-2.0-flash-exp',
const response = await client.models.generateContentStream({
model: 'gemini-2.5-flash-image',
contents:
'Generate an image of the Eiffel tower with fireworks in the background.',
config: {
Expand Down
2 changes: 1 addition & 1 deletion genai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test": "c8 mocha -p -j 2 --timeout 2400000 test/*.test.js test/**/*.test.js"
},
"dependencies": {
"@google/genai": "1.12.0",
"@google/genai": "1.20.0",
"axios": "^1.6.2",
"luxon": "^3.7.1",
"supertest": "^7.0.0"
Expand Down
10 changes: 7 additions & 3 deletions genai/test/imggen-mmflash-with-txt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ const {assert} = require('chai');
const {describe, it} = require('mocha');

const projectId = process.env.CAIP_PROJECT_ID;
const location = 'global';

const sample = require('../image-generation/imggen-mmflash-with-txt.js');
const {delay} = require('./util');

describe('imggen-mmflash-with-txt', async () => {
it('should generate images from a text prompt', async function () {
this.timeout(180000);
this.retries(10);
this.retries(5);
await delay(this.test);
const generatedFileNames = await sample.generateContent(projectId);
assert(Array.isArray(generatedFileNames));
const generatedFileNames = await sample.generateContent(
projectId,
location
);
assert(generatedFileNames.length > 0);
});
});
4 changes: 2 additions & 2 deletions genai/text-generation/textgen-code-with-pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function generateText(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
Expand All @@ -46,7 +46,7 @@ async function generateText(
},
];

const response = await ai.models.generateContent({
const response = await client.models.generateContent({
model: 'gemini-2.5-flash',
contents: contents,
});
Expand Down
4 changes: 2 additions & 2 deletions genai/text-generation/textgen-sys-instr-with-txt.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function generateContent(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
Expand All @@ -35,7 +35,7 @@ async function generateContent(
Answer:
`;

const response = await ai.models.generateContent({
const response = await client.models.generateContent({
model: 'gemini-2.5-flash',
contents: prompt,
config: {
Expand Down
4 changes: 2 additions & 2 deletions genai/text-generation/textgen-with-multi-img.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function generateContent(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
Expand All @@ -44,7 +44,7 @@ async function generateContent(
},
};

const response = await ai.models.generateContent({
const response = await client.models.generateContent({
model: 'gemini-2.5-flash',
contents: [
image1,
Expand Down
4 changes: 2 additions & 2 deletions genai/text-generation/textgen-with-multi-local-img.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function generateContent(
imagePath1,
imagePath2
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
Expand All @@ -42,7 +42,7 @@ async function generateContent(
const image1 = loadImageAsBase64(imagePath1);
const image2 = loadImageAsBase64(imagePath2);

const response = await ai.models.generateContent({
const response = await client.models.generateContent({
model: 'gemini-2.5-flash',
contents: [
{
Expand Down
4 changes: 2 additions & 2 deletions genai/text-generation/textgen-with-txt-img.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function generateContent(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
Expand All @@ -37,7 +37,7 @@ async function generateContent(
},
};

const response = await ai.models.generateContent({
const response = await client.models.generateContent({
model: 'gemini-2.5-flash',
contents: [image, 'What is shown in this image?'],
});
Expand Down
4 changes: 2 additions & 2 deletions genai/text-generation/textgen-with-txt-routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function generateContent(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
Expand All @@ -37,7 +37,7 @@ async function generateContent(
},
};

const response = await ai.models.generateContent({
const response = await client.models.generateContent({
model: 'model-optimizer-exp-04-09',
contents: 'How does AI work?',
config: generateContentConfig,
Expand Down
4 changes: 2 additions & 2 deletions genai/text-generation/textgen-with-txt-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ async function generateContent(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
});

const response = await ai.models.generateContentStream({
const response = await client.models.generateContentStream({
model: 'gemini-2.5-flash',
contents: 'Why is the sky blue?',
});
Expand Down
4 changes: 2 additions & 2 deletions genai/text-generation/textgen-with-txt.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ async function generateContent(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
});

const response = await ai.models.generateContent({
const response = await client.models.generateContent({
model: 'gemini-2.5-flash',
contents: 'How does AI work?',
});
Expand Down
4 changes: 2 additions & 2 deletions genai/text-generation/textgen-with-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function generateContent(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
Expand All @@ -43,7 +43,7 @@ async function generateContent(
},
};

const response = await ai.models.generateContent({
const response = await client.models.generateContent({
model: 'gemini-2.5-flash',
contents: [video, prompt],
});
Expand Down
4 changes: 2 additions & 2 deletions genai/tools/tools-code-exec-with-txt.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ async function generateContent(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
});

const response = await ai.models.generateContent({
const response = await client.models.generateContent({
model: 'gemini-2.5-flash',
contents:
'What is the sum of the first 50 prime numbers? Generate and run code for the calculation, and make sure you get all 50.',
Expand Down
4 changes: 2 additions & 2 deletions genai/tools/tools-func-desc-with-txt.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function generateContent(
projectId = GOOGLE_CLOUD_PROJECT,
location = GOOGLE_CLOUD_LOCATION
) {
const ai = new GoogleGenAI({
const client = new GoogleGenAI({
vertexai: true,
project: projectId,
location: location,
Expand Down Expand Up @@ -73,7 +73,7 @@ async function generateContent(

const MODEL_NAME = 'gemini-2.5-flash';

const response = await ai.models.generateContent({
const response = await client.models.generateContent({
model: MODEL_NAME,
contents: prompt,
config: {
Expand Down
Loading