draw_mermaid_png() — langchain Function Reference
Architecture documentation for the draw_mermaid_png() function in graph.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD e151d2f1_d848_ea86_47fa_455730afbb7a["draw_mermaid_png()"] 646f3bb5_a594_563e_cfbf_e18bdc9efb90["Graph"] e151d2f1_d848_ea86_47fa_455730afbb7a -->|defined in| 646f3bb5_a594_563e_cfbf_e18bdc9efb90 b9f04a0f_6507_1a21_7a91_357a589c2c3a["draw_mermaid()"] e151d2f1_d848_ea86_47fa_455730afbb7a -->|calls| b9f04a0f_6507_1a21_7a91_357a589c2c3a style e151d2f1_d848_ea86_47fa_455730afbb7a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/runnables/graph.py lines 630–703
def draw_mermaid_png(
self,
*,
curve_style: CurveStyle = CurveStyle.LINEAR,
node_colors: NodeStyles | None = None,
wrap_label_n_words: int = 9,
output_file_path: str | None = None,
draw_method: MermaidDrawMethod = MermaidDrawMethod.API,
background_color: str = "white",
padding: int = 10,
max_retries: int = 1,
retry_delay: float = 1.0,
frontmatter_config: dict[str, Any] | None = None,
base_url: str | None = None,
proxies: dict[str, str] | None = None,
) -> bytes:
"""Draw the graph as a PNG image using Mermaid.
Args:
curve_style: The style of the edges.
node_colors: The colors of the nodes.
wrap_label_n_words: The number of words to wrap the node labels at.
output_file_path: The path to save the image to. If `None`, the image
is not saved.
draw_method: The method to use to draw the graph.
background_color: The color of the background.
padding: The padding around the graph.
max_retries: The maximum number of retries (`MermaidDrawMethod.API`).
retry_delay: The delay between retries (`MermaidDrawMethod.API`).
frontmatter_config: Mermaid frontmatter config.
Can be used to customize theme and styles. Will be converted to YAML and
added to the beginning of the mermaid graph.
See more here: https://mermaid.js.org/config/configuration.html.
Example config:
```python
{
"config": {
"theme": "neutral",
"look": "handDrawn",
"themeVariables": {"primaryColor": "#e2e2e2"},
}
}
```
base_url: The base URL of the Mermaid server for rendering via API.
proxies: HTTP/HTTPS proxies for requests (e.g. `{"http": "http://127.0.0.1:7890"}`).
Returns:
The PNG image as bytes.
"""
# Import locally to prevent circular import
from langchain_core.runnables.graph_mermaid import ( # noqa: PLC0415
draw_mermaid_png,
)
mermaid_syntax = self.draw_mermaid(
curve_style=curve_style,
node_colors=node_colors,
wrap_label_n_words=wrap_label_n_words,
frontmatter_config=frontmatter_config,
)
return draw_mermaid_png(
mermaid_syntax=mermaid_syntax,
output_file_path=output_file_path,
draw_method=draw_method,
background_color=background_color,
padding=padding,
max_retries=max_retries,
retry_delay=retry_delay,
proxies=proxies,
base_url=base_url,
)
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does draw_mermaid_png() do?
draw_mermaid_png() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/graph.py.
Where is draw_mermaid_png() defined?
draw_mermaid_png() is defined in libs/core/langchain_core/runnables/graph.py at line 630.
What does draw_mermaid_png() call?
draw_mermaid_png() calls 1 function(s): draw_mermaid.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free