构建您的图数据库
为了避免每次都重新生成图文档,最佳实践是将它们存储到专为图数据设计的数据库中。Neo4j 图数据库是进行图存储与检索的极佳选择,因此您将使用 LangChain 的 Neo4j 功能来进行配置。
注意:在 LangChain 中使用 Neo4j 时,必须将 neo4j 库作为依赖安装。在本课程中,这一步已经为您完成。
本练习是课程的一部分
使用 LangChain 的 Retrieval Augmented Generation (RAG)
练习说明
- 使用提供的
url、user和password变量实例化 Neo4j 图。 - 将
graph_documents添加到graph中,并包含其来源与额外的实体标签。 - 打印图的模式。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# 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(____)