PE-I2I no longer bans tags for single-still edits, and the runner rewrites natural photo/image wording to <image1> so Start still stays bound. Co-authored-by: Cursor <cursoragent@cursor.com>
34 lines
1.4 KiB
JavaScript
34 lines
1.4 KiB
JavaScript
/** Qwen Edit / PE-I2I prompt helpers. Start still = <image1>; Hero is never a slot. */
|
|
|
|
export const QWEN21_EDIT_KEEP =
|
|
'Keep the identity, face, body, and pose of the person in <image1>.'
|
|
|
|
export const QWEN21_EDIT_KEEP_CHANGE =
|
|
`${QWEN21_EDIT_KEEP} Apply only this change:`
|
|
|
|
/** User omitted <image1> — prepend the keep-identity instruction once. */
|
|
export function ensureQwen21EditPrompt(prompt) {
|
|
const text = String(prompt || '').trim()
|
|
if (!text) return text
|
|
if (/<image1>/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 <image1>. 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 <image2>).
|
|
text = text
|
|
.replace(/\bthe woman in the (?:input )?(?:photo|picture|image)\b/gi, 'the person in <image1>')
|
|
.replace(/\bthe (?:person|man|subject) in the (?:input )?(?:photo|picture|image)\b/gi, 'the person in <image1>')
|
|
.replace(/\bin the (?:input )?(?:photo|picture|image)\b/gi, 'in <image1>')
|
|
.replace(/\bthe (?:input )?(?:photo|picture|image)\b/gi, '<image1>')
|
|
if (/<image1>/i.test(text)) return text
|
|
return `${QWEN21_EDIT_KEEP} ${text}`.trim()
|
|
}
|