Skip to content

Commit 44c8d02

Browse files
committed
fix(ai-node-canvas): 首尾帧请求把首帧声明成首帧
厂商只认一个结尾:带着 last_frame_image 时,input_image 必须声明成 first_frame(或不声明)。原来按 kind 判断,首尾帧那一种被写成了 last_frame,于是厂商直接拒掉这条请求,画布上弹的是厂商的英文原文。 改成按 kind === 'lastFrame' 判断:只有末帧那一种声明 last_frame, 其余都声明 first_frame。README 里那张字段表跟着改。 单测全量 335 条通过(此前 334 条,新增一条顶层回归测试:首尾帧必须 声明首帧)。变异自检做过两处:把判断改回旧写法、把末帧换成首帧, 新测试都会变红。没有发真机生成请求。
1 parent 25449d0 commit 44c8d02

6 files changed

Lines changed: 52 additions & 10 deletions

File tree

‎plugins/antianqi/ai-node-canvas/.minimax-plugin/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"schemaVersion": 1,
33
"name": "ai-node-canvas",
44
"displayName": "节点画布",
5-
"version": "1.22.9",
5+
"version": "1.22.10",
66
"description": "无限画布节点编排:把 MiniMax 模型生成的文本、图片、视频串成工作流,连线即数据流,上游产物可直接被下游引用。",
77
"author": "antianqi",
88
"icon": "icon.png",

‎plugins/antianqi/ai-node-canvas/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ English | [简体中文](README.zh-CN.md)
55
An infinite-canvas node graph for MiniMax Code, modelled on the canvas of
66
`work.batvid.com`.
77

8-
Author: [antianqi](https://github.com/antianqi) · Version: `1.22.9`
8+
Author: [antianqi](https://github.com/antianqi) · Version: `1.22.10`
99

1010
![The canvas with the 图片复刻 template on it: a reference picture goes in, the prompt is read back out of that picture, and a new picture is made from the prompt](docs/preview.png)
1111

@@ -465,7 +465,7 @@ video. They are not one request with different parameters:
465465
| Request | What is sent | Who can run it |
466466
| --- | --- | --- |
467467
| First frame | `input_image` + `reference_type: first_frame` | all three models |
468-
| First+last frame | the first frame + `last_frame_image` | H3 and H3-Max |
468+
| First+last frame | `input_image` + `reference_type: first_frame` + `last_frame_image` | H3 and H3-Max |
469469
| Last frame | `input_image` + `reference_type: last_frame` | H3 and H3-Max |
470470
| Reference set | `reference_images` / `reference_videos` / `reference_audios` | H3 only |
471471

‎plugins/antianqi/ai-node-canvas/README.zh-CN.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
MiniMax Code 里的无限画布节点图。每个节点是一次模型运行,每条连线是一条数据通路——
66
把文本节点连到图片节点,上游文本会自动注入下游提示词。
77

8-
作者:[antianqi](https://github.com/antianqi) · 版本:`1.22.9`
8+
作者:[antianqi](https://github.com/antianqi) · 版本:`1.22.10`
99

1010
![画布:铺了「图片复刻」模板——参考图进去,提示词从这张图里反推出来,再照着它重新生成一张](docs/preview.png)
1111

@@ -264,7 +264,7 @@ provider 有**几种不同的请求**把素材变成视频,不是同一个请
264264
| 请求 | 送什么 | 谁会跑 |
265265
| --- | --- | --- |
266266
| 首帧 | `input_image` + `reference_type: first_frame` | 三个模型都会 |
267-
| 首尾帧 | 首帧 + `last_frame_image` | H3、H3-Max |
267+
| 首尾帧 | `input_image` + `reference_type: first_frame` + `last_frame_image` | H3、H3-Max |
268268
| 末帧 | `input_image` + `reference_type: last_frame` | H3、H3-Max |
269269
| 参考集合 | `reference_images` / `reference_videos` / `reference_audios` | 只有 H3 |
270270

‎plugins/antianqi/ai-node-canvas/miniapp/node/connector-runner.mjs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,11 @@ export function createConnectorRunner(context, options = {}) {
555555
// one when the mode says the picture is the ending.
556556
const anchor = shape.kind === 'lastFrame' ? shape.last.url : shape.first.url;
557557
request.input_image = { url: anchor };
558-
// reference_type says which end the picture is: the first frame,
559-
// the last one, or a clip that ends on it.
560-
request.reference_type = shape.kind === 'keyframe' ? 'first_frame' : 'last_frame';
558+
// reference_type says what input_image is. The provider takes
559+
// ONE ending: when last_frame_image stands beside it, input_image
560+
// has to be declared the first frame — declaring it the last one
561+
// there is two endings, and the provider refuses the request.
562+
request.reference_type = shape.kind === 'lastFrame' ? 'last_frame' : 'first_frame';
561563
// The frame decides the shape, so the provider ignores a ratio here.
562564
// Without a frame there is nothing to follow, and the run is a plain
563565
// text-to-video one that needs a shape of its own.

‎plugins/antianqi/ai-node-canvas/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ai-node-canvas",
3-
"version": "1.22.9",
3+
"version": "1.22.10",
44
"private": true,
55
"description": "Node-graph canvas MiniApp for MiniMax Code: wire MiniMax model runs into a visual workflow.",
66
"mcode": {

‎plugins/antianqi/ai-node-canvas/tests/smoke.test.mjs‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3473,7 +3473,7 @@ test('a picture becomes a video in three different ways, and the provider is ask
34733473
const firstLast = await submitWith('firstLast');
34743474
assert.deepEqual(firstLast.input_image, { url: 'https://cdn.example.com/first.png' });
34753475
assert.deepEqual(firstLast.last_frame_image, { url: 'https://cdn.example.com/last.png' });
3476-
assert.equal(firstLast.reference_type, 'last_frame');
3476+
assert.equal(firstLast.reference_type, 'first_frame');
34773477
assert.equal(firstLast.ratio, 'adaptive');
34783478
assert.equal(firstLast.reference_images, undefined);
34793479

@@ -12078,3 +12078,43 @@ test('an audio the provider would refuse is converted before it goes up', async
1207812078
const leftovers = await readdir(workDir).catch(() => []);
1207912079
assert.deepEqual(leftovers.filter((name) => name.endsWith('.mp3')), [], 'the converted copy was left behind');
1208012080
});
12081+
12082+
test('the first and last frame request declares one ending only', async (t) => {
12083+
// The provider takes ONE ending. When last_frame_image stands beside
12084+
// input_image, input_image has to be declared the first frame — declaring
12085+
// it the last one there is two endings, and the provider refuses the
12086+
// request outright.
12087+
const connector = createMockHostConnector(undefined, { videoState: 'succeeded' });
12088+
const h = await createHarness({ hostConnector: connector });
12089+
t.after(() => h.cleanup());
12090+
12091+
const started = await fetch(`${h.base}/api/runs`, {
12092+
method: 'POST',
12093+
headers: { 'content-type': 'application/json' },
12094+
body: JSON.stringify({
12095+
nodeId: 'n_both_frames',
12096+
mode: 'video',
12097+
prompt: '一只猫在跑',
12098+
modelKey: 'MiniMax-H3',
12099+
params: { resolution: '768P', duration: 6 },
12100+
path: 'firstLast',
12101+
frames: [
12102+
{ id: 'n_first', kind: 'image', role: 'first', url: 'https://cdn.example.com/first.png' },
12103+
{ id: 'n_last', kind: 'image', role: 'last', url: 'https://cdn.example.com/last.png' },
12104+
],
12105+
references: [
12106+
{ id: 'n_first', title: '首帧', kind: 'image', text: '', media: [{ url: 'https://cdn.example.com/first.png', kind: 'image' }] },
12107+
{ id: 'n_last', title: '末帧', kind: 'image', text: '', media: [{ url: 'https://cdn.example.com/last.png', kind: 'image' }] },
12108+
],
12109+
}),
12110+
});
12111+
assert.equal(started.status, 202);
12112+
await waitForCall(connector.calls, (call) => call.toolRef.endsWith('submit-video-generation'));
12113+
const calls = connector.calls.filter((call) => call.toolRef.endsWith('submit-video-generation'));
12114+
const args = calls[calls.length - 1].args;
12115+
// The first picture is the first frame, and it says so.
12116+
assert.deepEqual(args.input_image, { url: 'https://cdn.example.com/first.png' });
12117+
assert.equal(args.reference_type, 'first_frame');
12118+
// The ending rides in its own field, so the two never both claim the end.
12119+
assert.deepEqual(args.last_frame_image, { url: 'https://cdn.example.com/last.png' });
12120+
});

0 commit comments

Comments
 (0)