Files

238 lines
4.6 KiB
Markdown
Raw Permalink Normal View History

# Agent Diary 🤖
**AI Agent 日记管理系统 | 工作记忆隔离 | RAG 支持**
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/)
[![React 18](https://img.shields.io/badge/react-18-blue.svg)](https://reactjs.org/)
[![PostgreSQL](https://img.shields.io/badge/postgresql-15-blue.svg)](https://www.postgresql.org/)
---
## 📖 项目介绍
Agent Diary 是一个专为 AI 助手设计的日记和工作记忆管理系统。
**核心功能**
- ✅ 多 AI Agent 实例管理
- ✅ 日记系统(成长之路)
- ✅ 工作记忆隔离
- ✅ 日历视图
- ✅ 标签和分类
- ✅ RAG 支持(预留 embedding 字段)
**适用场景**
- AI 助手开发者管理多个 Agent 实例
- OpenClaw/AutoGen/LangChain 用户
- 个人知识库管理
- 团队协作和知识共享
---
## 🚀 快速开始
### 方法 1: Docker Compose推荐
```bash
# 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/
```
### 方法 2: 本地开发
#### 后端
```bash
cd code/backend
# 创建虚拟环境
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
```
#### 前端
```bash
cd code/frontend
# 安装依赖
npm install
# 启动开发服务器
npm start
```
---
## 📊 功能展示
### 多 Agent 管理
```bash
curl http://localhost:8000/api/agents/
```
响应示例:
```json
[
{
"id": 1,
"name": "飞行侠",
"emoji": "🦸",
"specialty": "主力/通用",
"port": 18789
},
{
"id": 2,
"name": "道童",
"emoji": "☯️",
"specialty": "道德经注解",
"port": 18889
}
]
```
### 日记系统
每个 Agent 可以记录:
- **成长之路**:学习心得、成长记录
- **工作记忆**:日常工作、任务进展
- **技术笔记**:技术总结、问题解决
---
## 🗄️ 数据库配置
### SQLite开发环境
```python
# .env
DATABASE_URL=sqlite:///db.sqlite3
```
### PostgreSQL生产环境
```python
# .env
DATABASE_URL=postgresql://user:pass@localhost:5432/agent_diary_db
```
---
## 📝 API 文档
### Agent 相关
| 端点 | 方法 | 说明 |
|------|------|------|
| `/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 | 获取日记内容 |
---
## 🏗️ 技术架构
**后端**
- Django 4.x
- Django REST Framework
- PostgreSQL / SQLite
**前端**
- React 18
- React Router 6
- Axios
**部署**
- Docker
- Docker Compose
---
## 📂 项目结构
```
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
```
---
## 🔧 配置说明
### 环境变量
| 变量名 | 说明 | 默认值 |
|--------|------|--------|
| `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` |
---
## 🤝 贡献指南
欢迎提交 Issue 和 Pull Request
1. Fork 项目
2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
4. 推送到分支 (`git push origin feature/AmazingFeature`)
5. 开启 Pull Request
---
## 📄 开源协议
本项目采用 MIT 协议开源 - 查看 [LICENSE](LICENSE) 文件了解详情。
---
## 🙏 致谢
感谢所有贡献者和使用者!
---
**Made with ❤️ by Agent Diary Team**