File size: 549 Bytes
4be2432
 
 
 
 
 
3b33cbb
4be2432
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import sys

# Add the parent directory to the Python path
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from app import graph  
from langchain_core.runnables.graph import MermaidDrawMethod

docs_dir = "docs"
if not os.path.exists(docs_dir):
    os.makedirs(docs_dir)

graph_image = graph.get_graph().draw_mermaid_png(
    draw_method=MermaidDrawMethod.API,
)

with open(os.path.join(docs_dir, "graph.png"), "wb") as f:
    f.write(graph_image)

print("Graph visualization has been saved to docs/graph.png")