開始使用免費開始

建立你的圖形資料庫

為了避免每次都要重新產生圖形文件,最佳做法是把它們存放在專為圖形資料設計的資料庫中。Neo4j 圖形資料庫非常適合用於圖形的儲存與擷取,因此你會使用 LangChain 的 Neo4j 功能來設定一個實例。

注意:要在 LangChain 中使用 Neo4j,你也必須安裝 neo4j 函式庫作為相依套件。本課程已經替你完成這一步。

本練習屬於課程

使用 LangChain 的 Retrieval Augmented Generation(RAG)

檢視課程

練習說明

  • 使用提供的 urluserpassword 變數,建立 Neo4j 圖形物件。
  • graph_documents 加入 graph,並包含它們的來源與額外的實體標籤。
  • 列印圖的結構(schema)。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# 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(____)
編輯並執行程式碼