Random List Picker:
The Random List Picker node is a versatile tool designed for ComfyUI that allows you to randomly select items from a list with various customization options. Its primary purpose is to facilitate the random selection of one or more items from a user-provided list, which can be particularly useful in creative applications where randomness is desired. The node supports weighted picking, allowing you to assign different probabilities to each item by appending a weight to them. Additionally, it offers a shuffle mode to return the entire list in a random order. You can also customize the output by injecting selected items into a template string, or by adding prefixes and suffixes. The node provides case control to transform the text case of the selected items and allows you to specify a separator for joining multiple picks. It includes an exclude list to prevent certain items from being chosen and a fallback value for when no items are available for selection. The node can draw a specified number of unique items in one pass and provides the index of the first chosen item. With the ability to set a seed, you can achieve reproducible results or fresh randomness with each run.
Random List Picker Input Parameters:
items
This parameter is a newline-separated list of items from which the node will randomly select. Each item can optionally have a weight appended using the format item::weight to influence its selection probability. There is no explicit minimum or maximum value, but the list should be formatted correctly for optimal results.
template
A string that allows you to inject the selected item(s) into a custom format. Use {item} within the template to specify where the selected item should be placed. The default is an empty string, meaning no template is applied.
prefix
A string that will be added before each selected item if no template is used. The default is an empty string.
suffix
A string that will be added after each selected item if no template is used. The default is an empty string.
exclude
A multiline string where each line represents an item that should never be selected. Matching is case-insensitive. The default is an empty string.
fallback
A string value that is returned when no items remain after applying exclusions. The default is an empty string.
count
An integer specifying the number of unique items to pick in one pass. It is automatically capped at the size of the list. The default is 1, with a minimum of 1 and a maximum of 100.
separator
A string used to join multiple picked items. Common examples include ", ", " | ", or a newline character. The default is ", ".
case
Specifies the case transformation applied to each picked item. Options include original, uppercase, lowercase, title, and sentence. The default is original.
mode
Determines the operation mode of the node. Options are pick for selecting random items and shuffle for returning the entire list in a random order. The default is pick.
seed
An integer used to initialize the random number generator. Use -1 for a new random result each run, or any other value for reproducible results. The default is -1, with a minimum of -1 and a maximum of 0x7FFFFFFF.
Random List Picker Output Parameters:
joined
This output is a string containing the selected item(s), joined by the specified separator. It reflects the final result of the random selection process.
prompt
A string that represents the final output after applying the template, prefix, and suffix to the selected item(s). It provides a formatted version of the selection.
total
An integer indicating the total number of items available for selection after applying exclusions. It helps you understand the size of the usable list.
chosen_index
An integer representing the zero-based index of the first chosen item in the original list. It is useful for identifying the position of the selected item.
Random List Picker Usage Tips:
- Use the
weightfeature to influence the likelihood of certain items being picked, which can be useful for creating more balanced random selections. - Utilize the
template,prefix, andsuffixoptions to customize the output format, making it easier to integrate the selected items into larger projects or workflows. - Experiment with the
caseparameter to ensure the selected items match the desired text style, which can be important for maintaining consistency in your outputs.
Random List Picker Common Errors and Solutions:
No items remain after exclusions
- Explanation: This error occurs when all items in the list are excluded, leaving no items available for selection.
- Solution: Review the
excludelist to ensure it does not inadvertently block all items. Adjust the list or provide a suitablefallbackvalue.
Invalid weight format
- Explanation: This error arises when an item in the list has an improperly formatted weight, such as missing the
::separator. - Solution: Check the list for correct weight formatting, ensuring each item with a weight follows the
item::weightstructure.
Seed value out of range
- Explanation: This error occurs when the seed value is set outside the allowable range.
- Solution: Ensure the
seedvalue is within the range of-1to0x7FFFFFFF. Adjust the value accordingly.
