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): class ShouldRunNext(CustomComponent):
display_name = "Should Run Next" display_name = "Should Run Next"
description = "Decides whether to run the next component." description = "Decides whether to run the next component."
conditional_paths = ["True"]
def build_config(self): def build_config(self):
return { return {
@ -43,13 +44,7 @@ class ShouldRunNext(CustomComponent):
else: else:
result = result.get("response") result = result.get("response")
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)."
)
# The string should be the words true or false
# if not raise an error
if result.lower() not in ["true", "false"]:
raise ValueError( raise ValueError(
"The prompt should generate a boolean response (True or False)." "The prompt should generate a boolean response (True or False)."
) )

View file

@ -716,13 +716,13 @@ export default function GenericNode({
</div> </div>
<div> <div>
{data.node!.base_classes.length > 0 && {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 // then buildParameterComponent for each conditionalPath
// else buildParameterComponent for each data.node.base_classes // else buildParameterComponent for each data.node.base_classes
// first we check // first we check if there are any conditional paths
data.node!.conditionalPaths && data.node!.conditional_paths &&
data.node!.conditionalPaths.length > 1 data.node!.conditional_paths.length > 0
? data.node!.conditionalPaths.map((conditionalPath) => ? data.node!.conditional_paths.map((conditionalPath) =>
buildParameterComponent({ buildParameterComponent({
data, data,
conditionalPath, conditionalPath,

View file

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