Nodes/ComfyUI_DW_Chat/Ollama Text To Text
ComfyUI Node

Ollama Text To Text

Run your LLM prompt-engineer locally, no API key, no cloud

By yiwangsimple·Created 2 years ago·Updated about a year ago· 89
Ollama Text To Text
    • response
    • context
    prompt1girl
    model
    extra_modelnone
    systemYou are creating a prompt for Stable Diffusion to generate an image. First step: understand the input and generate a text prompt for the input. Second step: only respond in English with the prompt itself in phrase, but embellish it as needed but keep it under 200 tokens.
    seed0
    top_k40
    top_p0.90
    temperature0.50
    max_tokens100
    tfs_z1.00
    keep_alive
    context

    Ollama Text To Text is the "no cloud, no key" option in this pack - the one that talks to whatever LLM you already have running in Ollama on your own machine. The author adapted it from the ComfyUi-Ollama-YN and ComfyUI-Prompt-MZ projects (credited in the README), and it shows: this is the most parameter-heavy chat node here, because it's basically the whole Ollama generate API exposed as a node.

    The default system prompt is a tell: "You are creating a prompt for Stable Diffusion to generate an image..." with the output capped under 200 tokens. This node is designed as a local prompt-expander. Drop in "1girl" (the default prompt, cheekily), get a full SD-flavored prompt back, wire the response into your CLIP text encode. It talks to Ollama at http://localhost:11434 via the ollama Python client.

    The inputs are the full Ollama sampling kit: model (populated from models you have pulled), extra_model (an override - set it and it replaces the selected model for that run), prompt, system, seed, top_k, top_p, temperature, max_tokens, tfs_z, and keep_alive (how long to hold the model in RAM after a call - 0 unloads, 5m/30m keep it warm). Two outputs: response (the text) and context, which is Ollama's raw context tokens - feed that back into the context input of the same node to carry a multi-turn conversation cheaply, which is a neat trick most chat nodes here don't have.

    Installing it

    Same pack, plus two extras. First the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yiwangsimple/ComfyUI_GroqChat
    

    Second, the ollama Python package is not in requirements.txt, so install it yourself:

    pip install ollama
    

    Third - the big one - you need an Ollama server running with a model pulled. The README's install of Ollama is up to you; the node assumes it's already at localhost:11434 when ComfyUI starts.

    The gotcha that everyone hits

    The model dropdown is populated once, at import time, by querying http://localhost:11434/api/tags. If Ollama isn't running when ComfyUI boots, the dropdown reads "No models found" and stays that way until you restart ComfyUI. Restart order matters: start Ollama first, then ComfyUI, and pull your model (ollama pull llava for vision, or any text model) before the restart. This trips up more people than any other issue in this pack, and it's purely a timing thing.

    One more honest note: tfs_z and top_k default tuning barely matters for prompt expansion - leave them alone. The single lever that changes your results is which model you pulled and the system prompt.

    Category🌙DW/Chat

    Inputs (12)

    NameTypeDefaultDescription
    promptSTRING1girl
    modelCOMBO1 options: No models found
    extra_modelSTRINGnone
    systemSTRINGYou are creating a prompt for Stable Diffusion to generate an image. First step: understand the input and generate a text prompt for the input. Second step: only respond in English with the prompt itself in phrase, but embellish it as needed but keep it under 200 tokens.
    seedINT00–18446744073709550000
    top_kFLOAT400–100
    top_pFLOAT0.900–1
    temperatureFLOAT0.500–1
    max_tokensINT1001–1024
    tfs_zFLOAT1.001–1000
    keep_aliveCOMBO6 options: 0, 5m, 10m, 15m, 30m, 60m
    contextoptSTRING

    Outputs (2)

    NameTypeDescription
    responseSTRING
    contextSTRING