Nodes/arkennemasis Nodes/arkennemasis Avatar Script (split the model's answer)
ComfyUI Node

arkennemasis Avatar Script (split the model's answer)

Turning one messy LLM answer into a script, a caption, and a filename

By Hishamahmer·Created about a month ago·Updated a day ago· 6
arkennemasis Avatar Script (split the model's answer)
    • script
    • caption
    • headline
    • slug
    • save_prefix
    • scenes_json
    • word_count
    • report
    answer
    caption_answer
    prefixavatar
    max_words0

    LLMs are great at writing a script and terrible at returning it in the exact shape your graph needs. ArkAvatarScript is the part of the avatar pipeline that fixes that: it takes the script-writing model's raw JSON answer and splits it into the spoken script, a social caption, a headline, a filename slug, and a one-scene plan for the subtitle burner. One string in, seven useful things out, and nothing left to hand-parse.

    You reach for it because the alternative - asking the model for a script and then hoping the whole rest of the pipeline agrees on what "the script" is - is how you end up with a video whose subtitles say something other than what's spoken. This node is the contract between the LLM and everything downstream.

    How it works

    The answer input is the LLM's raw output, wired straight from its text socket. The node parses it as JSON and extracts the fields. The interesting design choice is the optional caption_answer: when the caption is written by its own LLM call with its own instructions, you wire that in and it wins. The pack's reasoning is sound - a prompt written for spoken words and a prompt written for social copy are different jobs, and asking one call to do both is why captions come out sounding like they were narrated.

    The one input a beginner should actually think about is max_words. It defaults to 0, meaning "accept whatever was written." Set it above 0 and the run stops dead when the script is longer, because an over-long script is only discovered as a video whose voice outruns its picture - after the render has been paid for. The error message does the math for you: at about two words a second, a 200-word script is ~100 seconds of speech, so the clip sized from it would render long and cost accordingly.

    Outputs:

    • script - the cleaned spoken lines, wired into the TTS.
    • caption - the social post copy.
    • headline - used by the picker and the record.
    • slug - the bare filename stem (no slashes), so a save node can build its own path safely.
    • save_prefix - the slug inside its prefix folder, for nodes that write one named file. The source comments note both exist because a slash in a filename silently asks for a subdirectory.
    • scenes_json, word_count, report - the subtitle plan, the count, and a diagnostic line.

    Installing

    Standard pack install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Hishamahmer/comfyui-arkennemasis
    pip install replicate httpx
    

    Restart ComfyUI (or use ComfyUI Manager, search arkennemasis). No model download, no key, no API calls from this node itself.

    Troubleshooting

    The max_words trip is the most common stop: it's not a bug, it's the guard working - shorten the brief or raise the cap deliberately. If the parse fails, look at what the model actually returned; a script-writing model that wrapped its answer in prose instead of JSON will fail here loudly rather than corrupting the render downstream, which is exactly what a parsing node should do.

    Categoryarkennemasis/Avatar

    Inputs (4)

    NameTypeDefaultDescription
    answerSTRINGThe script-writing model's raw answer. Wire the LLM's `text` output straight in.
    caption_answeroptSTRINGThe CAPTION model's answer, when the caption is written by its own call with its own instructions. Wired, it wins; unwired, the caption is taken from the script answer if it happens to carry one.
    prefixoptSTRINGavatarFolder the outputs file under. The slug is appended, so each story gets its own name inside it.
    max_wordsoptINT00–20000 = accept whatever was written. Above 0 the run STOPS when the script is longer, because an over-long script is only discovered as a video whose voice outruns its picture — after the render has been paid for.

    Outputs (8)

    NameTypeDescription
    scriptSTRING
    captionSTRING
    headlineSTRING
    slugSTRING
    save_prefixSTRING
    scenes_jsonSTRING
    word_countINT
    reportSTRING