Function calling not working in ChatGoogleGenerativeAI with gemini-1.5-pro or gemini-1.5-flash #6048
Replies: 1 comment 5 replies
-
Hey there, @DevDeepakBhattarai! I'm here to help you out with any bugs, questions, or contributions you have in mind. Let's tackle this issue together! 😊 The issue you're experiencing with the Gemini model returning an empty response when asked to use a tool could be due to several factors:
Here is an example of how to properly configure the tool declarations: const tools: GeminiTool[] = [
{
functionDeclarations: [
{
name: "test",
description: "Run a test with a specific name and get if it passed or failed",
parameters: {
type: "object",
properties: {
testName: {
type: "string",
description: "The name of the test that should be run.",
},
},
required: ["testName"],
},
},
],
},
]; Ensure that your tool calls and message content adhere to these specifications to avoid issues that might lead to empty responses from the Gemini model. |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
I am trying to build a LLM app with multiple model support in Next JS with app router and Vercel AI sdk. I currently have gpt, claude , groq(llama) and gemini. The app works as intended with other models like gpt, claude and groq. But when ever I try to use gemini in the app, it does not work.
When I ask gemini some random question like , "Hello" etc. It works and gives me answer. But as soon as I ask the model anything related to the tool (i.e tavily search tool and get weather at the momemt) it gives me completely empty response.
This is the output that I got from gemini in Langsmith
The response does not have
content
nor does it havetool_calls
.I saw that tool calling is a beta feature in Gemini , so I even changed the
apiVersion
ofChatGoogleGenerativeAI
tov1beta
after looking up the docs hereIs this a problem with langchain or is it problem with Google ?
System Info
pnpm version 9.4.0
platform Windows 10
Node version 18.17.0
Next Js 14.2.5
Beta Was this translation helpful? Give feedback.
All reactions