05. RAG chain to remember interactive
Chain creation method to remember previous conversations
Advance knowledge to understand this
RunnableWithMessageHistory: https://wikidocs.net/235581
Copy
# API KEY A configuration file for managing environment variables
from dotenv import load_dotenv
# API KEY load information
load_dotenv()Copy
True Copy
# LangSmith set up tracking. https://smith.langchain.com
# !pip install langchain-teddynote
from langchain_teddynote import logging
# Enter a project name.
logging.langsmith("CH12-RAG")Copy
One. Add only dialogs to regular Chain
Copy
Create a chain that records the conversation ( chain_with_history )
Copy
Run the first question
Copy
Copy
Copy
Then run the question
Copy
Copy
Copy
2. RAG + RunnableWithMessageHistory
First, create a regular RAG Chain. However, in the six-stage prompt {chat_history} Be sure to add
Copy
Define functions to save the conversation
Copy
Run the first question
Copy
Copy
Copy
Execute subsequent questions
Copy
Copy
Copy
Last updated