Gemini NodeJS SDK - ChatSession with Function Calling

117 views Asked by At

I am using the Gemini SDK for nodeJS, which has capability to start a new chat with history and generate a response from the AI model based on that. Gemini also has a function calling capability, and I was wondering if its somehow possible to utilize that within that chat session, i.e. start a chat session with both the history and a list of functions in the applicable schema, and then have Gemini determine when to call any of these functions if at all before completing the response.

Couldn't find a proper way to do that.

2

There are 2 answers

0
Connor Etherington On

Same issue, surprisingly difficult to find any helpful documentation on this anywhere on the net, or at least not that ive been able to find, if youre willing to take the time and function calling is a necessity to your project, you can switch to using the REST API, which is laid out here https://ai.google.dev/docs/function_calling#function-calling-one-and-a-half-turn-curl-sample

However, this is very much a makeshift and not the most practical approach

0
Raimundo Pereira da Silva Jr On

Looks like they are working on it. The lastet SKD holds functions methods but its not workig yet, check this out: https://github.com/google/generative-ai-js/issues/66