https://github.com/n0rthin/notion-chat
SaaS that turns your Notion in a chat bot
https://github.com/n0rthin/notion-chat
chatbot gpt-4 notion openai
Last synced: 3 months ago
JSON representation
SaaS that turns your Notion in a chat bot
- Host: GitHub
- URL: https://github.com/n0rthin/notion-chat
- Owner: n0rthin
- Created: 2023-03-19T16:54:01.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-11T09:19:01.000Z (over 2 years ago)
- Last Synced: 2024-02-12T09:35:44.369Z (over 2 years ago)
- Topics: chatbot, gpt-4, notion, openai
- Language: TypeScript
- Homepage:
- Size: 621 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NotionChat
NotionChat is a SaaS where you can create a GPT-4 powered chatbot based on your Notion docs.
This is an MVP I worked on some time ago; it's obsolete now since Notion released its chatting feature.
# How it works
This project is based on [Retrieval Augmented Generation (RAG)](https://www.promptingguide.ai/techniques/rag) pattern to give GPT access to notion docs.
The process of chatbot creation looks like this:
1. User gives access to their Notion workspace
2. The user chooses which pages should the bot have access to
3. The backend fetches selected pages
4. Each page is split into parts that will fit into GPT-4 context window
5. Then, embeddings for all generated page parts are created with OpenAI [Embedding API](https://platform.openai.com/docs/guides/embeddings)
6. Embeddings generated by [separate python service](https://github.com/n0rthin/nc-sync-service)
7. Embeddings are stored in [Pinecone](https://www.pinecone.io/) vector database
8. Once all embeddings are generated and stored the chatbot is ready for usage
When a user writes to the chatbot:
1. Generate an embedding vector for the user's message
2. Find the closest vectors in the Pinecone
3. Extract original parts contents linked to the found vectors
4. Fill the user message along with the related pages and previous chat history into prompt template
5. Send prompt to the OpenAI [Chat Completion API](https://platform.openai.com/docs/api-reference/chat)
6. Stream response to the client
Stack:
TypeScript, NestJS, TypeORM, PostgreSQL
Python for the service responsible for generating embeddings
NextJS, Tailwind, React Query