Q&A Agent with Knowledge Base

In this tutorial, we will use the HelperAI platform to create a question-answering agent. We will store the answers to common questions in a knowledge base, allowing the agent to respond to user queries using the knowledge base. For this purpose, we will use Netflix's Top 10 rankings webpage as the data source for our question-answering agent, enabling it to answer common questions about popular Netflix movies.

Prerequisites

  1. You have a HelperAI account. If not, please register here.
  2. You have an OpenAI API key which is able to access GPT4 model. If not, please follow the instructions here to get one.

Create New Project

  1. Start by logging in to the HelperAI Workspace.
  2. Click on the + button next to Project in the left sidebar.
  3. A dialogue window will appear:
    • Enter the project name in the Project Name field: "My FAQ Project"
    • Enter your OpenAI API Key in the OpenAI API Key field.
  4. Click the Create New Project button.
  5. You will be redirected to the project page, where you will see a project named "My FAQ Project"

Create a Knowledge Base

  1. On the project page, click the + New Knowledge Base button.
  2. In the popup dialog box, select the Loader for your knowledge base. Here, we will choose the url Loader as a demonstration.
  3. Click the Next Step button.
  4. Enter the relevant settings for the knowledge base:
    • Knowledge Base Prompt Name: "netflix-top10"
    • Comment: "Netflix Trending Website"
    • Knowledge Base Prompt Description: "Query this knowledge base when you need to know Netflix trending."
    • Interval Minutes: "60"
    • Chunk Size: 3000 (Unit: tokens)
    • Overlap Size: 100 (Unit: tokens)
  5. In the Properties section, enter the following settings to configure the Loader options:
    • urls: https://www.netflix.com/tudum/top10/
  6. Click the Add Knowledge Base button. You will now see a new knowledge base named "netflix-top10" created under the project.

Create New Agent Under the Project

  1. On the project page, click on the + New Agent button.
  2. A dialogue window will appear:
    • Enter the agent name in the Agent Name field: "Netflix Q&A Agent"
    • Click the "Create New Agent" button.
  3. You will be redirected to the agent page, where you will see an agent named "Netflix Q&A Agent"

The url Loader is a lightweight knowledge base Loader that can load the contents of a knowledge base from one or more URLs. In the future, we will also provide more knowledge base Loaders. If there is no suitable knowledge base Loader for you, you can also develop your own knowledge base Loader and integrate it into HelperAI.

Set Goals for the Agent

  1. On the agent page, click on the Overview tab.

  2. Click on the pencil icon (✏️) next to Goals to edit the goals. A dialogue window should pop up.

  3. Click the + Add Blank Goal button to add a new blank goal entry, and enter the following goal description:

    1. Answer common questions from customers about popular Netflix movies
      
  4. Click the Save Changes button to save your goal settings.

Set Constraints for the Agent

  1. On the agent page, click on the Overview tab.

  2. Click on the pencil icon (✏️) next to Constraints to edit the constraints. A dialogue window should pop up.

  3. Click the + Add Blank Constraint button to sequentially add the following constraints:

    Only respond to questions about popular Netflix movies.
    
    The responses provided to the customer must be brief and professional.
    
  4. Click the Save Changes button to save your constraint settings.

Bind Knowledge Base to the Agent

  1. On the agent page, click on the Knowledge tab.
  2. Click on the + button. A dialogue window should pop up.
  3. From the dropdown menu under Knowledge Base, select the previously created "netflix-top10" knowledge base.
  4. After selecting the "netflix-top10" knowledge base, you will see the content of the "Knowledge Base Prompt" automatically filled in. We do not need to modify this content.
  5. In the Score Threshold field, enter "0.7".
  6. In the Top K field, enter "2".
  7. Click on Next Step. You may see some additional suggestions for setting goals and constraints for this knowledge base. We do not need to modify this content.
  8. Click on the Add Knowledge button. You will now see that the knowledge base has been linked to the agent.

The Score Threshold represents the threshold value used by HelperAI when querying the knowledge base. When HelperAI queries the knowledge base, it compares the data in the knowledge base with the keywords being searched and calculates a score. When the score exceeds the "Score Threshold", HelperAI considers the data to be relevant and adds it to the list of candidate answers. Here, we have set the "Score Threshold" to 0.7, meaning that only when HelperAI determines the similarity between the data and the user's input is above 70%, the data will be used as the background information for the agent's response.

The Top K represents the number of responses HelperAI will return when querying the knowledge base. Here, we have set the Top K to 5, meaning that HelperAI will only return the top 5 most similar data when querying the knowledge base. It is important to note that currently, the "Top K" value does not have any practical effect since we only set one URL earlier, so querying the knowledge base may return at most one data entry.

Test the Agent

  1. On the agent page, click on the button with a chat bubble icon (💬) in the top left corner. This will open a testing dialogue window.

  2. Now you can start a conversation with your first agent. For example, you can ask the agent:
    What is the most popular movie on Netflix?or What is the most popular TV show on Netflix?
    You should notice that your agent responds with the answer to your question based on the content of the url you provided earlier.