Skip to content

draw mermaid wrong when node name is Chinese text #6036

@Ovi3

Description

@Ovi3

Checked other resources

  • This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

from langgraph.graph import MessagesState, StateGraph

def node_1(state):
    return {"a": 1}

def node_2(state):
    return {"b": 2}

# 添加节点
builder = StateGraph(MessagesState)
builder.add_node("开始", node_1)
builder.add_node("结束", node_2)

# 设置流程
builder.set_entry_point("开始")
builder.add_edge("开始", "结束")
builder.set_finish_point("结束")

# 编译图
graph = builder.compile()

print(graph.get_graph().draw_mermaid())

Error Message and Stack Trace (if applicable)

Description

When node names are Chinese text and Chinese text length is the same, mermaid image is wrong:

Image

the reason I saw is: It replace Chinese text to "__" (one Chinese char, one _ symbol)

System Info

langgraph==0.6.6

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpendingawaiting review/confirmation by maintainer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions