diff --git a/src/backend/langflow/interface/custom/custom_component/component.py b/src/backend/langflow/interface/custom/custom_component/component.py index b5e568333..bc8b5d31e 100644 --- a/src/backend/langflow/interface/custom/custom_component/component.py +++ b/src/backend/langflow/interface/custom/custom_component/component.py @@ -20,7 +20,9 @@ class ComponentFunctionEntrypointNameNullError(HTTPException): class Component: ERROR_CODE_NULL: ClassVar[str] = "Python code must be provided." - ERROR_FUNCTION_ENTRYPOINT_NAME_NULL: ClassVar[str] = "The name of the entrypoint function must be provided." + ERROR_FUNCTION_ENTRYPOINT_NAME_NULL: ClassVar[str] = ( + "The name of the entrypoint function must be provided." + ) code: Optional[str] = None _function_entrypoint_name: str = "build" @@ -67,6 +69,10 @@ class Component: return str(value) if value else "" + def getattr_return_bool(self, value): + if isinstance(value, bool): + return value + def build_template_config(self) -> dict: if not self.code: return {} @@ -80,6 +86,7 @@ class Component: "beta": self.getattr_return_str, "documentation": self.getattr_return_str, "icon": self.validate_icon, + "is_composition": self.getattr_return_bool, } for attribute, func in attributes_func_mapping.items(): diff --git a/src/backend/langflow/interface/custom/custom_component/custom_component.py b/src/backend/langflow/interface/custom/custom_component/custom_component.py index 8a5d72073..52f7e7be4 100644 --- a/src/backend/langflow/interface/custom/custom_component/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component/custom_component.py @@ -35,6 +35,9 @@ class CustomComponent(Component): """The field configuration of the component. Defaults to an empty dictionary.""" field_order: Optional[List[str]] = None """The field order of the component. Defaults to an empty list.""" + is_composition: Optional[bool] = None + """Whether the component is used for composition. + This affects the style of the edge connecting the component to the next component. Defaults to None.""" code_class_base_inheritance: ClassVar[str] = "CustomComponent" function_entrypoint_name: ClassVar[str] = "build" function: Optional[Callable] = None diff --git a/src/backend/langflow/interface/custom/utils.py b/src/backend/langflow/interface/custom/utils.py index ce15768e1..5e1e9932e 100644 --- a/src/backend/langflow/interface/custom/utils.py +++ b/src/backend/langflow/interface/custom/utils.py @@ -270,6 +270,7 @@ def sanitize_template_config(template_config): "documentation", "output_types", "icon", + "is_composition", } for key in template_config.copy(): if key not in attributes: