Skip to content

About

This project utilizes an AI agent to build a personal knowledge base, enabling it to extract and consolidate information from Notion and local note files. By interacting with it through natural language, it assists me in organizing materials, managing schedules, and drafting weekly reports.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🧠 Personal Knowledge Base Agent (Second Brain)

Python LlamaIndex Qdrant Chainlit Docker

你的“第二大脑”与智能助理。基于 RAG (检索增强生成) 技术,连接 Notion、本地文件与 LLM,帮助你管理知识、回答问题并执行任务。

✨ 核心功能

  • 📚 多源数据同步: 支持 Notion (增量同步) 和 本地文件 (Markdown/PDF) 的自动清洗与向量化。
  • 🧠 智能问答 (RAG): 基于 Qdrant 向量数据库,提供精准的语义检索与问答。
  • 🤖 意图路由 (Agentic Workflow): 使用 LangGraph 构建,自动识别用户意图(查资料、写周报、闲聊)并分发给不同的处理单元。
  • ⚙️ 任务执行: 支持 Function Calling,可自动查询日历、整理周报并回写到 Notion。
  • 💬 现代化 UI: 基于 Chainlit 构建,支持流式输出、中间步骤可视化 (Glass Box) 和引用源溯源。
  • 🐳 一键部署: 提供 Docker Compose 配置,一键拉起所有服务。

🏗️ 系统架构

本项目采用分层架构设计:

  1. 数据层: Notion / Local Files -> ETL (LlamaIndex) -> Qdrant (Vector DB)
  2. 推理层: LangGraph (Router Node -> RAG Node / Action Node)
  3. 交互层: Chainlit (Web UI)

🚀 快速开始

1. 环境准备

确保本地已安装:

  • Docker & Docker Compose
  • Python 3.11+ (如果本地运行)
  • OpenAI API Key (或兼容的 LLM Key)
  • Notion Integration Token (如果需要同步 Notion)

2. 配置环境变量

复制 .env.example 为 .env 并填入你的 Key:

cp .env.example .env

.env 内容示例:

OPENAI_API_KEY=sk-your-openai-key...
NOTION_INTEGRATION_TOKEN=secret_your-notion-token...
QDRANT_URL=http://qdrant:6333

3. Docker 一键启动 (推荐)

docker-compose up -d

启动后访问: http://localhost:8000

4. 本地开发运行

如果你想修改代码进行调试:

# 1. 安装依赖
pip install -r requirements.txt

# 2. 启动 Qdrant (使用 Docker)
docker run -p 6333:6333 qdrant/qdrant

# 3. 运行数据同步 (可选)
python ingest.py

# 4. 启动 Chainlit 应用
chainlit run app.py -w

📂 目录结构

personal_knowledge_base/
├── app.py               # Chainlit 入口 (交互层)
├── logic.py             # LangGraph 核心逻辑 (推理层)
├── ingest.py            # 数据同步脚本 (Notion -> Qdrant)
├── notion_sync.py       # Notion 全量同步逻辑
├── incremental_sync.py  # Notion 增量同步逻辑
├── requirements.txt     # Python 依赖
├── Dockerfile           # 构建镜像
├── docker-compose.yml   # 容器编排
└── .env                 # 环境变量

🛠️ 技术栈

  • LLM Framework: LlamaIndex (数据索引), LangGraph (Agent 控制流)
  • Vector Database: Qdrant
  • UI Framework: Chainlit
  • LLM Provider: OpenAI (GPT-4o / GPT-3.5)
  • Tools: Notion API, Google Calendar API (Optional)

🤝 贡献

欢迎提交 Issue 和 Pull Request 来改进这个“第二大脑”!

📄 License

MIT

About

This project utilizes an AI agent to build a personal knowledge base, enabling it to extract and consolidate information from Notion and local note files. By interacting with it through natural language, it assists me in organizing materials, managing schedules, and drafting weekly reports.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages