Skip to main content

Neo4j

Neo4j is an open-source graph database management system, renowned for its efficient management of highly connected data. Unlike traditional databases that store data in tables, Neo4j uses a graph structure with nodes, edges, and properties to represent and store data. This design allows for high-performance queries on complex data relationships.

This notebook goes over how to use Neo4j to store chat message history.

from langchain.memory import Neo4jChatMessageHistory

history = Neo4jChatMessageHistory(
url="bolt://localhost:7687",
username="neo4j",
password="password",
session_id="session_id_1",
)

history.add_user_message("hi!")

history.add_ai_message("whats up?")
history.messages