Hi, I am getting this typeerror for text key being undefined even when I am requesting with the same request body as in documentation. I am using NodeJS.
const { GoogleGenerativeAI } = require("@google/generative-ai");
// Access your API key as an environment variable (see "Set up your API key" above)
const genAI = new GoogleGenerativeAI(process.env.API_KEY);
async function run() {
// For text-only input, use the gemini-pro model
const model = genAI.getGenerativeModel({ model: "gemini-pro"});
const chat = model.startChat({
history: [
{
role: "user",
parts: [{ text: "Hello, I have 2 dogs in my house." }],
},
{
role: "model",
parts: [{ text: "Great to meet you. What would you like to know?" }],
},
],
generationConfig: {
maxOutputTokens: 100,
},
});
const msg = "How many paws are in my house?";
const result = await chat.sendMessage(msg);
const response = await result.response;
const text = response.text();
console.log(text);
}
run();
Response I am getting -
Cannot read properties of undefined (reading 'text') , with response code 500.
Hi, I am getting this typeerror for text key being undefined even when I am requesting with the same request body as in documentation. I am using NodeJS.
Code given in documentation - docs
Response I am getting - Cannot read properties of undefined (reading 'text') , with response code 500.
Your help is appriciated.