.ipynb
.pdf
Cassandra Chat Message History
Cassandra Chat Message History#
This notebook goes over how to use Cassandra to store chat message history.
Cassandra is a distributed database that is well suited for storing large amounts of data.
It is a good choice for storing chat message history because it is easy to scale and can handle a large number of writes.
# List of contact points to try connecting to Cassandra cluster.
contact_points = ["cassandra"]
from langchain.memory import CassandraChatMessageHistory
message_history = CassandraChatMessageHistory(
    contact_points=contact_points, session_id="test-session"
)
message_history.add_user_message("hi!")
message_history.add_ai_message("whats up?")
message_history.messages
[HumanMessage(content='hi!', additional_kwargs={}, example=False),
 AIMessage(content='whats up?', additional_kwargs={}, example=False)]
previous
Adding Message Memory backed by a database to an Agent
next
How to customize conversational memory
By Harrison Chase
    
      © Copyright 2023, Harrison Chase.
      
  Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/modules/memory/examples/cassandra_chat_message_history.html