Files
aigen/utils/identityPrompt.ts
T

41 lines
2.3 KiB
TypeScript

function extraPictureNumbers(extraRefs: number | number[]) {
if (Array.isArray(extraRefs)) {
return [...new Set(extraRefs.map(Number).filter(n => n >= 2 && n <= 5))].sort((a, b) => a - b)
}
const extras = Math.max(0, Math.min(4, extraRefs))
return Array.from({ length: extras }, (_, i) => i + 2)
}
export function identityBoilerplate(extraRefs: number | number[] = 0) {
const extras = extraPictureNumbers(extraRefs)
const secondary = extras.length === 0
? ''
: extras.length === 1
? ` <Picture ${extras[0]}> is that same person for face, hair, and body only — not a second character and not a wardrobe change.`
: ` ${extras.map(n => `<Picture ${n}>`).join(' and ')} are extra views of that same person for face, hair, and body only — not additional characters and not a wardrobe change.`
return `<Picture 1> is the current frame: keep this pose, clothes, place, and who is in shot. Do not reset the outfit to an earlier still.${secondary} Do not spawn extra people from reference stills. If this subject leaves the frame, they return as the person from the extra stills, wearing whatever Picture 1 already shows.`
}
export function looksLikeIdentityPrompt(text: string) {
return /^<Picture 1> is the (current frame|identity lock|primary identity anchor|exact facial identity)/i.test(String(text || '').trim())
}
export function buildIdentityPrompt(actionPrompt: string, extraRefs: number | number[] = 0) {
const action = String(actionPrompt || '').trim()
if (looksLikeIdentityPrompt(action)) return action
const boilerplate = identityBoilerplate(extraRefs)
return action ? `${boilerplate}\n\n${action}` : boilerplate
}
export const IDENTITY_ACTION_TEMPLATE = `[SHOT CONFIGURATION]
- Shot Type: Medium close-up, 50mm lens, eye-level
- Camera Movement: Slow tracking dolly-in following the subject
- Lighting: Warm golden-hour rim lighting with soft directional fill from screen left
- Environment/Scenery: Dense pine forest, soft ambient ground mist
[SUBJECT DIRECTION & ACTION]
The subject from <Picture 1> walks slowly through the path, glancing toward camera-left in awe. She turns slightly, speaking softly: "Look at the way the light hits the trees."
[AUDIO CUES]
Ambient forest breeze, soft footsteps on twigs, warm cinematic background strings.`