Wire Qwen Edit Start still to image_1 and PE-I2I identity keep.
Edit no longer invents strangers when the prompt omits <image1> or PE drops image tokens; Hero stays Klein-only. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/** 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: if the rewrite dropped every <imageN> token, stitch the
|
||||
* keep-identity line onto the rewrite (do not discard the rewrite).
|
||||
*/
|
||||
export function stitchQwen21PeEditPrompt(rewritten) {
|
||||
const text = String(rewritten || '').trim()
|
||||
if (!text) return text
|
||||
if (/<image\d+>/i.test(text)) return text
|
||||
return `${QWEN21_EDIT_KEEP} ${text}`.trim()
|
||||
}
|
||||
Reference in New Issue
Block a user