Skip to main content

Neptune Open Cypher QA Chain

This QA chain queries Neptune graph database using openCypher and returns human readable response

from langchain.graphs import NeptuneGraph

host = "<neptune-host>"
port = 8182
use_https = True

graph = NeptuneGraph(host=host, port=port, use_https=use_https)
from langchain.chains import NeptuneOpenCypherQAChain
from langchain.chat_models import ChatOpenAI

llm = ChatOpenAI(temperature=0, model="gpt-4")

chain = NeptuneOpenCypherQAChain.from_llm(llm=llm, graph=graph)

chain.run("how many outgoing routes does the Austin airport have?")
'The Austin airport has 98 outgoing routes.'