Load Random Txt File Tlant V2
The Random Prompt Loader, Now With a Seed (So You Can Reproduce a Good Roll)
- text
- txt_file
- seed
V2 is the middle child of the Tlant random-text-loader family: it takes the one-input idea from V1 and adds the two things V1 was missing - a seed and optional recursive scanning. Point it at a folder of prompt files, and it serves one at random per run. The seed is the real upgrade: keep it fixed and the same prompt comes back every run, so when you hit a roll you love you can hold it while you tweak the sampler instead of chasing a moving target.
How it works
Same shape as the rest of the family: scan for .txt files, then random.seed(seed) before random.choice, so a given seed always selects the same file from the same folder. The is_recursive toggle is an enum of "true" / "false" (not a boolean checkbox, which trips people up - you pick from the dropdown). Set to "false" and only the top level of dir_path is scanned; "true" walks every subfolder.
Reading is the pack's usual resilient chain - try utf-8, fall back to gbk, then latin-1 - so prompt files saved by Windows tools with legacy encodings still come through. If all three fail you get a decode error string back as text.
Inputs and outputs
dir_path- absolute path to the folder. Empty or wrong → the error comes back as text.seed- the reproducibility knob; change it to draw a different file.is_recursive-"true"/"false"string enum, default"false".
Outputs: text (the file contents), txt_file (absolute path of the chosen file), and seed (echoed back so you can route it elsewhere).
Install
It's part of the Tlant pack, so one install covers it:
cd ComfyUI/custom_nodes
git clone https://github.com/Tlant/ComfyUI-OllamaPromptsGeneratorTlant
restart ComfyUI, done. ComfyUI Manager also finds it under "Load Random Txt File Tlant V2". No model downloads, dependencies are just requests and aiohttp.
Where people get tripped up
The same trap as V1 and V3: errors don't raise, they arrive as the text output. Point it at a non-existent path and your positive prompt becomes "Directory not exists: ..." - check the text widget before debugging the sampler.
One more thing to know before you choose V2 over its siblings: V2 scans a folder but gives you no way to pick a subfolder from the UI - you type paths. If you want the browse button, that's V3. If you want "read each file exactly once before repeating," that's the Smart loader (V4). V2 is the right pick when you just need seeded randomness and nothing fancier.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| dir_path | STRING | — | |
| seed | INT | 10–18446744073709550000 | — |
| is_recursive | COMBO | false | 2 options: true, false |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| txt_file | STRING | — |
| seed | INT | — |