-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraw_graph.py
More file actions
26 lines (21 loc) 路 1.07 KB
/
Copy pathdraw_graph.py
File metadata and controls
26 lines (21 loc) 路 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
from agent.orchestrator.core.graph import main_agent
def generate_graph_diagram():
"""Renders the master orchestrator LangGraph as a visual PNG diagram."""
print("馃帹 Rendering LangGraph topology...")
try:
# draw_mermaid_png calls the mermaid.ink API under the hood,
# which means it works seamlessly without requiring local Graphviz system packages!
png_bytes = main_agent.get_graph().draw_mermaid_png()
output_filename = "orchestrator_graph.png"
with open(output_filename, "wb") as f:
f.write(png_bytes)
print(f"馃帀 Graph diagram successfully generated and saved to: '{os.path.abspath(output_filename)}'")
except Exception as e:
print(f"鈿狅笍 Could not generate PNG directly: {e}")
print("\nFallback: Printing raw Mermaid Markdown. You can paste this in any Mermaid viewer (like mermaid.live):")
print("=" * 60)
print(main_agent.get_graph().draw_mermaid())
print("=" * 60)
if __name__ == "__main__":
generate_graph_diagram()