Description
Checked other resources
- I added a very descriptive title to this issue.
- I searched the LangChain documentation with the integrated search.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangChain rather than my code.
- The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
`from langchain_redis import RedisChatMessageHistory
from langchain_core.messages import AIMessage, HumanMessage
history = RedisChatMessageHistory(session_id="test002",
redis_url="redis://localhost:6379",
key_prefix="chat_test:",
)
Add messages to the history
history.add_user_message("Hello, AI assistant!")
history.add_ai_message("Hello! How can I assist you today?")
Retrieve messages
print("Chat History:")
for message in history.messages:
print(f"{type(message).name}: {message.content}")
(myenv) PS D:\java-project\RuoYi\Russ-AI-Python> d:; cd 'd:\java-project\RuoYi\Russ-AI-Python'; & 'd:\software\system-software\Anaconda\envs\myenv\python.exe' 'c:\Users\yl.cursor\extensions\ms-python.debugpy-2024.6.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher' '60479' '--' 'd:\java-project\RuoYi\Russ-AI-Python\src\test555.py'
Chat History:
As long as key_prefix is added for the first initialization, history.messages will not get any value`
Error Message and Stack Trace (if applicable)
No response
Description
As long as key_prefix is added for the first initialization, history.messages will not get any value
System Info
(myenv) PS D:\java-project\RuoYi\Russ-AI-Python> d:; cd 'd:\java-project\RuoYi\Russ-AI-Python'; & 'd:\software\system-software\Anaconda\envs\myenv\python.exe' 'c:\Users\yl.cursor\extensions\ms-python.debugpy-2024.6.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher' '60479' '--' 'd:\java-project\RuoYi\Russ-AI-Python\src\test555.py'
Chat History: