visualize

package
v0.0.0-...-a80cde9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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".

func (*MermaidGenerator) OnFinish

func (m *MermaidGenerator) OnFinish(_ context.Context, info *compose.GraphInfo)

OnFinish is the compile callback entrypoint invoked by Eino after graph compilation. It reads the compile-time GraphInfo and writes a complete Mermaid diagram to the writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL