How to create content aware chatbot

This article explains to to add to our S2B AI Assistant wordpress plugin content aware feature.

OpenAI introduced new Assistant API Assistant API which allows it automatically to parse and chunk uploaded documents, to create and to store the embeddings, and use both vector and keyword search to retrieve relevant content to answer user queries. We implemented File Search API feature in our pugin. Before using this on your website, you should remember some important tips:

  1. It is Beta feature and not yet tested carefully. Thus it can cause unpredicted behavior. Therefore, we cannot guarantee the chatbot’s responses.
  2. OpenAI charges additionally besides used conversational tokens. At the moment of release version 1.4.1 of this plugin it costs $0.10 / GB of vector-storage per day (1 GB free) + used tokens during conversation. Please observe OpenAI page to be informed about pricing updates.
  3. The effectiveness and accuracy of the bot’s responses depends on the system instructions provided and the models used in the prompts.

Setup content aware feature for AI chatbot.

To setup content aware chatbot using Assistant API you need to open page Chatbot and select Tab Assistant API.

After you need to perform 3 steps:

1.Upload file that will be used as knowledge base by ChatGPT.

We conducted a test on creating a chatbot that should use articles from a DOCX file and answer visitors’ questions related to Bubble.io using information from the articles uploaded to the Assistant API. You can download the test file from here. Here is the list of test questions we asked the assistant.

  1. Which attributes of Order Item?
  2. How many fields Order data type has?
  3. How to Prepare Database?
  4. How to Prepare Design?
  5. How to Remove Order Item from the Cart?
  6. Please create 20 questions related to uploaded file.

List of supported file types by filesearch tool of OpenAI Assistant API:

File format MIME type
.c text/x-c
.cs text/x-csharp
.cpp text/x-c++
.doc application/msword
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.html text/html
.java text/x-java
.json application/json
.md text/markdown
.pdf application/pdf
.php text/x-php
.pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
.py text/x-python
.py text/x-script.python
.rb text/x-ruby
.tex text/x-tex
.txt text/plain
.css text/css
.js text/javascript
.sh application/x-sh
.ts application/typescript

See updated list of file types from OpenAI

2.Create new Assistant by filling instruction and selecting model.

In this step, you need to identify two important parameters that impact your results. The first is the model. Not all models are suitable for the Assistant API. Only compatible models are listed here Although OpenAI accepts models such as gpt-3.5-turbo-1106 (and subsequent versions), our experiments have shown that the best choice is gpt-4-turbo-preview (and subsequent dated model releases). These are wiser and more content-aware.

Second factor that affects on results is instructions. You need input it into ‘Instructions’ field on Step2 .


instructions

In this field, you need to inform the chatbot about how to use the provided database. In our experiments, we tried using various values. The first version of the instructions was:

Please use uploaded files as a source when you respond to visitor queries. If you cannot find an answer, then use your knowledge database regarding Bubble.io.

When we tried to ask questions listed above then ChatGPT gave correct answers from uploaded file but it included reference to the uploaded file in them. For example: For more detailed instructions and insights, you can refer to the document “assistant_file2_1713207035_3957.docx. OR To prepare the design for implementing cart features in multi-vendor stores using Bubble.io, follow these steps outlined in the document “assistant_file2_1713207035_3957.docx”

So, we decided to remove mentioned file from answer by correcting Instruction: Use uploaded files as source when you respond to visitor queries. Do not mention uploaded document in the answer. Do not mention about source from where you take information for answer. When you can not find answer then use your knowledge database regarding Bubble.io. This helped us to achieve necessary result. But this approach worked only when we used gpt-4-turbo-preview model.

3.Select assistant as chatbot provider.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top