When using function calling, Most of the time gemini API send the function call only. But sometimes, it sends text first and then call the function. I don’t want this behaviour. When invoking a function, I want the Gemini to send me function_name and parameters only.
How can I achieve this behaviour?
NOTE: I’m using StreamingResponse. Hence, I just can’t simply filter out text response. Current implementation of my app assumes that if we receive a text then it’s a response from Gemini and not a function call.
You can request it via system instructions, but to be 100% safe why not just filter it out from the response? It’s simple enough to get only the function call from the parts array.
Same issue here, I’m not using StreamingResponse but models.generateContent.
Used to work no problem, then text only is returned. Fine we can handle it somehow, but it’s so unpredictable and not sure how it will change in the next iteration of the model.
Hi @Naman_Vyas, I have tried with a sample code of using the function calling with both steaming and generate_content method the model was first calling the function all the time i have tried. Could you please let us know if you are still facing the issue, if yes please provide the standalone code you are using. Thank You.