Knowledge Base Demo | Voiceflow
Open AI GPT, Langchain, HNSWLib and Cheerio
This code utilizes Open AI GPT, Langchain, HNSWLib and Cheerio to fetch web content from URLs, create embeddings/vectors and save them in a local database. The knowledge base can then be used with GPT to answer questions.
Quickstart Video
Overview of the Voiceflow project https://loom.com/share/fafab48dc911417eadba61c77ae1e573
Voiceflow Project Template Link https://creator.voiceflow.com/prototype/643de15336147e000755e1f9
running on replit
- Import the github repo into a new project
- Run the following command in the shell to add a python package to the nix file:
sed -i 's/];/ pkgs.python311\n &/' replit.nix
- Run npm install in the shell
- run npm install ngrok
- Add the key-pairs from the .env.example file into the secrets section of replit
- When you're ready to start - run ngrok http in the shell to start a server
- Run npm start in the console to run the program
Fork this project directly on replit below
https://replit.com/@tubadsouza/Voiceflow-Replit-KB-Demo#.replit
Node.js
If you are running this on Node.js 16, either:
run your application with NODE_OPTIONS='--experimental-fetch' node ..., or install node-fetch and follow the instructions here
If you are running this on Node.js 18 or 19, you do not need to do anything.
Setup
Setup is simple, just run:
npm i
npm start
This app requires an .env
file with PORT
, OPENAI_API_KEY
and SECRET
(for API key encoding).
You can rename the .env.example file to .env and fill in the values.
Endpoints
There are 2 endpoints available:
/parser
This endpoint allows a POST request with the URL link of the page to parse. You need to pass the Voiceflow Assistant API Key in the body.
{
"url":"https://www.voiceflow.com/blog/prompt-chaining-conversational-ai",
"apikey":"VF.DM.XXX"
}
/question
This endpoint allows a POST request with the question. You need to pass the Voiceflow Assistant API Key in the body.
{
"question":"What is prompt chaining?",
"apikey":"VF.DM.XXX"
}
Using ngrok
To allow access to the app externally using the port set in the .env
file, you can use ngrok. Follow the steps below:
- Install ngrok: https://ngrok.com/download
- Run
ngrok http <port>
in your terminal (replace<port>
with the port set in your.env
file) - Copy the ngrok URL generated by the command and use it in your Voiceflow Assistant API step.
This can be handy if you want to quickly test this in an API step within your Voiceflow Assistant.