File size: 11,603 Bytes
3249e1b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
"""Prompt Studio: Python port of Chad's Muse 'AI KING' prompt console.

Source: sources/muse/ai-king-app.html (https://muse.ai/s/ai-king-lxt6oiy9xw1av).
The five modes (Text->Image, Image->Image, Image->Video, Prompt Coach, Enhancer)
keep the exact wording of the original JS builders, plus AI KING additions:
the CHAD likeness lock and the logo-preservation line.
"""

CHAD_LOCK = (
    "CHAD SYPHRETT, the exact same man as the reference photo: tall muscular athletic build, "
    "caramel-brown skin, light hazel eyes with caramel-brown irises, strong straight brows, full lips, "
    "full neat black beard, box-braid locs hanging to the jawline, gold chain with a gold inverted-triangle "
    "pendant with an eye at its center."
)
LOGO_LOCK = "Preserve the exact face, body, outfit and every original logo/emblem from the reference image."
UNIVERSAL_NEGATIVE = (
    "different face, different person, warped face, asymmetrical eyes, dark brown eyes, lighter or darker skin tone, "
    "different hairstyle, short hair, missing pendant, extra fingers, extra limbs, warped hands, Nike swoosh, "
    "Adidas stripes, Jordan jumpman, real brand logos, TikTok/Instagram/YouTube logos, watermark, signature, "
    "gibberish text, random letters, low resolution, blurry, oversaturated, plastic skin"
)

FAST_STARTS = {
    "Music video": "A cinematic music-video hero portrait in a futuristic recording studio",
    "Product launch": "A premium product campaign with a sculptural object on a precise studio set",
    "Character reveal": "An original superhero character arriving at a neon-lit urban arena",
    "Anthem stage": "A world-peace anthem performance on a vast concert stage",
}
TI_RATIOS = ["vertical 9:16 composition", "square 1:1 composition", "portrait 4:5 composition", "cinematic widescreen 16:9 composition"]
TI_SHOTS = ["heroic medium shot", "intimate close-up", "full-body editorial shot", "wide establishing shot", "low-angle tracking shot", "overhead graphic composition"]
TI_LIGHTS = ["cinematic edge lighting with controlled highlights", "soft window light with natural shadow falloff", "golden-hour directional light", "high-contrast stage lighting", "clean commercial studio lighting"]
TI_FINISHES = ["hyperrealistic photography", "luxury editorial photography", "cinematic film still", "ARRI ALEXA 35 cinematic still", "polished 3D realism", "graphic poster illustration"]
II_FINISHES = ["hyperrealistic final image", "cinematic film still", "premium magazine editorial", "polished product campaign"]
II_RATIOS = ["preserve source aspect ratio", "vertical 9:16 composition", "portrait 4:5 composition", "square 1:1 composition", "widescreen 16:9 composition"]
IV_CAMERAS = ["slow cinematic push-in", "gentle orbit around the subject", "low-angle forward tracking move", "controlled crane rise", "locked camera with subtle parallax", "handheld documentary drift"]
IV_DURATIONS = ["6", "10", "15", "20", "30"]
EN_GOALS = {
    "Cinematic impact": "a high-impact cinematic image",
    "Commercial polish": "a premium commercial image",
    "Character consistency": "strong character consistency",
    "Edit accuracy": "precise image editing",
    "Video motion": "smooth short-form motion",
}
EN_EMPHASIS = ["composition", "lighting", "camera", "quality", "motion"]

_DETAIL = ["clean essential detail", "controlled supporting detail", "rich material and environmental detail",
           "high micro-detail with realistic texture separation", "extreme micro-detail while preserving a natural, believable image"]
_STRENGTH = ["minimal correction only", "subtle transformation", "balanced transformation with clear preservation",
             "strong visual transformation", "complete art-direction shift while honoring preservation locks"]


def build_ti(idea, ratio, shot, light, finish, detail, notes, chad_lock=False):
    idea = (idea or "").strip()
    if not idea:
        return "Add a core idea first."
    parts = []
    if chad_lock:
        parts += ["LIKENESS LOCK", CHAD_LOCK + " " + LOGO_LOCK, ""]
    parts += ["SUBJECT & SCENE", idea.rstrip(".") + ".", "",
              "ART DIRECTION", f"{finish}; {ratio}; {shot}. Use {light}. Build a clear foreground, subject plane, and background with intentional depth.", "",
              "DETAIL & MATERIALS", _DETAIL[int(detail) - 1] + ". Physically believable materials, coherent reflections, accurate hands and anatomy, consistent perspective, intentional color separation, and a crisp focal hierarchy."]
    if (notes or "").strip():
        parts += ["", "MANDATORY NOTES", notes.strip().rstrip(".") + "."]
    parts += ["", "QUALITY CONTROL", "Complete rendering from edge to edge. No watermarks, interface elements, random typography, accidental trademarks, malformed anatomy, duplicate limbs, distorted faces, unfinished objects, or muddy detail. Keep the image polished, original, and production-ready."]
    return "\n".join(parts)


def build_ii(edit, lock, strength, finish, ratio, has_image=False, chad_lock=False):
    edit = (edit or "").strip()
    if not edit:
        return "Describe the edit first."
    parts = ["SOURCE", "Use the supplied reference image as the visual source." if has_image else "Apply this directive to the chosen source image.", "",
             "EDIT", edit.rstrip(".") + ".", "",
             "PRESERVATION LOCK", "Preserve " + ((lock or "").strip() or "the defining subject details") + ". Maintain recognizable continuity and avoid unintended changes outside the requested edit."]
    if chad_lock:
        parts[-1] += " " + LOGO_LOCK
    parts += ["", "TRANSFORMATION", f"{_STRENGTH[int(strength) - 1]}. Finish as {finish} in a {ratio}.", "",
              "QUALITY CONTROL", "Match lighting direction, perspective, lens behavior, shadows, scale, reflections, and color temperature across all edited areas. Keep facial anatomy, hands, edges, textures, and background geometry coherent. No watermarks, UI fragments, unwanted text, accidental logos, duplicated features, or incompletely rendered objects."]
    return "\n".join(parts)


def build_iv(action, camera, duration, continuity, beats, has_image=False, loop=False):
    action = (action or "").strip()
    if not action:
        return "Add a motion direction first."
    parts = ["START FRAME", "Animate from the supplied still image." if has_image else "Use the selected still image as the exact opening frame.", "",
             "DURATION", f"{duration} seconds, one continuous cinematic shot.", "",
             "DIRECTION", action, "",
             "CAMERA", f"{camera}. Use natural acceleration and deceleration, stable horizon logic, believable parallax, and no sudden lens jumps."]
    if (beats or "").strip():
        parts += ["", "MOTION BEATS", beats.strip().rstrip(".") + ". Sequence the beats clearly without overcrowding the shot."]
    parts += ["", "CONTINUITY LOCK", ((continuity or "").strip() or "preserve the defining visual details") + ". Keep identity, anatomy, object count, textures, reflections, and environment layout stable across every frame.", "",
              "QUALITY CONTROL", "Smooth temporal coherence; realistic body mechanics and fabric response; no morphing faces, flicker, frame warping, duplicate limbs, melting objects, random text, logos, or camera collisions. End on a composed final frame that can loop or cut cleanly."]
    if loop:
        parts += ["", "LOOP", "First frame identical to last frame for a perfect seamless loop."]
    return "\n".join(parts)


def enhance(draft, goal_label, emphasis):
    draft = (draft or "").strip()
    if not draft:
        return "Paste a draft prompt first."
    adds = {
        "composition": "COMPOSITION: Establish a decisive focal subject, clean silhouette separation, intentional foreground-to-background depth, and balanced negative space.",
        "lighting": "LIGHTING: Use motivated directional light, controlled highlights, realistic shadow falloff, coherent reflections, and deliberate color contrast.",
        "camera": "CAMERA: Choose lens perspective and camera height to support the story; maintain natural scale, straight spatial logic, and precise focus hierarchy.",
        "motion": "MOTION: Use smooth, physically believable movement with clear timing, stable subject identity, consistent geometry, and a composed ending frame.",
        "quality": "QUALITY CONTROL: Complete high-resolution rendering; accurate anatomy and hands; coherent materials and perspective; no watermarks, UI fragments, random text, accidental logos, duplicate features, flicker, or unfinished objects.",
    }
    out = "PRIMARY INTENT\n" + draft.rstrip(". \n") + ".\n\nTARGET\nCreate " + EN_GOALS.get(goal_label, goal_label) + "."
    picked = [adds[k] for k in EN_EMPHASIS if k in (emphasis or [])]
    if picked:
        out += "\n\n" + "\n\n".join(picked)
    return out


def coach_reply(q: str) -> str:
    lower = (q or "").lower()
    if "camera" in lower:
        return "Start with the story beat: reveal, intimacy, power, or scale. For power, use a low camera and slow push-in. For intimacy, use a close lens at eye level with minimal movement. For scale, open wide, then move toward the subject. Keep one dominant move per short clip."
    if "preserve" in lower or "edit" in lower:
        return "Lock identity, facial structure, pose, body proportions, wardrobe silhouette, important accessories, and lighting direction. Then name only the parts allowed to change. This separation reduces unintended redesigns. " + LOGO_LOCK
    if "negative" in lower or "avoid" in lower:
        return "Use a short risk-based negative list: " + UNIVERSAL_NEGATIVE + "."
    if "loop" in lower or "lofi" in lower:
        return "For a seamless lofi loop: locked camera, subtle motion only (rain, steam, lights, a slow head nod), and say 'first frame identical to last frame'. In AI KING, the Loop Maker tab can feed the same still as first and last frame to LTX, or ping-pong any clip with ffmpeg."
    if "video" in lower or "second" in lower or "motion" in lower:
        return "Build three beats: opening hold, one readable action, composed ending. Keep the camera move singular, motion physically believable, and identity locked across frames. For 10 seconds: 0-2 establish, 2-8 action, 8-10 settle."
    if "light" in lower:
        return "Name the motivated source, direction, softness, and contrast. Example: warm key from camera-left, cool city ambience behind, controlled edge light on the silhouette, natural shadow falloff, no clipped highlights."
    if "cover" in lower:
        return "Covers: square, 3000x3000 JPG, RGB, no text, URLs, handles or third-party logos. Generate square, upscale, then run the Cover Checker tab."
    if "improve" in lower or "prompt" in lower:
        return "Use five blocks: subject and action; environment; composition and camera; lighting and materials; quality controls. Put the non-negotiable subject details first, then add style. Avoid stacking vague adjectives when one concrete direction would do more."
    return "Clarify four things: the exact subject, the action or moment, the intended platform/frame, and the visual emotion. Then choose one camera idea and one lighting idea. If you paste the concept with those details, the Enhancer can structure it into a production prompt."

COACH_PRESETS = [
    "Improve my prompt about [subject].",
    "Give me a camera plan for [scene].",
    "What should I preserve in this edit?",
    "Turn [idea] into a 10-second video beat.",
    "Write negative constraints for [concept].",
    "How do I make a seamless lofi loop?",
]