diff --git a/CHANGELOG.md b/CHANGELOG.md index 34b7121..74b9084 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated ### Removed ### Fixed -### Security --> +### Security --> + +## [2.1.04] - 2025-04-01 +### Added +- `Griptape Util: Switch Node` - This node lets you choose an output from multiple inputs. + + ![switch node](docs/images/switch_node.png) ## [2.1.03] - 2025-03-01 ### Fixed diff --git a/__init__.py b/__init__.py index f1e6332..08649a6 100644 --- a/__init__.py +++ b/__init__.py @@ -292,6 +292,7 @@ from .nodes.tools.gtUIWebSearch import gtUIWebSearch from .nodes.utils.gtUICreateAgentModelfile import gtUICreateAgentModelfile from .nodes.utils.gtUICreateModelFromModelfile import gtUICreateModelFromModelfile from .nodes.utils.gtUIRemoveOllamaModel import gtUIRemoveOllamaModel +from .nodes.utils.gtUISwitchNode import gtUISwitchNode # Load existing environment variables load_dotenv() @@ -420,6 +421,7 @@ NODE_CLASS_MAPPINGS = { "Griptape Util: Create Agent Modelfile": gtUICreateAgentModelfile, "Griptape Util: Create Model from Modelfile": gtUICreateModelFromModelfile, "Griptape Util: Remove Ollama Model": gtUIRemoveOllamaModel, + "Griptape Util: Switch Node": gtUISwitchNode, # DISPLAY "Griptape Display: Image": gtUIOutputImageNode, "Griptape Display: Text": gtUIOutputStringNode, diff --git a/docs/images/switch_node.png b/docs/images/switch_node.png new file mode 100644 index 0000000..08274ee Binary files /dev/null and b/docs/images/switch_node.png differ diff --git a/js/CombineNodes.js b/js/CombineNodes.js index 9d9f5b0..d5da5ec 100644 --- a/js/CombineNodes.js +++ b/js/CombineNodes.js @@ -4,6 +4,7 @@ export function setupCombineNodes(nodeType, nodeData, app) { nodeData.name === "Griptape Combine: Rules List" || nodeData.name === "Griptape Combine: Tool List" || nodeData.name === "Griptape Combine: RAG Module List" || + nodeData.name === "Griptape Util: Switch Node" || nodeData.name === "Griptape Create: Pipeline") { setupCombineNode(nodeType, nodeData, app); diff --git a/nodes/utils/gtUISwitchNode.py b/nodes/utils/gtUISwitchNode.py new file mode 100644 index 0000000..0c5e79a --- /dev/null +++ b/nodes/utils/gtUISwitchNode.py @@ -0,0 +1,53 @@ +class AnyType(str): + def __ne__(self, __value: object) -> bool: + return False + + +any = AnyType("*") + + +class gtUISwitchNode: + """ + Takes any inputs and gives the user the ability to choose which one will be the output. + """ + + DESCRIPTION = "Takes any inputs and gives the user the ability to choose which one will be the output." + + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": {}, + "optional": { + "input_1": ( + any, + { + "tooltip": "An input to choose. Connect an input to dynamically create more inputs." + }, + ), + "switch": ( + "INT", + { + "default": 1, + "tooltip": "The input to choose.", + }, + ), + }, + } + + RETURN_TYPES = (any,) + RETURN_NAMES = ("OUTPUT",) + FUNCTION = "create" + + CATEGORY = "Griptape/Agent Utils" + + def create( + self, + **kwargs, + ): + switch = kwargs.pop("switch") + inputs = [value for value in kwargs.values()] + output = inputs[switch - 1] + return (output,) diff --git a/pyproject.toml b/pyproject.toml index e5258a3..89df733 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "comfyui-griptape" -version = "2.1.03" +version = "2.1.04" description = "Griptape LLM(Large Language Model) Nodes for ComfyUI." authors = ["Jason Schleifer "] readme = "README.md" @@ -9,7 +9,7 @@ readme = "README.md" [project] name = "comfyui-griptape" description = "Griptape LLM(Large Language Model) Nodes for ComfyUI." -version = "2.1.03" +version = "2.1.04" license = {file = "LICENSE"} dependencies = ["attrs==^24.3.0", "openai==^1.58.1", "griptape[all]==^1.1.0", "python-dotenv", "poetry==1.8.5", "griptape-black-forest @ git+https://github.com/griptape-ai/griptape-black-forest.git"]