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']}")
相关推荐
小陈phd2 小时前
混合知识库搭建:本地Docker部署Neo4j图数据库与Milvus向量库
数据库·docker·neo4j
玄同7655 小时前
Llama.cpp 全实战指南:跨平台部署本地大模型的零门槛方案
人工智能·语言模型·自然语言处理·langchain·交互·llama·ollama
玄同7655 小时前
LangChain v1.0+ Prompt 模板完全指南:构建精准可控的大模型交互
人工智能·语言模型·自然语言处理·langchain·nlp·交互·知识图谱
一只理智恩6 小时前
筹备计划·江湖邀请令!!!
python·langchain
华大哥6 小时前
AI大模型基于LangChain 进行RAG与Agent智能体开发
人工智能·langchain
玄同7657 小时前
LangChain v1.0+ Retrieval模块完全指南:从文档加载到RAG实战
人工智能·langchain·知识图谱·embedding·知识库·向量数据库·rag
卖芒果的潇洒农民10 小时前
20260201 GPT VPC中的CIDR Block 概念
笔记·gpt
码云数智-大飞11 小时前
基于语义内核(Semantic Kernel)与 Neo4j 构建轻量级知识问答系统
neo4j
薛定谔的猫198211 小时前
二十、使用PyTorch和Hugging Face Transformers训练中文GPT-2模型的技术实践
人工智能·pytorch·gpt
Bruk.Liu1 天前
(LangChain实战2):LangChain消息(message)的使用
开发语言·langchain