langchain+GPT+neo4j 图数据库

bash 复制代码
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()来查看是否安装成功

bash 复制代码
pip install neo4j


参考官网:https://python.langchain.com/docs/use_cases/more/graph/graph_cypher_qa

python 复制代码
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']}")
相关推荐
qq_5470261794 小时前
LangChain 中间件(Middleware)
中间件·langchain
Cha0DD4 小时前
【由浅入深探究langchain】第二十集-SQL Agent+Human-in-the-loop
人工智能·python·ai·langchain
Cha0DD4 小时前
【由浅入深探究langchain】第十九集-官方的SQL Agent示例
人工智能·python·ai·langchain
前端大波12 小时前
OpenClaw 本地安装与 GPT 模型接入计划(OpenAI 登录版)
gpt
Barkamin12 小时前
LangChain简单介绍
langchain
智算菩萨15 小时前
【论文复现】ML-MLM:基于PyTorch的多标签极小学习机完整复现教程(附GPT-5.4辅助科研提示词工程)
人工智能·pytorch·python·gpt·深度学习·论文笔记
百年੭ ᐕ)੭*⁾⁾16 小时前
Chroma简单上手
人工智能·语言模型·langchain·chroma·rag
ofoxcoding16 小时前
GPT-5.4 API 完全指南:性能实测、成本测算与接入方案(2026)
人工智能·gpt·算法·ai
147API16 小时前
GPT-5.4 vs Claude 4.6 接入差异对比(含迁移与统一接入)
gpt·claude·api中转·api大模型
Roselind_Yi17 小时前
【吴恩达2026 Agentic AI】面试向+项目实战(含面试题+项目案例)-2
人工智能·python·机器学习·面试·职场和发展·langchain·agent