fix: make detail scene prompt pack explicit

This commit is contained in:
Your Name 2026-06-04 10:07:00 +08:00
parent 2ea6f2e800
commit 0808f34021
2 changed files with 31 additions and 1 deletions

View File

@ -2484,6 +2484,20 @@ export function buildAgentReplacementPrompt(params: {
"如果参考图标题、标签或画面中出现可识别的外部品牌字样,不要保留该品牌名,不要换成相似字,不要生成伪 Logo;需要文字时只保留非品牌卖点语义或改成无品牌通用描述。",
]
: [];
const normalizedBasePrompt = String(params.basePrompt || "").trim();
const promptPackInstructionLines =
params.modeType === "detail_replacement" &&
shouldApplyPromptPack &&
normalizedBasePrompt
? [
"【必须生效的前置场景词包】",
normalizedBasePrompt,
isReferencePosterActionPlan
? "执行优先级:前置场景词包必须改造图片框内旧背景、空间、软装、灯光、墙面、地面、摆件和产品场景;参考图只锁人物数量、围坐/试坐/承重动作、产品受力关系、版式、机位、文案层和图片框边界,不锁旧背景物件。"
: "执行优先级:前置场景词包必须改造图片框内旧背景、空间、软装、灯光、墙面、地面、摆件和产品场景;参考图只锁版式、机位、文字层、主体位置和图片框边界,不锁旧背景物件。",
"如果最终图仍大量保留参考图原背景物件、原空间陈设或只做轻微修饰,判定为失败;必须能明显看出已按前置场景词包重建。",
]
: [];
const scenePlanLines = params.scenePlan
? [
@ -2559,6 +2573,7 @@ export function buildAgentReplacementPrompt(params: {
`当前要处理第 ${params.referenceIndex + 1} / ${params.totalReferences} 张详情参考图:${params.referenceLabel}`,
"【图片顺序规则】",
...imageOrderLines,
...promptPackInstructionLines,
...scenePlanLines,
...marketplaceBrandRemovalLines,
"你现在做的是‘仅替换产品’,不是重建场景,也不是重新设计整张详情图。",
@ -2586,6 +2601,7 @@ export function buildAgentReplacementPrompt(params: {
`当前要处理第 ${params.referenceIndex + 1} / ${params.totalReferences} 张详情参考图:${params.referenceLabel}`,
"【图片顺序规则】",
...imageOrderLines,
...promptPackInstructionLines,
...scenePlanLines,
...marketplaceBrandRemovalLines,
"你现在做的是“详情参考图背景/场景图替换”,不是重新设计整张详情图。",
@ -2711,7 +2727,7 @@ export function buildAgentReplacementPrompt(params: {
}
return [
params.modeType === "detail_replacement" && !shouldApplyPromptPack
params.modeType === "detail_replacement"
? ""
: params.basePrompt,
instructionLines.join("\n"),

View File

@ -3481,6 +3481,17 @@ export async function POST(request: Request) {
scenePlan: replacementExecutionPlan.scenePlan,
referenceGeometry,
});
chatApiLogger.info("[Chat API] Direct detail replacement prompt assembled:", {
referenceIndex: referenceIndex + 1,
totalReferences: replacementReferences.length,
referenceLabel: reference.label,
pageKind: replacementExecutionPlan.scenePlan.pageKind,
generationRoute: replacementExecutionPlan.scenePlan.generationRoute,
promptPackPolicy: replacementExecutionPlan.scenePlan.promptPackPolicy,
basePromptChars: baseReplacementPrompt.length,
promptChars: replacementPrompt.length,
hasPromptPackBlock: replacementPrompt.includes("【必须生效的前置场景词包】"),
});
try {
const result = await generateCanvasImage({
@ -4279,6 +4290,9 @@ export async function POST(request: Request) {
pageKind: replacementExecutionPlan.scenePlan.pageKind,
generationRoute: replacementExecutionPlan.scenePlan.generationRoute,
promptPackPolicy: replacementExecutionPlan.scenePlan.promptPackPolicy,
basePromptChars: baseReplacementPrompt.length,
promptChars: replacementPrompt.length,
hasPromptPackBlock: replacementPrompt.includes("【必须生效的前置场景词包】"),
sourceImageCount: sourceImageUrls.length,
generationAspectRatio,
imageOrder: {