neo4j版本是5.11.0,langchain的版本 0.0.288
下载apoc插件
https://neo4j.com/docs/apoc/current/installation/
neo4j.conf文件把apoc.*添加到dbms.security.procedures.unrestricted配置项
使用return apoc.version()来查看是否安装成功
pip install neo4j
图
参考官网:https://python.langchain.com/docs/use_cases/more/graph/graph_cypher_qa
from langchain.chat_models import ChatOpenAI
from langchain.chains import GraphCypherQAChain
from langchain.graphs import Neo4jGraph
import os
os.environ["OPENAI_API_KEY"] = 'xxx'
graph = Neo4jGraph(url="bolt://localhost:7687", username="neo4j", password="xxx"
)chain = GraphCypherQAChain.from_llm(ChatOpenAI(temperature=0), graph=graph, verbose=True, return_intermediate_steps=True
)result = chain("Who played in Top Gun?")
print(f"Intermediate steps: {result['intermediate_steps']}")
print(f"Final answer: {result['result']}")