generative-ai-js
generative-ai-js copied to clipboard
Chat History significantly degrades Function Calling performance
Description of the bug:
Whenever I use Chat History (from the last 12 hours, I add the last 20 messages), the amount of times that Function Calling works (ie. it calls a function) drops very significantly.
After 50 tests, with ChatHistory filled with the same request each time... With Chat History enabled: the function is called 10% of the time With Chat History disabled: the function is called 100% of the time
In the case of Chat History being enabled, I've found it is particularly susceptible to not calling the function when optional function parameters aren't specified in the prompt (ie. it thinks it needs the parameters when it doesn't).
Actual vs expected behavior:
Expected: Function Calling function is called as part of call to Gemini
Actual: Gemini decides not to use any functions
Any other information you'd like to share?
Running within a NodeJS Google Cloud Function Tried using both Gemini 1.5 Flash and Gemini 1.5 Pro but get the same results. Using Function Calling mode "Auto" (as expected, mode "Any" fixes the issue but this mode cannot be used in my use case).