🐛 fix(base.py): rename _remove_invalid_nodes() to _validate_nodes() for clarity and accuracy
🔥 chore(base.py): remove unnecessary check for single node and no edges in _validate_nodes() 🔥 chore(base.py): remove unused import statement 🔥 chore(base.py): remove unused _validate_node() method 🔥 chore(base.py): remove unused import statement
This commit is contained in:
parent
f2724f1116
commit
38da096245
1 changed files with 8 additions and 9 deletions
|
|
@ -60,7 +60,7 @@ class Graph:
|
|||
# the toolkit node
|
||||
self._build_node_params()
|
||||
# remove invalid nodes
|
||||
self._remove_invalid_nodes()
|
||||
self._validate_nodes()
|
||||
|
||||
def _build_node_params(self) -> None:
|
||||
"""Identifies and handles the LLM node within the graph."""
|
||||
|
|
@ -75,14 +75,13 @@ class Graph:
|
|||
if isinstance(node, ToolkitVertex):
|
||||
node.params["llm"] = llm_node
|
||||
|
||||
def _remove_invalid_nodes(self) -> None:
|
||||
"""Removes invalid nodes from the graph."""
|
||||
self.nodes = [
|
||||
node
|
||||
for node in self.nodes
|
||||
if self._validate_node(node)
|
||||
or (len(self.nodes) == 1 and len(self.edges) == 0)
|
||||
]
|
||||
def _validate_nodes(self) -> None:
|
||||
"""Check that all nodes have edges"""
|
||||
for node in self.nodes:
|
||||
if not self._validate_node(node):
|
||||
raise ValueError(
|
||||
f"{node.vertex_type} is not connected to any other components"
|
||||
)
|
||||
|
||||
def _validate_node(self, node: Vertex) -> bool:
|
||||
"""Validates a node."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue