graph_mermaid.py — langchain Source File
Architecture documentation for graph_mermaid.py, a python file in the langchain codebase. 14 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c545ef44_a033_15ff_e016_18af37277247["graph_mermaid.py"] e6310202_b39e_ec9f_8b57_921c9c39c97d["asyncio"] c545ef44_a033_15ff_e016_18af37277247 --> e6310202_b39e_ec9f_8b57_921c9c39c97d d3750461_97f2_1730_4a69_37dae25b7cb2["base64"] c545ef44_a033_15ff_e016_18af37277247 --> d3750461_97f2_1730_4a69_37dae25b7cb2 d33d86db_0d65_0c4a_5ba6_a863c29fa1c9["random"] c545ef44_a033_15ff_e016_18af37277247 --> d33d86db_0d65_0c4a_5ba6_a863c29fa1c9 b7996424_637b_0b54_6edf_2e18e9c1a8bf["re"] c545ef44_a033_15ff_e016_18af37277247 --> b7996424_637b_0b54_6edf_2e18e9c1a8bf b95bdb4f_719f_67c2_db8f_4a67783a7d72["string"] c545ef44_a033_15ff_e016_18af37277247 --> b95bdb4f_719f_67c2_db8f_4a67783a7d72 996b2db9_46dd_901f_f7eb_068bafab4b12["time"] c545ef44_a033_15ff_e016_18af37277247 --> 996b2db9_46dd_901f_f7eb_068bafab4b12 04123c52_4735_47d9_961c_24bd9d5e87f9["urllib.parse"] c545ef44_a033_15ff_e016_18af37277247 --> 04123c52_4735_47d9_961c_24bd9d5e87f9 cd5f8820_9b2e_4495_abb7_d76026ac826c["dataclasses"] c545ef44_a033_15ff_e016_18af37277247 --> cd5f8820_9b2e_4495_abb7_d76026ac826c 927570d8_11a6_5c17_0f0d_80baae0c733e["pathlib"] c545ef44_a033_15ff_e016_18af37277247 --> 927570d8_11a6_5c17_0f0d_80baae0c733e feec1ec4_6917_867b_d228_b134d0ff8099["typing"] c545ef44_a033_15ff_e016_18af37277247 --> feec1ec4_6917_867b_d228_b134d0ff8099 a869785a_d507_1688_0b32_0ec94043975a["yaml"] c545ef44_a033_15ff_e016_18af37277247 --> a869785a_d507_1688_0b32_0ec94043975a 8f87b7e3_86aa_987c_2f8b_0f1fe7c9f8c8["langchain_core.runnables.graph"] c545ef44_a033_15ff_e016_18af37277247 --> 8f87b7e3_86aa_987c_2f8b_0f1fe7c9f8c8 a83cf0c6_37ab_ef90_8783_e7ae0273a0a0["requests"] c545ef44_a033_15ff_e016_18af37277247 --> a83cf0c6_37ab_ef90_8783_e7ae0273a0a0 616d7184_c2fd_b6a2_9573_38e9284782d6["pyppeteer"] c545ef44_a033_15ff_e016_18af37277247 --> 616d7184_c2fd_b6a2_9573_38e9284782d6 style c545ef44_a033_15ff_e016_18af37277247 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Mermaid graph drawing utilities."""
from __future__ import annotations
import asyncio
import base64
import random
import re
import string
import time
import urllib.parse
from dataclasses import asdict
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal, cast
import yaml
from langchain_core.runnables.graph import (
CurveStyle,
MermaidDrawMethod,
NodeStyles,
)
if TYPE_CHECKING:
from langchain_core.runnables.graph import Edge, Node
try:
import requests
_HAS_REQUESTS = True
except ImportError:
_HAS_REQUESTS = False
try:
from pyppeteer import launch # type: ignore[import-not-found]
_HAS_PYPPETEER = True
except ImportError:
_HAS_PYPPETEER = False
MARKDOWN_SPECIAL_CHARS = "*_`"
def draw_mermaid(
nodes: dict[str, Node],
edges: list[Edge],
*,
first_node: str | None = None,
last_node: str | None = None,
with_styles: bool = True,
curve_style: CurveStyle = CurveStyle.LINEAR,
node_styles: NodeStyles | None = None,
wrap_label_n_words: int = 9,
frontmatter_config: dict[str, Any] | None = None,
) -> str:
"""Draws a Mermaid graph using the provided graph data.
Args:
nodes: List of node ids.
// ... (439 more lines)
Domain
Subdomains
Functions
Dependencies
- asyncio
- base64
- dataclasses
- langchain_core.runnables.graph
- pathlib
- pyppeteer
- random
- re
- requests
- string
- time
- typing
- urllib.parse
- yaml
Source
Frequently Asked Questions
What does graph_mermaid.py do?
graph_mermaid.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, Runnables subdomain.
What functions are defined in graph_mermaid.py?
graph_mermaid.py defines 11 function(s): _HAS_PYPPETEER, _HAS_REQUESTS, _generate_mermaid_graph_styles, _render_mermaid_using_api, _render_mermaid_using_pyppeteer, _to_safe_id, draw_mermaid, draw_mermaid_png, langchain_core, pyppeteer, and 1 more.
What does graph_mermaid.py depend on?
graph_mermaid.py imports 14 module(s): asyncio, base64, dataclasses, langchain_core.runnables.graph, pathlib, pyppeteer, random, re, and 6 more.
Where is graph_mermaid.py in the architecture?
graph_mermaid.py is located at libs/core/langchain_core/runnables/graph_mermaid.py (domain: LangChainCore, subdomain: Runnables, directory: libs/core/langchain_core/runnables).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free