ai-pdf-chatbot-langchain: Chat history is not included in the prompt (model is not aware of previous interactions)
Hi,
I have realized that the chat history is not included in the prompt. The logic for this is implemented, but the model is not aware of previous interactions (see the screenshot attached).
//Ask a question
const response = await chain.call({
question: sanitizedQuestion,
chat_history: history || [],
});

I feel that this is a bug or weird behaviour of Langchain, but I’m not sure. What do you think? Can you spot a bug? Is there any solution?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (1 by maintainers)
Made a new ticket: https://github.com/mayooear/gpt4-pdf-chatbot-langchain/issues/393
Here is what it means as chat_history.
If you input as this
`{ “question”: “why important?”,
“history”: [ “Upward management”
] }`
The answer will be “Upward management is important, because you want to earn trust from your boss…”
instead if you do this:
`{ “question”: “what is it?”,
“history”: [ “Upward management”
] }`
The answer will be “Upward management is a skill to manage your boss’s expectation…”
As you can see, the history is actually used to combine with current chat to format a standalone question, and then feed to LLM to get answer, please note that the chat history is NOT used as context!! The context is actually the document that you retrived from vector store.
Hope it helps
Console.log on the frontend or api route to verify the chathistory isn’t being passed on.