Skip to content

Commit e7b029d

Browse files
committed
feat: add Google Drive skills with Docker compatibility
- Add Google Drive API dependencies to backend pyproject.toml - Mount Google Drive credentials volume in Docker for token refresh - Add GOOGLE_DRIVE_TOKEN_PATH environment variable for runtime configuration - Supports token persistence and automatic refresh in Docker environment
1 parent 952059e commit e7b029d

20 files changed

Lines changed: 2303 additions & 18 deletions

backend/pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ dependencies = [
1616
"python-telegram-bot>=21.0",
1717
"langgraph-sdk>=0.1.51",
1818
"markdown-to-mrkdwn>=0.3.1",
19+
"websockets>=12.0",
20+
"google-api-python-client>=2.147.0",
21+
"google-auth-httplib2>=0.2.0",
22+
"google-auth-oauthlib>=1.2.1",
1923
]
2024

2125
[dependency-groups]

docker/docker-compose-dev.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ services:
5151
- deer-flow-dev
5252
restart: unless-stopped
5353
healthcheck:
54-
test: ["CMD", "curl", "-f", "http://localhost:8002/health"]
54+
test: [ "CMD", "curl", "-f", "http://localhost:8002/health" ]
5555
interval: 10s
5656
timeout: 5s
5757
retries: 6
@@ -100,8 +100,6 @@ services:
100100
- NODE_ENV=development
101101
- WATCHPACK_POLLING=true
102102
- CI=true
103-
- DEER_FLOW_INTERNAL_GATEWAY_BASE_URL=http://gateway:8001
104-
- DEER_FLOW_INTERNAL_LANGGRAPH_BASE_URL=http://langgraph:2024
105103
env_file:
106104
- ../frontend/.env
107105
networks:
@@ -117,9 +115,8 @@ services:
117115
args:
118116
APT_MIRROR: ${APT_MIRROR:-}
119117
UV_IMAGE: ${UV_IMAGE:-ghcr.io/astral-sh/uv:0.7.20}
120-
UV_INDEX_URL: ${UV_INDEX_URL:-https://pypi.org/simple}
121118
container_name: deer-flow-gateway
122-
command: sh -c "cd backend && uv sync && PYTHONPATH=. uv run uvicorn app.gateway.app:app --host 0.0.0.0 --port 8001 --reload --reload-include='*.yaml .env' > /app/logs/gateway.log 2>&1"
119+
command: sh -c "cd backend && PYTHONPATH=. uv run uvicorn app.gateway.app:app --host 0.0.0.0 --port 8001 --reload --reload-include='*.yaml .env' > /app/logs/gateway.log 2>&1"
123120
volumes:
124121
- ../backend/:/app/backend/
125122
# Preserve the .venv built during Docker image build — mounting the full backend/
@@ -146,6 +143,8 @@ services:
146143
read_only: true
147144
bind:
148145
create_host_path: true
146+
# Google Drive credentials (writeable for token refresh)
147+
- ../skills/custom/google-drive:/app/google-drive-credentials
149148
working_dir: /app
150149
environment:
151150
- CI=true
@@ -155,6 +154,8 @@ services:
155154
- DEER_FLOW_HOST_BASE_DIR=${DEER_FLOW_ROOT}/backend/.deer-flow
156155
- DEER_FLOW_HOST_SKILLS_PATH=${DEER_FLOW_ROOT}/skills
157156
- DEER_FLOW_SANDBOX_HOST=host.docker.internal
157+
# Google Drive token path (for write access)
158+
- GOOGLE_DRIVE_TOKEN_PATH=/app/google-drive-credentials/token.json
158159
env_file:
159160
- ../.env
160161
extra_hosts:
@@ -173,9 +174,8 @@ services:
173174
args:
174175
APT_MIRROR: ${APT_MIRROR:-}
175176
UV_IMAGE: ${UV_IMAGE:-ghcr.io/astral-sh/uv:0.7.20}
176-
UV_INDEX_URL: ${UV_INDEX_URL:-https://pypi.org/simple}
177177
container_name: deer-flow-langgraph
178-
command: sh -c "cd backend && uv sync && uv run langgraph dev --no-browser --allow-blocking --host 0.0.0.0 --port 2024 --n-jobs-per-worker 10 > /app/logs/langgraph.log 2>&1"
178+
command: sh -c "cd backend && uv run langgraph dev --no-browser --allow-blocking --host 0.0.0.0 --port 2024 > /app/logs/langgraph.log 2>&1"
179179
volumes:
180180
- ../backend/:/app/backend/
181181
# Preserve the .venv built during Docker image build — mounting the full backend/
@@ -202,13 +202,17 @@ services:
202202
read_only: true
203203
bind:
204204
create_host_path: true
205+
# Google Drive credentials (writeable for token refresh)
206+
- ../skills/custom/google-drive:/app/google-drive-credentials
205207
working_dir: /app
206208
environment:
207209
- CI=true
208210
- DEER_FLOW_HOME=/app/backend/.deer-flow
209211
- DEER_FLOW_HOST_BASE_DIR=${DEER_FLOW_ROOT}/backend/.deer-flow
210212
- DEER_FLOW_HOST_SKILLS_PATH=${DEER_FLOW_ROOT}/skills
211213
- DEER_FLOW_SANDBOX_HOST=host.docker.internal
214+
# Google Drive token path (for write access)
215+
- GOOGLE_DRIVE_TOKEN_PATH=/app/google-drive-credentials/token.json
212216
env_file:
213217
- ../.env
214218
extra_hosts:
@@ -224,6 +228,7 @@ volumes:
224228
gateway-venv:
225229
langgraph-venv:
226230

231+
227232
networks:
228233
deer-flow-dev:
229234
driver: bridge

docker/docker-compose.yaml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ services:
5050
container_name: deer-flow-frontend
5151
environment:
5252
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}
53-
- DEER_FLOW_INTERNAL_GATEWAY_BASE_URL=http://gateway:8001
54-
- DEER_FLOW_INTERNAL_LANGGRAPH_BASE_URL=http://langgraph:2024
5553
env_file:
5654
- ../frontend/.env
5755
networks:
@@ -66,7 +64,6 @@ services:
6664
args:
6765
APT_MIRROR: ${APT_MIRROR:-}
6866
UV_IMAGE: ${UV_IMAGE:-ghcr.io/astral-sh/uv:0.7.20}
69-
UV_INDEX_URL: ${UV_INDEX_URL:-https://pypi.org/simple}
7067
container_name: deer-flow-gateway
7168
command: sh -c "cd backend && PYTHONPATH=. uv run uvicorn app.gateway.app:app --host 0.0.0.0 --port 8001 --workers 2"
7269
volumes:
@@ -89,6 +86,8 @@ services:
8986
read_only: true
9087
bind:
9188
create_host_path: true
89+
# Google Drive credentials (writeable for token refresh)
90+
- ../skills/custom/google-drive:/app/google-drive-credentials
9291
working_dir: /app
9392
environment:
9493
- CI=true
@@ -99,13 +98,21 @@ services:
9998
- DEER_FLOW_HOST_BASE_DIR=${DEER_FLOW_HOME}
10099
- DEER_FLOW_HOST_SKILLS_PATH=${DEER_FLOW_REPO_ROOT}/skills
101100
- DEER_FLOW_SANDBOX_HOST=host.docker.internal
101+
# Google Drive token path (for write access)
102+
- GOOGLE_DRIVE_TOKEN_PATH=/app/google-drive-credentials/token.json
102103
env_file:
103104
- ../.env
104105
extra_hosts:
105106
- "host.docker.internal:host-gateway"
106107
networks:
107108
- deer-flow
108109
restart: unless-stopped
110+
healthcheck:
111+
test: [ "CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8001/health" ]
112+
interval: 2s
113+
timeout: 2s
114+
retries: 15
115+
start_period: 5s
109116

110117
# ── LangGraph Server ───────────────────────────────────────────────────────
111118
# TODO: switch to langchain/langgraph-api (licensed) once a license key is available.
@@ -117,12 +124,11 @@ services:
117124
args:
118125
APT_MIRROR: ${APT_MIRROR:-}
119126
UV_IMAGE: ${UV_IMAGE:-ghcr.io/astral-sh/uv:0.7.20}
120-
UV_INDEX_URL: ${UV_INDEX_URL:-https://pypi.org/simple}
121127
container_name: deer-flow-langgraph
122-
command: sh -c "cd /app/backend && uv run langgraph dev --no-browser --allow-blocking --no-reload --host 0.0.0.0 --port 2024 --n-jobs-per-worker 10"
128+
command: sh -c "cd /app/backend && uv run langgraph dev --no-browser --allow-blocking --no-reload --host 0.0.0.0 --port 2024"
123129
volumes:
124-
- ${DEER_FLOW_CONFIG_PATH}:/app/backend/config.yaml:ro
125-
- ${DEER_FLOW_EXTENSIONS_CONFIG_PATH}:/app/backend/extensions_config.json:ro
130+
- ${DEER_FLOW_CONFIG_PATH}:/app/config.yaml:ro
131+
- ${DEER_FLOW_EXTENSIONS_CONFIG_PATH}:/app/extensions_config.json:ro
126132
- ${DEER_FLOW_HOME}:/app/backend/.deer-flow
127133
- ../skills:/app/skills:ro
128134
- ../backend/.langgraph_api:/app/backend/.langgraph_api
@@ -141,22 +147,34 @@ services:
141147
read_only: true
142148
bind:
143149
create_host_path: true
150+
# Google Drive credentials (writeable for token refresh)
151+
- ../skills/custom/google-drive:/app/google-drive-credentials
144152
environment:
145153
- CI=true
146154
- DEER_FLOW_HOME=/app/backend/.deer-flow
147-
- DEER_FLOW_CONFIG_PATH=/app/backend/config.yaml
148-
- DEER_FLOW_EXTENSIONS_CONFIG_PATH=/app/backend/extensions_config.json
155+
- DEER_FLOW_CONFIG_PATH=/app/config.yaml
156+
- DEER_FLOW_EXTENSIONS_CONFIG_PATH=/app/extensions_config.json
149157
- DEER_FLOW_HOST_BASE_DIR=${DEER_FLOW_HOME}
150158
- DEER_FLOW_HOST_SKILLS_PATH=${DEER_FLOW_REPO_ROOT}/skills
151159
- DEER_FLOW_SANDBOX_HOST=host.docker.internal
152-
# LangSmith tracing: set LANGSMITH_TRACING=true and LANGSMITH_API_KEY in .env to enable.
160+
# Disable LangSmith tracing — LANGSMITH_API_KEY is not required.
161+
# Set LANGSMITH_TRACING=true and LANGSMITH_API_KEY in .env to enable.
162+
- LANGSMITH_TRACING=${LANGSMITH_TRACING:-false}
163+
# Google Drive token path (for write access)
164+
- GOOGLE_DRIVE_TOKEN_PATH=/app/google-drive-credentials/token.json
153165
env_file:
154166
- ../.env
155167
extra_hosts:
156168
- "host.docker.internal:host-gateway"
157169
networks:
158170
- deer-flow
159171
restart: unless-stopped
172+
healthcheck:
173+
test: [ "CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:2024/health" ]
174+
interval: 2s
175+
timeout: 2s
176+
retries: 15
177+
start_period: 5s
160178

161179
# ── Sandbox Provisioner (optional, Kubernetes mode) ────────────────────────
162180
provisioner:
@@ -186,7 +204,7 @@ services:
186204
- deer-flow
187205
restart: unless-stopped
188206
healthcheck:
189-
test: ["CMD", "curl", "-f", "http://localhost:8002/health"]
207+
test: [ "CMD", "curl", "-f", "http://localhost:8002/health" ]
190208
interval: 10s
191209
timeout: 5s
192210
retries: 6
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# 🚀 DeerFlow Google Drive 集成技能 - 最终版本
2+
3+
## 📋 版本信息
4+
5+
- **版本**: 1.0.0
6+
- **发布日期**: 2026-03-31
7+
- **兼容性**: DeerFlow 2.x + Python 3.8+
8+
9+
---
10+
11+
## 📦 完整目录结构
12+
13+
```
14+
google-drive-final/
15+
├── FINAL_VERSION.md # 本文档
16+
├── install.sh # 一键安装脚本
17+
├── SKILL.md # 技能定义
18+
├── README.md # 完整使用文档
19+
├── QUICKSTART.md # 5分钟快速开始
20+
├── requirements.txt # Python 依赖
21+
├── test_document.txt # 测试文件
22+
23+
├── scripts/ # 核心脚本
24+
│ ├── utils.py # 通用工具函数
25+
│ ├── auth_setup.py # OAuth 认证设置
26+
│ ├── list_files.py # 列出文件
27+
│ ├── read_file.py # 读取文件
28+
│ ├── create_file.py # 创建/上传文件
29+
│ ├── update_file.py # 更新文件
30+
│ └── search_files.py # 搜索文件
31+
32+
├── assets/ # 附加资源
33+
│ └── langgraph_integration_example.py
34+
35+
├── references/ # 参考文档
36+
│ └── google-drive-api.md
37+
38+
└── evals/ # 评估测试
39+
└── test_drive_basic.py
40+
```
41+
42+
---
43+
44+
## 🚀 快速开始(3步)
45+
46+
### 1️⃣ 安装技能
47+
48+
```bash
49+
# 解压后运行安装脚本
50+
cd google-drive-final
51+
./install.sh
52+
```
53+
54+
### 2️⃣ 配置认证
55+
56+
```bash
57+
# 进入技能目录
58+
cd ~/deer-flow/skills/custom/google-drive
59+
60+
# 安装依赖
61+
pip install -r requirements.txt
62+
63+
# 获取 credentials.json 并放在当前目录,然后运行:
64+
python scripts/auth_setup.py
65+
```
66+
67+
### 3️⃣ 测试上传
68+
69+
```bash
70+
# 上传测试文件
71+
python scripts/create_file.py upload test_document.txt --name "DeerFlow_Test.txt"
72+
```
73+
74+
---
75+
76+
## 📝 核心功能说明
77+
78+
### 📂 文件操作
79+
80+
| 功能 | 命令 |
81+
|------|------|
82+
| **列出文件** | `python scripts/list_files.py` |
83+
| **读取文件** | `python scripts/read_file.py <file-id>` |
84+
| **上传文件** | `python scripts/create_file.py upload <local-file>` |
85+
| **创建文件夹** | `python scripts/create_file.py folder <name>` |
86+
| **搜索文件** | `python scripts/search_files.py <query>` |
87+
88+
### 🔐 认证流程
89+
90+
1. 访问 [Google Cloud Console](https://console.cloud.google.com/)
91+
2. 创建项目 → 启用 Drive API → 创建 OAuth 凭证(桌面应用)
92+
3. 下载 `credentials.json` → 运行 `auth_setup.py` → 完成浏览器授权
93+
94+
---
95+
96+
## 🐳 Docker 集成
97+
98+
### 确认卷挂载
99+
100+
检查 `docker-compose.yml`
101+
102+
```yaml
103+
services:
104+
backend:
105+
volumes:
106+
- ./skills:/app/backend/skills # ✅ 需要这行
107+
```
108+
109+
### 重启 DeerFlow
110+
111+
```bash
112+
cd ~/deer-flow
113+
make down && make up
114+
```
115+
116+
---
117+
118+
## 📚 更多文档
119+
120+
- `README.md` - 完整的使用文档
121+
- `QUICKSTART.md` - 5分钟快速上手指南
122+
- `references/google-drive-api.md` - Google Drive API 参考
123+
124+
---
125+
126+
## 🔧 故障排除
127+
128+
### 常见问题
129+
130+
**Q: 认证失败?**
131+
- 检查 `credentials.json` 是否正确
132+
- 确认 API 是否已启用
133+
- 尝试删除 `token.json` 重新认证
134+
135+
**Q: Docker 看不到技能?**
136+
- 确认 `docker-compose.yml` 有正确的 volume 挂载
137+
- 文件权限问题:`chmod -R 755 ~/deer-flow/skills`
138+
- 重启 Docker 服务
139+
140+
**Q: 依赖安装失败?**
141+
```bash
142+
pip install --upgrade pip
143+
pip install -r requirements.txt
144+
```
145+
146+
---
147+
148+
## 📄 许可证
149+
150+
MIT License - 可自由使用、修改和分发
151+
152+
---
153+
154+
## 🆘 获取帮助
155+
156+
如有问题,请检查:
157+
1. DeerFlow 日志
158+
2. Google Cloud Console API 状态
159+
3. 网络连接
160+
161+
---
162+
163+
**🎉 祝您使用愉快!**

0 commit comments

Comments
 (0)