Maintain context in case of RAG (semantic search) when user query referes back to the previous conversation - for example: "How much does the second option cost?"

There are two ways to do this. Number one is, as @Macha suggests, sending the chat history with every request. The second is one I’ve used for some time now, and that is generating a Standalone question to send as your prompt: How to construct the prompt for a standalone question?

And, of course, using both methods together.

This is the classic use case for sending the Chat History with your requests.

That would be the Standalone question. That is, a question which contains the context of the conversation but can stand on it’s own. Combine that with the actual Chat History, and that should solve your problem.

2 Likes