Knowledge-Base is a slack bot that can be used to index webpages and chat with the bot to get relevant pages based on the message sent to the bot.
It can index complete websites using the sitemap of the website and can also index individual webpages.
It uses the pg_vector extension to create vectors of the webpage content and the user message and then uses the vectors to find the most relevant pages. It then uses the LLM (Language Model) to generate a response based on the context and the user message.
- Pull down the project from GitHub
git clone git@github.com:KamaniBhavin/knowledge-base.git
cd knowledge-base
- Start supabase local development containers
supabase start
-
Enable the pg_vector extension
- Get into the Supabase DB container and execute
sudo apt update sudo apt install postgresql-15-pgvector
- Execute the init.sql file under the supabase/functions directory
psql -U postgres -d postgres -f init.sql
-
Serve the functions
supabase serve
- Add the bot to your slack workspace from here
- use
/index <webpage url>
to index the webpage or/index-site-map <sitemap url>
all the pages in the sitemap - To chat with the bot just send a message from the bot message section.
When a user sends a site map url or a webpage url to the bot, the bot will embed the page and store it in the database. The bot will then use the pg_vector extension to create a vector of the page content and store it in the database. When a user sends a message to the bot, the bot will use the pg_vector extension to create a vector of the message and compare it with the vectors of the pages in the database and return the page with the highest similarity score.
Then this relevant pages are sent to LLM (Language Model) as a context and the LLM will generate a response based on the context and the user message. The response is then sent back to the user.
The bot is built using the following technologies:
- Supabase a. Database (Postgres) b. Edge Functions (Deno) c. Database Webhooks
- Slack API
- OpenAI API (GPT-3)
- pg_vector extension
- LangChain.js
- Other libraries(Eslint, Prettier, commit-lint, husky, lint-staged, typescript);
- Support for more file types like pdf, docs, etc.
- Support for more chat platforms like Discord, Telegram, etc.