In my project in which I am implementing the google/generative-ai module, I am experiencing the following problem.
TypeError: Headers is not a constructor
at getHeaders (/home/project/project-backend/node_modules/@google/generative-ai/dist/index.js:328:21)
at constructModelRequest (/home/project/project-backend/node_modules/@google/generative-ai/dist/index.js:358:
at makeModelRequest (/home/project/project-backend/node_modules/@google/generative-ai/dist/index.js:364:41)
at generateContent (/home/project/project-backend/node_modules/@google/generative-ai/dist/index.js:815:28)
at GenerativeModel.generateContent (/home/project/project-backend/node_modules/@google/generative-ai/dist/index.js:1296:16)
at GeminiService.createContent (/home/project/project-backend/dist/src/modules/google/services/gemini.service.js:34:40)
This is my code
import {GoogleGenerativeAI} from "@google/generative-ai";
const model = this.geminiAi.getGenerativeModel({ model: geminiContentCreate.model});
geminiAi: GoogleGenerativeAI;
constructor() {
this.geminiAi = new GoogleGenerativeAI(config.geminiApiKey);
}
async createContent(geminiContentCreate: GeminiContentCreateDtov): Promise<any> {
try {
const result = await model.generateContent(geminiContentCreate.prompt);
const response = await result.response;
const text = response.text();
} catch (e) {
console.log(e);
}
}
Description of the bug:
In my project in which I am implementing the google/generative-ai module, I am experiencing the following problem.
This is my code
Actual vs expected behavior:
No response
Any other information you'd like to share?
I have tried both 0.16.0 and 0.17.0 versions