Amazon Neptune is a high-performance graph analytics and serverless database for superior scalability and availability. This example shows the QA chain that queries theLangChain supports both Neptune Database and Neptune Analytics withNeptune
graph database usingopenCypher
and returns a human-readable response. Cypher is a declarative graph query language that allows for expressive and efficient data querying in a property graph. openCypher is an open-source implementation of Cypher.# Neptune Open Cypher QA Chain This QA chain queries Amazon Neptune using openCypher and returns human readable response
create_neptune_opencypher_qa_chain
.
Neptune Database is a serverless graph database designed for optimal scalability and availability. It provides a solution for graph database workloads that need to scale to 100,000 queries per second, Multi-AZ high availability, and multi-Region deployments. You can use Neptune Database for social networking, fraud alerting, and Customer 360 applications.
Neptune Analytics is an analytics database engine that can quickly analyze large amounts of graph data in memory to get insights and find trends. Neptune Analytics is a solution for quickly analyzing existing graph databases or graph datasets stored in a data lake. It uses popular graph analytic algorithms and low-latency analytic queries.
RunnableWithMessageHistory
. This adds message history to the chain, allowing us to create a chatbot that retains conversation state across multiple invocations.
To start, we need a way to store and load the message history. For this purpose, each thread will be created as an instance of InMemoryChatMessageHistory
, and stored into a dictionary for repeated access.
(Also see: https://python.langchain.com/docs/versions/migrating_memory/chat_history/#chatmessagehistory)
RunnableWithMessageHistory
. Note that we must set query
as the input key to match the format expected by the base chain.
session_id
needs to be generated for the conversation that the new InMemoryChatMessageHistory
will remember.
session_id
.
session_id
, responses will be returned in the context of previous queries in the conversation.