Create a simple chatbot for question-answering your Notion knowledge base/docs using Openai, Typescript, LangChain and Pinecone.
This repo uses a Notion template of the support docs from cron - a next-generation calendar for professionals and teams
- Clone the repo
- Install packages
pnpm install
- Set up your
.envfile
- Copy
.env.exampleinto.envYour.envfile should look like this:
OPENAI_API_KEY=
PINECONE_API_KEY=
PINECONE_ENVIRONMENT=
- In the
configfolder, go intopinecone-index.tsand replacePINECONE_INDEX_NAMEwith the index name in your pinecone dashboard.
Export your dataset from Notion. You can do this by clicking on the three dots in the upper right hand corner and then clicking Export.
Follow these Notion instructions: Exporting your content
When exporting, make sure to select the Markdown & CSV format option.
Select Everything, include subpages and Create folders for subpages. Then click Export
This will produce a .zip file in your Downloads folder. Move the .zip file into the root of this repository.
Either unzip the folder using 7-Zip (or WinZip) or run the following Unix/Linux command to unzip the zip file (replace the Export... with your own file name).
unzip Export-d3adfe0f-3131-4bf3-8987-a52017fc1bae.zip -d Notion_DBYou should see a Notion_DB folder in your root folder that contains markdown files and folders of your knowledge base.
Now we need to ingest your docs. In very simple terms, ingesting is the process of converting your docs into numbers (embedding) that can be easily stored and analyzed for similarity searches.
npm run ingest
Run your local dev environment npm run dev.
Use the search bar to ask a question about your docs.
Simple.
You can deploy this app to the cloud with Vercel (Documentation).
This repo is inspired by notion-qa