Quickstart
Familiarize yourself with Zep and the Zep Python SDK, culminating in building a simple chatbot.
In this guide, we’ll walk through a simple example of how to use Zep Cloud to build a chatbot. We’re going to upload a number of datasets to Zep, building a graph of data about a user.
Then we’ll use the Zep Python SDK to retrieve and search the data.
Finally, we’ll build a simple chatbot that uses Zep to retrieve and search data to respond to a user.
Set up your environment
-
Sign up for a Zep Cloud account.
-
Ensure you install required dependencies into your Python environment before running this notebook. See Installing Zep SDKs for more information. Optionally create your environment in a
virtualenv
.
- Ensure that you have a
.env
file in your working directory that includes yourZEP_API_KEY
andOPENAI_API_KEY
:
Project Settings
in the Zep dashboard to manage your API keys.Create User and add a Session
Users in Zep may have one or more chat sessions. These are threads of messages between the user and an agent.
Datasets
We’re going to upload an assortment of data to Zep. These include past dialog with the agent, CRM support cases, and billing data.
Wait a minute or two!
We’ve batch uploaded a number of datasets that need to be ingested into Zep’s graph before they can be queried. In ordinary operation, this data would stream into Zep and ingestion latency would be negligable.
Retrieve data from Zep
We’ll start with getting a list of facts. We’ll see the temporal data associated with facts as well as the graph nodes the fact is related to.
The high-level memory
API offers a simple method for retrieving facts relevant to the current conversation, using the last 4 messages in the conversation and proximity to the User node to determine relevance.
The memory.get
method is a good starting point for retrieving relevant facts for a conversation. It’s a shortcut for passing in recent messages to the graph.search
API. It returns not just facts but
historical chat messages, too, offering everything you need to populate your agent’s prompts.
We can also use the graph.search
method to search facts for arbritary text. This API offers more options, including the ability to search node summaries and various rerankers.
Creating a simple Chatbot
In the next cells, Emily starts a new chat session with a support agent and complains that she can’t log in. Our simple chatbot will, given relevant facts retrieved from Zep’s graph, respond accordingly.
Here, the support agent is provided with Emily’s billing information and account status, which Zep retrieves as most relevant to Emily’s login issue.