griptape-nodes 0.66.1__py3-none-any.whl → 0.67.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. griptape_nodes/common/node_executor.py +77 -0
  2. griptape_nodes/exe_types/core_types.py +28 -1
  3. griptape_nodes/exe_types/node_groups/base_iterative_node_group.py +27 -8
  4. griptape_nodes/exe_types/node_groups/base_node_group.py +64 -1
  5. griptape_nodes/exe_types/node_groups/subflow_node_group.py +0 -34
  6. griptape_nodes/exe_types/param_components/seed_parameter.py +3 -2
  7. griptape_nodes/exe_types/param_types/parameter_audio.py +3 -0
  8. griptape_nodes/exe_types/param_types/parameter_bool.py +3 -0
  9. griptape_nodes/exe_types/param_types/parameter_button.py +3 -0
  10. griptape_nodes/exe_types/param_types/parameter_dict.py +151 -0
  11. griptape_nodes/exe_types/param_types/parameter_float.py +3 -0
  12. griptape_nodes/exe_types/param_types/parameter_image.py +3 -0
  13. griptape_nodes/exe_types/param_types/parameter_int.py +3 -0
  14. griptape_nodes/exe_types/param_types/parameter_json.py +268 -0
  15. griptape_nodes/exe_types/param_types/parameter_number.py +3 -0
  16. griptape_nodes/exe_types/param_types/parameter_range.py +393 -0
  17. griptape_nodes/exe_types/param_types/parameter_string.py +3 -0
  18. griptape_nodes/exe_types/param_types/parameter_three_d.py +3 -0
  19. griptape_nodes/exe_types/param_types/parameter_video.py +3 -0
  20. griptape_nodes/retained_mode/events/library_events.py +2 -0
  21. griptape_nodes/retained_mode/events/parameter_events.py +89 -1
  22. griptape_nodes/retained_mode/managers/event_manager.py +176 -10
  23. griptape_nodes/retained_mode/managers/library_manager.py +14 -4
  24. griptape_nodes/retained_mode/managers/node_manager.py +187 -7
  25. griptape_nodes/retained_mode/managers/workflow_manager.py +58 -16
  26. griptape_nodes/utils/file_utils.py +58 -0
  27. griptape_nodes/utils/git_utils.py +6 -0
  28. {griptape_nodes-0.66.1.dist-info → griptape_nodes-0.67.0.dist-info}/METADATA +1 -1
  29. {griptape_nodes-0.66.1.dist-info → griptape_nodes-0.67.0.dist-info}/RECORD +31 -28
  30. {griptape_nodes-0.66.1.dist-info → griptape_nodes-0.67.0.dist-info}/WHEEL +1 -1
  31. {griptape_nodes-0.66.1.dist-info → griptape_nodes-0.67.0.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,151 @@
1
+ """ParameterDict component for dictionary inputs with enhanced UI options."""
2
+
3
+ from collections.abc import Callable
4
+ from typing import Any
5
+
6
+ from griptape_nodes.exe_types.core_types import Parameter, ParameterMode, Trait
7
+ from griptape_nodes.utils.dict_utils import to_dict
8
+
9
+
10
+ class ParameterDict(Parameter):
11
+ """A specialized Parameter class for dictionary inputs with enhanced UI options.
12
+
13
+ This class provides a convenient way to create dictionary parameters with common
14
+ UI customizations. It exposes these UI options as direct properties for easy runtime modification.
15
+
16
+ Example:
17
+ param = ParameterDict(
18
+ name="config",
19
+ tooltip="Enter configuration dictionary",
20
+ default_value={}
21
+ )
22
+ param.accept_any = True # Change conversion behavior at runtime
23
+ """
24
+
25
+ def __init__( # noqa: PLR0913
26
+ self,
27
+ name: str,
28
+ tooltip: str | None = None,
29
+ *,
30
+ type: str = "dict", # noqa: A002, ARG002
31
+ input_types: list[str] | None = None, # noqa: ARG002
32
+ output_type: str = "dict", # noqa: ARG002
33
+ default_value: Any = None,
34
+ tooltip_as_input: str | None = None,
35
+ tooltip_as_property: str | None = None,
36
+ tooltip_as_output: str | None = None,
37
+ allowed_modes: set[ParameterMode] | None = None,
38
+ traits: set[type[Trait] | Trait] | None = None,
39
+ converters: list[Callable[[Any], Any]] | None = None,
40
+ validators: list[Callable[[Parameter, Any], None]] | None = None,
41
+ ui_options: dict | None = None,
42
+ accept_any: bool = True,
43
+ hide: bool | None = None,
44
+ hide_label: bool = False,
45
+ hide_property: bool = False,
46
+ allow_input: bool = True,
47
+ allow_property: bool = True,
48
+ allow_output: bool = True,
49
+ settable: bool = True,
50
+ serializable: bool = True,
51
+ user_defined: bool = False,
52
+ private: bool = False,
53
+ element_id: str | None = None,
54
+ element_type: str | None = None,
55
+ parent_container_name: str | None = None,
56
+ ) -> None:
57
+ """Initialize a dictionary parameter with enhanced UI options.
58
+
59
+ Args:
60
+ name: Parameter name
61
+ tooltip: Parameter tooltip
62
+ type: Parameter type (ignored, always "dict" for ParameterDict)
63
+ input_types: Allowed input types (ignored, set based on accept_any)
64
+ output_type: Output type (ignored, always "dict" for ParameterDict)
65
+ default_value: Default parameter value
66
+ tooltip_as_input: Tooltip for input mode
67
+ tooltip_as_property: Tooltip for property mode
68
+ tooltip_as_output: Tooltip for output mode
69
+ allowed_modes: Allowed parameter modes
70
+ traits: Parameter traits
71
+ converters: Parameter converters
72
+ validators: Parameter validators
73
+ ui_options: Dictionary of UI options
74
+ accept_any: Whether to accept any input type and convert to dict (default: True)
75
+ hide: Whether to hide the entire parameter
76
+ hide_label: Whether to hide the parameter label
77
+ hide_property: Whether to hide the parameter in property mode
78
+ allow_input: Whether to allow input mode
79
+ allow_property: Whether to allow property mode
80
+ allow_output: Whether to allow output mode
81
+ settable: Whether the parameter is settable
82
+ serializable: Whether the parameter is serializable
83
+ user_defined: Whether the parameter is user-defined
84
+ private: Whether this parameter is private
85
+ element_id: Element ID
86
+ element_type: Element type
87
+ parent_container_name: Name of parent container
88
+ """
89
+ # Build ui_options dictionary from the provided UI-specific parameters
90
+ if ui_options is None:
91
+ ui_options = {}
92
+ else:
93
+ ui_options = ui_options.copy()
94
+
95
+ # Set up dictionary conversion based on accept_any setting
96
+ if converters is None:
97
+ existing_converters = []
98
+ else:
99
+ existing_converters = converters
100
+
101
+ if accept_any:
102
+ final_input_types = ["any"]
103
+ final_converters = [self._convert_to_dict, *existing_converters]
104
+ else:
105
+ final_input_types = ["dict"]
106
+ final_converters = existing_converters
107
+
108
+ # Call parent with explicit parameters, following ControlParameter pattern
109
+ super().__init__(
110
+ name=name,
111
+ tooltip=tooltip,
112
+ type="dict", # Always a dict type for ParameterDict
113
+ input_types=final_input_types,
114
+ output_type="dict", # Always output as dict
115
+ default_value=default_value,
116
+ tooltip_as_input=tooltip_as_input,
117
+ tooltip_as_property=tooltip_as_property,
118
+ tooltip_as_output=tooltip_as_output,
119
+ allowed_modes=allowed_modes,
120
+ traits=traits,
121
+ converters=final_converters,
122
+ validators=validators,
123
+ ui_options=ui_options,
124
+ hide=hide,
125
+ hide_label=hide_label,
126
+ hide_property=hide_property,
127
+ allow_input=allow_input,
128
+ allow_property=allow_property,
129
+ allow_output=allow_output,
130
+ settable=settable,
131
+ serializable=serializable,
132
+ user_defined=user_defined,
133
+ private=private,
134
+ element_id=element_id,
135
+ element_type=element_type,
136
+ parent_container_name=parent_container_name,
137
+ )
138
+
139
+ def _convert_to_dict(self, value: Any) -> dict:
140
+ """Convert any input value to a dictionary.
141
+
142
+ Uses the to_dict utility function which handles various input types
143
+ including strings, lists, tuples, and other objects.
144
+
145
+ Args:
146
+ value: The value to convert to dictionary
147
+
148
+ Returns:
149
+ Dictionary representation of the value
150
+ """
151
+ return to_dict(value)
@@ -56,6 +56,7 @@ class ParameterFloat(ParameterNumber):
56
56
  settable: bool = True,
57
57
  serializable: bool = True,
58
58
  user_defined: bool = False,
59
+ private: bool = False,
59
60
  element_id: str | None = None,
60
61
  element_type: str | None = None,
61
62
  parent_container_name: str | None = None,
@@ -89,6 +90,7 @@ class ParameterFloat(ParameterNumber):
89
90
  settable: Whether the parameter is settable
90
91
  serializable: Whether the parameter is serializable
91
92
  user_defined: Whether the parameter is user-defined
93
+ private: Whether this parameter is private
92
94
  element_id: Element ID
93
95
  element_type: Element type
94
96
  parent_container_name: Name of parent container
@@ -124,6 +126,7 @@ class ParameterFloat(ParameterNumber):
124
126
  settable=settable,
125
127
  serializable=serializable,
126
128
  user_defined=user_defined,
129
+ private=private,
127
130
  element_id=element_id,
128
131
  element_type=element_type,
129
132
  parent_container_name=parent_container_name,
@@ -55,6 +55,7 @@ class ParameterImage(Parameter):
55
55
  settable: bool = True,
56
56
  serializable: bool = True,
57
57
  user_defined: bool = False,
58
+ private: bool = False,
58
59
  element_id: str | None = None,
59
60
  element_type: str | None = None,
60
61
  parent_container_name: str | None = None,
@@ -90,6 +91,7 @@ class ParameterImage(Parameter):
90
91
  settable: Whether the parameter is settable
91
92
  serializable: Whether the parameter is serializable
92
93
  user_defined: Whether the parameter is user-defined
94
+ private: Whether this parameter is private
93
95
  element_id: Element ID
94
96
  element_type: Element type
95
97
  parent_container_name: Name of parent container
@@ -145,6 +147,7 @@ class ParameterImage(Parameter):
145
147
  settable=settable,
146
148
  serializable=serializable,
147
149
  user_defined=user_defined,
150
+ private=private,
148
151
  element_id=element_id,
149
152
  element_type=element_type,
150
153
  parent_container_name=parent_container_name,
@@ -56,6 +56,7 @@ class ParameterInt(ParameterNumber):
56
56
  settable: bool = True,
57
57
  serializable: bool = True,
58
58
  user_defined: bool = False,
59
+ private: bool = False,
59
60
  element_id: str | None = None,
60
61
  element_type: str | None = None,
61
62
  parent_container_name: str | None = None,
@@ -89,6 +90,7 @@ class ParameterInt(ParameterNumber):
89
90
  settable: Whether the parameter is settable
90
91
  serializable: Whether the parameter is serializable
91
92
  user_defined: Whether the parameter is user-defined
93
+ private: Whether this parameter is private
92
94
  element_id: Element ID
93
95
  element_type: Element type
94
96
  parent_container_name: Name of parent container
@@ -124,6 +126,7 @@ class ParameterInt(ParameterNumber):
124
126
  settable=settable,
125
127
  serializable=serializable,
126
128
  user_defined=user_defined,
129
+ private=private,
127
130
  element_id=element_id,
128
131
  element_type=element_type,
129
132
  parent_container_name=parent_container_name,
@@ -0,0 +1,268 @@
1
+ """ParameterJson component for JSON inputs with enhanced UI options."""
2
+
3
+ from collections.abc import Callable
4
+ from typing import Any
5
+
6
+ from json_repair import repair_json
7
+
8
+ from griptape_nodes.exe_types.core_types import Parameter, ParameterMode, Trait
9
+
10
+
11
+ class ParameterJson(Parameter):
12
+ """A specialized Parameter class for JSON inputs with enhanced UI options.
13
+
14
+ This class provides a convenient way to create JSON parameters with common
15
+ UI customizations. It exposes these UI options as direct properties for easy runtime modification.
16
+
17
+ Example:
18
+ param = ParameterJson(
19
+ name="data",
20
+ tooltip="Enter JSON data",
21
+ default_value={},
22
+ button=True,
23
+ button_label="Load JSON",
24
+ button_icon="refresh"
25
+ )
26
+ param.accept_any = True # Change conversion behavior at runtime
27
+ param.button_label = "Reload" # Change button label at runtime
28
+ param.button_icon = "reload" # Change button icon at runtime
29
+ """
30
+
31
+ def __init__( # noqa: PLR0913
32
+ self,
33
+ name: str,
34
+ tooltip: str | None = None,
35
+ *,
36
+ type: str = "json", # noqa: A002, ARG002
37
+ input_types: list[str] | None = None, # noqa: ARG002
38
+ output_type: str = "json", # noqa: ARG002
39
+ default_value: Any = None,
40
+ tooltip_as_input: str | None = None,
41
+ tooltip_as_property: str | None = None,
42
+ tooltip_as_output: str | None = None,
43
+ allowed_modes: set[ParameterMode] | None = None,
44
+ traits: set[type[Trait] | Trait] | None = None,
45
+ converters: list[Callable[[Any], Any]] | None = None,
46
+ validators: list[Callable[[Parameter, Any], None]] | None = None,
47
+ ui_options: dict | None = None,
48
+ accept_any: bool = True,
49
+ button: bool = False,
50
+ button_label: str | None = "Edit",
51
+ button_icon: str | None = None,
52
+ hide: bool | None = None,
53
+ hide_label: bool = False,
54
+ hide_property: bool = False,
55
+ allow_input: bool = True,
56
+ allow_property: bool = True,
57
+ allow_output: bool = True,
58
+ settable: bool = True,
59
+ serializable: bool = True,
60
+ user_defined: bool = False,
61
+ private: bool = False,
62
+ element_id: str | None = None,
63
+ element_type: str | None = None,
64
+ parent_container_name: str | None = None,
65
+ ) -> None:
66
+ """Initialize a JSON parameter with enhanced UI options.
67
+
68
+ Args:
69
+ name: Parameter name
70
+ tooltip: Parameter tooltip
71
+ type: Parameter type (ignored, always "json" for ParameterJson)
72
+ input_types: Allowed input types (ignored, set based on accept_any)
73
+ output_type: Output type (ignored, always "json" for ParameterJson)
74
+ default_value: Default parameter value
75
+ tooltip_as_input: Tooltip for input mode
76
+ tooltip_as_property: Tooltip for property mode
77
+ tooltip_as_output: Tooltip for output mode
78
+ allowed_modes: Allowed parameter modes
79
+ traits: Parameter traits
80
+ converters: Parameter converters
81
+ validators: Parameter validators
82
+ ui_options: Dictionary of UI options
83
+ accept_any: Whether to accept any input type and convert to JSON (default: True)
84
+ button: Whether to show a button in the UI (default: False)
85
+ button_label: Label text for the button (default: "Edit")
86
+ button_icon: Icon identifier/name for the button (optional)
87
+ hide: Whether to hide the entire parameter
88
+ hide_label: Whether to hide the parameter label
89
+ hide_property: Whether to hide the parameter in property mode
90
+ allow_input: Whether to allow input mode
91
+ allow_property: Whether to allow property mode
92
+ allow_output: Whether to allow output mode
93
+ settable: Whether the parameter is settable
94
+ serializable: Whether the parameter is serializable
95
+ user_defined: Whether the parameter is user-defined
96
+ private: Whether this parameter is private
97
+ element_id: Element ID
98
+ element_type: Element type
99
+ parent_container_name: Name of parent container
100
+ """
101
+ # Build ui_options dictionary from the provided UI-specific parameters
102
+ if ui_options is None:
103
+ ui_options = {}
104
+ else:
105
+ ui_options = ui_options.copy()
106
+
107
+ # Add JSON-specific UI options if they have values
108
+ if button:
109
+ ui_options["button"] = button
110
+ if button_label is not None:
111
+ ui_options["button_label"] = button_label
112
+ if button_icon is not None:
113
+ ui_options["button_icon"] = button_icon
114
+
115
+ # Set up JSON conversion based on accept_any setting
116
+ if converters is None:
117
+ existing_converters = []
118
+ else:
119
+ existing_converters = converters
120
+
121
+ if accept_any:
122
+ final_input_types = ["any"]
123
+ final_converters = [self._convert_to_json, *existing_converters]
124
+ else:
125
+ final_input_types = ["json", "str", "dict"]
126
+ final_converters = existing_converters
127
+
128
+ # Call parent with explicit parameters, following ControlParameter pattern
129
+ super().__init__(
130
+ name=name,
131
+ tooltip=tooltip,
132
+ type="json", # Always a json type for ParameterJson
133
+ input_types=final_input_types,
134
+ output_type="json", # Always output as json
135
+ default_value=default_value,
136
+ tooltip_as_input=tooltip_as_input,
137
+ tooltip_as_property=tooltip_as_property,
138
+ tooltip_as_output=tooltip_as_output,
139
+ allowed_modes=allowed_modes,
140
+ traits=traits,
141
+ converters=final_converters,
142
+ validators=validators,
143
+ ui_options=ui_options,
144
+ hide=hide,
145
+ hide_label=hide_label,
146
+ hide_property=hide_property,
147
+ allow_input=allow_input,
148
+ allow_property=allow_property,
149
+ allow_output=allow_output,
150
+ settable=settable,
151
+ serializable=serializable,
152
+ user_defined=user_defined,
153
+ private=private,
154
+ element_id=element_id,
155
+ element_type=element_type,
156
+ parent_container_name=parent_container_name,
157
+ )
158
+
159
+ def _convert_to_json(self, value: Any) -> dict | list | str | int | float | bool | None:
160
+ """Convert any input value to JSON-compatible format.
161
+
162
+ Uses json_repair for robust handling of malformed JSON strings.
163
+ Handles various input types including strings, dicts, and other objects.
164
+
165
+ Args:
166
+ value: The value to convert to JSON
167
+
168
+ Returns:
169
+ JSON-compatible representation of the value (dict, list, or primitive)
170
+
171
+ Raises:
172
+ ValueError: If the value cannot be converted to JSON
173
+ """
174
+ # Handle None
175
+ if value is None:
176
+ return None
177
+
178
+ # If it's already a dict, use it as is
179
+ if isinstance(value, dict):
180
+ return value
181
+
182
+ # If it's already a list, use it as is
183
+ if isinstance(value, list):
184
+ return value
185
+
186
+ # If it's a string, try to repair and parse it
187
+ if isinstance(value, str):
188
+ try:
189
+ return repair_json(value)
190
+ except Exception as e:
191
+ msg = f"ParameterJson: Failed to repair and parse JSON string: {e}. Input: {value[:200]!r}"
192
+ raise ValueError(msg) from e
193
+
194
+ # For other types, convert to string and try to repair
195
+ try:
196
+ return repair_json(str(value))
197
+ except Exception as e:
198
+ msg = f"ParameterJson: Failed to convert input to JSON: {e}. Input type: {type(value)}, value: {value!r}"
199
+ raise ValueError(msg) from e
200
+
201
+ @property
202
+ def button(self) -> bool:
203
+ """Get whether a button is shown in the UI.
204
+
205
+ Returns:
206
+ True if button is enabled, False otherwise
207
+ """
208
+ return self.ui_options.get("button", False)
209
+
210
+ @button.setter
211
+ def button(self, value: bool) -> None:
212
+ """Set whether a button is shown in the UI.
213
+
214
+ Args:
215
+ value: Whether to show a button
216
+ """
217
+ if value:
218
+ self.update_ui_options_key("button", value)
219
+ else:
220
+ ui_options = self.ui_options.copy()
221
+ ui_options.pop("button", None)
222
+ self.ui_options = ui_options
223
+
224
+ @property
225
+ def button_label(self) -> str | None:
226
+ """Get the label text for the button.
227
+
228
+ Returns:
229
+ The button label if set, None otherwise
230
+ """
231
+ return self.ui_options.get("button_label")
232
+
233
+ @button_label.setter
234
+ def button_label(self, value: str | None) -> None:
235
+ """Set the label text for the button.
236
+
237
+ Args:
238
+ value: The button label to use, or None to remove it
239
+ """
240
+ if value is None:
241
+ ui_options = self.ui_options.copy()
242
+ ui_options.pop("button_label", None)
243
+ self.ui_options = ui_options
244
+ else:
245
+ self.update_ui_options_key("button_label", value)
246
+
247
+ @property
248
+ def button_icon(self) -> str | None:
249
+ """Get the icon identifier/name for the button.
250
+
251
+ Returns:
252
+ The button icon if set, None otherwise
253
+ """
254
+ return self.ui_options.get("button_icon")
255
+
256
+ @button_icon.setter
257
+ def button_icon(self, value: str | None) -> None:
258
+ """Set the icon identifier/name for the button.
259
+
260
+ Args:
261
+ value: The button icon to use, or None to remove it
262
+ """
263
+ if value is None:
264
+ ui_options = self.ui_options.copy()
265
+ ui_options.pop("button_icon", None)
266
+ self.ui_options = ui_options
267
+ else:
268
+ self.update_ui_options_key("button_icon", value)
@@ -50,6 +50,7 @@ class ParameterNumber(Parameter):
50
50
  settable: bool = True,
51
51
  serializable: bool = True,
52
52
  user_defined: bool = False,
53
+ private: bool = False,
53
54
  element_id: str | None = None,
54
55
  element_type: str | None = None,
55
56
  parent_container_name: str | None = None,
@@ -86,6 +87,7 @@ class ParameterNumber(Parameter):
86
87
  settable: Whether the parameter is settable
87
88
  serializable: Whether the parameter is serializable
88
89
  user_defined: Whether the parameter is user-defined
90
+ private: Whether this parameter is private
89
91
  element_id: Element ID
90
92
  element_type: Element type
91
93
  parent_container_name: Name of parent container
@@ -154,6 +156,7 @@ class ParameterNumber(Parameter):
154
156
  settable=settable,
155
157
  serializable=serializable,
156
158
  user_defined=user_defined,
159
+ private=private,
157
160
  element_id=element_id,
158
161
  element_type=element_type,
159
162
  parent_container_name=parent_container_name,