AgencyKit RAG API Starter is a Node.js project designed to leverage Notion as a queryable knowledge base (via NotionCMS) and provide a robust framework for building dynamic knowledge bases with rich content. It utilizes the power of OpenAI for processing and generating content based on the knowledge base created from Notion pages.
- Notion CMS Integration: Utilizes
@agency-kit/notion-cms
for seamless Notion integration, turning Notion pages into a dynamic knowledge base that you can directly ask about. Thanks to NotionCMS, we can get plaintext/markdown straight from Notion API with ease. - Knowledge Base Indexing: Implements full-text search capabilities with
lunr
, making it easy to search through the knowledge base. - OpenAI Content Generation: Leverages
openai
SDK for generating responses and content suggestions based on the knowledge base content. - Customizable Routes: Offers a flexible routing system with
h3
to handle API requests and serve knowledge base content.
- Node.js (Version 14 or higher recommended)
- A Notion account and API key
- An OpenAI API key
-
Clone the repository to your local machine:
git clone https://github.com/agency-kit/agencykit-rag-api-starter.git cd agencykit-rag-api-starter
-
Install the dependencies:
npm install
-
Create a
.env
file in the root directory and add your Notion API key and OpenAI API key:NOTION_API=<Your_Notion_API_Key> OPEN_AI_API_KEY=<Your_OpenAI_API_Key>
-
Populate your Notion database with content and note down the database ID. Don't know how to get that? See this guide.
-
Update the
notionCMSService.js
file with your Notion database ID:databaseId: 'Your_Notion_Database_ID',
Make sure to update your NotionCMS options to match your DB setup. See the full list of options here.
-
Start the server with
npm run serve
. The server listens on port 3000 by default. -
Make a POST request to
/search
with a query to search through the knowledge base.Example request body:
{ "query": "How to build a blog with NotionCMS" }
Contributions are welcome! Please fork the repository and open a pull request with your changes or improvements.
This project is licensed under the MIT License. See the LICENSE
file for details.