MCPcopy
hub / github.com/langchain-ai/langchain / add_node

Method add_node

libs/core/langchain_core/runnables/graph.py:239–247  ·  view source on GitHub ↗

Add a node to the graph and return it.

(
        self, data: Union[Type[BaseModel], RunnableType], id: Optional[str] = None
    )

Source from the content-addressed store, hash-verified

237 return uuid4().hex
238
239 def add_node(
240 self, data: Union[Type[BaseModel], RunnableType], id: Optional[str] = None
241 ) -> Node:
242 """Add a node to the graph and return it."""
243 if id is not None and id in self.nodes:
244 raise ValueError(f"Node with id {id} already exists")
245 node = Node(id=id or self.next_id(), data=data)
246 self.nodes[node.id] = node
247 return node
248
249 def remove_node(self, node: Node) -> None:
250 """Remove a node from the graphm and all edges connected to it."""

Callers 4

get_graphMethod · 0.95
get_graphMethod · 0.95
get_graphMethod · 0.95
get_graphMethod · 0.45

Calls 2

next_idMethod · 0.95
NodeClass · 0.70

Tested by

no test coverage detected