@q253595422/dsh-imagegen-video 1.13.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +81 -0
- package/README.md +44 -0
- package/docs/releases/v1.14.0.md +51 -0
- package/docs/releases/v1.15.0.md +77 -0
- package/lib/client.js +277 -46
- package/lib/client.js.map +1 -1
- package/lib/index.js +10587 -8576
- package/lib/locale-tables-chunk.js +18 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,87 @@ Attribution for third-party code is in [NOTICE](./NOTICE).
|
|
|
5
5
|
|
|
6
6
|
## Releases
|
|
7
7
|
|
|
8
|
+
### 1.15.0 — Volcengine Ark, properly
|
|
9
|
+
|
|
10
|
+
- **Seedream gets the real Ark contract.** The official ids
|
|
11
|
+
(`doubao-seedream-5-0-pro-260628` and friends) have no `aspect_ratio`
|
|
12
|
+
parameter at all, and their `size` is EITHER a tier (`1K`/`1.5K`/`2K`/`3K`/
|
|
13
|
+
`4K`) OR an explicit `WxH` — never both. Sending a bare tier therefore
|
|
14
|
+
threw the panel's ratio away and a 16:9 request came back square or 1:1.
|
|
15
|
+
Ark ids now receive explicit even dimensions solved from the chosen ratio
|
|
16
|
+
inside that model's documented pixel budget (5.0 pro/flash cap at
|
|
17
|
+
`2048x2048x1.1025`; 4.5 and 5.0 lite at `4096x4096`; 3.0 at `2048x2048`).
|
|
18
|
+
`auto` still sends the tier string, which is Ark's "you choose" form.
|
|
19
|
+
- **The watermark is turned off explicitly.** Ark documents `watermark: true`
|
|
20
|
+
as the default, so every Ark request used to come back with a visible
|
|
21
|
+
"AI生成" stamp in the corner. Both the text-to-image and the edit request
|
|
22
|
+
now send `watermark: false`. Gateway-shaped Seedream still sends
|
|
23
|
+
`b64_json`; only the official Ark shape uses `response_format: 'url'`.
|
|
24
|
+
- **Seedance is a first-class video family.** `doubao-seedance-*` ids were
|
|
25
|
+
being classified as the generic OpenAI-style video endpoint, which posted
|
|
26
|
+
to `/videos` and never worked. They now speak Ark's own task contract:
|
|
27
|
+
`POST /contents/generations/tasks`, poll
|
|
28
|
+
`GET /contents/generations/tasks/{id}`, clip at `content.video_url`.
|
|
29
|
+
The prompt and every reference ride in a `content` array — images carry a
|
|
30
|
+
`role` of `first_frame` / `last_frame` / `reference_image` — the ratio field
|
|
31
|
+
is `ratio`, resolution is lowercase, and duration is an integer.
|
|
32
|
+
- **Values are narrowed where the model would reject them.** Seedance 2.x
|
|
33
|
+
accepts 4–15 seconds and 1.0 accepts 2–12; the `fast`/`mini` ids cap at
|
|
34
|
+
720p and reject 1080p and 4k upstream. Requests are clamped to the window
|
|
35
|
+
and degraded to the best tier the id does support (a 1080P ask on a fast id
|
|
36
|
+
becomes 720p, not 480p) instead of being sent as a guaranteed 400.
|
|
37
|
+
- **Silent by default, not by accident.** `generate_audio` also defaults to
|
|
38
|
+
true upstream; the panel has no audio control, so both flags are sent
|
|
39
|
+
explicitly as `false`.
|
|
40
|
+
- **One channel, both halves.** The built-in preset is now "字节 · 火山方舟
|
|
41
|
+
(Seedream / Seedance)" with real model ids and a video catalog, so one
|
|
42
|
+
Ark channel serves images and videos.
|
|
43
|
+
- **Offline coverage.** `B7` asserts the Ark pixel size stays inside the
|
|
44
|
+
budget, keeps the ratio and is even, plus `watermark: false`; two new
|
|
45
|
+
`smoke-video` cases cover the Seedance submit body, the poll path and
|
|
46
|
+
`content.video_url`, and the duration/resolution narrowing.
|
|
47
|
+
|
|
48
|
+
### 1.14.0 — draw it in code, render it here
|
|
49
|
+
|
|
50
|
+
- **A second renderer, chosen per task.** The canvas composer now carries a
|
|
51
|
+
*Rendering* select: **Model** (the historical path, unchanged and still the
|
|
52
|
+
default) or **Code**. The choice belongs to the task being submitted — it is
|
|
53
|
+
not a setting, not a global switch, and nothing is written to disk, so the
|
|
54
|
+
next generation on the same canvas can use the other one.
|
|
55
|
+
- **No image or video provider involved.** In code mode the drawing program is
|
|
56
|
+
written by the conversation model DSH already has (`ctx.agentDefaultModel`,
|
|
57
|
+
mounted through the host's `agents` and `agentPresets` services) — not the
|
|
58
|
+
plugin's prompt-enhancement endpoint — and rendered on this machine. One
|
|
59
|
+
headless turn, no tools, no vendor SDK, no second credential.
|
|
60
|
+
- **Rendered, not prompted.** The returned JavaScript runs in a `node:vm`
|
|
61
|
+
context with a drawing API and no `require`, `process` or filesystem; each
|
|
62
|
+
frame is RGBA pixels handed to ffmpeg, or encoded straight to PNG. Nothing
|
|
63
|
+
leaves the machine, so a code render costs no image/video quota.
|
|
64
|
+
- **Same pipeline, same slots.** A code result is submitted through the same
|
|
65
|
+
`GenerateRequest` / `VideoGenerateRequest` (an extra `renderer: 'code'`),
|
|
66
|
+
lands in the same `images/` and `videos/` directories and the same history
|
|
67
|
+
stores, and is therefore stitchable, timeline-cuttable, transitionable,
|
|
68
|
+
favouritable and re-framable exactly like a model result. Resolution,
|
|
69
|
+
aspect and duration come from the same composer controls; frames =
|
|
70
|
+
duration × 30 fps.
|
|
71
|
+
- **Failures are named and recoverable.** `code-prompt-empty`,
|
|
72
|
+
`code-prompt-too-long`, `code-no-chat-model`, `code-chat-failed`,
|
|
73
|
+
`code-not-code`, `code-syntax`, `code-runtime`, `render-timeout`,
|
|
74
|
+
`render-no-ffmpeg`, `render-cancelled`, `render-encoder-died`,
|
|
75
|
+
`render-encoder-failed`, `render-empty`. The node shows the host's own
|
|
76
|
+
message plus a hint to switch back to Model and retry; a missing ffmpeg is
|
|
77
|
+
warned about in the composer *before* submitting (`POST /code/probe`).
|
|
78
|
+
- **A non-code answer still produces something.** If the model replies with
|
|
79
|
+
prose instead of a program, the render falls back to a built-in title card
|
|
80
|
+
and the task is marked `degraded` with the reason — a wasted render is worse
|
|
81
|
+
than a plain one.
|
|
82
|
+
- **Retry replays the program.** The generated source is kept on the task, so
|
|
83
|
+
retrying a failed *render* does not ask the model again; generating again
|
|
84
|
+
does.
|
|
85
|
+
- **No new dependency.** `node:vm`, hand-written PNG encoding and the existing
|
|
86
|
+
`locateFfmpeg()` / `clip-compose.ts` path — ffmpeg remains the only external
|
|
87
|
+
tool, needed for code videos only.
|
|
88
|
+
|
|
8
89
|
### 1.13.0 — the video is directed before it is rendered
|
|
9
90
|
|
|
10
91
|
- **A planning step before every render.** With the studio's new *Plan first*
|
package/README.md
CHANGED
|
@@ -87,6 +87,7 @@ dsh plugin --profile web add ./q253595422-dsh-imagegen-video-1.7.8.tgz
|
|
|
87
87
|
| **电商套图** | 从商品参考图生成主图、卖点图、场景图等成套素材。 |
|
|
88
88
|
| **文生图 / 图生图** | 使用兼容的生图渠道生成、编辑并比较图片。 |
|
|
89
89
|
| **生视频** | 文生视频、图生视频、首尾帧与多参考图;按协议族适配异步渲染与轮询。 |
|
|
90
|
+
| **代码生成** | 让 DSH 里已有的对话模型写绘图程序,本机渲染成视频或图片;不调生图/生视频模型,每个任务单独选。 |
|
|
90
91
|
| **对话与 Agent** | 在 DSH 对话中生成图片、继续编辑,并把结果带回会话。 |
|
|
91
92
|
| **画廊与历史** | 图片与视频同列管理,支持模板与标签;在不同设备上接续创作。 |
|
|
92
93
|
|
|
@@ -184,13 +185,56 @@ dsh plugin --profile web add ./q253595422-dsh-imagegen-video-1.7.8.tgz
|
|
|
184
185
|
| 协议族 | 模型示例 | 说明 |
|
|
185
186
|
| --- | --- | --- |
|
|
186
187
|
| Agnes 视频 | `agnes-video-2.5-flash`、`agnes-video-2.5` | 提交 `POST /v1/videos`,轮询 `GET /v1/videos/{id}`,取 `metadata.url`;支持文生视频、首尾帧、多参考图、`seed`。 |
|
|
188
|
+
| 火山 Seedance(方舟) | `doubao-seedance-2-0-260128`、`doubao-seedance-2-0-fast-260128`、`doubao-seedance-1-0-pro-250528` | 方舟原生任务协议:提交 `POST /contents/generations/tasks`,轮询 `GET /contents/generations/tasks/{id}`,成片在 `content.video_url`。提示词与参考图放在 `content` 数组里(参考图带 `role`:`first_frame` / `last_frame` / `reference_image`),比例字段是 `ratio`,分辨率小写,时长 2.x 为 4–15 秒、1.0 为 2–12 秒。`fast` / `mini` 型号上游只到 720p,面板会把 1080P 收敛到 720p 而不是让请求 400。 |
|
|
187
189
|
| 算力萌 comemoe | `wan2.2-t2v`、`zhimeng-h3-local` | `wan2.2-t2v` 仅文生视频;`zhimeng-h3-local` 支持图生视频。比例只接受 16:9 / 9:16 / 1:1;5 秒片子实测约 9 分钟。 |
|
|
190
|
+
| xAI Grok | `grok-imagine-video-1.5`、`grok-imagine-video-1.5-lite` | 提交 `POST /videos/generations`(注意不是 `/videos`),轮询 `GET /videos/{id}`,取 `video.url` 与 `video.duration`。 |
|
|
188
191
|
| 通用视频 | 其他视频模型 id | 按 OpenAI 兼容视频端点尽力适配;未识别的协议族会明确报错,不会静默发出错误请求。 |
|
|
189
192
|
|
|
190
193
|
- **生成模式**:文生视频、图生视频(单张参考图)、首尾帧(首帧+尾帧插值)、参考图(多张风格/主体参考);不同模型支持的模式不同,面板只会给出该模型支持的选项。
|
|
191
194
|
- **成片存储**:视频保存在本机数据目录的 `videos/` 下,历史列表只存元数据,播放走支持 Range 的同源路由,所以可以拖动进度条。
|
|
192
195
|
- **Agent 调用**:Agent 可调用 `generate_video`(文生视频)与 `generate_video_from_image`(图生视频/首尾帧/参考图),并用 `get_video_generation_task` 查询进度;视频渲染较慢,不要紧凑轮询。
|
|
193
196
|
|
|
197
|
+
**火山方舟(Seedream / Seedance)** 的生图与生视频可以共用一个渠道(`https://ark.cn-beijing.volces.com/api/v3`),渠道里分别填图片模型与视频模型即可:
|
|
198
|
+
|
|
199
|
+
- **生图(Seedream)**:方舟的 `size` 只能是档位(`1K`/`1.5K`/`2K`/`3K`/`4K`)**或** `宽x高`,二选一,且没有 `aspect_ratio` 参数。所以选了具体比例时,插件按该模型的像素预算换算出显式的偶数宽高(例如 5.0 pro 在 16:9 / 4K 下是 `2866x1612`),这样比例才真的生效;`auto` 才回落到档位字符串。
|
|
200
|
+
- **水印**:方舟的 `watermark` 默认是 **true**(右下角「AI生成」),插件每次都显式发 `watermark: false`。生视频同理,并额外关掉 `generate_audio`(面板没有音轨控制,不想凭空多一条声音)。
|
|
201
|
+
- **响应格式**:方舟的 Seedream 用 `response_format: 'url'`,插件随后回源下载;网关版的 Seedream 仍走 `b64_json`。
|
|
202
|
+
- **模型 ID**:预置里是方舟控制台的模型 ID;如果用的是推理接入点,把模型 id 换成 `ep-…` 也能工作(协议族按请求形状判断,不依赖具体 id)。
|
|
203
|
+
|
|
204
|
+
</details>
|
|
205
|
+
|
|
206
|
+
#### 代码生成路径(不调生图/生视频模型)
|
|
207
|
+
|
|
208
|
+
画布合成栏里有一个「生成方式」下拉,两个选项:**模型生成**(默认,就是上面那整条链路)和**代码生成**。它**按任务选**,不写进设置、不做全局开关;同一个画布上这一张用模型、下一张用代码都行。
|
|
209
|
+
|
|
210
|
+
选「代码生成」时:
|
|
211
|
+
|
|
212
|
+
- **谁来画**:用 **DSH 里已经接入的对话模型**——就是你在对话面板里选中的那个模型,不是插件设置里的「提示词增强模型」,插件也不新增任何模型或密钥配置。宿主把这个请求当成一次无头对话:系统提示里给绘图 API 与约束,用户消息就是你的描述,模型返回一段 JavaScript 绘图程序。
|
|
213
|
+
- **谁来渲染**:本机 `node:vm` 沙箱逐帧执行这段程序,拿到 RGBA 像素后交给 ffmpeg 编码(视频)或直接写成 PNG(图片)。全过程不产生任何网络请求,也不消耗生图/生视频额度。沙箱里没有 `require`、没有 `process`、没有文件系统,只有一套绘图方法(矩形、圆、路径、渐变、文字等)。
|
|
214
|
+
- **参数照旧**:分辨率、比例、时长仍按合成栏选的档位生效(`480P`/`720P`/`1080P` × 比例,30fps),视频帧数 = 时长 × 30。同一套档位,代码路径不另立一套。
|
|
215
|
+
- **产物对等**:视频落进同一个 `videos/` 目录、同一条视频历史(条目带 `renderer: 'code'`),因此预览、下载、收藏、取尾帧、多选拼接、时间线裁剪与转场、工作流执行器全部照常;图片落进同一个 `images/` 与图片历史,可以继续做标注、海报编辑、当参考图。
|
|
216
|
+
- **模型会「答非所问」时降级**:如果模型返回的不是代码(比如直接回了一段说明),会改用内置标题卡渲染,任务标记 `degraded` 并记录原因——**照样出图/出片**,不会白跑一趟。真正无法继续的情况(语法错、运行时抛错、超时、缺 ffmpeg)才失败。
|
|
217
|
+
- **重试不重复问模型**:第一次生成的绘图程序存在任务里,重试会沿用它;想换一版再重新生成。
|
|
218
|
+
|
|
219
|
+
失败语义(错误码会直接显示在节点上,并附一行「可在上方「生成方式」里切回模型生成后重试」):
|
|
220
|
+
|
|
221
|
+
| 错误码 | 含义 | 怎么办 |
|
|
222
|
+
| --- | --- | --- |
|
|
223
|
+
| `code-prompt-empty` | 描述为空 | 写一句画面描述(代码路径靠这句话绘图,不会自己编) |
|
|
224
|
+
| `code-prompt-too-long` | 描述超过 4000 字符 | 压缩到核心画面与文案 |
|
|
225
|
+
| `code-no-chat-model` | DSH 里没有选中的对话模型 | 在对话面板选一个模型,或切回模型生成 |
|
|
226
|
+
| `code-chat-failed` | 对话模型调用失败(鉴权、网络、上游报错) | 看节点上的原始原因;换模型或切回模型生成 |
|
|
227
|
+
| `code-not-code` / `code-syntax` | 模型返回的不是可执行代码,或代码编译不过 | 重试(会重新问模型),或切回模型生成 |
|
|
228
|
+
| `code-runtime` | 代码逐帧执行时抛错(报文里带第几帧) | 同上 |
|
|
229
|
+
| `render-timeout` | 整次渲染超过 120 秒 | 缩短时长或降分辨率后重试 |
|
|
230
|
+
| `render-no-ffmpeg` | 本机找不到 ffmpeg,无法编码视频 | `brew install ffmpeg`,或在设置里填 `FFMPEG_PATH`;图片不需要 ffmpeg |
|
|
231
|
+
| `render-cancelled` | 用户取消 | 重新提交即可 |
|
|
232
|
+
| `render-encoder-died` / `render-encoder-failed` | ffmpeg 进程异常退出 | 重试;持续失败请查 ffmpeg 是否可用 |
|
|
233
|
+
|
|
234
|
+
缺 ffmpeg 在**提交前**就会提示(合成栏下方一行黄色说明),不会等渲染到一半才报。
|
|
235
|
+
|
|
236
|
+
依赖只有 ffmpeg(视频路径;图片路径零依赖)。不引入任何新框架或原生模块。
|
|
237
|
+
|
|
194
238
|
</details>
|
|
195
239
|
|
|
196
240
|
#### 多模型对比
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# v1.14.0 — 代码生成:对话模型写程序,本机渲染成片
|
|
2
|
+
|
|
3
|
+
一句话概括:画布合成栏多了一个「生成方式」选项。选「代码生成」后,DSH 里已经在用的对话模型写一段绘图程序,本机把它渲染成视频或图片——**不需要任何生图或生视频模型**。「模型生成」原样保留,仍是默认值,两条路每个任务各选一次。
|
|
4
|
+
|
|
5
|
+
## 为什么
|
|
6
|
+
|
|
7
|
+
生图和生视频都受两件事约束:要有额度,要等上游。而有些画面——标题卡、数据动图、几何转场、确定性的图表动画——用代码直接画出来更快、更准、更便宜,也更容易复现。DSH 里本来就有对话模型,缺的只是「让它写程序、由本机执行」这一段。
|
|
8
|
+
|
|
9
|
+
## 做了什么
|
|
10
|
+
|
|
11
|
+
- **每任务选择,不做全局开关**:入口在现有合成栏里(`生成方式` 下拉),状态只活在当前画布,不写设置、不落盘。选「代码生成」时该分支的模型选择器隐藏,比例 / 分辨率 / 时长保留——它们照常决定输出。
|
|
12
|
+
- **走宿主已有的模型,不新增配置**:`ctx.inject(['skills','agents'])` 拿到宿主的 `agents` 与 `agentPresets`,用 `ctx.agentDefaultModel` 的当前选择组一次无头回合:系统提示放绘图 API 与约束,用户消息就是那句描述,回合结束读最后一条助手文本。**不是**插件设置里的「提示词增强模型」,也不需要新密钥。没选模型时报 `code-no-chat-model`。
|
|
13
|
+
- **沙箱执行**:`node:vm` + `Object.create(null)` 上下文,2 秒编译超时 + 整次渲染 deadline(默认 120 秒)。上下文里没有 `require` / `process` / `fs`,只有一套固定的绘图方法(矩形、圆、路径、渐变、文字、图像的像素级操作)。生成源码上限 60000 字符。
|
|
14
|
+
- **渲染**:逐帧得到 RGBA 缓冲,视频写进 ffmpeg 的 stdin 编成 MP4(`libx264` + `yuv420p`,可直接播放,也能被 `clip-compose.ts` 拼接);图片用自写的 PNG 编码(IHDR/IDAT/IEND + CRC32 + `zlib.deflateSync`)直接落盘,零原生依赖。
|
|
15
|
+
- **产物对等**:不新开队列,不新开存储。请求只多一个 `renderer: 'code'`,其余照旧走 `GenerationRequest` / `VideoGenerateRequest`,因此占位节点、轮询、取消、重试、历史、画廊、取尾帧、多选拼接、时间线裁剪与转场、工作流执行器**全部直接复用**。视频条目与图片条目都带 `renderer: 'code'` 与 `renderSource`。
|
|
16
|
+
- **唯一的额外路由是只读的**:`POST /api/dsh-imagegen/code/probe` 回答「会渲染成多大、多少帧、本机有没有 ffmpeg」,不调模型、不渲染。故意**没有** `code/render`——两条生产入口迟早会让占位/取消/重试各写一遍并漂移。
|
|
17
|
+
- **降级而不是死路**:模型回了一段散文而不是代码时,改用内置标题卡渲染,任务标 `degraded` 并记原因;`code-not-code` 只用于拿不到可执行内容的情况。
|
|
18
|
+
|
|
19
|
+
## 失败语义
|
|
20
|
+
|
|
21
|
+
节点上直接显示宿主原文,并在下方补一行「可在上方「生成方式」里切回模型生成后重试」。
|
|
22
|
+
|
|
23
|
+
| 错误码 | 触发条件 |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `code-prompt-empty` / `code-prompt-too-long` | 描述为空 / 超过 4000 字符(路由边界拦,不调模型) |
|
|
26
|
+
| `code-no-chat-model` | DSH 里没有选中的对话模型,或 `agents` 服务不可用 |
|
|
27
|
+
| `code-chat-failed` | 回合失败(鉴权、网络、上游报错),报文带宿主持久化的失败原因 |
|
|
28
|
+
| `code-not-code` / `code-syntax` | 模型没给出可执行代码 / 代码编译不过 |
|
|
29
|
+
| `code-runtime` | 逐帧执行抛错,报文标明第几帧 |
|
|
30
|
+
| `render-timeout` | 超过 120 秒 |
|
|
31
|
+
| `render-no-ffmpeg` | 找不到 ffmpeg(含 `FFMPEG_PATH` 候选),提示安装方式 |
|
|
32
|
+
| `render-cancelled` | 用户取消 |
|
|
33
|
+
| `render-encoder-died` / `render-encoder-failed` / `render-empty` | ffmpeg 异常退出 / 无输出 |
|
|
34
|
+
|
|
35
|
+
缺 ffmpeg 会在**提交前**预警(`code/probe`),且只影响视频——图片路径不需要 ffmpeg。
|
|
36
|
+
|
|
37
|
+
## 重试
|
|
38
|
+
|
|
39
|
+
生成出的绘图程序存在任务上。重试一次**渲染失败**的任务会沿用同一份源码,不再问模型;想换一版就重新生成。
|
|
40
|
+
|
|
41
|
+
## 验证
|
|
42
|
+
|
|
43
|
+
- `pnpm run typecheck`、`pnpm run build`、`pnpm test` 全绿。
|
|
44
|
+
- `node scripts/smoke-code-render.mjs`:13 项,含真实 ffmpeg 出片(ffprobe 复核 1280×720 / 30fps / ~3s)、真实 PNG(校验签名与 `1080x1080`)、代码片段进入 `createClipComposer()` 拼接出带 `ftyp` 的 MP4,以及宿主 seam 的正常与三类失败(无 `agents`、无模型、回合 `turn/end` 为 error)。
|
|
45
|
+
- `scripts/smoke.mjs` 里补了画布交互用例:默认「模型生成」、切到「代码生成」后模型选择器消失而比例/分辨率/时长保留、提交体带 `renderer: 'code'` 且 `model` / `channelId` 为空、占位节点带 `renderer`、失败节点显示错误码与切回提示、切回后模型选择器回来。
|
|
46
|
+
|
|
47
|
+
## 依赖与边界
|
|
48
|
+
|
|
49
|
+
- 新增依赖:**无**。ffmpeg 仍是唯一外部工具,仅视频路径需要。
|
|
50
|
+
- 代码路径不参与导演规划:代码本身就是规划。
|
|
51
|
+
- 代码渲染是 CPU 任务,视频队列并发为 1,与模型渲染串行;`MAX_PIXELS` 限 4096²。
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# v1.15.0 — 火山方舟:Seedream 生图与 Seedance 生视频按真实协议适配
|
|
2
|
+
|
|
3
|
+
一句话概括:火山方舟(Volcengine Ark)的 Seedream 生图与 Seedance 生视频不再是「名字看着像就按通用协议发」,而是各按方舟自己的契约整形请求。一个 Ark 渠道同时服务生图与生视频。
|
|
4
|
+
|
|
5
|
+
## 为什么
|
|
6
|
+
|
|
7
|
+
之前这两个模型族走的是兜底形状,在真上游上会以不同方式失真:
|
|
8
|
+
|
|
9
|
+
- **Seedream**:方舟没有 `aspect_ratio` 参数,`size` 只能填档位(`1K`/`1.5K`/`2K`/`3K`/`4K`)或显式 `宽x高`,二者不可混用。原先发的是档位字符串,于是你在面板里选的比例被直接丢掉——选 16:9 出来的仍是接近正方形的图。另外 `watermark` 在方舟**默认 true**,每张图右下角都带「AI生成」。
|
|
10
|
+
- **Seedance**:`doubao-seedance-*` 之前被归到通用视频端点,提交到 `/videos`,而方舟的接口在 `/contents/generations/tasks`,请求体形状也完全不同(`content` 数组 + `role`),所以这条路径在真上游上根本走不通。
|
|
11
|
+
|
|
12
|
+
## 做了什么
|
|
13
|
+
|
|
14
|
+
### 生图(Seedream / Ark)
|
|
15
|
+
|
|
16
|
+
- 选了具体比例时,按该模型的**文档像素预算**换算出显式的偶数宽高:
|
|
17
|
+
|
|
18
|
+
| 模型族 | 总像素区间 |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| 5.0 pro / flash | `1280x720` ~ `2048x2048x1.1025` |
|
|
21
|
+
| 5.0 lite、4.5 | `2560x1440` ~ `4096x4096` |
|
|
22
|
+
| 4.0 | `1280x720` ~ `4096x4096` |
|
|
23
|
+
| 3.0 t2i | `512x512` ~ `2048x2048`(只接受像素值) |
|
|
24
|
+
|
|
25
|
+
例:5.0 pro、比例 16:9、清晰度 4K → `2866x1612`(比例 1.7779,总像素 4,619,992,在预算内)。
|
|
26
|
+
- `auto` 保留档位字符串,这是方舟「让模型自己决定」的合法写法。
|
|
27
|
+
- 每次显式发送 `watermark: false`(文生图与图生图都一样)。
|
|
28
|
+
- 响应格式:方舟用 `response_format: 'url'` 并回源下载;网关形态的 Seedream 仍用 `b64_json`。
|
|
29
|
+
|
|
30
|
+
### 生视频(Seedance / Ark)
|
|
31
|
+
|
|
32
|
+
- 新增 `seedance` 协议族:提交 `POST /contents/generations/tasks`,轮询 `GET /contents/generations/tasks/{id}`。
|
|
33
|
+
- 请求体:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"model": "doubao-seedance-2-0-260128",
|
|
38
|
+
"content": [
|
|
39
|
+
{ "type": "text", "text": "…" },
|
|
40
|
+
{ "type": "image_url", "image_url": { "url": "data:image/png;base64,…" }, "role": "first_frame" }
|
|
41
|
+
],
|
|
42
|
+
"ratio": "9:16",
|
|
43
|
+
"resolution": "1080p",
|
|
44
|
+
"duration": 5,
|
|
45
|
+
"watermark": false,
|
|
46
|
+
"generate_audio": false
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- 首尾帧模式发 `first_frame` / `last_frame`;参考图模式逐张发 `reference_image`(2.x 支持);图生视频发单张 `first_frame`。
|
|
51
|
+
- 比例字段是 `ratio`;分辨率小写;时长是整数秒。
|
|
52
|
+
- 轮询结果从 `content.video_url` 取成片,`content.last_frame_url` 作为封面回落,`duration` 作为真实时长。
|
|
53
|
+
- **收敛而不是硬发**:2.x 时长窗口 4–15 秒,1.0 为 2–12 秒;`fast` / `mini` 上游最高 720p。越界的请求会被收进窗口,并把分辨率降到该型号真正支持的最高档(1080P 在 fast 型号上降为 720p,而不是掉到 480p)。
|
|
54
|
+
- `watermark` 与 `generate_audio` 在方舟都默认 true,插件每次都显式发 `false`。
|
|
55
|
+
|
|
56
|
+
### 渠道预设
|
|
57
|
+
|
|
58
|
+
`volc-ark-seedream` 改名为「字节 · 火山方舟(Seedream / Seedance)」,图片模型换成方舟控制台的真实 ID,并新增视频模型目录:
|
|
59
|
+
|
|
60
|
+
- `doubao-seedream-5-0-pro-260628` / `-5-0-260128` / `-4-5-251128` / `-4-0-250828`(保留旧的 `seedream-5.0-pro` / `seedream-4.0` 别名兼容)
|
|
61
|
+
- `doubao-seedance-2-0-260128` / `doubao-seedance-2-0-fast-260128` / `doubao-seedance-1-0-pro-250528`
|
|
62
|
+
|
|
63
|
+
用推理接入点(`ep-…`)也能工作:协议族按请求形状与模型 id 前缀判断,不依赖固定 id。
|
|
64
|
+
|
|
65
|
+
## 验证
|
|
66
|
+
|
|
67
|
+
- `pnpm run typecheck`、`pnpm run build`、`pnpm test` 全绿(含 UI 契约检查)。
|
|
68
|
+
- `scripts/smoke.mjs` 的 `B7`:断言 Ark 的 `size` 是 `宽x高`、比例保持在 16:9、宽高为偶数、总像素落在 5.0 pro 的预算内,且 `watermark === false`、`response_format === 'url'`、不出现 `resolution` 字段。
|
|
69
|
+
- `scripts/smoke-video.mjs` 新增两项:
|
|
70
|
+
- `V1c2`:Seedance 提交体是 `content[{text}] + content[{image_url, role:'first_frame'|'last_frame'}]`,带 `ratio`、小写 `resolution`、整数 `duration`、`watermark:false`、`generate_audio:false`;轮询打到 `/v1/contents/generations/tasks/{id}` 并由 `content.video_url` 取到成片。
|
|
71
|
+
- `V1c3`:fast 型号请求 `1080P` / 30 秒 → `720p` / 15 秒;1.0 pro 请求 1 秒 → 2 秒、`1080p` 保留。
|
|
72
|
+
|
|
73
|
+
## 依赖与边界
|
|
74
|
+
|
|
75
|
+
- 新增依赖:**无**。
|
|
76
|
+
- 仍只支持方舟文档化的字段;未文档化的参数(如多图参考在 1.0 上)不发送,面板也会把不支持的选项收起来。
|
|
77
|
+
- 收敛后的值会写进请求,但**不会改写你在面板里选的原值**:同一次生成之外,选择保持原样。
|