Update ShouldRunNext and GenericNode components

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-01 08:06:48 -03:00
commit 6ab07d7ca3
3 changed files with 8 additions and 13 deletions

View file

@ -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)."
)

View file

@ -716,13 +716,13 @@ export default function GenericNode({
</div>
<div>
{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,

View file

@ -20,7 +20,7 @@ export type APIClassType = {
icon?: string;
is_input?: boolean;
is_output?: boolean;
conditionalPaths?: Array<string>;
conditional_paths?: Array<string>;
input_types?: Array<string>;
output_types?: Array<string>;
custom_fields?: CustomFieldsType;