Build a Chatbot with a Knowledge Base
MindsDB provides the CREATE CHATBOT
statement that lets you customize your chatbot with an AI model and a data source of your choice. Follow this tutorial to learn build a chatbot with a knowledge base.
The CREATE CHATBOT
statement requires the following components:
-
Chat app: A connection to a chat app, such as Slack or MS Teams.
-
AI agent: An AI agent that comes with an AI model trained with the provided training data. Learn more about AI agents here.
Learn more about chatbots here.
Let’s go over getting all the components ready.
Chatbot Components
Chat App
Use the CREATE DATABASE
statement to connect the chat app to MindsDB.
AI Agent
Start by creating and deploying the model.
If you haven’t created a LangChain engine, use the CREATE ML_ENGINE
statement, as explained here.
Here is the command to check its status:
The status should read complete
before proceeding.
Next step is to create one or more skills for an AI agent. Here we create a knowledge base and assign it as a skill.
In this example, let’s create an embedding model (you can choose one from OpenAI, Hugging Face, or LangChain) for the knowledge base.
Now let’s create a knowledge base that uses this embedding model and the default storage vector database (that is, ChromaDB).
This is how you can insert data into the knowledge base and select it.
Use this knowledge base to create a skill for an agent:
This skill enables a model to answer questions about data from the knowledge base.
Now let’s create an AI agent using the above model and skill.
Create Chatbot
Once all the components are ready, let’s proceed to creating the chatbot.
The database
parameter stores connection to a chat app. And the agent
parameter stores an AI agent created by passing a model and training data.
You can query all chatbot using this query:
Now you can go to Slack or MS Teams and chat with the chatbot created with MindsDB.
Was this page helpful?