feat(video-from-script): 集成可灵图像生成器并优化审查流程

- 新增 kling-image-generator.js 作为可灵 API 图像生成模块,支持文生图和图生图
- 在 pipeline.js 中集成可灵生图,支持在 images 阶段使用 kling 模型
- 更新 SKILL.md 文档:简化用户审查流程,支持"自行选图"模式
- 实现模型降级链(gemini → kling → mj → gemini),增强生图容错性
- 扩展 `--image-model` 参数支持,允许在重试时切换模型
This commit is contained in:
2026-04-30 00:49:33 +08:00
parent 5dd83fdb45
commit 8301c7b780
3 changed files with 243 additions and 5 deletions

View File

@@ -156,7 +156,7 @@ async function phaseImages(manifest, manifestPath, options) {
if (items.length === 0) { log('images', '无待处理 item跳过'); return }
const accountConfig = options.accountConfig || {}
let model = manifest.imageModel || accountConfig.imageModel || 'gemini'
let model = options.imageModel || manifest.imageModel || accountConfig.imageModel || 'gemini'
const ratio = manifest.format || accountConfig.defaultFormat || '9:16'
// 首尾帧模式MJ 降级为 GeminiMJ 出4张候选图无法一一对应首尾帧
@@ -217,8 +217,22 @@ async function phaseImages(manifest, manifestPath, options) {
item.file = item.candidates[0]
log('images', `[${idx}/${items.length}] ${result.files.length} 张候选默认选第1张`)
}
} else if (model === 'kling') {
const { generate: klingGen } = require('./kling-image-generator')
const klingOpts = { outputDir: imagesDir, aspectRatio: ratio }
if (refs.urls.length > 0) {
klingOpts.referenceImageUrl = refs.urls[0]
}
log('images', `[${idx}/${items.length}] 可灵生图: ${item.imagePrompt.substring(0, 60)}...`)
result = await klingGen(item.imagePrompt, klingOpts)
if (result.savedFiles && result.savedFiles.length > 0) {
item.file = renameGeneratedFile(
path.relative(dir, result.savedFiles[0]).replace(/\\/g, '/'),
dir, idx, item.keyword, ''
)
}
} else {
throw new Error(`不支持的模型: ${model}(支持: gemini, mj`)
throw new Error(`不支持的模型: ${model}(支持: gemini, mj, kling`)
}
if (item.file) {
@@ -254,6 +268,13 @@ async function phaseImages(manifest, manifestPath, options) {
mjOpts.styleWeight = 200
}
lastResult = await mjGen(item.lastFramePrompt, mjOpts)
} else if (model === 'kling') {
const { generate: klingGen } = require('./kling-image-generator')
lastResult = await klingGen(item.lastFramePrompt, {
outputDir: imagesDir,
referenceImageUrl: item.url || '',
aspectRatio: ratio,
})
}
if (lastResult) {