Context for chat is retained

This commit is contained in:
Mahesh Kommareddi 2024-07-28 21:56:25 -04:00
parent eea1f255cd
commit c1d4cd7578

View File

@ -22,6 +22,7 @@
let generatedImagePath = '';
let fileTree = '';
let fileContents = '';
let context = '';
let urlInput = '';
let urlContent = '';
@ -41,6 +42,7 @@
ipcRenderer.on('response-chunk', (event, chunk) => {
currentStreamingMessage += chunk;
messages = [...messages.slice(0, -1), { content: currentStreamingMessage, sender: 'ai' }];
context += chunk; // Move this line here
});
ipcRenderer.on('response-end', () => {
@ -156,6 +158,7 @@
{ content: userMessage, sender: 'user' },
{ content: '', sender: 'ai' }
];
context += `User: ${newMessage}\n`; // Add this line here
const promptToSend = newMessage;
newMessage = '';
const imagePathToSend = imagePath;
@ -170,7 +173,7 @@
model: selectedModel,
temperature,
maxTokens,
context: urlContent,
context: `${context}${urlContent}\n\nFile Tree:\n${fileTree}\n\nFile Contents:\n${fileContents}`,
fileTree,
fileContents
});