Skip to content

Commit e23c263

Browse files
add functions calling
1 parent 9438d1b commit e23c263

File tree

2 files changed

+413
-14
lines changed

2 files changed

+413
-14
lines changed

code_execution.js

+8-14
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ const model = genAI.getGenerativeModel({
99
model: 'gemini-1.5-pro',
1010
tools: [
1111
{
12-
codeExecution: {},
13-
},
14-
],
12+
codeExecution: {}
13+
}
14+
]
1515
});
1616

1717
const rl = readline.createInterface({
1818
input: process.stdin,
19-
output: process.stdout,
19+
output: process.stdout
2020
});
2121

2222
async function askQuestion(query) {
@@ -30,9 +30,7 @@ async function askQuestion(query) {
3030
async function main() {
3131
while (true) {
3232
try {
33-
const userQuestion1 = await askQuestion(
34-
"Enter your condition (or type 'exit' to quit): "
35-
);
33+
const userQuestion1 = await askQuestion("Enter your condition (or type 'exit' to quit): ");
3634

3735
if (userQuestion1.toLowerCase() === 'exit') {
3836
console.log('Exiting the program. Goodbye!');
@@ -41,9 +39,7 @@ async function main() {
4139
}
4240
let userQuestion2;
4341
if (userQuestion1 !== '') {
44-
userQuestion2 = await askQuestion(
45-
"Enter your question (or type 'exit' to quit): "
46-
);
42+
userQuestion2 = await askQuestion("Enter your question (or type 'exit' to quit): ");
4743
if (userQuestion2.toLowerCase() === 'exit') {
4844
console.log('Exiting the program. Goodbye!');
4945
rl.close();
@@ -52,10 +48,8 @@ async function main() {
5248
}
5349

5450
if (userQuestion1 !== '' && userQuestion2 !== '') {
55-
const result = await model.generateContent(
56-
userQuestion1 + userQuestion2
57-
);
58-
const response = result.response;
51+
const result = await model.generateContent(userQuestion1 + userQuestion2);
52+
console.log('Response:', result.response);
5953
}
6054
} catch (error) {
6155
console.error('An error occurred:', error);

0 commit comments

Comments
 (0)