This tool empowers you to interrogate your Notion database using natural language queries. This project leverages the capabilities of LangChain for language processing.
To ensure the correct functioning of this tool, follow the steps below:
- Install all necessary dependencies with the following command:
pip install -r requirements.txt
- You'll also need to setup your OpenAI API key. If you don't have one yet, you can obtain it from OpenAI's official site. Once you have the key, set it up in your environment using the command:
export OPENAI_API_KEY=....
Here's a brief overview of what's included in this repository:
- A sample dataset from Blendle.
- Python script for querying your Notion data with a question.
- Codebase for deployment on StreamLit.
- Guidelines for importing your own dataset into the tool.
As an example, we have included the Blendle Employee Handbook dataset in this repository. Please note that this dataset was fetched on October 18th and may not represent the current state of the data.
To pose a question, execute the following command:
python qa.py "What is the work from home policy"
You can replace "What is the work from home policy"
with any question of your choice. This launches a chat-based interface for accessing information from a Notion database. It provides a more user-friendly and intuitive way of extracting information.
The necessary code to launch this tool as a StreamLit app is located in main.py
. Please ensure to add your OPENAI_API_KEY
as a secret environment variable while setting up the StreamLit app.
Here's how you can import your data from Notion:
- Start by exporting your data from Notion. Click on the three-dot menu on the top right corner of your page and select
Export
.
- While exporting, ensure to choose the
Markdown & CSV
format.
-
The export process results in a
.zip
file in your Downloads folder. Transfer this file into the repository's directory. -
Use the following command to unzip the file (Replace
Export...
with the actual filename).
unzip Export-d3adfe0f-3131-4bf3-8987-a52017fc1bae.zip -d Notion_DB
- Now, ingest the data into the tool with this command:
python ingest.py
That's it! You've successfully ingested your own data. Now you can query it as follows:
python chat.py "What is the work from home policy"