draw_mermaid_png#

langchain_core.runnables.graph_mermaid.draw_mermaid_png(
mermaid_syntax: str,
output_file_path: str | None = None,
draw_method: MermaidDrawMethod = MermaidDrawMethod.API,
background_color: str | None = 'white',
padding: int = 10,
max_retries: int = 1,
retry_delay: float = 1.0,
) β†’ bytes[source]#

Draws a Mermaid graph as PNG using provided syntax.

Parameters:
  • mermaid_syntax (str) – Mermaid graph syntax.

  • output_file_path (str, optional) – Path to save the PNG image. Defaults to None.

  • draw_method (MermaidDrawMethod, optional) – Method to draw the graph. Defaults to MermaidDrawMethod.API.

  • background_color (str, optional) – Background color of the image. Defaults to β€œwhite”.

  • padding (int, optional) – Padding around the image. Defaults to 10.

  • max_retries (int, optional) – Maximum number of retries (MermaidDrawMethod.API). Defaults to 1.

  • retry_delay (float, optional) – Delay between retries (MermaidDrawMethod.API). Defaults to 1.0.

Returns:

PNG image bytes.

Return type:

bytes

Raises:

ValueError – If an invalid draw method is provided.