Skip to content

Commit 11f722d

Browse files
author
Guiners
committed
adding samples, test, lints
1 parent 6ceefd1 commit 11f722d

7 files changed

+59
-49
lines changed

genai/controlled-generation/ctrlgen-with-class-schema.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,27 @@ async function generateContent(
5151
});
5252

5353
console.log(response.text);
54+
55+
// Example output:
56+
// [Recipe(recipe_name='Chocolate Chip Cookies', ingredients=['2 1/4 cups all-purpose flour'
57+
// {
58+
// "ingredients": [
59+
// "2 1/4 cups all-purpose flour",
60+
// "1 teaspoon baking soda",
61+
// "1 teaspoon salt",
62+
// "1 cup (2 sticks) unsalted butter, softened",
63+
// "3/4 cup granulated sugar",
64+
// "3/4 cup packed brown sugar",
65+
// "1 teaspoon vanilla extract",
66+
// "2 large eggs",
67+
// "2 cups chocolate chips"
68+
// ],
69+
// "recipe_name": "Classic Chocolate Chip Cookies"
70+
// }, ... ]
71+
5472
return response.text;
5573
}
56-
// Example output:
57-
// [Recipe(recipe_name='Chocolate Chip Cookies', ingredients=['2 1/4 cups all-purpose flour'
58-
// {
59-
// "ingredients": [
60-
// "2 1/4 cups all-purpose flour",
61-
// "1 teaspoon baking soda",
62-
// "1 teaspoon salt",
63-
// "1 cup (2 sticks) unsalted butter, softened",
64-
// "3/4 cup granulated sugar",
65-
// "3/4 cup packed brown sugar",
66-
// "1 teaspoon vanilla extract",
67-
// "2 large eggs",
68-
// "2 cups chocolate chips"
69-
// ],
70-
// "recipe_name": "Classic Chocolate Chip Cookies"
71-
// }, ... ]
74+
7275
// [END googlegenaisdk_ctrlgen_with_class_schema]
7376

7477
module.exports = {

genai/controlled-generation/ctrlgen-with-enum-class-schema.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ async function generateContent(
6464

6565
console.log(response.text);
6666

67+
// Example output:
68+
// String
69+
6770
return response.text;
6871
}
69-
// Example output:
70-
// String
72+
7173
// [END googlegenaisdk_ctrlgen_with_enum_class_schema]
7274

7375
module.exports = {

genai/controlled-generation/ctrlgen-with-enum-schema.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ async function generateContent(
4545
});
4646

4747
console.log(response.text);
48-
48+
// Example output:
49+
// Woodwind
4950
return response.text;
5051
}
51-
// Example output:
52-
// Woodwind
52+
5353
// [END googlegenaisdk_ctrlgen_with_enum_schema]
5454

5555
module.exports = {

genai/controlled-generation/ctrlgen-with-nested-class-schema.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ async function generateContent(
6565

6666
console.log(response.text);
6767

68+
// Example output:
69+
// [{"rating": "a+", "recipe_name": "Classic Chocolate Chip Cookies"}, ...]
70+
6871
return response.text;
6972
}
70-
// Example output:
71-
// [{"rating": "a+", "recipe_name": "Classic Chocolate Chip Cookies"}, ...]
73+
7274
// [END googlegenaisdk_ctrlgen_with_nested_class_schema]
7375

7476
module.exports = {

genai/controlled-generation/ctrlgen-with-nullable-schema.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,18 @@ async function generateContent(
7171
});
7272
console.log(response.text);
7373

74+
// Example output:
75+
// {"forecast": [{"Day": "Sunday", "Forecast": "sunny", "Temperature": 77, "Wind Speed": 10, "Humidity": "50%"},
76+
// {"Day": "Monday", "Forecast": "partly cloudy", "Temperature": 72, "Wind Speed": 15},
77+
// {"Day": "Tuesday", "Forecast": "rain showers", "Temperature": 64, "Wind Speed": null, "Humidity": "70%"},
78+
// {"Day": "Wednesday", "Forecast": "thunderstorms", "Temperature": 68, "Wind Speed": null},
79+
// {"Day": "Thursday", "Forecast": "cloudy", "Temperature": 66, "Wind Speed": null, "Humidity": "60%"},
80+
// {"Day": "Friday", "Forecast": "partly cloudy", "Temperature": 73, "Wind Speed": 12},
81+
// {"Day": "Saturday", "Forecast": "sunny", "Temperature": 80, "Wind Speed": 8, "Humidity": "40%"}]}
82+
7483
return response.text;
7584
}
76-
// Example output:
77-
// {"forecast": [{"Day": "Sunday", "Forecast": "sunny", "Temperature": 77, "Wind Speed": 10, "Humidity": "50%"},
78-
// {"Day": "Monday", "Forecast": "partly cloudy", "Temperature": 72, "Wind Speed": 15},
79-
// {"Day": "Tuesday", "Forecast": "rain showers", "Temperature": 64, "Wind Speed": null, "Humidity": "70%"},
80-
// {"Day": "Wednesday", "Forecast": "thunderstorms", "Temperature": 68, "Wind Speed": null},
81-
// {"Day": "Thursday", "Forecast": "cloudy", "Temperature": 66, "Wind Speed": null, "Humidity": "60%"},
82-
// {"Day": "Friday", "Forecast": "partly cloudy", "Temperature": 73, "Wind Speed": 12},
83-
// {"Day": "Saturday", "Forecast": "sunny", "Temperature": 80, "Wind Speed": 8, "Humidity": "40%"}]}
85+
8486
// [END googlegenaisdk_ctrlgen_with_nullable_schema]
8587

8688
module.exports = {

genai/controlled-generation/ctrlgen-with-resp-schema.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,27 @@ async function generateContent(
5858

5959
console.log(response.text);
6060

61+
// Example output:
62+
// [
63+
// {
64+
// "ingredients": [
65+
// "2 1/4 cups all-purpose flour",
66+
// "1 teaspoon baking soda",
67+
// "1 teaspoon salt",
68+
// "1 cup (2 sticks) unsalted butter, softened",
69+
// "3/4 cup granulated sugar",
70+
// "3/4 cup packed brown sugar",
71+
// "1 teaspoon vanilla extract",
72+
// "2 large eggs",
73+
// "2 cups chocolate chips",
74+
// ],
75+
// "recipe_name": "Chocolate Chip Cookies",
76+
// }
77+
// ]
78+
6179
return response.text;
6280
}
63-
// Example output:
64-
// [
65-
// {
66-
// "ingredients": [
67-
// "2 1/4 cups all-purpose flour",
68-
// "1 teaspoon baking soda",
69-
// "1 teaspoon salt",
70-
// "1 cup (2 sticks) unsalted butter, softened",
71-
// "3/4 cup granulated sugar",
72-
// "3/4 cup packed brown sugar",
73-
// "1 teaspoon vanilla extract",
74-
// "2 large eggs",
75-
// "2 cups chocolate chips",
76-
// ],
77-
// "recipe_name": "Chocolate Chip Cookies",
78-
// }
79-
// ]
81+
8082
// [END googlegenaisdk_ctrlgen_with_resp_schema]
8183

8284
module.exports = {

genai/test/ctrlgen-with-nested-class-schema.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const projectId = process.env.CAIP_PROJECT_ID;
2121
const sample = require('../controlled-generation/ctrlgen-with-nested-class-schema.js');
2222
const {delay} = require('./util');
2323

24-
2524
describe('ctrlgen-with-nested-class-schema', () => {
2625
it('should generate text content using nested schema', async function () {
2726
this.timeout(180000);

0 commit comments

Comments
 (0)