2026-04-03 19:14:21 +08:00
|
|
|
|
# Agent Diary 🤖
|
2026-04-01 20:48:44 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
**AI Agent 日记管理系统 | 工作记忆隔离 | RAG 支持**
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
[](https://opensource.org/licenses/MIT)
|
|
|
|
|
|
[](https://www.python.org/downloads/)
|
|
|
|
|
|
[](https://reactjs.org/)
|
|
|
|
|
|
[](https://www.postgresql.org/)
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
## 📖 项目介绍
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
Agent Diary 是一个专为 AI 助手设计的日记和工作记忆管理系统。
|
|
|
|
|
|
|
|
|
|
|
|
**核心功能**:
|
|
|
|
|
|
- ✅ 多 AI Agent 实例管理
|
|
|
|
|
|
- ✅ 日记系统(成长之路)
|
|
|
|
|
|
- ✅ 工作记忆隔离
|
|
|
|
|
|
- ✅ 日历视图
|
|
|
|
|
|
- ✅ 标签和分类
|
|
|
|
|
|
- ✅ RAG 支持(预留 embedding 字段)
|
|
|
|
|
|
|
|
|
|
|
|
**适用场景**:
|
|
|
|
|
|
- AI 助手开发者管理多个 Agent 实例
|
|
|
|
|
|
- OpenClaw/AutoGen/LangChain 用户
|
|
|
|
|
|
- 个人知识库管理
|
|
|
|
|
|
- 团队协作和知识共享
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
|
|
|
|
|
---
|
2026-04-01 20:48:44 +08:00
|
|
|
|
|
|
|
|
|
|
## 🚀 快速开始
|
|
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
### 方法 1: Docker Compose(推荐)
|
|
|
|
|
|
|
2026-04-01 20:48:44 +08:00
|
|
|
|
```bash
|
2026-04-03 19:14:21 +08:00
|
|
|
|
# 1. 克隆项目
|
|
|
|
|
|
git clone https://github.com/yourusername/agent-diary.git
|
|
|
|
|
|
cd agent-diary
|
|
|
|
|
|
|
|
|
|
|
|
# 2. 复制环境变量
|
|
|
|
|
|
cp .env.example .env
|
|
|
|
|
|
|
|
|
|
|
|
# 3. 启动服务
|
|
|
|
|
|
docker-compose up -d
|
|
|
|
|
|
|
|
|
|
|
|
# 4. 访问应用
|
|
|
|
|
|
# 前端:http://localhost:3000
|
|
|
|
|
|
# 后端 API: http://localhost:8000/api/agents/
|
2026-04-01 20:48:44 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
### 方法 2: 本地开发
|
|
|
|
|
|
|
|
|
|
|
|
#### 后端
|
|
|
|
|
|
|
2026-04-01 20:48:44 +08:00
|
|
|
|
```bash
|
|
|
|
|
|
cd code/backend
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
# 创建虚拟环境
|
|
|
|
|
|
python -m venv venv
|
|
|
|
|
|
source venv/bin/activate # Windows: venv\Scripts\activate
|
|
|
|
|
|
|
|
|
|
|
|
# 安装依赖
|
|
|
|
|
|
pip install -r requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
# 数据库迁移
|
|
|
|
|
|
python manage.py migrate
|
|
|
|
|
|
|
|
|
|
|
|
# 启动服务
|
|
|
|
|
|
python manage.py runserver 0.0.0.0:8000
|
2026-04-01 20:52:24 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
#### 前端
|
|
|
|
|
|
|
2026-04-01 20:52:24 +08:00
|
|
|
|
```bash
|
2026-04-03 19:14:21 +08:00
|
|
|
|
cd code/frontend
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
# 安装依赖
|
|
|
|
|
|
npm install
|
2026-04-01 20:48:44 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
# 启动开发服务器
|
|
|
|
|
|
npm start
|
|
|
|
|
|
```
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
## 📊 功能展示
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
### 多 Agent 管理
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
```bash
|
|
|
|
|
|
curl http://localhost:8000/api/agents/
|
|
|
|
|
|
```
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
响应示例:
|
|
|
|
|
|
```json
|
|
|
|
|
|
[
|
|
|
|
|
|
{
|
|
|
|
|
|
"id": 1,
|
|
|
|
|
|
"name": "飞行侠",
|
|
|
|
|
|
"emoji": "🦸",
|
|
|
|
|
|
"specialty": "主力/通用",
|
|
|
|
|
|
"port": 18789
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"id": 2,
|
|
|
|
|
|
"name": "道童",
|
|
|
|
|
|
"emoji": "☯️",
|
|
|
|
|
|
"specialty": "道德经注解",
|
|
|
|
|
|
"port": 18889
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
```
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
### 日记系统
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
每个 Agent 可以记录:
|
|
|
|
|
|
- **成长之路**:学习心得、成长记录
|
|
|
|
|
|
- **工作记忆**:日常工作、任务进展
|
|
|
|
|
|
- **技术笔记**:技术总结、问题解决
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
## 🗄️ 数据库配置
|
2026-04-01 20:48:44 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
### SQLite(开发环境)
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
|
# .env
|
|
|
|
|
|
DATABASE_URL=sqlite:///db.sqlite3
|
2026-04-01 20:48:44 +08:00
|
|
|
|
```
|
2026-04-03 19:14:21 +08:00
|
|
|
|
|
|
|
|
|
|
### PostgreSQL(生产环境)
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
|
# .env
|
|
|
|
|
|
DATABASE_URL=postgresql://user:pass@localhost:5432/agent_diary_db
|
2026-04-01 20:48:44 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-04-01 20:52:24 +08:00
|
|
|
|
---
|
|
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
## 📝 API 文档
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
### Agent 相关
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
| 端点 | 方法 | 说明 |
|
|
|
|
|
|
|------|------|------|
|
|
|
|
|
|
| `/api/agents/` | GET | 获取所有 Agent |
|
|
|
|
|
|
| `/api/agents/<id>/` | GET | 获取 Agent 详情 |
|
|
|
|
|
|
| `/api/agents/<id>/memory/dates/` | GET | 获取工作记忆日期 |
|
|
|
|
|
|
| `/api/agents/<id>/memory/<date>/` | GET | 获取工作记忆内容 |
|
|
|
|
|
|
| `/api/agents/<id>/diary/dates/` | GET | 获取日记日期 |
|
|
|
|
|
|
| `/api/agents/<id>/diary/<date>/` | GET | 获取日记内容 |
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
---
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
## 🏗️ 技术架构
|
|
|
|
|
|
|
|
|
|
|
|
**后端**:
|
|
|
|
|
|
- Django 4.x
|
|
|
|
|
|
- Django REST Framework
|
|
|
|
|
|
- PostgreSQL / SQLite
|
|
|
|
|
|
|
|
|
|
|
|
**前端**:
|
|
|
|
|
|
- React 18
|
|
|
|
|
|
- React Router 6
|
|
|
|
|
|
- Axios
|
|
|
|
|
|
|
|
|
|
|
|
**部署**:
|
|
|
|
|
|
- Docker
|
|
|
|
|
|
- Docker Compose
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
|
|
|
|
|
---
|
2026-04-01 20:48:44 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
## 📂 项目结构
|
2026-04-01 20:48:44 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
```
|
|
|
|
|
|
agent-diary/
|
|
|
|
|
|
├── code/
|
|
|
|
|
|
│ ├── backend/ # Django 后端
|
|
|
|
|
|
│ │ ├── agents/ # Agent 模型
|
|
|
|
|
|
│ │ ├── api/ # API 视图
|
|
|
|
|
|
│ │ └── manage.py
|
|
|
|
|
|
│ └── frontend/ # React 前端
|
|
|
|
|
|
│ ├── src/
|
|
|
|
|
|
│ │ ├── components/
|
|
|
|
|
|
│ │ └── pages/
|
|
|
|
|
|
│ └── package.json
|
|
|
|
|
|
├── docker-compose.yml
|
|
|
|
|
|
├── .env.example
|
|
|
|
|
|
├── README.md
|
|
|
|
|
|
└── requirements.txt
|
|
|
|
|
|
```
|
2026-04-01 20:48:44 +08:00
|
|
|
|
|
2026-04-01 20:52:24 +08:00
|
|
|
|
---
|
2026-04-01 20:48:44 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
## 🔧 配置说明
|
2026-04-01 20:48:44 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
### 环境变量
|
|
|
|
|
|
|
|
|
|
|
|
| 变量名 | 说明 | 默认值 |
|
|
|
|
|
|
|--------|------|--------|
|
|
|
|
|
|
| `WORKSPACE_BASE` | 工作区基础路径 | `/home/node/.openclaw/workspace` |
|
|
|
|
|
|
| `DATABASE_URL` | 数据库连接 URL | - |
|
|
|
|
|
|
| `SECRET_KEY` | Django 密钥 | - |
|
|
|
|
|
|
| `DEBUG` | 调试模式 | `True` |
|
|
|
|
|
|
| `POSTGRES_DB` | PostgreSQL 数据库名 | `agent_diary_db` |
|
|
|
|
|
|
| `POSTGRES_USER` | PostgreSQL 用户名 | `agent_user` |
|
|
|
|
|
|
| `POSTGRES_PASSWORD` | PostgreSQL 密码 | `agent2026` |
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
## 🤝 贡献指南
|
|
|
|
|
|
|
|
|
|
|
|
欢迎提交 Issue 和 Pull Request!
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
1. Fork 项目
|
|
|
|
|
|
2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
|
|
|
|
|
|
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
|
|
|
|
|
|
4. 推送到分支 (`git push origin feature/AmazingFeature`)
|
|
|
|
|
|
5. 开启 Pull Request
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
## 📄 开源协议
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
本项目采用 MIT 协议开源 - 查看 [LICENSE](LICENSE) 文件了解详情。
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
## 🙏 致谢
|
|
|
|
|
|
|
|
|
|
|
|
感谢所有贡献者和使用者!
|
|
|
|
|
|
|
|
|
|
|
|
---
|
2026-04-01 20:52:24 +08:00
|
|
|
|
|
2026-04-03 19:14:21 +08:00
|
|
|
|
**Made with ❤️ by Agent Diary Team**
|