From 98a2d45239791fe604f88ca96aca99b2dc0f8098 Mon Sep 17 00:00:00 2001 From: Guiners Date: Fri, 1 Aug 2025 13:34:12 +0200 Subject: [PATCH 1/8] bumping version and fixing tests --- .../ctrlgen-with-enum-schema.js | 2 +- .../ctrlgen_with_class_schema.js | 62 +++++++++++++++ .../ctrlgen_with_enum_class_schema.js | 75 +++++++++++++++++++ 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 genai/controlled-generation/ctrlgen_with_class_schema.js create mode 100644 genai/controlled-generation/ctrlgen_with_enum_class_schema.js diff --git a/genai/controlled-generation/ctrlgen-with-enum-schema.js b/genai/controlled-generation/ctrlgen-with-enum-schema.js index e0002a2b9d..b87c513aab 100644 --- a/genai/controlled-generation/ctrlgen-with-enum-schema.js +++ b/genai/controlled-generation/ctrlgen-with-enum-schema.js @@ -36,7 +36,7 @@ async function generateContent( }; const response = await ai.models.generateContent({ - model: 'gemini-2.0-flash', + model: 'gemini-2.5-flash', contents: 'What type of instrument is an oboe?', config: { responseMimeType: 'text/x.enum', diff --git a/genai/controlled-generation/ctrlgen_with_class_schema.js b/genai/controlled-generation/ctrlgen_with_class_schema.js new file mode 100644 index 0000000000..a6f9585112 --- /dev/null +++ b/genai/controlled-generation/ctrlgen_with_class_schema.js @@ -0,0 +1,62 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START googlegenaisdk_ctrlgen_with_class_schema] +const {GoogleGenAI, Type} = require('@google/genai'); + +const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT; +const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global'; + +async function generateContent( + projectId = GOOGLE_CLOUD_PROJECT, + location = GOOGLE_CLOUD_LOCATION +) { + const ai = new GoogleGenAI({ + vertexai: true, + project: projectId, + location: location, + }); + + class Recipe { + /** + * @param {string} recipe_name + * @param {string[]} ingredients + */ + constructor(recipe_name, ingredients) { + this.recipe_name = recipe_name; + this.ingredients = ingredients; + } + } + + const response = await ai.models.generateContent({ + model: 'gemini-2.5-flash', + contents: 'List a few popular cookie recipes?', + config: { + responseMimeType: 'application/json', + responseSchema: Recipe, + }, + }); + + console.log(response.text); + console.log(response); + + return response.text; +} +// [END googlegenaisdk_ctrlgen_with_class_schema] + +module.exports = { + generateContent, +}; \ No newline at end of file diff --git a/genai/controlled-generation/ctrlgen_with_enum_class_schema.js b/genai/controlled-generation/ctrlgen_with_enum_class_schema.js new file mode 100644 index 0000000000..fef62d14b5 --- /dev/null +++ b/genai/controlled-generation/ctrlgen_with_enum_class_schema.js @@ -0,0 +1,75 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START googlegenaisdk_ctrlgen_with_enum_class_schema] +const {GoogleGenAI, Type} = require('@google/genai'); + +const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT; +const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global'; + +async function generateContent( + projectId = GOOGLE_CLOUD_PROJECT, + location = GOOGLE_CLOUD_LOCATION +) { + const ai = new GoogleGenAI({ + vertexai: true, + project: projectId, + location: location, + }); + + class InstrumentClass { + static PERCUSSION = "Percussion"; + static STRING = "String"; + static WOODWIND = "Woodwind"; + static BRASS = "Brass"; + static KEYBOARD = "Keyboard"; + + static values() { + return [ + this.PERCUSSION, + this.STRING, + this.WOODWIND, + this.BRASS, + this.KEYBOARD + ]; + } + } + + const responseSchema = { + type: "string", + enum: InstrumentClass.values(), + }; + + + const response = await ai.models.generateContent({ + model: 'gemini-2.5-flash', + contents: 'What type of instrument is a guitar?', + config: { + responseMimeType: 'text/x.enum', + responseSchema: responseSchema, + }, + }); + console.log(response); + + console.log(response.text); + + return response.text; +} +// [END googlegenaisdk_ctrlgen_with_enum_class_schema] + +module.exports = { + generateContent, +}; \ No newline at end of file From 99f5214c690102a72ebdf8afebabe5080a11cfe1 Mon Sep 17 00:00:00 2001 From: Guiners Date: Fri, 1 Aug 2025 13:34:36 +0200 Subject: [PATCH 2/8] bumping version and fixing tests --- genai/controlled-generation/ctrlgen_with_class_schema.js | 2 +- genai/controlled-generation/ctrlgen_with_enum_class_schema.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/genai/controlled-generation/ctrlgen_with_class_schema.js b/genai/controlled-generation/ctrlgen_with_class_schema.js index a6f9585112..63a6003dd7 100644 --- a/genai/controlled-generation/ctrlgen_with_class_schema.js +++ b/genai/controlled-generation/ctrlgen_with_class_schema.js @@ -15,7 +15,7 @@ 'use strict'; // [START googlegenaisdk_ctrlgen_with_class_schema] -const {GoogleGenAI, Type} = require('@google/genai'); +const {GoogleGenAI} = require('@google/genai'); const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT; const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global'; diff --git a/genai/controlled-generation/ctrlgen_with_enum_class_schema.js b/genai/controlled-generation/ctrlgen_with_enum_class_schema.js index fef62d14b5..57af881994 100644 --- a/genai/controlled-generation/ctrlgen_with_enum_class_schema.js +++ b/genai/controlled-generation/ctrlgen_with_enum_class_schema.js @@ -15,7 +15,7 @@ 'use strict'; // [START googlegenaisdk_ctrlgen_with_enum_class_schema] -const {GoogleGenAI, Type} = require('@google/genai'); +const {GoogleGenAI} = require('@google/genai'); const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT; const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global'; From 77e4dca4da168e80a1f91e971896eae40d967b0e Mon Sep 17 00:00:00 2001 From: Guiners Date: Fri, 1 Aug 2025 16:17:47 +0200 Subject: [PATCH 3/8] bumping version and fixing tests --- .../ctrlgen_with_nested_class_schema.js | 74 +++++++++++++++++ .../ctrlgen_with_nullable_schema.js | 75 +++++++++++++++++ .../ctrlgen_with_resp_schema.js | 82 +++++++++++++++++++ 3 files changed, 231 insertions(+) create mode 100644 genai/controlled-generation/ctrlgen_with_nested_class_schema.js create mode 100644 genai/controlled-generation/ctrlgen_with_nullable_schema.js create mode 100644 genai/controlled-generation/ctrlgen_with_resp_schema.js diff --git a/genai/controlled-generation/ctrlgen_with_nested_class_schema.js b/genai/controlled-generation/ctrlgen_with_nested_class_schema.js new file mode 100644 index 0000000000..bda9617e18 --- /dev/null +++ b/genai/controlled-generation/ctrlgen_with_nested_class_schema.js @@ -0,0 +1,74 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START googlegenaisdk_ctrlgen_with_nested_class_schema] +const {GoogleGenAI, Type} = require('@google/genai'); + +const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT; +const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global'; + +async function generateContent( + projectId = GOOGLE_CLOUD_PROJECT, + location = GOOGLE_CLOUD_LOCATION +) { + const ai = new GoogleGenAI({ + vertexai: true, + project: projectId, + location: location, + }); + + + const Grade = Object.freeze({ + A_PLUS: 'a+', + A: 'a', + B: 'b', + C: 'c', + D: 'd', + F: 'f', + }); + + class Recipe { + /** + * @param {string} recipe_name + * @param {string} rating - Must be one of Grade enum values + */ + constructor(recipe_name, rating) { + if (!Object.values(Grade).includes(rating)) { + throw new Error(`Invalid rating: ${rating}`); + } + this.recipe_name = recipe_name; + this.rating = rating; + } + } + + const response = await ai.models.generateContent({ + model: 'gemini-2.5-flash', + contents: 'List about 10 home-baked cookies and give them grades based on tastiness.', + config: { + responseMimeType: 'application/json', + responseSchema: Recipe, + }, + }); + + console.log(response.text); + + return response.text; +} +// [END googlegenaisdk_ctrlgen_with_nested_class_schema] + +module.exports = { + generateContent, +}; diff --git a/genai/controlled-generation/ctrlgen_with_nullable_schema.js b/genai/controlled-generation/ctrlgen_with_nullable_schema.js new file mode 100644 index 0000000000..2fde8f75db --- /dev/null +++ b/genai/controlled-generation/ctrlgen_with_nullable_schema.js @@ -0,0 +1,75 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START googlegenaisdk_ctrlgen_with_nullable_schema] +const {GoogleGenAI} = require('@google/genai'); + +const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT; +const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global'; + +async function generateContent( + projectId = GOOGLE_CLOUD_PROJECT, + location = GOOGLE_CLOUD_LOCATION +) { + const ai = new GoogleGenAI({ + vertexai: true, + project: projectId, + location: location, + }); + + class InstrumentClass { + static PERCUSSION = "Percussion"; + static STRING = "String"; + static WOODWIND = "Woodwind"; + static BRASS = "Brass"; + static KEYBOARD = "Keyboard"; + + static values() { + return [ + this.PERCUSSION, + this.STRING, + this.WOODWIND, + this.BRASS, + this.KEYBOARD + ]; + } + } + + const responseSchema = { + type: "string", + enum: InstrumentClass.values(), + }; + + + const response = await ai.models.generateContent({ + model: 'gemini-2.5-flash', + contents: 'What type of instrument is a guitar?', + config: { + responseMimeType: 'text/x.enum', + responseSchema: responseSchema, + }, + }); + console.log(response); + + console.log(response.text); + + return response.text; +} +// [END googlegenaisdk_ctrlgen_with_nullable_schema] + +module.exports = { + generateContent, +}; \ No newline at end of file diff --git a/genai/controlled-generation/ctrlgen_with_resp_schema.js b/genai/controlled-generation/ctrlgen_with_resp_schema.js new file mode 100644 index 0000000000..43538dbfd4 --- /dev/null +++ b/genai/controlled-generation/ctrlgen_with_resp_schema.js @@ -0,0 +1,82 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START googlegenaisdk_ctrlgen_with_resp_schema] +const {GoogleGenAI} = require('@google/genai'); + +const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT; +const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global'; + +async function generateContent( + projectId = GOOGLE_CLOUD_PROJECT, + location = GOOGLE_CLOUD_LOCATION +) { + const ai = new GoogleGenAI({ + vertexai: true, + project: projectId, + location: location, + }); + + const prompt = ` + The week ahead brings a mix of weather conditions. + Sunday is expected to be sunny with a temperature of 77°F and a humidity level of 50%. Winds will be light at around 10 km/h. + Monday will see partly cloudy skies with a slightly cooler temperature of 72°F and the winds will pick up slightly to around 15 km/h. + Tuesday brings rain showers, with temperatures dropping to 64°F and humidity rising to 70%. + Wednesday may see thunderstorms, with a temperature of 68°F. + Thursday will be cloudy with a temperature of 66°F and moderate humidity at 60%. + Friday returns to partly cloudy conditions, with a temperature of 73°F and the Winds will be light at 12 km/h. + Finally, Saturday rounds off the week with sunny skies, a temperature of 80°F, and a humidity level of 40%. Winds will be gentle at 8 km/h. +`; + + const responseSchema = { + type: 'object', + properties: { + forecast: { + type: 'array', + items: { + type: 'object', + properties: { + Day: { type: 'string', nullable: true }, + Forecast: { type: 'string', nullable: true }, + Temperature: { type: 'integer', nullable: true }, + Humidity: { type: 'string', nullable: true }, + 'Wind Speed': { type: 'integer', nullable: true }, + }, + required: ['Day', 'Temperature', 'Forecast', 'Wind Speed'], + }, + }, + }, + }; + + const response = await ai.models.generateContent({ + model: 'gemini-2.5-flash', + contents: prompt, + config: { + responseMimeType: 'application/json', + responseSchema: responseSchema, + }, + }); + console.log(response); + + console.log(response.text); + + return response.text; +} +// [END googlegenaisdk_ctrlgen_with_resp_schema] + +module.exports = { + generateContent, +}; \ No newline at end of file From 554afd031770957fadaaed4292d9b0e26f01d378 Mon Sep 17 00:00:00 2001 From: Guiners Date: Fri, 1 Aug 2025 16:17:59 +0200 Subject: [PATCH 4/8] bumping version and fixing tests --- genai/controlled-generation/ctrlgen_with_nested_class_schema.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genai/controlled-generation/ctrlgen_with_nested_class_schema.js b/genai/controlled-generation/ctrlgen_with_nested_class_schema.js index bda9617e18..639bb61e64 100644 --- a/genai/controlled-generation/ctrlgen_with_nested_class_schema.js +++ b/genai/controlled-generation/ctrlgen_with_nested_class_schema.js @@ -15,7 +15,7 @@ 'use strict'; // [START googlegenaisdk_ctrlgen_with_nested_class_schema] -const {GoogleGenAI, Type} = require('@google/genai'); +const {GoogleGenAI} = require('@google/genai'); const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT; const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global'; From aa02890fa78a4eaa533109ea1b422de3aef2f916 Mon Sep 17 00:00:00 2001 From: Guiners Date: Mon, 4 Aug 2025 12:22:37 +0200 Subject: [PATCH 5/8] adding tests --- .../ctrlgen_with_class_schema.js | 4 +- .../ctrlgen_with_enum_class_schema.js | 28 +++++----- .../ctrlgen_with_nested_class_schema.js | 4 +- .../ctrlgen_with_nullable_schema.js | 55 ++++++++++--------- .../ctrlgen_with_resp_schema.js | 38 ++++--------- genai/test/ctrlgen_with_class_schema.test.js | 29 ++++++++++ .../ctrlgen_with_enum_class_schema.test.js | 29 ++++++++++ .../ctrlgen_with_nested_class_schema.test.js | 29 ++++++++++ .../test/ctrlgen_with_nullable_schema.test.js | 29 ++++++++++ genai/test/ctrlgen_with_resp_schema.test.js | 29 ++++++++++ 10 files changed, 203 insertions(+), 71 deletions(-) create mode 100644 genai/test/ctrlgen_with_class_schema.test.js create mode 100644 genai/test/ctrlgen_with_enum_class_schema.test.js create mode 100644 genai/test/ctrlgen_with_nested_class_schema.test.js create mode 100644 genai/test/ctrlgen_with_nullable_schema.test.js create mode 100644 genai/test/ctrlgen_with_resp_schema.test.js diff --git a/genai/controlled-generation/ctrlgen_with_class_schema.js b/genai/controlled-generation/ctrlgen_with_class_schema.js index 63a6003dd7..a4a6609f9b 100644 --- a/genai/controlled-generation/ctrlgen_with_class_schema.js +++ b/genai/controlled-generation/ctrlgen_with_class_schema.js @@ -51,12 +51,10 @@ async function generateContent( }); console.log(response.text); - console.log(response); - return response.text; } // [END googlegenaisdk_ctrlgen_with_class_schema] module.exports = { generateContent, -}; \ No newline at end of file +}; diff --git a/genai/controlled-generation/ctrlgen_with_enum_class_schema.js b/genai/controlled-generation/ctrlgen_with_enum_class_schema.js index 57af881994..c6e42b1ea7 100644 --- a/genai/controlled-generation/ctrlgen_with_enum_class_schema.js +++ b/genai/controlled-generation/ctrlgen_with_enum_class_schema.js @@ -31,29 +31,28 @@ async function generateContent( }); class InstrumentClass { - static PERCUSSION = "Percussion"; - static STRING = "String"; - static WOODWIND = "Woodwind"; - static BRASS = "Brass"; - static KEYBOARD = "Keyboard"; - static values() { return [ - this.PERCUSSION, - this.STRING, - this.WOODWIND, - this.BRASS, - this.KEYBOARD + InstrumentClass.PERCUSSION, + InstrumentClass.STRING, + InstrumentClass.WOODWIND, + InstrumentClass.BRASS, + InstrumentClass.KEYBOARD, ]; } } + InstrumentClass.PERCUSSION = 'Percussion'; + InstrumentClass.STRING = 'String'; + InstrumentClass.WOODWIND = 'Woodwind'; + InstrumentClass.BRASS = 'Brass'; + InstrumentClass.KEYBOARD = 'Keyboard'; + const responseSchema = { - type: "string", + type: 'string', enum: InstrumentClass.values(), }; - const response = await ai.models.generateContent({ model: 'gemini-2.5-flash', contents: 'What type of instrument is a guitar?', @@ -62,7 +61,6 @@ async function generateContent( responseSchema: responseSchema, }, }); - console.log(response); console.log(response.text); @@ -72,4 +70,4 @@ async function generateContent( module.exports = { generateContent, -}; \ No newline at end of file +}; diff --git a/genai/controlled-generation/ctrlgen_with_nested_class_schema.js b/genai/controlled-generation/ctrlgen_with_nested_class_schema.js index 639bb61e64..c4dce84842 100644 --- a/genai/controlled-generation/ctrlgen_with_nested_class_schema.js +++ b/genai/controlled-generation/ctrlgen_with_nested_class_schema.js @@ -30,7 +30,6 @@ async function generateContent( location: location, }); - const Grade = Object.freeze({ A_PLUS: 'a+', A: 'a', @@ -56,7 +55,8 @@ async function generateContent( const response = await ai.models.generateContent({ model: 'gemini-2.5-flash', - contents: 'List about 10 home-baked cookies and give them grades based on tastiness.', + contents: + 'List about 10 home-baked cookies and give them grades based on tastiness.', config: { responseMimeType: 'application/json', responseSchema: Recipe, diff --git a/genai/controlled-generation/ctrlgen_with_nullable_schema.js b/genai/controlled-generation/ctrlgen_with_nullable_schema.js index 2fde8f75db..aae571855e 100644 --- a/genai/controlled-generation/ctrlgen_with_nullable_schema.js +++ b/genai/controlled-generation/ctrlgen_with_nullable_schema.js @@ -30,40 +30,45 @@ async function generateContent( location: location, }); - class InstrumentClass { - static PERCUSSION = "Percussion"; - static STRING = "String"; - static WOODWIND = "Woodwind"; - static BRASS = "Brass"; - static KEYBOARD = "Keyboard"; - - static values() { - return [ - this.PERCUSSION, - this.STRING, - this.WOODWIND, - this.BRASS, - this.KEYBOARD - ]; - } - } + const prompt = ` + The week ahead brings a mix of weather conditions. + Sunday is expected to be sunny with a temperature of 77°F and a humidity level of 50%. Winds will be light at around 10 km/h. + Monday will see partly cloudy skies with a slightly cooler temperature of 72°F and the winds will pick up slightly to around 15 km/h. + Tuesday brings rain showers, with temperatures dropping to 64°F and humidity rising to 70%. + Wednesday may see thunderstorms, with a temperature of 68°F. + Thursday will be cloudy with a temperature of 66°F and moderate humidity at 60%. + Friday returns to partly cloudy conditions, with a temperature of 73°F and the Winds will be light at 12 km/h. + Finally, Saturday rounds off the week with sunny skies, a temperature of 80°F, and a humidity level of 40%. Winds will be gentle at 8 km/h. +`; const responseSchema = { - type: "string", - enum: InstrumentClass.values(), + type: 'object', + properties: { + forecast: { + type: 'array', + items: { + type: 'object', + properties: { + Day: {type: 'string', nullable: true}, + Forecast: {type: 'string', nullable: true}, + Temperature: {type: 'integer', nullable: true}, + Humidity: {type: 'string', nullable: true}, + 'Wind Speed': {type: 'integer', nullable: true}, + }, + required: ['Day', 'Temperature', 'Forecast', 'Wind Speed'], + }, + }, + }, }; - const response = await ai.models.generateContent({ model: 'gemini-2.5-flash', - contents: 'What type of instrument is a guitar?', + contents: prompt, config: { - responseMimeType: 'text/x.enum', + responseMimeType: 'application/json', responseSchema: responseSchema, }, }); - console.log(response); - console.log(response.text); return response.text; @@ -72,4 +77,4 @@ async function generateContent( module.exports = { generateContent, -}; \ No newline at end of file +}; diff --git a/genai/controlled-generation/ctrlgen_with_resp_schema.js b/genai/controlled-generation/ctrlgen_with_resp_schema.js index 43538dbfd4..89f625ea29 100644 --- a/genai/controlled-generation/ctrlgen_with_resp_schema.js +++ b/genai/controlled-generation/ctrlgen_with_resp_schema.js @@ -15,6 +15,7 @@ 'use strict'; // [START googlegenaisdk_ctrlgen_with_resp_schema] +// todo const {GoogleGenAI} = require('@google/genai'); const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT; @@ -30,34 +31,20 @@ async function generateContent( location: location, }); - const prompt = ` - The week ahead brings a mix of weather conditions. - Sunday is expected to be sunny with a temperature of 77°F and a humidity level of 50%. Winds will be light at around 10 km/h. - Monday will see partly cloudy skies with a slightly cooler temperature of 72°F and the winds will pick up slightly to around 15 km/h. - Tuesday brings rain showers, with temperatures dropping to 64°F and humidity rising to 70%. - Wednesday may see thunderstorms, with a temperature of 68°F. - Thursday will be cloudy with a temperature of 66°F and moderate humidity at 60%. - Friday returns to partly cloudy conditions, with a temperature of 73°F and the Winds will be light at 12 km/h. - Finally, Saturday rounds off the week with sunny skies, a temperature of 80°F, and a humidity level of 40%. Winds will be gentle at 8 km/h. -`; + const prompt = 'List a few popular cookie recipes.'; const responseSchema = { - type: 'object', - properties: { - forecast: { - type: 'array', - items: { - type: 'object', - properties: { - Day: { type: 'string', nullable: true }, - Forecast: { type: 'string', nullable: true }, - Temperature: { type: 'integer', nullable: true }, - Humidity: { type: 'string', nullable: true }, - 'Wind Speed': { type: 'integer', nullable: true }, - }, - required: ['Day', 'Temperature', 'Forecast', 'Wind Speed'], + type: 'ARRAY', + items: { + type: 'OBJECT', + properties: { + recipe_name: {type: 'STRING'}, + ingredients: { + type: 'ARRAY', + items: {type: 'STRING'}, }, }, + required: ['recipe_name', 'ingredients'], }, }; @@ -69,7 +56,6 @@ async function generateContent( responseSchema: responseSchema, }, }); - console.log(response); console.log(response.text); @@ -79,4 +65,4 @@ async function generateContent( module.exports = { generateContent, -}; \ No newline at end of file +}; diff --git a/genai/test/ctrlgen_with_class_schema.test.js b/genai/test/ctrlgen_with_class_schema.test.js new file mode 100644 index 0000000000..ebff55bfe3 --- /dev/null +++ b/genai/test/ctrlgen_with_class_schema.test.js @@ -0,0 +1,29 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +const {assert} = require('chai'); +const {describe, it} = require('mocha'); + +const projectId = process.env.CAIP_PROJECT_ID; +const sample = require('../controlled-generation/ctrlgen_with_class_schema.js'); + +describe('ctrlgen_with_class_schema', () => { + it('should generate text content in Json', async function () { + this.timeout(10000); + const output = await sample.generateContent(projectId); + assert(output.length > 0 && output.includes('Cookies')); + }); +}); diff --git a/genai/test/ctrlgen_with_enum_class_schema.test.js b/genai/test/ctrlgen_with_enum_class_schema.test.js new file mode 100644 index 0000000000..c8fbb4c28a --- /dev/null +++ b/genai/test/ctrlgen_with_enum_class_schema.test.js @@ -0,0 +1,29 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +const {assert} = require('chai'); +const {describe, it} = require('mocha'); + +const projectId = process.env.CAIP_PROJECT_ID; +const sample = require('../controlled-generation/ctrlgen_with_enum_class_schema.js'); + +describe('ctrlgen_with_enum_class_schema', () => { + it('should generate text content in Json', async function () { + this.timeout(10000); + const output = await sample.generateContent(projectId); + assert(output.length > 0 && output.includes('String')); + }); +}); diff --git a/genai/test/ctrlgen_with_nested_class_schema.test.js b/genai/test/ctrlgen_with_nested_class_schema.test.js new file mode 100644 index 0000000000..f3a20feba3 --- /dev/null +++ b/genai/test/ctrlgen_with_nested_class_schema.test.js @@ -0,0 +1,29 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +const {assert} = require('chai'); +const {describe, it} = require('mocha'); + +const projectId = process.env.CAIP_PROJECT_ID; +const sample = require('../controlled-generation/ctrlgen_with_nested_class_schema.js'); + +describe('ctrlgen_with_nested_class_schema', () => { + it('should generate text content in Json', async function () { + this.timeout(10000); + const output = await sample.generateContent(projectId); + assert(output.length > 0 && output.includes('B')); + }); +}); diff --git a/genai/test/ctrlgen_with_nullable_schema.test.js b/genai/test/ctrlgen_with_nullable_schema.test.js new file mode 100644 index 0000000000..0d180ff3ae --- /dev/null +++ b/genai/test/ctrlgen_with_nullable_schema.test.js @@ -0,0 +1,29 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +const {assert} = require('chai'); +const {describe, it} = require('mocha'); + +const projectId = process.env.CAIP_PROJECT_ID; +const sample = require('../controlled-generation/ctrlgen_with_nullable_schema.js'); + +describe('ctrlgen_with_nullable_schema', () => { + it('should generate text content in Json', async function () { + this.timeout(10000); + const output = await sample.generateContent(projectId); + assert(output.length > 0 && output.includes('Day')); + }); +}); diff --git a/genai/test/ctrlgen_with_resp_schema.test.js b/genai/test/ctrlgen_with_resp_schema.test.js new file mode 100644 index 0000000000..66fba37d84 --- /dev/null +++ b/genai/test/ctrlgen_with_resp_schema.test.js @@ -0,0 +1,29 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +const {assert} = require('chai'); +const {describe, it} = require('mocha'); + +const projectId = process.env.CAIP_PROJECT_ID; +const sample = require('../controlled-generation/ctrlgen_with_resp_schema.js'); + +describe('ctrlgen_with_resp_schema', () => { + it('should generate text content in Json', async function () { + this.timeout(10000); + const output = await sample.generateContent(projectId); + assert(output.length > 0 && output.includes('Cookies')); + }); +}); From 6cbd2c981a04b4f38fe6546bbd0d8f0793755870 Mon Sep 17 00:00:00 2001 From: Guiners Date: Mon, 4 Aug 2025 12:22:58 +0200 Subject: [PATCH 6/8] adding tests --- genai/controlled-generation/ctrlgen_with_resp_schema.js | 1 - 1 file changed, 1 deletion(-) diff --git a/genai/controlled-generation/ctrlgen_with_resp_schema.js b/genai/controlled-generation/ctrlgen_with_resp_schema.js index 89f625ea29..da1e0f8493 100644 --- a/genai/controlled-generation/ctrlgen_with_resp_schema.js +++ b/genai/controlled-generation/ctrlgen_with_resp_schema.js @@ -15,7 +15,6 @@ 'use strict'; // [START googlegenaisdk_ctrlgen_with_resp_schema] -// todo const {GoogleGenAI} = require('@google/genai'); const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT; From 5dd5c7764b58113446dce853641c91f206cf33db Mon Sep 17 00:00:00 2001 From: Guiners Date: Mon, 4 Aug 2025 14:27:12 +0200 Subject: [PATCH 7/8] fixing filenames --- ...lgen_with_class_schema.js => ctrlgen-with-class-schema.js} | 0 ...enum_class_schema.js => ctrlgen-with-enum-class-schema.js} | 0 ...ed_class_schema.js => ctrlgen-with-nested-class-schema.js} | 0 ...ith_nullable_schema.js => ctrlgen-with-nullable-schema.js} | 0 ...trlgen_with_resp_schema.js => ctrlgen-with-resp-schema.js} | 0 ...class_schema.test.js => ctrlgen-with-class-schema.test.js} | 4 ++-- ..._schema.test.js => ctrlgen-with-enum-class-schema.test.js} | 2 +- ...chema.test.js => ctrlgen-with-nested-class-schema.test.js} | 2 +- ...le_schema.test.js => ctrlgen-with-nullable-schema.test.js} | 2 +- ...h_resp_schema.test.js => ctrlgen-with-resp-schema.test.js} | 2 +- genai/test/tools-code-exec-with-txt.test.js | 3 ++- genai/tools/tools-code-exec-with-txt.js | 2 +- 12 files changed, 9 insertions(+), 8 deletions(-) rename genai/controlled-generation/{ctrlgen_with_class_schema.js => ctrlgen-with-class-schema.js} (100%) rename genai/controlled-generation/{ctrlgen_with_enum_class_schema.js => ctrlgen-with-enum-class-schema.js} (100%) rename genai/controlled-generation/{ctrlgen_with_nested_class_schema.js => ctrlgen-with-nested-class-schema.js} (100%) rename genai/controlled-generation/{ctrlgen_with_nullable_schema.js => ctrlgen-with-nullable-schema.js} (100%) rename genai/controlled-generation/{ctrlgen_with_resp_schema.js => ctrlgen-with-resp-schema.js} (100%) rename genai/test/{ctrlgen_with_class_schema.test.js => ctrlgen-with-class-schema.test.js} (88%) rename genai/test/{ctrlgen_with_enum_class_schema.test.js => ctrlgen-with-enum-class-schema.test.js} (92%) rename genai/test/{ctrlgen_with_nested_class_schema.test.js => ctrlgen-with-nested-class-schema.test.js} (91%) rename genai/test/{ctrlgen_with_nullable_schema.test.js => ctrlgen-with-nullable-schema.test.js} (92%) rename genai/test/{ctrlgen_with_resp_schema.test.js => ctrlgen-with-resp-schema.test.js} (92%) diff --git a/genai/controlled-generation/ctrlgen_with_class_schema.js b/genai/controlled-generation/ctrlgen-with-class-schema.js similarity index 100% rename from genai/controlled-generation/ctrlgen_with_class_schema.js rename to genai/controlled-generation/ctrlgen-with-class-schema.js diff --git a/genai/controlled-generation/ctrlgen_with_enum_class_schema.js b/genai/controlled-generation/ctrlgen-with-enum-class-schema.js similarity index 100% rename from genai/controlled-generation/ctrlgen_with_enum_class_schema.js rename to genai/controlled-generation/ctrlgen-with-enum-class-schema.js diff --git a/genai/controlled-generation/ctrlgen_with_nested_class_schema.js b/genai/controlled-generation/ctrlgen-with-nested-class-schema.js similarity index 100% rename from genai/controlled-generation/ctrlgen_with_nested_class_schema.js rename to genai/controlled-generation/ctrlgen-with-nested-class-schema.js diff --git a/genai/controlled-generation/ctrlgen_with_nullable_schema.js b/genai/controlled-generation/ctrlgen-with-nullable-schema.js similarity index 100% rename from genai/controlled-generation/ctrlgen_with_nullable_schema.js rename to genai/controlled-generation/ctrlgen-with-nullable-schema.js diff --git a/genai/controlled-generation/ctrlgen_with_resp_schema.js b/genai/controlled-generation/ctrlgen-with-resp-schema.js similarity index 100% rename from genai/controlled-generation/ctrlgen_with_resp_schema.js rename to genai/controlled-generation/ctrlgen-with-resp-schema.js diff --git a/genai/test/ctrlgen_with_class_schema.test.js b/genai/test/ctrlgen-with-class-schema.test.js similarity index 88% rename from genai/test/ctrlgen_with_class_schema.test.js rename to genai/test/ctrlgen-with-class-schema.test.js index ebff55bfe3..00c5d95f71 100644 --- a/genai/test/ctrlgen_with_class_schema.test.js +++ b/genai/test/ctrlgen-with-class-schema.test.js @@ -18,9 +18,9 @@ const {assert} = require('chai'); const {describe, it} = require('mocha'); const projectId = process.env.CAIP_PROJECT_ID; -const sample = require('../controlled-generation/ctrlgen_with_class_schema.js'); +const sample = require('../controlled-generation/ctrlgen-with-class-schema.js'); -describe('ctrlgen_with_class_schema', () => { +describe('ctrlgen-with-class-schema', () => { it('should generate text content in Json', async function () { this.timeout(10000); const output = await sample.generateContent(projectId); diff --git a/genai/test/ctrlgen_with_enum_class_schema.test.js b/genai/test/ctrlgen-with-enum-class-schema.test.js similarity index 92% rename from genai/test/ctrlgen_with_enum_class_schema.test.js rename to genai/test/ctrlgen-with-enum-class-schema.test.js index c8fbb4c28a..93ffda262f 100644 --- a/genai/test/ctrlgen_with_enum_class_schema.test.js +++ b/genai/test/ctrlgen-with-enum-class-schema.test.js @@ -18,7 +18,7 @@ const {assert} = require('chai'); const {describe, it} = require('mocha'); const projectId = process.env.CAIP_PROJECT_ID; -const sample = require('../controlled-generation/ctrlgen_with_enum_class_schema.js'); +const sample = require('../controlled-generation/ctrlgen-with-enum-class-schema.js'); describe('ctrlgen_with_enum_class_schema', () => { it('should generate text content in Json', async function () { diff --git a/genai/test/ctrlgen_with_nested_class_schema.test.js b/genai/test/ctrlgen-with-nested-class-schema.test.js similarity index 91% rename from genai/test/ctrlgen_with_nested_class_schema.test.js rename to genai/test/ctrlgen-with-nested-class-schema.test.js index f3a20feba3..58589c1247 100644 --- a/genai/test/ctrlgen_with_nested_class_schema.test.js +++ b/genai/test/ctrlgen-with-nested-class-schema.test.js @@ -18,7 +18,7 @@ const {assert} = require('chai'); const {describe, it} = require('mocha'); const projectId = process.env.CAIP_PROJECT_ID; -const sample = require('../controlled-generation/ctrlgen_with_nested_class_schema.js'); +const sample = require('../controlled-generation/ctrlgen-with-nested-class-schema.js'); describe('ctrlgen_with_nested_class_schema', () => { it('should generate text content in Json', async function () { diff --git a/genai/test/ctrlgen_with_nullable_schema.test.js b/genai/test/ctrlgen-with-nullable-schema.test.js similarity index 92% rename from genai/test/ctrlgen_with_nullable_schema.test.js rename to genai/test/ctrlgen-with-nullable-schema.test.js index 0d180ff3ae..e4587f9012 100644 --- a/genai/test/ctrlgen_with_nullable_schema.test.js +++ b/genai/test/ctrlgen-with-nullable-schema.test.js @@ -18,7 +18,7 @@ const {assert} = require('chai'); const {describe, it} = require('mocha'); const projectId = process.env.CAIP_PROJECT_ID; -const sample = require('../controlled-generation/ctrlgen_with_nullable_schema.js'); +const sample = require('../controlled-generation/ctrlgen-with-nullable-schema.js'); describe('ctrlgen_with_nullable_schema', () => { it('should generate text content in Json', async function () { diff --git a/genai/test/ctrlgen_with_resp_schema.test.js b/genai/test/ctrlgen-with-resp-schema.test.js similarity index 92% rename from genai/test/ctrlgen_with_resp_schema.test.js rename to genai/test/ctrlgen-with-resp-schema.test.js index 66fba37d84..1b9d32c9b7 100644 --- a/genai/test/ctrlgen_with_resp_schema.test.js +++ b/genai/test/ctrlgen-with-resp-schema.test.js @@ -18,7 +18,7 @@ const {assert} = require('chai'); const {describe, it} = require('mocha'); const projectId = process.env.CAIP_PROJECT_ID; -const sample = require('../controlled-generation/ctrlgen_with_resp_schema.js'); +const sample = require('../controlled-generation/ctrlgen-with-resp-schema.js'); describe('ctrlgen_with_resp_schema', () => { it('should generate text content in Json', async function () { diff --git a/genai/test/tools-code-exec-with-txt.test.js b/genai/test/tools-code-exec-with-txt.test.js index cedd6f6b7c..01d7b20942 100644 --- a/genai/test/tools-code-exec-with-txt.test.js +++ b/genai/test/tools-code-exec-with-txt.test.js @@ -21,7 +21,8 @@ const projectId = process.env.CAIP_PROJECT_ID; const sample = require('../tools/tools-code-exec-with-txt.js'); describe('tools-code-exec-with-txt', async () => { - it('should generate code and execution result', async () => { + it('should generate code and execution result', async function () { + this.timeout(100000); const output = await sample.generateContent(projectId); assert(output.length > 0); }); diff --git a/genai/tools/tools-code-exec-with-txt.js b/genai/tools/tools-code-exec-with-txt.js index 7590be8237..0d0b883ac8 100644 --- a/genai/tools/tools-code-exec-with-txt.js +++ b/genai/tools/tools-code-exec-with-txt.js @@ -31,7 +31,7 @@ async function generateContent( }); const response = await ai.models.generateContent({ - model: 'gemini-2.5-flash-preview-05-20', + 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.', config: { From f7f1b54c142f2a57346f6505d85fe417c137ff15 Mon Sep 17 00:00:00 2001 From: Guiners Date: Tue, 5 Aug 2025 10:51:14 +0200 Subject: [PATCH 8/8] fixing code from code review and adding linters --- genai/controlled-generation/ctrlgen-with-class-schema.js | 6 +++--- .../ctrlgen-with-nested-class-schema.js | 6 +++--- genai/controlled-generation/ctrlgen-with-nullable-schema.js | 4 ++-- genai/controlled-generation/ctrlgen-with-resp-schema.js | 4 ++-- genai/test/ctrlgen-with-enum-class-schema.test.js | 4 ++-- genai/test/ctrlgen-with-nested-class-schema.test.js | 4 ++-- genai/test/ctrlgen-with-nullable-schema.test.js | 4 ++-- genai/test/ctrlgen-with-resp-schema.test.js | 4 ++-- genai/test/tools-code-exec-with-txt.test.js | 2 +- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/genai/controlled-generation/ctrlgen-with-class-schema.js b/genai/controlled-generation/ctrlgen-with-class-schema.js index a4a6609f9b..2c9ca1de18 100644 --- a/genai/controlled-generation/ctrlgen-with-class-schema.js +++ b/genai/controlled-generation/ctrlgen-with-class-schema.js @@ -32,11 +32,11 @@ async function generateContent( class Recipe { /** - * @param {string} recipe_name + * @param {string} recipeName * @param {string[]} ingredients */ - constructor(recipe_name, ingredients) { - this.recipe_name = recipe_name; + constructor(recipeName, ingredients) { + this.recipeName = recipeName; this.ingredients = ingredients; } } diff --git a/genai/controlled-generation/ctrlgen-with-nested-class-schema.js b/genai/controlled-generation/ctrlgen-with-nested-class-schema.js index c4dce84842..502acb1d1d 100644 --- a/genai/controlled-generation/ctrlgen-with-nested-class-schema.js +++ b/genai/controlled-generation/ctrlgen-with-nested-class-schema.js @@ -41,14 +41,14 @@ async function generateContent( class Recipe { /** - * @param {string} recipe_name + * @param {string} recipeName * @param {string} rating - Must be one of Grade enum values */ - constructor(recipe_name, rating) { + constructor(recipeName, rating) { if (!Object.values(Grade).includes(rating)) { throw new Error(`Invalid rating: ${rating}`); } - this.recipe_name = recipe_name; + this.recipeName = recipeName; this.rating = rating; } } diff --git a/genai/controlled-generation/ctrlgen-with-nullable-schema.js b/genai/controlled-generation/ctrlgen-with-nullable-schema.js index aae571855e..5459fc8c3e 100644 --- a/genai/controlled-generation/ctrlgen-with-nullable-schema.js +++ b/genai/controlled-generation/ctrlgen-with-nullable-schema.js @@ -53,9 +53,9 @@ async function generateContent( Forecast: {type: 'string', nullable: true}, Temperature: {type: 'integer', nullable: true}, Humidity: {type: 'string', nullable: true}, - 'Wind Speed': {type: 'integer', nullable: true}, + WindSpeed: {type: 'integer', nullable: true}, }, - required: ['Day', 'Temperature', 'Forecast', 'Wind Speed'], + required: ['Day', 'Temperature', 'Forecast', 'WindSpeed'], }, }, }, diff --git a/genai/controlled-generation/ctrlgen-with-resp-schema.js b/genai/controlled-generation/ctrlgen-with-resp-schema.js index da1e0f8493..4e54fcee64 100644 --- a/genai/controlled-generation/ctrlgen-with-resp-schema.js +++ b/genai/controlled-generation/ctrlgen-with-resp-schema.js @@ -37,13 +37,13 @@ async function generateContent( items: { type: 'OBJECT', properties: { - recipe_name: {type: 'STRING'}, + recipeName: {type: 'STRING'}, ingredients: { type: 'ARRAY', items: {type: 'STRING'}, }, }, - required: ['recipe_name', 'ingredients'], + required: ['recipeName', 'ingredients'], }, }; diff --git a/genai/test/ctrlgen-with-enum-class-schema.test.js b/genai/test/ctrlgen-with-enum-class-schema.test.js index 93ffda262f..6f7eece291 100644 --- a/genai/test/ctrlgen-with-enum-class-schema.test.js +++ b/genai/test/ctrlgen-with-enum-class-schema.test.js @@ -20,8 +20,8 @@ const {describe, it} = require('mocha'); const projectId = process.env.CAIP_PROJECT_ID; const sample = require('../controlled-generation/ctrlgen-with-enum-class-schema.js'); -describe('ctrlgen_with_enum_class_schema', () => { - it('should generate text content in Json', async function () { +describe('ctrlgen-with-enum-class-schema', () => { + it('should generate text content matching enum schema', async function () { this.timeout(10000); const output = await sample.generateContent(projectId); assert(output.length > 0 && output.includes('String')); diff --git a/genai/test/ctrlgen-with-nested-class-schema.test.js b/genai/test/ctrlgen-with-nested-class-schema.test.js index 58589c1247..824d9918ca 100644 --- a/genai/test/ctrlgen-with-nested-class-schema.test.js +++ b/genai/test/ctrlgen-with-nested-class-schema.test.js @@ -20,8 +20,8 @@ const {describe, it} = require('mocha'); const projectId = process.env.CAIP_PROJECT_ID; const sample = require('../controlled-generation/ctrlgen-with-nested-class-schema.js'); -describe('ctrlgen_with_nested_class_schema', () => { - it('should generate text content in Json', async function () { +describe('ctrlgen-with-nested-class-schema', () => { + it('should generate text content using nested schema', async function () { this.timeout(10000); const output = await sample.generateContent(projectId); assert(output.length > 0 && output.includes('B')); diff --git a/genai/test/ctrlgen-with-nullable-schema.test.js b/genai/test/ctrlgen-with-nullable-schema.test.js index e4587f9012..b3097e3029 100644 --- a/genai/test/ctrlgen-with-nullable-schema.test.js +++ b/genai/test/ctrlgen-with-nullable-schema.test.js @@ -20,8 +20,8 @@ const {describe, it} = require('mocha'); const projectId = process.env.CAIP_PROJECT_ID; const sample = require('../controlled-generation/ctrlgen-with-nullable-schema.js'); -describe('ctrlgen_with_nullable_schema', () => { - it('should generate text content in Json', async function () { +describe('ctrlgen-with-nullable-schema', () => { + it('should generate text content using nullable schema', async function () { this.timeout(10000); const output = await sample.generateContent(projectId); assert(output.length > 0 && output.includes('Day')); diff --git a/genai/test/ctrlgen-with-resp-schema.test.js b/genai/test/ctrlgen-with-resp-schema.test.js index 1b9d32c9b7..8653d6fadf 100644 --- a/genai/test/ctrlgen-with-resp-schema.test.js +++ b/genai/test/ctrlgen-with-resp-schema.test.js @@ -20,8 +20,8 @@ const {describe, it} = require('mocha'); const projectId = process.env.CAIP_PROJECT_ID; const sample = require('../controlled-generation/ctrlgen-with-resp-schema.js'); -describe('ctrlgen_with_resp_schema', () => { - it('should generate text content in Json', async function () { +describe('ctrlgen-with-resp-schema', () => { + it('should generate text content in given schema', async function () { this.timeout(10000); const output = await sample.generateContent(projectId); assert(output.length > 0 && output.includes('Cookies')); diff --git a/genai/test/tools-code-exec-with-txt.test.js b/genai/test/tools-code-exec-with-txt.test.js index 01d7b20942..61bd5d9513 100644 --- a/genai/test/tools-code-exec-with-txt.test.js +++ b/genai/test/tools-code-exec-with-txt.test.js @@ -20,7 +20,7 @@ const {describe, it} = require('mocha'); const projectId = process.env.CAIP_PROJECT_ID; const sample = require('../tools/tools-code-exec-with-txt.js'); -describe('tools-code-exec-with-txt', async () => { +describe('tools-code-exec-with-txt', () => { it('should generate code and execution result', async function () { this.timeout(100000); const output = await sample.generateContent(projectId);