Nodes/AUN ComfyUI Nodes/Text Index Switch 5
ComfyUI Node

Text Index Switch 5

Put sampler settings inside the prompt — the node strips them back out

By loz2754·Created 7 months ago·Updated about 8 hours ago· 5
Text Index Switch 5
    • text
    • label
    • index
    • model
    • sampler
    • scheduler
    • cfg
    • steps
    • seed
    minimum1
    maximum10
    modeSelect
    index1
    slot_count2
    range1,2,5-8,12
    text1Slot 1
    text2Slot 2
    text3Slot 3
    text4Slot 4
    text5Slot 5
    text6Slot 6
    text7Slot 7
    text8Slot 8
    text9Slot 9
    text10Slot 10
    text11Slot 11
    text12Slot 12
    text13Slot 13
    text14Slot 14
    text15Slot 15
    text16Slot 16
    text17Slot 17
    text18Slot 18
    text19Slot 19
    text20Slot 20

    A plain text index switch picks a prompt and hands it down - fine, but then you still have to deal with the fact that different prompts want different sampler settings. AUNTextIndexSwitch5 is the version that lets you put those settings inside the prompt. It switches between up to 20 text slots (Select / Increment / Random / Range modes, same as the rest of the AUN text-switch family), then scans the selected text for key=value tokens - model, sampler, scheduler, cfg, steps, seed - outputs each as a typed value on its own socket, and removes those tokens from the text output so your prompt stays clean.

    So a slot containing:

    sampler=dpmpp_2m scheduler=karras cfg=4.5 steps=22 seed=7
    A cinematic portrait, soft light
    

    ...outputs "A cinematic portrait, soft light" as text, plus a sampler STRING of dpmpp_2m, a scheduler STRING, a cfg FLOAT of 4.5, steps INT of 22, and seed INT of 7. Token values can be a single space-free token or quoted (cfg="1.4"), and keys match case-insensitively. Any key=value pair not on that list is left alone in the text - so unrelated tokens don't get mangled.

    Inputs are the standard index-switch set: minimum, maximum, mode, index, slot_count (how many of the 20 text slots show), range (for Range mode, e.g. 1,2,5-8,12), and text1text20. Outputs: text, label, index, plus the six extracted values (model, sampler, scheduler, cfg, steps, seed). The label is derived from the connected node title, a custom label, or the first line of the text. When a token is absent from the selected text, its output falls back to a default - cfg defaults to 2.0, steps to 10, seed to 0.

    Where this pays off: dynamic prompt sets where every variation carries its own sampler recipe. Wire cfg/steps/seed into a KSampler (convert those widgets to inputs) and the whole sampling setup follows the prompt automatically. Feed index into AUNLoRAsByPromptIndex and the LoRA stack follows too. The model token is a string, not a loaded model - that's for naming/tracking or for loaders that accept a string name, not a checkpoint loader replacement.

    Note this is the predecessor to AUNInputsBasicSwitch, which folds an actual checkpoint loader into the same node. If you want the loader built in, use that one; if you want a pure prompt-side switch whose extracted values you wire yourself, this is it.

    Install: ComfyUI Manager (search "AUN"), or cd ComfyUI/custom_nodes && git clone https://github.com/loz2754/AUN-ComfyUI-Nodes, restart; pip install -r requirements.txt if a manual install complains about missing piexif/cv2.

    Troubleshooting:

    • A token stays in your prompt output → the key isn't on the known list (only the six are stripped) or it's malformed (needs key=value with no spaces around =).
    • Dynamic modes (Increment/Random/Range) re-execute every run - expect a new pick each queue.
    • The cfg/steps/seed sockets look like they do nothing until you actually wire them into your sampler; they're values, not magic.
    CategoryAUN Nodes/Prompts

    Inputs (26)

    NameTypeDefaultDescription
    minimumINT11–20The minimum index for selection (inclusive).
    maximumINT101–20The maximum index for selection (inclusive).
    modeCOMBOSelectSelect mode: Select for fixed index, Increment for cycling through range, Random for random index within range, Range for selecting from a list of indices.
    indexINT11–20Current or target index, constrained by slot_count).
    slot_countINT21–20Number of visible text slots.
    rangeSTRING1,2,5-8,12A comma-separated list of indices or ranges to select from in Range mode (e.g. 1, 2, 5-8, 12).
    text1STRINGSlot 1
    text2STRINGSlot 2
    text3STRINGSlot 3
    text4STRINGSlot 4
    text5STRINGSlot 5
    text6STRINGSlot 6
    text7STRINGSlot 7
    text8STRINGSlot 8
    text9STRINGSlot 9
    text10STRINGSlot 10
    text11STRINGSlot 11
    text12STRINGSlot 12
    text13STRINGSlot 13
    text14STRINGSlot 14
    text15STRINGSlot 15
    text16STRINGSlot 16
    text17STRINGSlot 17
    text18STRINGSlot 18
    text19STRINGSlot 19
    text20STRINGSlot 20

    Outputs (9)

    NameTypeDescription
    textSTRING
    labelSTRING
    indexINT
    modelSTRING
    samplerSTRING
    schedulerSTRING
    cfgFLOAT
    stepsINT
    seedINT