Skip to content

Commit

Permalink
feat: skip note nodes when building vertices"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ogabrielluiz committed Aug 23, 2024
1 parent 672fa7f commit 8109494
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/backend/base/langflow/graph/graph/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions src/backend/base/langflow/graph/vertex/schema.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,3 +24,4 @@ class NodeData(TypedDict):
positionAbsolute: NotRequired[Position]
selected: NotRequired[bool]
parent_node_id: NotRequired[str]
type: NotRequired[NodeTypeEnum]

0 comments on commit 8109494

Please sign in to comment.