js-genai: Model never correctly calls any function, but it used to work
Function calling was working for me last week, but in the past few days the model never calls a function, but instead responds with text of the JSON it would use for the function call.
This used to work, so I believe my configuration and prompts are fine.
Hereโs an example response:
{
"candidates": [
{
"content": {
"parts": [
{
"text": "```tool_code\n{\n \"candidates\": [\n {\n \"content\": {\n \"parts\": [\n {\n \"functionCall\": {\n \"name\": \"get_weather\",\n \"args\": \"{\\\"zip_code\\\":\\\"11217\\\"}\"\n }\n }\n ]\n }\n }\n ]\n}\n```\n"
}
],
"role": "model"
},
"finishReason": "STOP",
"avgLogprobs": -0.027122719534512223
}
],
"modelVersion": "gemini-2.0-flash-001",
"usageMetadata": {
"promptTokenCount": 1819,
"candidatesTokenCount": 87,
"totalTokenCount": 1906,
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 1819
}
],
"candidatesTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 87
}
]
}
}
Note: There is no function called get_weather, but there is a function called getWeather, so it hallucinated the function, too
Any advice?
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 15 (6 by maintainers)
Currently, the gemini-2.5-flash-preview-native-audio-dialog model canโt invoke function tools. Additionally, when the gemini-2.0-flash-live-001 model does trigger function tools, however it generates a tool_outputs string block at the beginning.
Iโm running into this issue as well with the native audio dialog models
I have tried a couple times, can not really reproduce the issue, I think you also mentioned it is
sometimes responses are text of the function call, suspecting it is a model related behavior, created a bug internally to investigate. ๐Ohhhhh, thank you for the clarification, I think I understand your issue a lot better now. ๐ You meant that instead of giving a FunctionCall object, it instead gives the function call as text.
Thank you for surfacing this issue. Let me take a close look on this issue.
Can you explain a bit more on:
Can you paste your test case, I can try to reproduce it?
Thank you ๐