Files · Perplexity Knowledge Agent for Notion SMB FAQ
85 (1 binary, 557.6 kB total)attempt 1
README.md·1665 B·markdown
markdown
# Perplexity Knowledge Agent for Notion SMB FAQ
## What this is
A conversational AI that answers employee and customer questions by searching Notion workspaces with Perplexity-augmented hybrid RAG using budget enforcement.
## Setup
Required environment variables:
- `NOTION_API_KEY` — OAuth token or integration token for your Notion workspace
- `PERPLEXITY_API_KEY` — API key for Perplexity Sonar Pro / pplx-70b-online
- `QDRANT_URL` — URL of your Qdrant instance (cloud or local)
- `QDRANT_API_KEY` — API key for Qdrant
```bash
pnpm install
```
To get Notion API keys, visit https://www.notion.so/profile/integrations. For Perplexity, sign up at https://perplexity.ai and create an API key. For Qdrant, use the cloud at https://cloud.qdrant.io or run locally with Docker.
## Usage
```bash
pnpm dev
```
The dev server starts with an initial indexing of configured Notion pages on boot. To ask a question:
```bash
curl -X POST http://localhost:3000/api/chat \
-H "Content-Type: application/json" \
-d '{"query": "What is our PTO policy?"}'
```
## Architecture
The pipeline follows these stages:
1. **Notion pages** are fetched via the Notion API and split into chunks
2. **FastEmbed BGEBaseEN** generates embeddings for each chunk
3. **Qdrant** (via `@reaatech/hybrid-rag-qdrant`) stores and retrieves chunks with hybrid search (dense + sparse)
4. **Perplexity pplx-70b-online** receives the query plus retrieved context chunks and generates a cited answer
5. **Zod validation & repair** ensures the response conforms to the expected schema
6. **Budget gating** enforces per-session and per-user spend limits before returning the response