This repo is an implementation of a locally hosted chatbot specifically focused on question answering over the Quarto documentation. Built with LangChain and FastAPI.
The app leverages LangChain's streaming support and async API to update the page in real time for multiple users.
- Install dependencies:
pip install -r requirements.txt
- Install Quarto per these instructions.
- Clone the Quarto repo
- Run the command
quarto render
. This will generate the file_site/search.json
locally. Move that file to the root of this repo. - Run the app:
make start
- In templates/index.html, change the line of code
var endpoint = "wss://quarto-bot.onrender.com/chat";
tovar endpoint = "ws://localhost:9000/chat
(this is super hacky will fix this later). - Open localhost:9000 in your browser.
Deployed version: https://quarto-bot.onrender.com/
I am using render to deploy the site. The render.yaml facilitates this deployment.
There are two components: ingestion and question-answering.
Ingestion has the following steps:
- Pull search.json from the rendered site
- Load the search.json into a vector database (see
startup_event
inmain.py
). - Split documents with LangChain's TextSplitter
- Create a vectorstore of embeddings, using LangChain's vectorstore wrapper (with OpenAI's embeddings and FAISS vectorstore).
Question-Answering has the following steps, all handled by ChatVectorDBChain:
- Given the chat history and new user input, determine what a standalone question would be (using GPT-3).
- Given that standalone question, look up relevant documents from the vectorstore.
- Pass the standalone question and relevant documents to GPT-3 to generate a final answer.