Portkey-AI / gateway

A Blazing Fast AI Gateway. Route to 200+ LLMs with 1 fast & friendly API.
https://portkey.ai/features/ai-gateway
MIT License
5.21k stars 356 forks source link

Fix tool calling for gemini #426

Open narengogi opened 5 days ago

narengogi commented 5 days ago

Title:

Description: (optional)


// Access your API key as an environment variable (see "Set up your API key" above)
const genAI = new GoogleGenerativeAI(process.env.API_KEY);

// ...

const generativeModel = genAI.getGenerativeModel({
  // Use a model that supports function calling, like a Gemini 1.5 model
  model: "gemini-1.5-flash",

  // Specify the function declaration.
  tools: {
    functionDeclarations: [controlLightFunctionDeclaration],
  },
});

Also added usage tokens while at it

Related Issue: https://github.com/Portkey-AI/gateway/issues/335