10. Add ChatMessageHistory to RunnableWithMessageHistory

Chain creation method to remember previous conversations

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("CH05-Memory")

Copy

 Start tracking LangSmith. 
[Project name] 
CH05-Memory 

Multi-turn Chain to remember previous conversations

Copy

Create a chain that records the conversation ( chain_with_history )

Copy

Copy

Run the first question

Copy

Copy

Copy

Then run the question

Copy

Copy

Copy

Below session_id If this is different, a new session is created.

Copy

Copy

Copy

Last updated