google-gemini/cookbook

Function calling cookbook does not adequately explain how function calling works

Closed this issue · 1 comments

The documentation and the function calling cookbook examples confer the impression that the model will use one of the tool functions supplied by the client in the function_declarations array. In fact, the model predicts a tool function and is in no way constrained to use the tools listed.
Consider the following request (used in v1beta, gemini-pro)
Model request.json
It generated response like this (Headers and response body)
BadFunctionResponse2.txt
BadFunctionResponse2.json

The actual name of the functionCall the model will predict varies. This is another model response to that same identical model request
BadFunctionResponse3.json

The cookbook should, in my opinion, clarify that the function declaration section is not like a traditional software interface with strictly defined operations that specify a contract. The interface is open ended, with the model predicting useful tool functions it considers should be there.

I think the model is a lot better than it was at first launch at honoring your intent, and we now have a recipe showing how to use t he function_calling_config arg too: https://github.com/google-gemini/cookbook/blob/main/quickstarts/Function_calling_config.ipynb

Feel free to reopen if you think there's more we can do.