Getting the following exception when providing a return value from a tool call when using the google generative ai provider.
Uncaught APICallError AI_APICallError: Invalid value at 'contents[2].parts[0].function_response.response' (type.googleapis.com/google.protobuf.Struct), 25
Code example
import { createGoogleGenerativeAI } from '@ai-sdk/google';
import { generateText } from 'ai';
import { z } from 'zod';
async function main()
{
let google = createGoogleGenerativeAI({
apiKey: GoogleAIKey
});
let gemini = google("models/gemini-1.5-pro-latest");
let result = await generateText({
model: gemini,
tools: {
getTemperature: {
description: "get the current temperature in a city",
parameters: z.object({
city: z.string().describe("the city to get the temperature for")
}),
execute: async ({ city }) =>
{
console.log("getting temperature for " + city);
return 25;
}
},
},
prompt: "Get the temperature in Berlin",
maxToolRoundtrips: 1
});
console.log(result.text);
}
main();
Description
Getting the following exception when providing a return value from a tool call when using the google generative ai provider.
Uncaught APICallError AI_APICallError: Invalid value at 'contents[2].parts[0].function_response.response' (type.googleapis.com/google.protobuf.Struct), 25
Code example
Additional context
No response