Nodes/ComfyUI-PromptEngine/Step 3: Dictionary Generator
ComfyUI Node

Step 3: Dictionary Generator

Turn your clusters into a prompt dictionary

By aiimagestudio·Created 6 months ago·Updated 5 months ago· 4
Step 3: Dictionary Generator
  • llm_config
  • STRING
cluster_input_dir/tmp/ComfyUI/custom_nodes/ComfyUI-PromptEngine/output/step2_clusters

Step 3: Dictionary Generator is the payoff of the ComfyUI-PromptEngine toolchain. Step 1 turned your prompt file into structured JSON, Step 2 grouped the phrases into clusters, and this node turns those clusters into actual dictionary entries - the same kind of entries the prompt composition nodes read. Run it once and your own vocabulary starts showing up in the PromptEngineNode and PromptEngineFull dropdowns.

The clever bit is that it writes incremental user dictionaries and merges them with the bundled base dictionaries at runtime. It never touches the shipped files, so your additions and the stock entries coexist, and you can regenerate your part without nuking the defaults.

How it works

The node reads each dimension's cluster file from Step 2 (output/step2_clusters/<dim>/<dim>_clusters.json) and, per cluster, sends the grouped phrases to an LLM with a naming-assistant system prompt. The LLM produces a canonical phrase, a display name, samples, and tags for that cluster - the exact shape the dictionaries already use (check dim_dictionaries/visual_style_dict.json and you'll see canonical_name, canonical_phrase, samples, tags). Results are written to output/step3_dictionaries/<dim>_dict.json. Then the node calls the pack's dictionary loader again, so the backend is reading your new entries immediately.

Inputs are minimal:

  • cluster_input_dir - where Step 2 wrote its clusters. The default already points at the plugin's output/step2_clusters, so you usually don't touch it.
  • llm_config - an LLM_CONFIG from the pack's LLMConfigNode. Unlike Step 1, this one is required: there's no built-in fallback, so if you run it unwired it errors out immediately.

Output is a single STRING: a status message telling you how many dimensions were updated and where the dictionaries landed.

Wiring the whole pipeline

The flow the README diagrams:

prompts.txt
  -> Step1DimensionExtract
  -> output/step1_json/*.json
  -> Step2Clustering
  -> output/step2_clusters/<dim>/<dim>_clusters.json
  -> Step3DictionaryGen
  -> output/step3_dictionaries/<dim>_dict.json

One LLMConfigNode feeds both Step 1 and Step 3 - same endpoint, same key. The author's own dictionary-generation sample workflow is exactly that: LLMConfigNode → Step1 → Step2 → Step3, chained in order.

Gotchas

  • Refresh the page to see new dropdowns. The backend picks up new entries immediately, but the frontend caches the dropdown lists until you reload ComfyUI's web UI. The README says this outright; it trips everyone once.
  • It needs an LLM, again. Same story as Step 1 - an OpenAI-compatible endpoint (the tool's default config names a local Qwen GGUF model on localhost:8080/v1). No model bundled, no free lunch.
  • Incremental, not aggressive. The README's known-limitations section is candid: Step 3 favors incremental generation over aggressive normalization. Entries get appended and merged; don't expect it to ruthlessly deduplicate your mess. Quality in, quality out - sparse Step 1 data means noisy clusters here.
  • Small datasets propagate their weakness from Step 2: if Step 2 gave up and made one bucket per dimension, that's what you'll get here.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/jinxishe/ComfyUI-PromptEngine
pip install -r requirements.txt

Restart, or use ComfyUI Manager (search "ComfyUI-PromptEngine"). This node itself only needs the core openai/tqdm deps; the heavy Step 2 stack is upstream of it, not required just to run Step 3 on existing clusters.

CategoryPromptEngine/Tools

Inputs (2)

NameTypeDefaultDescription
cluster_input_dirSTRING/tmp/ComfyUI/custom_nodes/ComfyUI-PromptEngine/output/step2_clusters
llm_configLLM_CONFIG

Outputs (1)

NameTypeDescription
STRINGSTRING