Skip to content

Commit 06a3907

Browse files
committed
sample(js-gemini): added code execution sample for gemini
1 parent d9234d1 commit 06a3907

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

samples/js-gemini/src/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,20 @@ ai.defineFlow('reasoning', async (_, { sendChunk }) => {
218218
return message;
219219
});
220220

221+
// Gemini code execution.
222+
ai.defineFlow('code-execution', async (_, { sendChunk }) => {
223+
const { message } = await ai.generate({
224+
prompt: 'Calculate x^6-2x^5+x+11 for x=22',
225+
model: googleAI.model('gemini-2.5-flash'),
226+
config: {
227+
codeExecution: true,
228+
},
229+
onChunk: sendChunk,
230+
});
231+
232+
return message;
233+
});
234+
221235
// Image editing with Gemini.
222236
ai.defineFlow('gemini-image-editing', async (_) => {
223237
const plant = fs.readFileSync('palm_tree.png', { encoding: 'base64' });

0 commit comments

Comments
 (0)