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']}")
相关推荐
阿加犀智能1 小时前
使用Langchain生成本地rag知识库并搭载大模型
服务器·python·langchain
陈敬雷-充电了么-CEO兼CTO4 小时前
BLIP-2革新多模态预训练:QFormer桥接视觉语言,零样本任务性能飙升10.7%!
人工智能·gpt·机器学习·机器人·多模态·blip·多模态大模型
安思派Anspire15 小时前
GPT-OSS 深度解析:OpenAI 最新大语言模型(LLM)架构
gpt·语言模型·架构
乔巴先生2415 小时前
LLMCompiler:基于LangGraph的并行化Agent架构高效实现
人工智能·python·langchain·人机交互
AI Echoes1 天前
LLMOps平台:开源项目LMForge = GPTs + Coze
人工智能·python·langchain·开源·agent
YUELEI1181 天前
langchain 输出解析器 Output Parser
langchain
玲小珑1 天前
LangChain.js 完全开发手册(七)RAG(检索增强生成)架构设计与实现
前端·langchain·ai编程
danns8881 天前
neo4j数据库创建范例(SQL文)
数据库·sql·neo4j
虫无涯1 天前
LangChain中的Prompt模板如何使用?
服务器·langchain·prompt
ChinaRainbowSea2 天前
7. LangChain4j + 记忆缓存详细说明
java·数据库·redis·后端·缓存·langchain·ai编程