Introduction
Creating a stateful chatbot is very straight forward and by way of example we will use the chomsky datasets that are already loaded and available in AllegroGraph.cloud. You can easily create a chatbot with your own data with only a few additional steps that are covered in our documentation.
(If you are using an installed AllegroGraph server, create repos as described here naming the repos chomsky
and chomsky-vec
rather than chomsky47
and chomsky47-vec
.)
The Chomsky Chatbot is built on AllegroGraph’s ChatStream functionality with the key feature being the chatState Magic Predicate which delivers 'Retrieval Augmented Generation with Feedback', or 'RAG with Feedback'. The term 'Feedback' in this case refers to storing short-term memories of the recent dialog in the long-term memory of a vector database.
The following assumes you have created an AllegroGraph.cloud account and are logged in.
You will also need your OpenAI API key that may be obtained from openai.com. (Keys shown in examples in the AllegroGraph documentation are not valid.)
Getting started
Open WebView and then open the chomsky
repository. Choose Query from the Repository menu on the left, then select ChatBot from the New Query drop down menu in the upper right.
You will be prompted with the option to first add your OpenAPI key or review documentation about this step. Select Navigate to the page.
In the Name field start typing openaiApiKey and select it. For the Value add your OpenAI API key. For the Scope you can just go with the default User but there are options to share your Chatbot with other AllegroGraph users.
Click on Save Query Options.
You are now set up to create a chatbot.
Creating the Chatbot
Navigate back to the chomsky
repository by clicking on root
(the root
catalog in the upper left and choosing the chomsky
repo. Get to the Query page (if necessary) by clicking Query from the Repository menu on the left, then select ChatBot from the New Query drop down menu in the upper right.
You will see a dialog with links to create a chatbot and documentation.
Select this page to create the Chomsky Chatbot.
On this page, click on Select a vector database and choose chomsky-vdb from the choices. That vector database is already created in AllegroGraph.cloud. To learn more about creating a vector database from your own Knowledge Graph-RDF Data, the Embedding Knowledge Graph Specification document.
Click on the Create button.
There are many advanced options in the Advanced Settings. We do not go into these options in this example.
Click on the Create button at the bottom (out of the image) to create the Chatbot and get to the chatbot page.
From this dialog you can start chatting with Chomsky, make edits, and delete the Chatbot.
You can create additional Chatbots by selecting the Add new Chatbot button.
Click on the Chat button. You now have a Chatbot that is ready to answer questions based on the data contained in the Knowledge Graph which directs the Large Language Model (LLM). This is an example of Graph Retrieval Augmented Generation or Graph RAG.
Start typing your questions to the Chomsky Bot in the question field at the bottom.
We asked Who is Noam Chomsky? and this is the response:
You can explore the logic used in answering the questions. Click on the Show Bot Logic button. AllegroGraph provides extensive details for tuning the responses in order to ensure accurate answers and understand variability for reduced hallucinations. (The logic is cut off in the image.)
Because we have implemented chatState Magic Predicate in AllegroGraph, the conversation is stored in AllegroGraph and the Chatbot can draw upon this dialog history to maintain continuity.
Ask the Chatbot what you have discussed and based on the history it will provide a valid response that is in context with your dialog over time.