Skip to content

The agent engineering platform.

core: allow mermaid node labels to have any characters (#21385)

Nuno Camposad0f3c14c280
diff --git a/libs/core/langchain_core/runnables/graph_mermaid.py b/libs/core/langchain_core/runnables/graph_mermaid.py
index 69a2d84562..b99c90f9a7 100644
--- a/libs/core/langchain_core/runnables/graph_mermaid.py
+++ b/libs/core/langchain_core/runnables/graph_mermaid.py
@@ -57,7 +57,7 @@ def draw_mermaid(
# Add nodes to the graph
for node in nodes.values():
node_label = format_dict.get(node, format_dict[default_class_label]).format(
- _escape_node_label(node), _escape_node_label(node.split(":", 1)[-1])
+ _escape_node_label(node), node.split(":", 1)[-1]
)
mermaid_graph += f"\t{node_label};\n"
diff --git a/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr b/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr
index f715157c5b..85d0e00cb8 100644
--- a/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr
+++ b/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr
@@ -122,7 +122,7 @@
PromptInput[PromptInput]:::startclass;
PromptTemplate([PromptTemplate]):::otherclass;
FakeListLLM([FakeListLLM]):::otherclass;
- Parallel_as_list_as_str_Input([Parallel_as_list_as_str_Input]):::otherclass;
+ Parallel_as_list_as_str_Input([Parallel<as_list,as_str>Input]):::otherclass;
Parallel_as_list_as_str_Output[Parallel_as_list_as_str_Output]:::endclass;
CommaSeparatedListOutputParser([CommaSeparatedListOutputParser]):::otherclass;
conditional_str_parser_input([conditional_str_parser_input]):::otherclass;