Skip to content

Commit 40e54a0

Browse files
author
Guiners
committed
adding samples, test, lints
1 parent 87e4e16 commit 40e54a0

File tree

4 files changed

+47
-39
lines changed

4 files changed

+47
-39
lines changed

genai/tools/tools-code-exec-with-txt-local-img.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ async function generateContent(
8181
console.debug(response.executableCode);
8282
console.debug(response.codeExecutionResult);
8383

84+
// Example response:
85+
// Win percentage when switching: 65.50%
86+
// Win percentage when not switching: 34.50%
87+
8488
return response.codeExecutionResult;
8589
}
86-
// Example response:
87-
// Win percentage when switching: 65.50%
88-
// Win percentage when not switching: 34.50%
90+
8991
// [END googlegenaisdk_tools_code_exec_with_txt]
9092

9193
module.exports = {

genai/tools/tools-code-exec-with-txt.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,33 @@ async function generateContent(
4141
});
4242

4343
console.debug(response.executableCode);
44+
45+
// Example response:
46+
// Code:
47+
// function fibonacci(n) {
48+
// if (n <= 0) {
49+
// return 0;
50+
// } else if (n === 1) {
51+
// return 1;
52+
// } else {
53+
// let a = 0, b = 1;
54+
// for (let i = 2; i <= n; i++) {
55+
// [a, b] = [b, a + b];
56+
// }
57+
// return b;
58+
// }
59+
// }
60+
//
61+
// const fib20 = fibonacci(20);
62+
// console.log(`fib20=${fib20}`);
63+
4464
console.debug(response.codeExecutionResult);
4565

66+
// Outcome:
67+
// fib20=6765
68+
4669
return response.codeExecutionResult;
4770
}
48-
// Example response:
49-
// // Code:
50-
// function fibonacci(n) {
51-
// if (n <= 0) {
52-
// return 0;
53-
// } else if (n === 1) {
54-
// return 1;
55-
// } else {
56-
// let a = 0, b = 1;
57-
// for (let i = 2; i <= n; i++) {
58-
// [a, b] = [b, a + b];
59-
// }
60-
// return b;
61-
// }
62-
// }
63-
//
64-
// const fib20 = fibonacci(20);
65-
// console.log(`fib20=${fib20}`);
66-
//
67-
// // Outcome:
68-
// // fib20=6765
6971

7072
// [END googlegenaisdk_tools_code_exec_with_txt]
7173

genai/tools/tools-func-desc-with-txt.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,23 @@ async function generateContent(
8181
const output = JSON.stringify(response.functionCalls, null, 2);
8282
console.log(output);
8383

84+
// Example response:
85+
// [FunctionCall(
86+
// id=None,
87+
// name="get_album_sales",
88+
// args={
89+
// "albums": [
90+
// {"album_name": "Echoes of the Night", "copies_sold": 350000},
91+
// {"copies_sold": 120000, "album_name": "Reckless Hearts"},
92+
// {"copies_sold": 75000, "album_name": "Whispers of Dawn"},
93+
// {"copies_sold": 100000, "album_name": "Street Symphony"},
94+
// ]
95+
// },
96+
// )]
97+
8498
return output;
8599
}
86-
// Example response:
87-
// [FunctionCall(
88-
// id=None,
89-
// name="get_album_sales",
90-
// args={
91-
// "albums": [
92-
// {"album_name": "Echoes of the Night", "copies_sold": 350000},
93-
// {"copies_sold": 120000, "album_name": "Reckless Hearts"},
94-
// {"copies_sold": 75000, "album_name": "Whispers of Dawn"},
95-
// {"copies_sold": 100000, "album_name": "Street Symphony"},
96-
// ]
97-
// },
98-
// )]
100+
99101
// [END googlegenaisdk_tools_func_desc_with_txt]
100102

101103
module.exports = {

genai/tools/tools-google-search-with-txt.js

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

4545
console.log(response.text);
4646

47+
// Example response:
48+
// 'The next total solar eclipse in Poland will occur on ...'
49+
4750
return response.text;
4851
}
49-
// Example response:
50-
// 'The next total solar eclipse in Poland will occur on ...'
52+
5153
// [END googlegenaisdk_tools_google_search_with_txt]
5254

5355
module.exports = {

0 commit comments

Comments
 (0)