Make lazy status for specific inputs on DynamicInputs work by having the values of the dictionary for check_lazy_status be a tuple, where the second element is the key of the input that can be returned

This commit is contained in:
Jedrzej Kosinski 2025-12-18 16:20:28 -08:00
parent bef33564c1
commit dd4786bcf8
2 changed files with 14 additions and 2 deletions

View File

@ -1131,7 +1131,11 @@ if len(DYNAMIC_INPUT_LOOKUP) == 0:
class V3Data(TypedDict): class V3Data(TypedDict):
hidden_inputs: dict[str, Any] hidden_inputs: dict[str, Any]
'Dictionary where the keys are the hidden input ids and the values are the values of the hidden inputs.'
dynamic_paths: dict[str, Any] dynamic_paths: dict[str, Any]
'Dictionary where the keys are the input ids and the values dictate how to turn the inputs into a nested dictionary.'
create_dynamic_tuple: bool
'When True, the value of the dynamic input will be in the format (value, path_key).'
class HiddenHolder: class HiddenHolder:
def __init__(self, unique_id: str, prompt: Any, def __init__(self, unique_id: str, prompt: Any,
@ -1468,6 +1472,8 @@ def build_nested_inputs(values: dict[str, Any], v3_data: V3Data):
values = values.copy() values = values.copy()
result = {} result = {}
create_tuple = v3_data.get("create_dynamic_tuple", False)
for key, path in paths.items(): for key, path in paths.items():
parts = path.split(".") parts = path.split(".")
current = result current = result
@ -1476,7 +1482,10 @@ def build_nested_inputs(values: dict[str, Any], v3_data: V3Data):
is_last = (i == len(parts) - 1) is_last = (i == len(parts) - 1)
if is_last: if is_last:
current[p] = values.pop(key, None) value = values.pop(key, None)
if create_tuple:
value = (value, key)
current[p] = value
else: else:
current = current.setdefault(p, {}) current = current.setdefault(p, {})

View File

@ -480,7 +480,10 @@ async def execute(server, dynprompt, caches, current_item, extra_data, executed,
else: else:
lazy_status_present = getattr(obj, "check_lazy_status", None) is not None lazy_status_present = getattr(obj, "check_lazy_status", None) is not None
if lazy_status_present: if lazy_status_present:
required_inputs = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, "check_lazy_status", allow_interrupt=True, v3_data=v3_data) # for check_lazy_status, the returned data should include the original key of the input
v3_data_lazy = v3_data.copy()
v3_data_lazy["create_dynamic_tuple"] = True
required_inputs = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, "check_lazy_status", allow_interrupt=True, v3_data=v3_data_lazy)
required_inputs = await resolve_map_node_over_list_results(required_inputs) required_inputs = await resolve_map_node_over_list_results(required_inputs)
required_inputs = set(sum([r for r in required_inputs if isinstance(r,list)], [])) required_inputs = set(sum([r for r in required_inputs if isinstance(r,list)], []))
required_inputs = [x for x in required_inputs if isinstance(x,str) and ( required_inputs = [x for x in required_inputs if isinstance(x,str) and (