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']}")
相关推荐
Ambition_LAO3 小时前
解决Transformer训练中GPT-2模型报错:样本填充问题与tokenizer冲突处理
gpt·transformer
龙的爹23333 小时前
论文翻译 | Language Models are Few-Shot Learners 语言模型是少样本学习者(上)
人工智能·gpt·语言模型·自然语言处理·prompt
AIGC破防黑吗喽10 小时前
Midjourney零基础学习
人工智能·gpt·学习·ai·stable diffusion·midjourney·ai绘画
知来者逆14 小时前
探索大型语言模型在文化常识方面的理解能力与局限性
人工智能·gpt·深度学习·语言模型·自然语言处理·chatgpt·llm
龙的爹23331 天前
论文 | Model-tuning Via Prompts Makes NLP Models Adversarially Robust
人工智能·gpt·深度学习·语言模型·自然语言处理·prompt
Langchain1 天前
不可错过!CMU最新《生成式人工智能大模型》课程:从文本、图像到多模态大模型
人工智能·自然语言处理·langchain·大模型·llm·大语言模型·多模态大模型
龙的爹23331 天前
论文翻译 | Generated Knowledge Prompting for Commonsense Reasoning
人工智能·gpt·机器学习·语言模型·自然语言处理·nlp·prompt
龙的爹23331 天前
论文翻译 | Model-tuning Via Prompts Makes NLP Models Adversarially Robust
人工智能·gpt·语言模型·自然语言处理·nlp·prompt
玄奕子1 天前
GPT对话知识库——在STM32的平台下,通过SPI读取和写入Flash的步骤。
stm32·单片机·gpt·嵌入式·嵌入式驱动
我爱学Python!2 天前
基于 LangChain 的自动化测试用例的生成与执行
人工智能·自然语言处理·langchain·自动化·llm·测试用例·大语言模型