diff --git a/libs/core/langchain_core/runnables/graph.py b/libs/core/langchain_core/runnables/graph.py index 77137d0a86b..557a2028c38 100644 --- a/libs/core/langchain_core/runnables/graph.py +++ b/libs/core/langchain_core/runnables/graph.py @@ -263,4 +263,17 @@ class Graph: ) -> Union[bytes, None]: from langchain_core.runnables.graph_png import PngDrawer - return PngDrawer(fontname, labels).draw(self, output_file_path) + default_node_labels = { + node.id: node_data_str(node) for node in self.nodes.values() + } + + return PngDrawer( + fontname, + LabelsDict( + nodes={ + **default_node_labels, + **(labels["nodes"] if labels is not None else {}), + }, + edges=labels["edges"] if labels is not None else {}, + ), + ).draw(self, output_file_path)