Force <image1> on every Qwen Edit PE rewrite.
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>
This commit is contained in:
@@ -15,12 +15,19 @@ export function ensureQwen21EditPrompt(prompt) {
|
||||
}
|
||||
|
||||
/**
|
||||
* After PE-I2I: if the rewrite dropped every <imageN> token, stitch the
|
||||
* keep-identity line onto the rewrite (do not discard the rewrite).
|
||||
* 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) {
|
||||
const text = String(rewritten || '').trim()
|
||||
let text = String(rewritten || '').trim()
|
||||
if (!text) return text
|
||||
if (/<image\d+>/i.test(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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user