Skip to content

Commit 23f5a05

Browse files
author
Guiners
committed
fixing functions names
1 parent 79f65d5 commit 23f5a05

10 files changed

+30
-25
lines changed

genai/bounding-box/boundingbox-with-txt-img.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ async function plotBoundingBoxes(imageUri, boundingBoxes) {
6161
console.log('Saved output to file: output.png');
6262
}
6363

64-
async function generateContent(
64+
async function createBoundingBox(
6565
projectId = GOOGLE_CLOUD_PROJECT,
6666
location = GOOGLE_CLOUD_LOCATION
6767
) {
68-
const ai = new GoogleGenAI({
68+
const client = new GoogleGenAI({
6969
vertexai: true,
7070
project: projectId,
7171
location: location,
@@ -117,7 +117,7 @@ async function generateContent(
117117
},
118118
};
119119

120-
const response = await ai.models.generateContent({
120+
const response = await client.models.generateContent({
121121
model: 'gemini-2.5-flash',
122122
contents: [
123123
{
@@ -154,4 +154,6 @@ async function generateContent(
154154
}
155155
// [END googlegenaisdk_boundingbox_with_txt_img]
156156

157-
module.exports = {generateContent};
157+
module.exports = {
158+
createBoundingBox,
159+
};

genai/embeddings/embeddings-docretrieval-with-txt.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,18 @@ const {GoogleGenAI} = require('@google/genai');
1919

2020
const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT;
2121

22-
async function generateContent(projectId = GOOGLE_CLOUD_PROJECT) {
23-
const ai = new GoogleGenAI(projectId);
22+
async function generateEmbeddingsForRetrieval(
23+
projectId = GOOGLE_CLOUD_PROJECT
24+
) {
25+
const client = new GoogleGenAI(projectId);
2426

2527
const prompt = [
2628
"How do I get a driver's license/learner's permit?",
2729
"How long is my driver's license valid for?",
2830
"Driver's knowledge test study guide",
2931
];
3032

31-
const response = await ai.models.embedContent({
33+
const response = await client.models.embedContent({
3234
model: 'gemini-embedding-001',
3335
contents: prompt,
3436
config: {
@@ -50,5 +52,5 @@ async function generateContent(projectId = GOOGLE_CLOUD_PROJECT) {
5052
// [END googlegenaisdk_embeddings_docretrieval_with_txt]
5153

5254
module.exports = {
53-
generateContent,
55+
generateEmbeddingsForRetrieval,
5456
};

genai/express-mode/api-key-example.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
const {GoogleGenAI} = require('@google/genai');
1919
const API_KEY = 'PUT HERE YOUR API KEY';
2020

21-
async function generateContent(apiKey = API_KEY) {
22-
const ai = new GoogleGenAI({
21+
async function generateWithApiKey(apiKey = API_KEY) {
22+
const client = new GoogleGenAI({
2323
vertexai: true,
2424
apiKey: apiKey,
2525
});
2626

27-
const response = await ai.models.generateContentStream({
27+
const response = await client.models.generateContentStream({
2828
model: 'gemini-2.5-flash',
2929
contents: 'Explain bubble sort to me.',
3030
});
@@ -39,5 +39,5 @@ async function generateContent(apiKey = API_KEY) {
3939
// [END googlegenaisdk_vertexai_express_mode]
4040

4141
module.exports = {
42-
generateContent,
42+
generateWithApiKey,
4343
};

genai/provisioned-throughput/provisionedthroughput-with-txt.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ const {GoogleGenAI} = require('@google/genai');
2020
const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT;
2121
const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global';
2222

23-
async function generateContent(
23+
async function generateWithProvisionedThroughput(
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,
@@ -40,7 +40,7 @@ async function generateContent(
4040
},
4141
});
4242

43-
const response = await ai.models.generateContent({
43+
const response = await client.models.generateContent({
4444
model: 'gemini-2.5-flash',
4545
contents: 'How does AI work?',
4646
});
@@ -58,5 +58,5 @@ async function generateContent(
5858
// [END googlegenaisdk_provisionedthroughput_with_txt]
5959

6060
module.exports = {
61-
generateContent,
61+
generateWithProvisionedThroughput,
6262
};

genai/safety/safety-with-txt.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ const {GoogleGenAI} = require('@google/genai');
2020
const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT;
2121
const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global';
2222

23-
async function generateContent(
23+
async function generateWithSafetySettings(
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,
@@ -54,7 +54,7 @@ async function generateContent(
5454
},
5555
];
5656

57-
const response = await ai.models.generateContent({
57+
const response = await client.models.generateContent({
5858
model: 'gemini-2.5-flash',
5959
contents: prompt,
6060
config: {
@@ -111,5 +111,5 @@ async function generateContent(
111111
// [END googlegenaisdk_safety_with_txt]
112112

113113
module.exports = {
114-
generateContent,
114+
generateWithSafetySettings,
115115
};

genai/test/api-key-example.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('vertexai-express-mode', () => {
4242
'@google/genai': {GoogleGenAI: MockGoogleGenAI},
4343
});
4444

45-
const response = await sample.generateContent('FAKE_API_KEY');
45+
const response = await sample.generateWithApiKey('FAKE_API_KEY');
4646

4747
assert.strictEqual(response.text, mockGenerateContentStreamResult.text);
4848
});

genai/test/boundingbox-with-txt-img.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const sample = require('../bounding-box/boundingbox-with-txt-img');
2323
describe('boundingbox-with-txt-img', async () => {
2424
it('should return the bounding box', async function () {
2525
this.timeout(100000);
26-
const output = await sample.generateContent(projectId);
26+
const output = await sample.createBoundingBox(projectId);
2727
assert(output.length > 0);
2828
});
2929
});

genai/test/embeddings-docretrieval-with-txt.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const sample = require('../embeddings/embeddings-docretrieval-with-txt.js');
2222

2323
describe('embeddings-docretrieval-with-txt', async () => {
2424
it('should return an object containing embeddings and metadata', async () => {
25-
const generatedFileNames = await sample.generateContent(projectId);
25+
const generatedFileNames =
26+
await sample.generateEmbeddingsForRetrieval(projectId);
2627
assert.containsAllKeys(generatedFileNames, ['embeddings', 'metadata']);
2728
});
2829
});

genai/test/provisionedthroughput-with-txt.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const sample = require('../provisioned-throughput/provisionedthroughput-with-txt
2323
describe('provisionedthroughput-with-txt', () => {
2424
it('should return provisioned throughput result', async function () {
2525
this.timeout(50000);
26-
const output = await sample.generateContent(projectId);
26+
const output = await sample.generateWithProvisionedThroughput(projectId);
2727
assert(output.length > 0);
2828
});
2929
});

genai/test/safety-with-txt.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const sample = require('../safety/safety-with-txt.js');
2323
describe('safety-with-txt', () => {
2424
it('should call generateContentStream with safety instructions', async function () {
2525
this.timeout(50000);
26-
const output = await sample.generateContent(projectId);
26+
const output = await sample.generateWithSafetySettings(projectId);
2727
assert(output.text.length > 0);
2828
});
2929
});

0 commit comments

Comments
 (0)