Replies: 1 comment
-
Based on the code you've shared and the issues you're facing, it seems like the chatbot is not able to recall the context from previous conversations. This could be due to the way the In your current implementation, you're using To resolve this issue, you can modify your Here is a basic example of how you could do this: class CustomConversationalRetrievalChain(ConversationalRetrievalChain):
def _call(
self,
inputs: Dict[str, Any],
run_manager: Optional[CallbackManagerForChainRun] = None,
) -> Dict[str, Any]:
# Your custom logic here In this new class, you can add your logic to validate if retrieval of new documents is necessary and decide whether these documents should replace the new context or be appended to the old context. Additionally, if you want to modify how the context is stored or updated, you could also consider creating a new class that inherits from Please note that this is a high-level suggestion and you might need to adjust the code according to your specific requirements. You can refer to the ConversationalRetrievalChain and ConversationBufferMemory classes in the LangChain repository for more details. I hope this helps! If you have any further questions or need more clarification, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
The problem is that, with the standard Langchain chain, the chat is only able to reason from the results of the vector store similarity search. This introduces us to the following problem:
If I send a message to the AI introducing my friend Bob and say he is 28 years old, the bot will reason from the input message, maybe consider some vector store context (if there is any) and give us a response.
Then, if I ask the bot how old Bob is, it will be unable to answer "28 years old," because the bot will try to search for Bob in the vector store, but Bob was only mentioned in the message history.
How can I fix the above problem, as even after conversation is stored in chat_history, its not able to answer the question I asked from previos conversation .
System Info
langchain==0.1.1
pgvector
upstash_redis
Beta Was this translation helpful? Give feedback.
All reactions