Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MermaidGenerator ¶
type MermaidGenerator struct {
// contains filtered or unexported fields
}
MermaidGenerator renders a Mermaid diagram from a compiled Eino graph (Graph/Chain/Workflow).
Core concepts and mapping: - Nodes: labeled with their key and component type. Lambda nodes use rounded shapes. - Special nodes: START/END are rendered with safe IDs (start_node/end_node) to avoid Mermaid keyword conflicts. - SubGraphs: nested Graph/Chain/Workflow are rendered as Mermaid sub-graphs with their component type in the title. - Edges:
- In general graphs/chains: a single solid arrow (-->), representing standard control+data execution.
- In workflows (workflowStyle=true): edges are distinguished by semantics:
- control+data: normal arrow with label "control+data" ("-- control+data -->")
- control-only: bold arrow with label "control-only" ("== control-only ==>")
- data-only: dotted arrow with label "data-only" ("-. data-only .->") Branch decision diamonds and their incoming/outgoing edges are treated as control-only in workflows.
Usage:
buf := &bytes.Buffer{}
gen := visualize.NewMermaidGenerator(buf) // for Graph/Chain
// or
gen := visualize.NewMermaidGeneratorWorkflow(buf) // for Workflow with labeled edges
_, _ = g.Compile(ctx, compose.WithGraphCompileCallbacks(gen), compose.WithGraphName("MyGraph"))
// Write to a Markdown file:
md := "```mermaid\n" + buf.String() + "\n```\n"
_ = os.WriteFile("my_graph.md", []byte(md), 0644)
func NewMermaidGenerator ¶
func NewMermaidGenerator(dir string) *MermaidGenerator
NewMermaidGenerator creates a generator that auto-writes Markdown and attempts PNG/SVG generation. If dir is empty, current working directory is used. File name is derived from graph name or defaults to "topology".