/** Qwen Edit / PE-I2I prompt helpers. Start still = ; Hero is never a slot. */ export const QWEN21_EDIT_KEEP = 'Keep the identity, face, body, and pose of the person in .' export const QWEN21_EDIT_KEEP_CHANGE = `${QWEN21_EDIT_KEEP} Apply only this change:` /** User omitted — prepend the keep-identity instruction once. */ export function ensureQwen21EditPrompt(prompt) { const text = String(prompt || '').trim() if (!text) return text if (//i.test(text)) return text return `${QWEN21_EDIT_KEEP_CHANGE} ${text}`.trim() } /** * After PE-I2I: official PE told N=1 not to use tags, so rewrites often say * "the photo" / "the image" with zero . Qwen Edit only binds Start still * when the text contains the tag — force it onto every Edit rewrite. */ export function stitchQwen21PeEditPrompt(rewritten) { let text = String(rewritten || '').trim() if (!text) return text // Prefer the tag over natural substitutes (do not invent ). text = text .replace(/\bthe woman in the (?:input )?(?:photo|picture|image)\b/gi, 'the person in ') .replace(/\bthe (?:person|man|subject) in the (?:input )?(?:photo|picture|image)\b/gi, 'the person in ') .replace(/\bin the (?:input )?(?:photo|picture|image)\b/gi, 'in ') .replace(/\bthe (?:input )?(?:photo|picture|image)\b/gi, '') if (//i.test(text)) return text return `${QWEN21_EDIT_KEEP} ${text}`.trim() }