Issue: Prompts Always Start a New Chat Instead of Continuing
Unanswered
Payal Verma posted this in #help-forum
I’m facing an issue: whenever I enter a new prompt, it creates a new chat. However, what I want is for the new content to be added to the previous chat instead of creating a new one every time. When I select a previous chat, it works fine and adds the new content to that particular chat.
GitHub: https://github.com/PayalVerma1/Chat-ai.git
Please help me with this issue.
GitHub: https://github.com/PayalVerma1/Chat-ai.git
Please help me with this issue.
8 Replies
Boerboel
My guess is your not appending the chat but rather your replace the new message to the whole state
But look at it the store chat context does spread the previous chat so that might not be the issue
Is the issue fixed cause i see no issue so far
It's not fixed ...and i don't know why the chat is not fetching the id of prev chat
@Payal Verma I’m facing an issue: whenever I enter a new prompt, it creates a new chat. However, what I want is for the new content to be added to the previous chat instead of creating a new one every time. When I select a previous chat, it works fine and adds the new content to that particular chat.
GitHub: https://github.com/PayalVerma1/Chat-ai.git
Please help me with this issue.
const res = await axios.post("/api/chat", {
prompt: newPrompt,
chatId: id,
});
here you are only sending the new prompt to the backend,
const response = await groq.chat.completions.create({
model: "llama-3.3-70b-versatile",
messages: [{ role: "user", content: prompt }],
});
and the backend only sends that single prompt to the LLM. so every time you send a message, as far as the backend and the LLM are concerned it is an entirely new chat.
to keep it the same chat you need to get the chat history first and then send the whole thing to the LLM
const response = await groq.chat.completions.create({
model: "llama-3.3-70b-versatile",
messages: [
...chatHistory, // <- HERE
{ role: "user", content: prompt }
],
});
you need to get the
chatHistory
, either from the POST payload or from the database, your choiceIt also didn't worked
Help us help you. How do I know what went wrong if all you say is “it didn’t work”?
The thing you suggested didn't worked...it didn't served the purpose ...the problem was i only made folder for id but there was no folder for no id ....so i made one now it is working