From 6ab07d7ca345f1428e688c8891143c0a0b82ed50 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 1 Mar 2024 08:06:48 -0300 Subject: [PATCH] Update ShouldRunNext and GenericNode components --- .../langflow/components/utilities/ShouldRunNext.py | 9 ++------- src/frontend/src/CustomNodes/GenericNode/index.tsx | 10 +++++----- src/frontend/src/types/api/index.ts | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/backend/langflow/components/utilities/ShouldRunNext.py b/src/backend/langflow/components/utilities/ShouldRunNext.py index 5270e4d34..8b2350cfb 100644 --- a/src/backend/langflow/components/utilities/ShouldRunNext.py +++ b/src/backend/langflow/components/utilities/ShouldRunNext.py @@ -11,6 +11,7 @@ from langflow.schema import Decision class ShouldRunNext(CustomComponent): display_name = "Should Run Next" description = "Decides whether to run the next component." + conditional_paths = ["True"] def build_config(self): return { @@ -43,13 +44,7 @@ class ShouldRunNext(CustomComponent): else: result = result.get("response") - if result.lower() not in ["true", "false"]: - raise ValueError( - "The prompt should generate a boolean response (True or False)." - ) - # The string should be the words true or false - # if not raise an error - if result.lower() not in ["true", "false"]: + if result.lower() not in self.conditional_paths: raise ValueError( "The prompt should generate a boolean response (True or False)." ) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index bb343a147..d52908953 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -716,13 +716,13 @@ export default function GenericNode({
{data.node!.base_classes.length > 0 && - // if conditionalPaths in data.node.conditionalPaths + // if conditional_paths in data.node.conditional_paths // then buildParameterComponent for each conditionalPath // else buildParameterComponent for each data.node.base_classes - // first we check - data.node!.conditionalPaths && - data.node!.conditionalPaths.length > 1 - ? data.node!.conditionalPaths.map((conditionalPath) => + // first we check if there are any conditional paths + data.node!.conditional_paths && + data.node!.conditional_paths.length > 0 + ? data.node!.conditional_paths.map((conditionalPath) => buildParameterComponent({ data, conditionalPath, diff --git a/src/frontend/src/types/api/index.ts b/src/frontend/src/types/api/index.ts index d2735e7ed..3423a84c9 100644 --- a/src/frontend/src/types/api/index.ts +++ b/src/frontend/src/types/api/index.ts @@ -20,7 +20,7 @@ export type APIClassType = { icon?: string; is_input?: boolean; is_output?: boolean; - conditionalPaths?: Array; + conditional_paths?: Array; input_types?: Array; output_types?: Array; custom_fields?: CustomFieldsType;