feat(skills): 集成 GPT Image 图片生成和编辑能力
- 新增 gpt-image-generator.js 脚本,支持文生图、图生图/重绘、批量生成 - 更新 pipeline 和 phase-images 支持 GPT Image 模型 - 更新技能文档,添加 GPT Image 使用说明和 API 特点 - 新增配置文件中的 GPT Image API 参数
This commit is contained in:
@@ -24,7 +24,7 @@ function validateManifest(manifestPath) {
|
||||
}
|
||||
|
||||
if (!manifest.account) issues.push('缺少顶层 account')
|
||||
if (!manifest.imageModel) issues.push('缺少顶层 imageModel(可选: gemini, mj)')
|
||||
if (!manifest.imageModel) issues.push('缺少顶层 imageModel(可选: gemini, gpt-image, mj)')
|
||||
if (!manifest.format) issues.push('缺少顶层 format(如 9:16)')
|
||||
if (!manifest.items || !Array.isArray(manifest.items)) issues.push('缺少顶层 items 数组')
|
||||
if (!manifest.mode) issues.push('缺少顶层 mode(single 或 framePair)')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Phase: images — 图片生成
|
||||
*
|
||||
* 支持 Gemini / MJ / Kling 三种模型,含首尾帧模式
|
||||
* 支持 Gemini / GPT Image / MJ / Kling 四种模型,含首尾帧模式
|
||||
* 并发生成,支持 task ID 恢复(MJ)
|
||||
*/
|
||||
|
||||
@@ -130,6 +130,32 @@ async function generateMJ(item, idx, dir, imagesDir, ratio, refs, manifestPath,
|
||||
return harvestMJ(item, idx, dir, imagesDir, ratio, refs, manifestPath, manifest)
|
||||
}
|
||||
|
||||
async function generateGptImage(item, idx, dir, imagesDir, ratio, refs) {
|
||||
const { generate: gptGen, edit: gptEdit, ratioToSize } = require('../gpt-image-generator')
|
||||
const size = ratioToSize(ratio)
|
||||
let result
|
||||
if (refs.localPaths.length > 0) {
|
||||
log('images', `[${idx}] GPT Image 图生图: ${item.imagePrompt.substring(0, 60)}...`)
|
||||
result = await gptEdit(item.imagePrompt, refs.localPaths, {
|
||||
outputDir: imagesDir,
|
||||
size,
|
||||
})
|
||||
} else {
|
||||
log('images', `[${idx}] GPT Image 文生图: ${item.imagePrompt.substring(0, 60)}...`)
|
||||
result = await gptGen(item.imagePrompt, {
|
||||
outputDir: imagesDir, size,
|
||||
quality: 'auto',
|
||||
})
|
||||
}
|
||||
const file = (result.savedFiles && result.savedFiles.length > 0)
|
||||
? renameGeneratedFile(
|
||||
path.relative(dir, result.savedFiles[0]).replace(/\\/g, '/'),
|
||||
dir, idx, item.script || item.shotDesc, ''
|
||||
)
|
||||
: null
|
||||
return { file }
|
||||
}
|
||||
|
||||
async function generateKling(item, idx, dir, imagesDir, ratio, refs) {
|
||||
const { generate: klingGen } = require('../kling-image-generator')
|
||||
const klingOpts = { outputDir: imagesDir, aspectRatio: ratio }
|
||||
@@ -158,6 +184,12 @@ async function generateLastFrame(item, idx, manifest, dir, imagesDir, model, rat
|
||||
outputDir: imagesDir,
|
||||
aspectRatio: ratio,
|
||||
})
|
||||
} else if (model === 'gpt-image') {
|
||||
const { edit: gptEdit, ratioToSize } = require('../gpt-image-generator')
|
||||
lastResult = await gptEdit(item.lastFramePrompt, [firstFramePath], {
|
||||
outputDir: imagesDir,
|
||||
size: ratioToSize(ratio),
|
||||
})
|
||||
} else if (model === 'kling') {
|
||||
const { generate: klingGen } = require('../kling-image-generator')
|
||||
lastResult = await klingGen(item.lastFramePrompt, {
|
||||
@@ -273,10 +305,12 @@ async function processItem(item, manifest, manifestPath, dir, imagesDir, model,
|
||||
let result
|
||||
if (model === 'gemini') {
|
||||
result = await generateGemini(item, idx, dir, imagesDir, ratio, refs)
|
||||
} else if (model === 'gpt-image') {
|
||||
result = await generateGptImage(item, idx, dir, imagesDir, ratio, refs)
|
||||
} else if (model === 'kling') {
|
||||
result = await generateKling(item, idx, dir, imagesDir, ratio, refs)
|
||||
} else {
|
||||
throw new Error(`不支持的模型: ${model}(支持: gemini, mj, kling)`)
|
||||
throw new Error(`不支持的模型: ${model}(支持: gemini, gpt-image, mj, kling)`)
|
||||
}
|
||||
|
||||
if (result.file) {
|
||||
|
||||
Reference in New Issue
Block a user