diff --git a/src/backend/langflow/interface/custom/custom_component.py b/src/backend/langflow/interface/custom/custom_component.py index 79ca64bdc..1cc0ca620 100644 --- a/src/backend/langflow/interface/custom/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component.py @@ -147,10 +147,10 @@ class CustomComponent(Component, extra=Extra.allow): raise ValueError(f"Flow {flow_id} not found") return build_sorted_vertices_with_caching(data_graph) - def list_flow_names(self): + def list_flows(self): with session_getter() as session: flows = session.query(Flow).all() - return [flow.name for flow in flows] + return flows def build(self): raise NotImplementedError diff --git a/src/backend/langflow/interface/types.py b/src/backend/langflow/interface/types.py index ea85013fd..6f7a43f38 100644 --- a/src/backend/langflow/interface/types.py +++ b/src/backend/langflow/interface/types.py @@ -18,9 +18,8 @@ from langflow.interface.custom.base import custom_component_creator from langflow.interface.custom.custom_component import CustomComponent from langflow.template.field.base import TemplateField -from langflow.template.frontend_node.tools import ( - CustomComponentNode, - CustomComponentEmptyNode, +from langflow.template.frontend_node.custom_components import ( + CustomComponentFrontendNode, ) from langflow.interface.retrievers.base import retriever_creator @@ -165,7 +164,9 @@ def extract_type_from_optional(field_type): def build_langchain_template_custom_component(custom_component: CustomComponent): # Build base "CustomComponent" template - frontend_node = CustomComponentNode().to_dict().get(type(custom_component).__name__) + frontend_node = ( + CustomComponentFrontendNode().to_dict().get(type(custom_component).__name__) + ) function_args = custom_component.get_function_entrypoint_args return_type = custom_component.get_function_entrypoint_return_type diff --git a/src/backend/langflow/template/frontend_node/base.py b/src/backend/langflow/template/frontend_node/base.py index d6d9f911a..dcd9a58a0 100644 --- a/src/backend/langflow/template/frontend_node/base.py +++ b/src/backend/langflow/template/frontend_node/base.py @@ -52,6 +52,7 @@ class FrontendNode(BaseModel): custom_fields: defaultdict = defaultdict(list) output_types: List[str] = [] field_formatters: FieldFormatters = Field(default_factory=FieldFormatters) + beta: bool = False # field formatters is an instance attribute but it is not used in the class # so we need to create a method to get it @@ -83,6 +84,7 @@ class FrontendNode(BaseModel): "custom_fields": self.custom_fields, "output_types": self.output_types, "documentation": self.documentation, + "beta": self.beta, }, } diff --git a/src/backend/langflow/template/frontend_node/custom_components.py b/src/backend/langflow/template/frontend_node/custom_components.py index 8a3474d24..4f36a1c9f 100644 --- a/src/backend/langflow/template/frontend_node/custom_components.py +++ b/src/backend/langflow/template/frontend_node/custom_components.py @@ -7,6 +7,7 @@ from langflow.interface.custom.constants import DEFAULT_CUSTOM_COMPONENT_CODE class CustomComponentFrontendNode(FrontendNode): name: str = "CustomComponent" display_name: str = "Custom Component" + beta: bool = True template: Template = Template( type_name="CustomComponent", fields=[ diff --git a/src/backend/langflow/template/frontend_node/tools.py b/src/backend/langflow/template/frontend_node/tools.py index c7ed716c1..66f0eae3a 100644 --- a/src/backend/langflow/template/frontend_node/tools.py +++ b/src/backend/langflow/template/frontend_node/tools.py @@ -1,4 +1,3 @@ -from langflow.interface.custom.constants import DEFAULT_CUSTOM_COMPONENT_CODE from langflow.template.field.base import TemplateField from langflow.template.frontend_node.base import FrontendNode from langflow.template.template.base import Template @@ -141,53 +140,3 @@ class PythonFunctionNode(FrontendNode): def to_dict(self): return super().to_dict() - - -class CustomComponentNode(FrontendNode): - name: str = "CustomComponent" - template: Template = Template( - type_name="CustomComponent", - fields=[ - TemplateField( - field_type="code", - required=True, - placeholder="", - is_list=False, - show=True, - value=DEFAULT_CUSTOM_COMPONENT_CODE, - name="code", - advanced=False, - dynamic=True, - ) - ], - ) - description: str = "Dynamic Python code to be executed." - base_classes: list[str] = [] - - def to_dict(self): - return super().to_dict() - - -class CustomComponentEmptyNode(FrontendNode): - name: str = "CustomComponent" - template: Template = Template( - type_name="CustomComponent", - fields=[ - TemplateField( - field_type="code", - required=True, - placeholder="", - is_list=False, - show=True, - value="", - name="code", - advanced=False, - dynamic=True, - ) - ], - ) - description: str = "Dynamic Python code to be executed." - base_classes: list[str] = [] - - def to_dict(self): - return super().to_dict() diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 9c933dcf7..95fd70a7e 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -95,6 +95,11 @@ export default function GenericNode({ "generic-node-div" )} > + {data.node.beta && ( +