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']}")
相关推荐
带刺的坐椅3 小时前
LangChain4j 比 SolonAI 强在哪?弱在哪?
java·ai·langchain·solon·mcp
Kay_Liang4 小时前
大语言模型如何精准调用函数—— Function Calling 系统笔记
java·大数据·spring boot·笔记·ai·langchain·tools
沐雪架构师17 小时前
乐学LangChain(1):总体架构和核心组件
langchain·学习方法
马尚来21 小时前
helloworld入门【从0到1,LangChain+RAG全链路实战AI知识库】
langchain
马尚来21 小时前
从0到1,LangChain+RAG全链路实战AI知识库
langchain
叼菠萝1 天前
AI 应用开发三剑客系列:LangChain 如何撑起 LLM 应用开发基石?
python·langchain
MichaelIp1 天前
基于MCP协议的多AGENT文章自动编写系统
语言模型·langchain·prompt·ai写作·llamaindex·langgraph·mcp
玲小珑1 天前
LangChain.js 完全开发手册(十六)实战综合项目二:AI 驱动的代码助手
前端·langchain·ai编程
viperrrrrrrrrr72 天前
Agent向量存储中的记忆衰退与记忆过载解决方案
langchain·大模型·agent·rag
问问计算机2 天前
2.Neo4j是什么?
neo4j