generative-ai icon indicating copy to clipboard operation
generative-ai copied to clipboard

[Bug]: Support for multi-turn function calling

Open TaoChenOSU opened this issue 1 year ago • 1 comments

File Name

gemini/function-calling/function_calling_data_structures.ipynb

What happened?

Hi!

I am experiencing function calling with Gemini. On this document, it says Gemini support multi-turn function calling: https://ai.google.dev/gemini-api/docs/function-calling?_gl=15vmwdb_upMQ.._gaMTk5OTQ2NDQ4Ni4xNzI0OTYzMDg1_ga_P1DBVKWT6V*MTcyNDk2MzA4NS4xLjAuMTcyNDk2MzA4OS4wLjAuMTI0MjY5MDE1Ng..#function-calling-one-and-a-half-turn-curl-sample. However, in my experience, it doesn't support the following scenario:

  • I have two simple functions: one that doesn't take any parameter and just returns the current location of the user (getLocation); another one that take a location and return the weather of that location (getWeather).
  • I ask the following question: "What is the weather in my location?". The model is unable to first return a function call to getLocation then wait for the result of the call and finally issue a second turn that asks for getWeather.

Is this something that the model supports?

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

TaoChenOSU avatar Aug 29 '24 22:08 TaoChenOSU

Hi @TaoChenOSU, thanks for the report!

The sample notebook that you mentioned is for the Gemini API on Vertex AI, whereas the docs that you linked to are related to the Gemini API on Google AI.

Are you running that sample notebook with the Vertex AI SDK, or are you running the notebook (or a different code sample) using the Google AI SDK from https://ai.google.dev/gemini-api/docs/function-calling?

Both flavors of the Gemini API (Vertex AI Studio and Google AI Studio) support parallel function calling and multi-turn function calling. So the scenario that you described should work, and is demonstrated using Gemini on Vertex AI in the "Chat example: Using Function Calling in a chat session to answer user's questions about the Google Store" section in the Intro to Function Calling notebook.

koverholt avatar Aug 29 '24 23:08 koverholt

Closing due to inactivity. Please reopen if you have an update here. Thanks!

koverholt avatar Feb 05 '25 23:02 koverholt