Skip to content

Commit 58f7a43

Browse files
committed
Improve readability and asserts
1 parent ba6e10f commit 58f7a43

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const sample = require('../text-generation/textgen-with-txt.js');
2323
describe('textgen-with-txt', async () => {
2424
it('should generate text content from a text prompt', async () => {
2525
const output = await sample.generateContent(projectId);
26-
assert(output.length > 0);
26+
assert(
27+
output.length > 0 && output.includes('AI') && output.includes('models')
28+
);
2729
});
2830
});

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
// [START googlegenaisdk_textgen_with_txt]
1818
const {GoogleGenAI} = require('@google/genai');
1919

20+
const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT;
21+
const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global';
22+
2023
async function generateContent(
21-
projectId = process.env.GOOGLE_CLOUD_PROJECT,
22-
location = process.env.GOOGLE_CLOUD_LOCATION || 'global'
24+
projectId = GOOGLE_CLOUD_PROJECT,
25+
location = GOOGLE_CLOUD_LOCATION
2326
) {
2427
const ai = new GoogleGenAI({
2528
vertexai: true,

0 commit comments

Comments
 (0)