From 8109494e52f61ee71053ab3e62149b53cc138f79 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 23 Aug 2024 10:29:32 -0300 Subject: [PATCH] feat: skip note nodes when building vertices" add check to skip nodes of type NoteNode when building vertices in the graph this prevents unnecessary processing of note nodes which are not part of the actual graph logic --- src/backend/base/langflow/graph/graph/base.py | 4 +++- src/backend/base/langflow/graph/vertex/schema.py | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/backend/base/langflow/graph/graph/base.py b/src/backend/base/langflow/graph/graph/base.py index 20f74d41b971..db55b1009e76 100644 --- a/src/backend/base/langflow/graph/graph/base.py +++ b/src/backend/base/langflow/graph/graph/base.py @@ -23,7 +23,7 @@ from langflow.graph.graph.utils import find_start_component_id, process_flow, should_continue, sort_up_to_vertex from langflow.graph.schema import InterfaceComponentTypes, RunOutputs from langflow.graph.vertex.base import Vertex, VertexStates -from langflow.graph.vertex.schema import NodeData +from langflow.graph.vertex.schema import NodeData, NodeTypeEnum from langflow.graph.vertex.types import ComponentVertex, InterfaceVertex, StateVertex from langflow.logging.logger import LogConfig, configure from langflow.schema import Data @@ -1583,6 +1583,8 @@ def _build_vertices(self) -> List["Vertex"]: """Builds the vertices of the graph.""" vertices: List["Vertex"] = [] for frontend_data in self._vertices: + if frontend_data.get("type") == NodeTypeEnum.NoteNode: + continue try: vertex_instance = self.get_vertex(frontend_data["id"]) except ValueError: diff --git a/src/backend/base/langflow/graph/vertex/schema.py b/src/backend/base/langflow/graph/vertex/schema.py index f7ffd32b689f..45d9e4808b41 100644 --- a/src/backend/base/langflow/graph/vertex/schema.py +++ b/src/backend/base/langflow/graph/vertex/schema.py @@ -1,8 +1,14 @@ +from enum import Enum from typing import Dict from typing_extensions import NotRequired, TypedDict +class NodeTypeEnum(str, Enum): + NoteNode = "noteNode" + GenericNode = "genericNode" + + class Position(TypedDict): x: float y: float @@ -18,3 +24,4 @@ class NodeData(TypedDict): positionAbsolute: NotRequired[Position] selected: NotRequired[bool] parent_node_id: NotRequired[str] + type: NotRequired[NodeTypeEnum]