Skip to content

Commit 485bea6

Browse files
committed
Merge branch 'implement-deepseek-files-api'
2 parents 78d8553 + 0a1ff9c commit 485bea6

15 files changed

Lines changed: 1139 additions & 55 deletions

File tree

‎docs/configuration.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ Deep Code 使用 `settings.json` 设置文件进行持久化配置,支持两
3333
| `thinkingEnabled` | boolean | 是否启用思考模式(DeepSeek V4 系列默认启用) |
3434
| `reasoningEffort` | string | 推理强度,可选 `"low"`、`"high"` 或 `"max"`(默认 `"max"`) |
3535
| `multimodal` | string | 多模态(图片)能力开关,可选 `"default"`、`"on"` 或 `"off"`(默认 `"default"`) |
36+
| `filesApiEnabled` | boolean | 是否通过 DeepSeek Files API 发送图片(默认 `false`) |
37+
| `filesApiTimeoutMs` | number | 单张图片 Files API 处理超时,默认 `60000`,最大 `600000` 毫秒 |
38+
| `fileExpiresAfterSeconds` | number | 远端文件有效期,默认 `604800` 秒 |
39+
| `fileRefreshMarginSeconds` | number | 剩余有效期低于该值时刷新缓存,默认 `3600` 秒 |
40+
| `fileQuotaCleanupBatch` | number | 配额不足时清理的最旧 Deep Code 文件数,默认 `100` |
41+
| `maxRequestFilesBytes` | number | 单次请求内图片原始字节总上限,默认 `134217728`(128 MiB) |
3642
| `debugLogEnabled` | boolean | 是否启用调试日志输出(默认 `false`) |
3743
| `telemetryEnabled` | boolean | 是否启用匿名使用数据上报(默认 `true`) |
3844
| `notify` | string | 任务完成通知脚本的完整路径(如 Slack 通知脚本) |
@@ -99,6 +105,23 @@ Deep Code 使用 `settings.json` 设置文件进行持久化配置,支持两
99105

100106
当使用的模型未内置在已知模型列表中、或其实际能力与默认判定不符时,可通过该配置覆盖。
101107

108+
#### DeepSeek Files API
109+
110+
设置 `filesApiEnabled: true` 后,Deep Code 会将图片上传到固定的 `https://api.deepseek.com/files`,并在聊天请求中使用 `file_id`。上传或缓存刷新失败时,本次请求直接失败;关闭开关时图片处理逻辑保持不变。
111+
112+
```json
113+
{
114+
"filesApiEnabled": true,
115+
"filesApiTimeoutMs": 60000,
116+
"fileExpiresAfterSeconds": 604800,
117+
"fileRefreshMarginSeconds": 3600,
118+
"fileQuotaCleanupBatch": 100,
119+
"maxRequestFilesBytes": 134217728
120+
}
121+
```
122+
123+
单个文件最大 64 MiB,上传超时不能超过 DeepSeek 规定的 10 分钟。远端文件 ID 会缓存在 `~/.deepcode/files-api-cache.json`;缓存不保存明文 API Key。遇到远端存储配额错误时,只会清理文件名以 `deepcode-` 开头的最旧文件,然后重试一次。
124+
102125
#### `notify` — 任务完成通知
103126

104127
设置一个 Shell 脚本的完整路径。当 AI 助手完成一轮任务后,会自动执行该脚本,可用于发送通知(如 Slack 消息)。

‎docs/configuration_en.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ The following are all the top-level fields supported in `settings.json`, along w
3333
| `thinkingEnabled` | boolean | Whether to enable thinking mode (enabled by default for DeepSeek V4 series)|
3434
| `reasoningEffort` | string | Reasoning intensity: `"low"`, `"high"`, or `"max"` (default `"max"`) |
3535
| `multimodal` | string | Multimodal (image) capability override: `"default"`, `"on"`, or `"off"` (default `"default"`) |
36+
| `filesApiEnabled` | boolean | Send images through the DeepSeek Files API (default `false`) |
37+
| `filesApiTimeoutMs` | number | Per-image Files API timeout; defaults to `60000`, maximum `600000` ms |
38+
| `fileExpiresAfterSeconds` | number | Remote file lifetime, default `604800` seconds |
39+
| `fileRefreshMarginSeconds` | number | Refresh cached IDs below this remaining lifetime, default `3600` seconds |
40+
| `fileQuotaCleanupBatch` | number | Oldest Deep Code files removed during quota recovery, default `100` |
41+
| `maxRequestFilesBytes` | number | Raw image byte limit per request, default `134217728` (128 MiB) |
3642
| `debugLogEnabled` | boolean | Enable debug log output (default `false`) |
3743
| `telemetryEnabled` | boolean | Enable anonymous usage reporting (default `true`) |
3844
| `notify` | string | Full path to a task-completion notification script (e.g., Slack notification script) |
@@ -99,6 +105,23 @@ Controls whether the current model is treated as a multimodal model that accepts
99105

100106
Use this to override the default detection when your model is not in the known-model list, or when its actual capability differs from the default.
101107

108+
#### DeepSeek Files API
109+
110+
With `filesApiEnabled: true`, Deep Code uploads images to the fixed `https://api.deepseek.com/files` endpoint and sends `file_id` references in chat requests. An upload or cache-refresh failure fails the request; disabling the setting preserves the existing image path.
111+
112+
```json
113+
{
114+
"filesApiEnabled": true,
115+
"filesApiTimeoutMs": 60000,
116+
"fileExpiresAfterSeconds": 604800,
117+
"fileRefreshMarginSeconds": 3600,
118+
"fileQuotaCleanupBatch": 100,
119+
"maxRequestFilesBytes": 134217728
120+
}
121+
```
122+
123+
Each file is limited to 64 MiB, and the upload timeout cannot exceed DeepSeek's 10-minute limit. Remote IDs are cached in `~/.deepcode/files-api-cache.json` without storing the plaintext API key. On a remote storage-quota error, only the oldest files whose names start with `deepcode-` are removed before one retry.
124+
102125
#### `notify` — Task Completion Notification
103126

104127
Set a full path to a shell script. When the AI assistant finishes a round of tasks, the script is executed automatically, which can be used to send notifications (e.g., a Slack message).

‎packages/cli/src/tests/exec-runner.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ function createSettings(
3232
debugLogEnabled: false,
3333
telemetryEnabled: false,
3434
multimodal: "default",
35+
filesApiEnabled: false,
36+
filesApiTimeoutMs: 60_000,
37+
fileExpiresAfterSeconds: 604_800,
38+
fileRefreshMarginSeconds: 3_600,
39+
fileQuotaCleanupBatch: 100,
40+
maxRequestFilesBytes: 128 * 1024 * 1024,
3541
permissions,
3642
enabledSkills: {},
3743
statusline: { enabled: false, refreshMs: 1000, separator: " | ", providers: [] },

0 commit comments

Comments
 (0)