Hi guys, i'm new to javascript and i'm trying to create a chatbot on discord using gemini to help me develop. I'm having an issue when i try to add history to the session. Here is my the snippet causing the error;
const chatSession = model.startChat({
generationConfig: {
temperature: 1,
topP: 0.95,
topK: 64,
maxOutputTokens: 8192,
responseMimeType: 'text/plain',
},history: [
{ role: 'user', parts: [Array] },
{ parts: [Array], role: 'model' }
],
});```
The error disappears and it works perfect when i remove the history part. But i couldn't find any solution on web. To make history work
The error i'm getting;
```Error generating response: GoogleGenerativeAIFetchError: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent: [400 Bad Request] * GenerateContentRequest.contents[0].parts: contents.parts must not be empty.
* GenerateContentRequest.contents[1].parts: contents.parts must not be empty.
at handleResponseNotOk (C:\yazılım\python\discord\squirrelbot\my-discord-bot\node_modules\@google\generative-ai\dist\index.js:403:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async makeRequest (C:\yazılım\python\discord\squirrelbot\my-discord-bot\node_modules\@google\generative-ai\dist\index.js:376:9)
at async generateContent (C:\yazılım\python\discord\squirrelbot\my-discord-bot\node_modules\@google\generative-ai\dist\index.js:815:22)
at async ChatSession.sendMessage (C:\yazılım\python\discord\squirrelbot\my-discord-bot\node_modules\@google\generative-ai\dist\index.js:1129:9)
at async Client.<anonymous> (C:\yazılım\python\discord\squirrelbot\my-discord-bot\index.js:183:28) {
status: 400,
statusText: 'Bad Request',
errorDetails: undefined
}
``` As i said, i'm new to javascript and using generative ai API's so i really don't even know what am i doing. Any help would be appericated, thank you.