ai-chatbot/lib/agents/scene-image-role-prompt.ts
Your Name f0086e26da
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
fix: preserve secondary sku scene references
2026-04-02 12:06:10 +08:00

111 lines
5.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export function buildAgentSceneImageRolePrompt(params: {
primaryProductImageCount: number;
bundleProductImageCount: number;
includeModelImage: boolean;
}) {
const primaryProductImageCount = Math.max(
0,
Math.floor(Number(params.primaryProductImageCount) || 0)
);
const bundleProductImageCount = Math.max(
0,
Math.floor(Number(params.bundleProductImageCount) || 0)
);
const uploadedImageCount =
primaryProductImageCount +
bundleProductImageCount +
(params.includeModelImage ? 1 : 0);
if (uploadedImageCount <= 0) {
return "";
}
const lines = ["【输入图片角色说明】"];
const hasPrimaryProductImage = primaryProductImageCount > 0;
const hasBundleProductImage = bundleProductImageCount > 0;
const hasModelImage = params.includeModelImage;
const bundleStartIndex = primaryProductImageCount;
const modelImageIndex = primaryProductImageCount + bundleProductImageCount;
for (let index = 0; index < uploadedImageCount; index += 1) {
if (index < primaryProductImageCount) {
lines.push(
`图片${index + 1}:主SKU白底参考图,用于锁定主产品的外观、比例、材质、颜色、结构和细节。`
);
continue;
}
if (index >= bundleStartIndex && index < bundleStartIndex + bundleProductImageCount) {
lines.push(
`图片${index + 1}:搭配SKU白底参考图,用于锁定搭配产品本身的外观与结构。它是独立的第二产品,只能用于组合展示、场景搭配或补充关联销售,不能替代主SKU,也不能和主SKU融合成一件产品。`
);
continue;
}
if (hasModelImage && index === modelImageIndex) {
lines.push(
`图片${index + 1}:固定模特图。若画面需要人物,必须复用这张图中的同一模特(脸型、发型、体型、肤色、穿搭风格保持一致),不得替换成其他人物。`
);
continue;
}
lines.push(
`图片${index + 1}:补充参考图,只用于补充产品角度、细节或辅助信息,不可替代主产品外观。`
);
}
if (hasPrimaryProductImage) {
lines.push(
`必须以图片1${
primaryProductImageCount > 1 ? `到图片${primaryProductImageCount}` : ""
}中的主SKU信息为最高优先级,严格保持主产品身份不变。`
);
lines.push(
"【产品锁定约束】生成结果中的主SKU必须与主SKU白底参考图保持同一产品身份,禁止改成另一款产品。"
);
lines.push(
"严禁改变主SKU的主体结构、外轮廓、长宽高比例、层板数量与位置、抽屉数量与位置、柜门/开孔/隔断布局、弧度造型、柜腿样式、把手/五金位置。"
);
lines.push(
"严禁改变主SKU主色、木纹方向、材质类型、表面纹理、明暗层次和细节做工;不得把深色木纹改成浅色、白色、金属色或其他颜色体系。"
);
lines.push(
"如果场景风格与主SKU外观产生冲突,必须优先保留主产品本体不变,只允许调整周边场景、软装、灯光、背景和道具,不允许为了适配风格而修改主产品。"
);
lines.push(
"主SKU白底图是主产品身份锁定图,不是灵感参考图。输出时必须让人一眼看出是同一个主产品,只能换场景,不能换主产品本体。"
);
}
if (hasBundleProductImage) {
lines.push(
"【搭配产品约束】搭配SKU是独立的第二产品。需要搭配展示时,结果中必须同时出现主SKU与搭配SKU,清楚表现组合关系与使用场景。"
);
lines.push(
"严禁把搭配SKU当成主SKU的另一视角、局部细节或替代品;也严禁把主SKU与搭配SKU融合、拼接、嫁接成单一产品。"
);
lines.push(
"如果当前场景不适合展示搭配SKU,可以弱化其占比,但不得因此篡改、替换或覆盖主SKU。"
);
}
lines.push(
hasModelImage
? `如果当前场景有人物展示需求,只允许使用图片${modelImageIndex + 1}里的模特;如果不需要人物,则不要强行加入人物。`
: "当前没有固定模特图,不要凭空生成强人物主体。"
);
if (hasModelImage) {
lines.push(
"【模特锁定约束】固定模特图是人物身份锁定图。结果中出现的人物必须与模特图为同一人,不得换脸、换人、换性别、换年龄段,不得改变五官特征、脸型、发际线、发型主体、肤色、身材和辨识度。"
);
lines.push(
"允许根据场景构图调整模特的站姿、坐姿、手势、视线和轻微表情,但必须让人一眼看出是同一个模特。"
);
lines.push(
"只有当工作流设定或补充要求里明确要求修改模特衣服、穿搭或服装颜色时,才允许更换或调整服饰;如果没有明确要求,默认保持模特原有服装风格和穿搭关系一致。"
);
lines.push(
"如果模特衣服被允许调整,也只能改衣服,不得借机改变模特本人;人物身份稳定性始终高于服装变化。"
);
}
return lines.join("\n");
}