ComfyUI Node

Text Loader

A ComfyUI node in Zuellni/Text with 9 inputs and 1 output.

By Zuellni·Created 3 years ago·Updated 3 years ago· 44
Text Loader
    • PARAMS
    characterExample
    templateWizardLM
    apihttp://localhost:5000/api/v1/chat
    min_tokens32
    max_tokens64
    penalty1.15
    temperature2.00
    top_k30
    top_p0.18

    The pack's text nodes let you generate prompts with an LLM instead of typing them - and Text Loader is the settings hub for that whole setup. It doesn't generate anything itself. It collects the API endpoint, the character, the instruction template, and every sampling parameter into one PARAMS dictionary that the pack's Text Prompt node (the one that actually calls the LLM) consumes. Loader without Prompt is a config you can't spend; Prompt without Loader is a node with no settings.

    What it is

    One output - a DICT of PARAMS - built from ten inputs. The values are packed into a request that gets POSTed to a running text-generation-webui instance, which must be started with --api and a preloaded model (the API can't swap models, so the model has to be loaded before ComfyUI starts asking).

    The inputs that matter

    • api - the endpoint. Default http://localhost:5000/api/v1/chat, which is text-generation-webui's chat API. Change it if your webui is elsewhere or on another machine.
    • character - the character name used in the chat prompt. The author's README example uses WizardLM; the default is "Example." This is where you shape how the LLM talks - a character definition that biases it toward prompt-writing.
    • template - the instruction template, default "WizardLM". This must match the model's format in text-generation-webui ("might not be necessary" per the README, but wrong templates produce garbled output).

    Then the sampling knobs, which you'll mostly leave alone unless you're tuning generation quality:

    • min_tokens / max_tokens (32 / 64) - the length envelope for generated prompts.
    • temperature (2.0) - high by modern standards. This is aggressive sampling; text-generation-webui's chat mode with these defaults is tuned for the WizardLM-7B-uncensored style of creative, loose generation the author built this for.
    • top_k (30), top_p (0.18), penalty (1.15) - the repetition penalty and nucleus/top-k sampling. The penalty of 1.15 above 1.0 actively discourages repeating words, which matters when an LLM is generating prompts (LLMs love to loop).

    The setup you actually need

    Two machines running at once, effectively: ComfyUI, and a text-generation-webui with a model preloaded and --api on. The README's example startup for a WizardLM GPTQ model:

    python server.py --api --model llama-7b-4bit-128g-wizard
    

    Then wire PARAMS into the pack's Text Prompt node, give it a seed and a prompt, and it returns a string you can feed straight into a CLIP Text Encode. Round out the loop with Text Format to assemble and Text Condition to guard.

    The gotchas

    • The webui must be running and listening. If ComfyUI can't reach the endpoint you'll get connection errors, not a helpful message. Check that --api is on and the URL matches.
    • Model must be preloaded. The API can't load models, so whatever you want to chat with has to be loaded before you queue.
    • The defaults are tuned for a specific setup (WizardLM-era models). With a modern model, temperature=2 will give you nonsense; drop it toward 1.0 and re-tune top_p.

    Install

    Part of Zuellni/ComfyUI-Custom-Nodes, via ComfyUI Manager (search "Zuellni") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Zuellni/ComfyUI-Custom-Nodes
    

    Requires requests (usually already present) - no LLM runs inside ComfyUI, no model downloads. The pack is archived, and this node is the most environment-dependent of the text family: it works, but it's built around a specific 2023-era webui API that has evolved since. If the API shape has drifted on your webui version, this is where you'll feel it.

    CategoryZuellni/Text

    Inputs (9)

    NameTypeDefaultDescription
    characterSTRINGExample
    templateSTRINGWizardLM
    apiSTRINGhttp://localhost:5000/api/v1/chat
    min_tokensINT321–2048
    max_tokensINT641–2048
    penaltyFLOAT1.151–2
    temperatureFLOAT2.000–10
    top_kINT300–1000
    top_pFLOAT0.180–1

    Outputs (1)

    NameTypeDescription
    PARAMSDICT