Building-up your graph database
So that you don't have to regenerate your graph documents every time, it's best practice to store them in a database that's specifically designed for graph data. Neo4j graph databases are an excellent choice for graph storage and retrieval, so you'll set one up using LangChain's Neo4j functionality.
Note: to use Neo4j in LangChain, you must also have the neo4j
library installed as a dependency. In this course, this has already been done for you.
This exercise is part of the course
Retrieval Augmented Generation (RAG) with LangChain
Exercise instructions
- Instantiate the Neo4j graph using the
url
,user
, andpassword
variables provided. - Add the
graph_documents
to thegraph
, including their sources and additional entity labels. - Print the graph's schema.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Instantiate the Neo4j graph
graph = ____(url=url, username=user, password=password)
# Add the graph documents, sources, and include entity labels
graph.____
graph.refresh_schema()
# Print the graph schema
print(____)