Nodes/Music Production Toolkit/Parse Structured Music LLM Output
ComfyUI Node

Parse Structured Music LLM Output

Turning an LLM's rambling reply into four clean song fields

By jplenio·Created 21 days ago·Updated a day ago· 60
Parse Structured Music LLM Output
    • caption
    • lyrics
    • title
    • image_prompt
    • source_name
    • generation_seed
    • run_index
    • variant_count
    • source_path
    • prompt_origin
    • prompt_provenance_json
    song_count1
    seed_moderandom_each_song
    base_seed1
    user_promptInstrumental Progressive House with melodic and subtle trance influences, highly atmospheric and spacious, driven by memorable signature motifs and distinctive recurring synth riffs. Emotional, smooth, modern, with strong progression and evolving layers. create a 4–5 minutes long melodic story in the track.
    source_name_override
    fallback_titlellm-song
    structured_llm_output
    manual_caption
    manual_lyrics
    manual_title
    manual_image_prompt
    model_check_report
    llm_status
    max_prompt_tokens4500
    trim_long_prompttrue
    model_profile_json
    cover_source_json
    structured_summary_json
    cover_lyrics
    cover_lyrics_lock

    Anyone who's wired a chat LLM into a generation graph knows the pain: the model gives you exactly what you asked for, wrapped in "Here is your enhanced prompt!" and a closing paragraph, and you have to scrape the good parts out of the chat-shaped noise. That's failure mode one from the local-LLM playbook, and it's exactly what this node exists to kill. Parse Structured Music LLM Output takes the assistant's text, extracts the [Caption], [Lyrics], [Title], and [Image_Prompt] sections, validates that the required music sections are present, and emits each one as a clean STRING - plus per-song seeds and provenance.

    The bundled system prompt demands the canonical [Caption] → [Lyrics] → [Title] → [Image_Prompt] order, but the parser is deliberately order-tolerant: an LLM that shuffles the sections won't nuke an otherwise usable result. What it won't tolerate is missing or empty required sections - it raises an error rather than silently generating a song with no caption. Silent failure is worse than a loud one here.

    Inputs

    • structured_llm_output - the full assistant text from your LLM node.
    • song_count - how many song variants to emit from this source (1–100). More songs = more downstream generation time, obviously.
    • seed_mode - random_each_song (fresh seed per variant) or increment_from_base (reproducible sequential seeds from base_seed). For reproducible batches, increment is the one you want.
    • base_seed - only meaningful in increment mode.
    • user_prompt - stored with the parsed result for provenance.
    • source_name_override - replaces the auto-derived source identifier when non-empty.
    • fallback_title - used only when no usable [Title] survives parsing; it never replaces a valid LLM title.

    Outputs

    Every output is a list (is_list), so ComfyUI maps them across your batch: caption, lyrics, title, image_prompt, source_name, generation_seed, run_index, variant_count, source_path, prompt_origin, and prompt_provenance_json. Wire caption + lyrics into the MiniMax Music 3 node, image_prompt into the artwork branch, and the provenance outputs into MiniMax Song Metadata.

    Installing it

    Pack install via ComfyUI Manager (search "MiniMax Music Production Toolkit") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/jplenio/ComfyUI-MiniMax-Music-Production-Toolkit.git
    cd ComfyUI-MiniMax-Music-Production-Toolkit
    python -m pip install -r requirements.txt
    

    Dependencies: scipy, soundfile, imageio-ffmpeg, mutagen, Pillow. Restart ComfyUI and hard-refresh once.

    Gotchas

    If you get a hard parse error, the LLM probably skipped a required section or mangled the tags - the README's honest caveat applies: "the example LLM stage depends on the quality and instruction-following ability of the GGUF model you choose." A small or heavily-quantized model that truncates its output mid-[Lyrics] will trip this node on purpose. And the cache-buster rule applies upstream: if the LLM output looks identical every run, the LLM node is caching - wire in the LLM Session ID node, not the parser.

    CategoryMiniMax Music Production Toolkit/prompts

    Inputs (20)

    NameTypeDefaultDescription
    song_countINT11–100Number of song variants to emit from the selected source. Higher values repeat the downstream workflow for additional variants and therefore increase total generation time.
    seed_modeCOMBOrandom_each_songControls how generation seeds are created for multiple songs. random_each_song chooses a fresh seed per item; increment_from_base produces reproducible sequential seeds starting from base_seed.
    base_seedINT10–9223372036854776000Base integer used when deterministic/incrementing seed generation is selected. With random_each_song it is not the source of the random values; with increment_from_base each variant is derived from this value.
    user_promptSTRINGInstrumental Progressive House with melodic and subtle trance influences, highly atmospheric and spacious, driven by memorable signature motifs and distinctive recurring synth riffs. Emotional, smooth, modern, with strong progression and evolving layers. create a 4–5 minutes long melodic story in the track.Short user/music request sent to the external LLM or stored with the parsed result. This is the concise creative request that the long system prompt expands into MiniMax fields.
    source_name_overrideSTRINGOptional explicit source name. When non-empty it replaces the automatically derived source identifier used for filenames/provenance.
    fallback_titleSTRINGllm-songTitle used when the LLM answer and the manual fields contain none. A cover still takes its title from the source filename.
    structured_llm_outputoptSTRINGRaw text answer from the LLM chat node, with the [Style], [Lyrics], [Title] and [Image_Prompt] sections the parser expects.
    manual_captionoptSTRINGManual MiniMax Music caption used when manual source mode is selected. Put musical/production instructions here, not structural Lyrics tags.
    manual_lyricsoptSTRINGManual MiniMax Music Lyrics field. Use supported section tags and lyric text only; instrumental tracks should contain structural tags rather than prose production instructions.
    manual_titleoptSTRINGFallback/manual song title used in manual source mode. It may later be replaced by an LLM-generated title depending on the workflow branch.
    manual_image_promptoptSTRINGArtwork prompt used when the LLM answer contains none. The text-free prohibition is appended automatically when it is missing.
    model_check_reportoptSTRINGText report from the model preflight: which artifacts are present, already downloaded or missing. Recorded for the log and the production JSON only.
    llm_statusoptSTRINGStatus line from the LLM node, kept in the provenance so a run can be traced back to the model and provider that produced it.
    max_prompt_tokensoptINT4500500–4800Token budget for the combined Caption+Lyrics sent to MiniMax Music 3. The MiniMax text encoder hard-rejects prompts over 5000 tokens, so the default 4500 keeps a safety margin for the estimation error. The estimate is conservative (calibrated against the real MiniMax tokenizer).
    trim_long_promptoptBOOLEANtrueWhen the estimated prompt exceeds the budget: ON trims softly (whole lines from the end of the lyrics, orphan section tags removed, caption intact) and logs a warning; OFF raises a clear error instead so the MiniMax encoder never fails cryptically.
    model_profile_jsonoptSTRINGJSON profile of the selected song model: which model is active, its duration window, prompt hard limit and capabilities. This node adapts its behaviour to that profile; it comes from the song model profile node.
    cover_source_jsonoptSTRINGSource audio identity and shared transcription mode from Cover song / Source audio. Used only for YuE2 Cover; the filename owns the final title.
    structured_summary_jsonoptSTRINGSummary JSON from the structured prompt node (template, fields, requested length). Used for provenance and to honour a requested song length.
    cover_lyricsoptSTRINGCover-only: source transcript with timestamps. Original words are placed in measured score sections, restored after LLM rewrites, then checked for complete word order including repetitions. New lyrics use the timing as guidance.
    cover_lyrics_lockoptSTRINGCover Studio only, and empty by default. A deliberately locked lyrics block: when connected and non-empty it replaces the LLM's words verbatim and marks them as intentional, so the 'new lyrics' copy guard does not mistake a user lock for a lazy model answer. Leave it empty to keep the previous behaviour.

    Outputs (11)

    NameTypeDescription
    captionSTRING
    lyricsSTRING
    titleSTRING
    image_promptSTRING
    source_nameSTRING
    generation_seedINT
    run_indexINT
    variant_countINT
    source_pathSTRING
    prompt_originSTRING
    prompt_provenance_jsonSTRING