I am making a very simple attempt using the Node JS sdk to make a chat message request with some systemInstructions defined, using 1.5
But, I am getting an error that the system_instruction is invalid:
Solved! Go to Solution.
Figured it out. Although the Node js SDK indicates that you can put `systemInstruction` in the startChat api......this is false and wrong.
You need to put the systemInstruction in the place that you make the `getGenerativeModel` call. Like this
Figured it out. Although the Node js SDK indicates that you can put `systemInstruction` in the startChat api......this is false and wrong.
You need to put the systemInstruction in the place that you make the `getGenerativeModel` call. Like this
const cacheManager = new GoogleAICacheManager(process.env.GEMINI_KEY);
let cache = null
try {
cache = await cacheManager.create({
name: "ai expert",
model: "gemini-1.5-flash-001",
systemInstruction: "how AI works?"
});
const genAI = new GoogleGenerativeAI(process.env.GEMINI_KEY);
const cacheModel = genAI.getGenerativeModelFromCachedContent(cache)
const content = await cacheModel.generateContent(["why we need ai"])
return {cache, cacheManager, content: content }
} catch (error) {
return error
}
I am trying to create context. I tried this solution, but it didn’t work with this code. Is there any other way to do same?