StepExecutor - altoiddealer/ad_discordbot GitHub Wiki
StepExecutor is the processing system used by API Endpoint Response Handling, Workflows, and Custom Commands
- Streamlines many complicated functions via simple "Step" configurations:
- Processes each defined "Step" sequentially.
- The result of the previous step will be input for the next step
- Can execute a "for-each" loop of steps from a list of data
- Can even run a step "groups" in parallel
- Uses a sophisticated context management system
- Step results / extracted values can be stored via
save_as - Context values, Bot Variables, even Websocket variables can be used anywhere in the system which will automatically resolve to their actual values
- Step results / extracted values can be stored via
Any Step can include Meta parameters, set as top level items in each step dictionary (not nested in each "step config")
Meta Parameters are applied in the following order: on_error -> save_as -> returns -> log
Saves the result into a Context dictionary using the given key name
Saved values can then be injected anywhere using {this_syntax}.
The script can also convert a string value like this into actual python value: "{some_key: {saved_value}}" - this will be turned into an actual dictionary object with the resolved value from context {'some_key': \<the value previously saved to context as 'saved_value'\>}
Can override what is typically returned by a Step.
-
"data"(default) the Step result -
"input"the original input to the Step -
"context"the entire stored context dictionary -
"a key name"If the step result is a dict, you can return a top-level key value from it. For deeper values just use extract_key
Provides additional logging for a step. Useful for debugging
Allows gracefully handling exceptions without aborting StepExecutor
-
"raise"(default) raises Exception (aborts StepExecutor) -
"skip"returns the input value to the next step. -
"default"A specific value to return for the next step.
| Step Name | Description |
|---|---|
| if | Conditionally execute steps if condition evaluates to True. |
| if_group | Similar to "if" step, but also supports elif and else. |
| group | Executes multiple step sequences in parallel, each defined as a list of steps. |
| for_each | Runs a sub-StepExecutor for each item in a list or each key-value pair in a dict. |
| run_workflow | Runs a predefined workflow (a sub-StepExecutor) |
| prompt_user | Prompts the user for input via Discord message interaction. |
| send_content | Sends text or files to the Discord interaction channel. |
| load_data_file | Loads a data file as a dictionary |
| save | Saves input data to a file |
| offload | Releases the current Task from it's queue, freeing up a slot for another Task. |
| pass | Does nothing. Can be useful when you simply want to use a meta parameter |
| extract_key | Retrieves a nested value from a data structure (dicts/lists) based on a specified path |
| extract_values | Applies extract_key to build a new dictionary using user-defined key names for the extracted values. |
| set_context | Sets arbitrary key values into the Context dict |
| set_key | Sets a value within a data structure (dicts/lists) based on a specified path |
| return | Helpful for passing a specific variable from saved Context as input to the next step. |
| format | Creates a string or python object depending on usage. Accepts {placeholder syntax} to resolve values into the string. |
| dict | Creates a dictionary, ideal to work with {placeholder syntax} for non-JSON serializable objects |
| list | Creates a list, ideal to work with {placeholder syntax} for non-JSON serializable objects |
| type | Converts the input data to a specified target type. |
| cast | Like type except it can convert multiple dictionary value types at once. |
| map | Transforms each element of a list into a dict. The key name can be arbitrary, or set by a dynamic context value |
| regex | Extracts text from an input string using a regular expression pattern. It returns the first captured group if one exists, or the entire match if not. |
| call_api | Performs an API call, and returns the result. |
| poll_api | Like call_api except that it repeatedly calls the API, collecting each result to a list which is returned after polling is stopped. |
| track_progress | Polls an endpoint while sending a progress Embed to discord. |
| upload_files | Specialized method for uploading multipart form payloads |
| load_llmmodel | For TGWUI integrated installs only. Loads or unloads LLM Model. |
| call_imggen | Simplifies execution of main ImgGen API requests |
| call_comfy | Simplifies execution of ComfyUI prompts |
| free_comfy_memory | Unload models and/or free up memory |
| comfy_delete_nodes | Delete nodes from a ComfyUI payload |
| decode_base64 | Decodes a Base64-encoded string into raw bytes |
Evaluates a condition, typically by comparing two values, and executes the steps if evalues to True.
Refer to the List of valid operators (accordion menu below), and the correct usage of these parameters should make sense.
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| value1 | Any | The value to check | |
| operator | string | (optional) If not provided, the last step result is passed in. Use null to run without any input. |
<last step result> |
| value2 | Any | Usually the second value to compare value1 against. Optional in some cases (exists, notexists, isnone, isnotnone, etc) |
None |
| steps | list |
Steps to be executed if condition evaluates True
|
[] |
List of valid operators
These must be strings (some values require quotes) - e.g. "!="
| Operator | Description |
|---|---|
| = / == | True if value1 is equal to value2 |
| != | True if value1 is not equal to value2 |
| > | True if value1 is greater than value2 |
| < | True if value1 is less than value2 |
| >= | True if value1 is greater than or equal to value2 |
| <= | True if value1 is less than or equal to value2 |
| beginswith | True if value1 is a string starting with value2 |
| endswith | True if value1 is a string ending with value2 |
| contains | True if value2 exists in value1 (string, list, dict keys, etc.) |
| type | True if type of value1 matches value2 (e.g., "str", "list", "dict") |
| len / length | True if length of value1 equals value2 |
| isnone | True if value1 is None |
| isnotnone | True if value1 is not None |
| exists | True if value1 (string key) exists in the context dictionary |
| notexists | True if value1 (string key) does not exist in the context dictionary |
Returns: If True, returns the final step result from the "steps". If False, returns the current "result" (last step result).
Like the if step, but also supports elif and else logic.
This step is formatted as a list of dictionaries; configs for if / elif (optional) / else. It's formatted as a list so that multiple elif can be chained.
-
if and elif are formatted same as the if step above.
-
else is expected to simply be a list of steps, optionally nested in a "steps" key.
Refer to the List of valid operators (accordion menu in "if" step, above).
Example usage for if_group
- if_group:
- if:
value1: status
operator: ==
value2: active
steps:
- send_content: "**Status**: Active"
- elif:
value1: status
operator: ==
value2: pending
steps:
- send_content: "**Status**: Pending"
- elif:
value1: status
operator: ==
value2: cancelled
steps:
- send_content: "**Status**: Cancelled"
- else:
- send_content: "**Status**: Unknown"
Returns: Returns the final step result from whichever condition block is executed.
Executes multiple step sequences in parallel, each defined as a list of steps.
Each item in the config is a list of steps (a sub-workflow), which is executed in parallel with others.
Any changes to "context" in each branch will not be reflected instantly, but will be captured/merged into the original context to be available in subsequent steps.
Config: sub-lists of Steps sequences (any Steps)
Returns: A list of results from each parallel sub-sequence
Runs a sub-StepExecutor for each item in a list or each key-value pair in a dict.
Any changes to "context" in this iteration will be captured and available in subsequent steps.
| Options | Option Description |
|---|---|
| in | The list object to be iterated over (A variable saved to context) |
| as | A label to use for dynamic placeholders, based on the current index |
| steps |
list of Steps to be executed. Each value from the in list is the input data for each loop |
Example Usage
response_handling:
# Capture 'images' list as context variable "image_list"
- extract_key: images
save_as: image_list
# Execute a 'for loop' of steps on each value in 'image_list'
- for_each:
in: image_list
as: image
steps:
- decode_base64: true
- save:
file_format: png
file_path: "images"
file_name: "img_{image_index}"
Returns: a list of all the last step results from each loop
Runs a predefined workflow (a sub-StepExecutor), returning the last step result of that workflow.
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| name | string | The name of the workflow to run | |
| input_data | dict | (optional) If not provided, the last step result is passed in. Use null to run without any input. |
<last step result> |
| context | dict | (optional) Pass context into the workflow. "{context}" string would resolve to the full context dict of the current steps execution. |
None |
Returns last step result from the workflow
Releases the executing "Task" from the internal task manager's queue - freeing up a slot for another Task.
This is useful when there are only low-compute, time-consuming steps remaining (uploading files, etc).
Example usage:
- offload: true
Prompts the user for input via Discord message interaction.
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| prompt | string | The message the bot will send to the user | "Please respond." |
| type | string | Valid values: select, text, file
|
|
| timeout | int | How long it should wait to receive the input before cancelling | 60 |
| options | list/dict |
required if type: select. Can be a list of values, or key value pairs (key will be display name), or a list of dicts with {'label': "The Label", 'value': "My value"}, ...
|
Returns
-
if type is "text": string
-
if type is "select": the selected value.
-
if type is "file": dictionary with keys:
-
file_dict(ready to attach to afilepayload) -
bytes(ready for additional processing ex. "save" step) -
file_formatthe file type string (ex: "png") -
filenamethe filename without extension (string) -
Tip: use extract_values to capture the
bytesandfile_format, to use in a save step) -
Tip: Passing the bytes into a
savestep can be useful for further processing (getting a file path to send to an API, etc).
-
{
"file_dict": { # "file_dict" is a value ready to for a "files" payload, to upload to an API
"image": { # 'image' is example value - will be dynamic (string)
"file": file_obj, # io.BytesIO object
"filename": filename, # filename without extension (string)
"content_type": mime_type} # mime type ex: 'image/png' (string)
},
"bytes": <bytes>, # raw bytes
"file_format": "png" # file format
"filename": "my_image" # filename without extension (string)
}
Sends text or files to Discord interaction channel.
Valid value types: string or list of strings
File paths are automatically identified and handled appropriately, and can be absolute (full path) or relative (must be relative to '/output/' or '/user/')
Example usage:
- send_content: '{result}' (the value would be resolved from the last step)
- send_content: Hello world!
- send_content: ['/images/image1.png', '/images/image2.png']
Loads a .json or .yaml or .yml file as a dictionary.
Can be an absolute path or relative to root bot dir (expected to be relative to /user/ subdir).
The file must be in an "allowed path" as configured in config.yaml.
Example usage:
- load_data_file: payloads/comfy_wan-txt2vid.json
Returns dictionary
Saves input data to a file
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| file_format | string | (optional) Explicit format (e.g. 'json', 'jpg'). When not provided, script will try to infer the correct type | |
| file_name | string | (optional) File name to save as (without extension) | |
| file_path | string | (optional) Should be a path relative to /output. Can be a full path (path must be configured as "allowed" in config.yaml) |
|
| use_timestamp | bool | Whether to add a timestamp to the filename | True |
| overwrite | bool | Whether to overwrite an existing file | False |
Returns dictionary
{"file_path": <(string) full file path including extension>,
"file_format": <(string) file format without leading period>,
"file_name": <(string) filename without extension>,
"file_data": <the original or decoded data as applicable}
Does nothing. Can be useful when you simply want to use a meta parameter
Retrieves a nested value from a data structure (dicts and lists) based on a specified path. The path is expressed as a dot/bracket notation string (e.g., "a.b[0].c"), and can optionally return a default value if the path is invalid or inaccessible.
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| path | string | The path to the value expressed as a dot/bracket notation string (ex: "user.name[1]" / "[0].images") |
|
| default | string | (optional) The default value to return if the path is not found. can be a "{context_variable}" |
Returns: Any - The extracted value, or the default value
Example Usage
Scenario:
data = {
"user": {
"name": ["Alice", "Bob"],
"profile": {
"age": 30
}
}
}
Example 1:
path: "user.name[1]"
Returns: "Bob"
Example 2:
path: "user.profile.age"
Returns: 30
Example 3:
path: "user.address"
default: "Unknown"
Returns: "Unknown"
Applies extract_key to build a new dictionary using user-defined key names for the extracted values.
The dictionary can be stored to Context. Each item can then be resolved in future steps using dot/bracket notation.
Example Usage:
- extract_values:
image: data.image
description: data.description
save_as: image_data
log: true
printed in cmd log: 'image_data': {'image': <the image data>, 'description': <the image description>}
The value for 'image' (Saved to context in the 'image_data' dict) can then be resolved into another field like this:
image: "{image_data.image}"
Sets arbitrary key values into the Context dict. This is intended to set values you don't "extract" from another object, etc.
You can set any number of key values in the same step.
Example usage:
- set_context:
lora_weight: 1.0
another_key: "Another value!"
context will now include:
self.context = {
'lora_weight': 1.0,
'another_key': "Another value!"
}
Returns: The last step result
Sets a value within a data structure (dicts/lists) based on a specified path. The path is expressed using the same dot/bracket notation string as extract_key (e.g., "a.b[0].c").
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| path | string | The path to the value expressed as a dot/bracket notation string (ex: "user.name[1]" / "[0].images") |
|
| value | Any | The value to set. |
Returns: The updated data structure (dict or list)
Helpful for passing a specific variable from saved Context as input to the next step.
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| return | string | The name of a context variable (not expressed in dot/bracket notation |
Creates a string or python object depending on usage. Accepts {placeholder syntax} to resolve values into the string (it will "stringify" many python values). It will subsequently try to resolve the string into an object if it is loosely formatted like a python object (dict / list / etc). Does not work with non-JSON serializable objects (bytes, etc) - objects which cannot be converted to strings
Example 1:
self.context = {..., 'my_saved_name': "Robby", ...}
- format: "{name: {my_saved_name}, location: 'Baltimore'}"
Result is python dictionary {'name': "Robby", 'location': "Baltimore"}
Example 2:
format: "[{my_saved_name}, {another_saved_value}]"
Result is a python list
Example 3:
format: "{my_saved_name} is a great friend"
Result is the string "Robby is a great friend"
Returns: The result of this step.
Make a dict, typically from stored variables.
Unlike the format step, you can work with non-JSON serializable objects (bytes, etc).
Example usage:
- dict:
bytes: "{my_saved_image_bytes}"
filename: "{my_saved_filename}"
Returns: The dictionary, with resolved placeholders.
Make a list. Unlike the format step, you can collect non-JSON serializable objects (bytes, etc).
Example usage:
- list:
- "{my_saved_base64_string}"
- "{another_base64_string}"
Returns: The list, with resolved placeholders.
Converts the input data to a specified target type. For "bool": "true", 1, and "yes" will return True otherwise False
Valid types: "int", "float", "str", "bool"
Example usage:
- type: "int" - Would convert the input value to an integer
Like type except it can convert multiple dictionary value types at once.
Example Usage
Example scenario:
data = {"age": "30", "height": "5.8", "name": 123, "active": "yes"}
- cast:
age: "int"
height: "float"
name: "str"
active: "bool"
Output:
{
"age": 30, # converted to int
"height": 5.8, # converted to float
"name": "123", # converted to str
"active": True # converted to bool ("yes" → True)
}
Transforms each element of a list into a dict. The key name can be arbitrary, or set by a dynamic context value:
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| key | string | Defines the key to use in the resulting dictionary |
Example Usage
data = ["apple", "banana", "cherry"]
- map:
as: "dict"
key: "fruit"
Returns: [{"fruit": "apple"}, {"fruit": "banana"}, {"fruit": "cherry"}]
Extracts text from an input string using a regular expression pattern. It returns the first captured group if one exists, or the entire match if not.
Behavior: Uses re.search, which returns the first match anywhere in the string. Safely handles missing matches and avoids exceptions.
Returns: The first capturing group (group(1)) if the pattern contains any capturing groups. Otherwise, the full matched string (group(0)). If no match is found, logs a warning and returns the original data.
Example Usage
Example 1:
data = "Order #12345 received"
- regex: r"#(\d+)"
Returns: "12345" (captures group 1)
Example 2:
data = "Email: [email protected]"
- regex: r"\w+@\w+\.\w+"
Returns: "[email protected]" (no group, returns full match)
Example 3:
data = "Hello world"
- regex: r"ID: (\d+)"
Returns: "Hello world" (no match found, logs warning and returns original data)
(Except for get_payload): For these Steps, any Endpoint Parameters can be included in addition to the inputs defined here, which will override the configured Endpoint behaviors for the Step interaction.
IMPORTANT For non-websocket API calls: Unless config input_data: null, the bot will send the current "result" / defined input.
Gets the base_payload from an API Endpoint.
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| client_name | string | (required) the name of the API client (in all_apis list). client may be used alternatively. |
|
| endpoint_name | string | (required) the name of the Endpoint. endpoint may be used alternatively. |
Returns: The Endpoint's base_payload.
Performs an API call, and returns the result.
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| input_data | Any | (optional) The input value to send to the API. If not specified, the current "Step Result" will be used as input. | <last step result> |
| init_payload | bool | (optional) If True: overrides input_data; fetches the base_payload from the Endpoint; tries resolving internal variables before sending to API |
False |
| client_name | string | (required) the name of the API client (in all_apis list). client may be used alternatively. |
|
| endpoint_name | string | (required) the name of the Endpoint. endpoint may be used alternatively. |
Returns: Result is dependent on the Endpoint configuration / extra API Endpoint parameters included.
Like call_api except that it repeatedly calls the API, collecting each result to a list which is returned after polling is stopped.
Uses same parameters as call_api with a few additions
| Parameter | Value Type | Description | Default |
|---|---|---|---|
All of the parameters for call_api are applicable here, additionally: |
|||
| input_data | Any | (optional) The input value to send to the API. If not specified, the current "Step Result" will be used as input. | <last step result> |
| return_values | dict | A dict where keys are output keys, and values are paths to extract values from the response, using the same mechanism/syntax as extract_key (dot/bracket notation) | |
| interval | float | How frequently (in seconds) to call the API | 1.0 |
| duration | int | If specified, will stop polling after the given timeframe | -1 (not factored) |
| num_yields | int | If specified, will stop polling after the given number of API calls | -1 (not factored) |
Returns: A list of the results from the API calls, dependent on the Endpoint configuration / extra API Endpoint parameters included.
Polls an endpoint while sending a progress Embed to discord.
Like poll_api except specialized for purpose of tracking progress from a previous or concurrent call_api step.
If max_key is specified, progress is interpreted as a step count and normalized as (progress / max). Otherwise, progress is assumed to be a float between 0.0 and 1.0.
Uses same parameters as call_api and poll_api with a few additions
| Parameter | Value Type | Description | Default |
|---|---|---|---|
All of the parameters for call_api and poll_api are applicable here, additionally: |
|||
| input_data | Any | (optional) The input value to send to the API. If not specified, defaults to None
|
None |
| progress_key | string | Uses same mechanism as extract_key (dot/bracket notation) to get the progress value from API response | "progress" |
| max_key | string | (optional) Also uses extract_key. If applicable, should return the maximum value of "progress" | |
| eta_key | string | (optional) Also uses extract_key. If applicable, discord embed will include the ETA value. | |
| message | string | (optional) Message for the discord embed | "Generating" |
| completion_condition | dict | A data structure which must be matched in a response to signify that the progress being tracked is completed. If only the presence of a key is important (not it's value), assign value as "*" (string) | |
| use_ws | bool | Controls whether the polling method is via http or the Client's Websocket (which must be properly configured in Client config) | False |
| type_filter | list of strings | (Websocket only) Message types to be analyzed. Types not in the list are ignored. | ["progress", "executed"] |
| data_filter | dict | (Websocket only) Required key-values in the data field. | None |
Complete Websocket example including a call_api step
- call_api:
api_name: ComfyUI
endpoint_name: Prompt
payload_type: json
input_data:
prompt: "{prompt}"
save_as: prompt_id
- track_progress:
client_name: ComfyUI
progress_key: data.value # Required. dot notation gets the value nested in "data"
max_key: data.max # Optional. If applicable, should return the maximum value of "progress".
eta_key: null # Optional. If applicable, discord embed will include the ETA value.
message: Generating a video # message for the discord embed
completion_condition: # Optional: All key/values must be matched to stop fetching progress
type: executed
data: {prompt_id: "{prompt_id}"}
# websocket exclusive values
use_ws: True
type_filter: [progress, executed] # ignores other message types
data_filter: {prompt_id: "{prompt_id}"} # must '.get()' these key/values
Handles multipart form payloads for uploading to a specified endpoint.
The input_data param can be any of the following:
- full filepath string, or a list of full filepath strings
- bytes (must include a
file_namevalue) - dict containing
file_path, or bytes (asbytesorfile_data) andfile_name - list of dicts (see above)
Accepts same parameters as call_api with a few additions
| Parameter | Value Type | Description | Default |
|---|---|---|---|
All of the parameters for call_api are applicable here, additionally: |
|||
| input_data | Any | (optional) The input value to send to the API. If not specified, the current "Step Result" will be used as input. | <last step result> |
| file_name | string | Required if input_data is bytes or list of bytes |
'file.bin' |
| file_key | string | The key name that the endpoint expects the file to be nested in. ('<key>': '<the file dict>'). |
'file' |
Returns: The response body (one file upload) or a list of response bodies (multiple files uploaded)
Applicable for TGWUI-Integrated installations of this bot
Loads an LLM Model by name. Will raise ValueError if the name is invalid!
Does not accept other model loading arguments. Recommended to pre-configure your model settings as described here
Name 'None' will temporarily unload the current model ('None' string - not actual Nonetype null).
For persistent model unloading, use /llmmodel command.
Example to load a model:
- load_llmmodel: "gemma-3-4b-it-Q4_K_S.gguf"
Example to temporarily unload current model:
- load_llmmodel: "None"
Reduces tediousness and complexity for expected interactions.
Executes the standardized internal workflow for the average "txt2img / img2img" API request. This step may work for other similar endpoints / user cases - if not, use call_api, track_progress, etc.
API client > tracks progress > (optional) save output > returns dictionaries of file data.
To send results to Discord:
- This step can be the last step in a "run_workflow" Tag (the results will be sent at the end of the Task).
- Or, follow it up with a
send_contentstep.
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| client_name | string | (required) the name of the API client (in all_apis list). client may be used alternatively. |
|
| endpoint_name | string | (required) the name of the endpoint. endpoint may be used alternatively. |
|
| input_data | dict | The payload to send. If omitted, the last step result is used. | <last step result> |
| message | string | (optional) The message to print in the progress tracking embed | "Generating" |
| file_path | string | (optional) If provided, will save the output to disk. Path relative to '/outputs' | '' |
Returns: list of file dictionaries which can be passed directly to save_file, or send_content, or returned to caller and bot will send to channel automatically.
File dict contents
- file_obj (IO[bytes]): The file-like object (e.g., BytesIO or open file).
- filename (str): The name of the file (e.g., "image.png")
- mime_type (str): The MIME type of the file (e.g., "image/png")
- file_size (int): The size of the file in bytes.
Posts prompt to a ComfyUI API client > tracks progress > saves outputs > returns output filepath(s).
To send results to Discord:
- This step can be the last step in a "run_workflow" Tag (the results will be sent at the end of the Task).
- Or, follow it up with a
send_contentstep.
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| client_name | string | (required) the name of the API client (in all_apis list). client may be used alternatively. |
|
| input_data | dict | The payload to send to ComfyUI. If omitted, the last step result is used. | <last step result> |
| message | string | (optional) The message to print in the progress tracking embed | "Generating" |
| outputs | list | (optional) List of key names to return output from, such as 'gifs' (same key for videos), etc | ['images'] |
| output_node_ids | list | (optional) List of integers, the node IDs to return outputs from | (all nodes with outputs) |
| completed_node_id | integer | (optional) If provided, will stop and return output as soon as this node has results | None |
| file_path | string | (optional) path relative to '/outputs' | '' |
| unload_models | string | (optional) Unloads all models, before and/or after prompt is executed. Valid: before, after, both
|
None |
| free_memory | string | (optional) Frees up memory(?) before and/or after prompt is executed. Valid: before, after, both
|
None |
| returns | string | (optional) Instead of returning a list of dictionaries, will return a list of values for the specified dict key | 'file_path' |
Returns: list of file paths (by default). This is all the bot needs to send content to discord. Can optionally return list of complete file dictionaries (returns: None), or lists of other data based on the "returns" param.
File dict contents
- file_path: full file path string
- file_format: format without leading period
- file_name: file name including extension
- file_data: original or decoded data when applicable
Use this to unload models and/or "free memory".
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| client_name | string | (required) the name of the API client (in all_apis list). client may be used alternatively. |
|
| unload_models | bool | signals ComfyUI to unload all models | True |
| free_memory | bool | Unsure exactly what gets freed up, otherwise self explanatory | True |
Returns: last step result
Deletes specified nodes from a ComfyUI payload and reroutes/cleans up the references.
| Parameter | Value Type | Description | Default |
|---|---|---|---|
| input_data | dict | The ComfyUI payload. If omitted, the last step result is used. | <last step result> |
| delete_nodes | int or str or list of either | Node(s) to delete, which can be an ID (int or str) or a _meta["title"] string, or a list which can be mixed input types. Ignores Node Class - only use Meta title if referencing by name. | [] |
| delete_until | int or str or list of either | (optional) If provided, the mode will change to a recursive downstream deletion starting at every delete_nodes node, which will persistently delete nodes and reroute connections until encountering a delete_until node (which will NOT be deleted). The logic will branch out from nodes with multiple output connections, so be sure to consider this when defining these stop condition nodes. This method can have unexpected results, especially if any deleted nodes has multiple inputs on a single slot. Recommended to drag-drop one of your output images into ComfyUI to check that node deletions/re-routings were handled as desired!
|
[] |
Returns: the updated payload
Decodes a Base64-encoded string into raw bytes. For convenience, checks for a data URI (e.g., "data:image/png;base64,...") and splits it, using only the part after the comma for decoding.
Returns: bytes