Documentation
¶
Index ¶
- func CompileGraph[T, V any](o *GenericOps, g *compose.Graph[T, V], opts ...compose.GraphCompileOption) (compose.Runnable[T, V], error)
- func InvokeGraph[T, V any](rail flow.Rail, genops *GenericOps, graph compose.Runnable[T, V], ...) (V, error)
- func WithTraceCallback(name string, genops *GenericOps) compose.Option
- type GenericOps
- type MermaidGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompileGraph ¶
func CompileGraph[T, V any](o *GenericOps, g *compose.Graph[T, V], opts ...compose.GraphCompileOption) (compose.Runnable[T, V], error)
func InvokeGraph ¶
func InvokeGraph[T, V any](rail flow.Rail, genops *GenericOps, graph compose.Runnable[T, V], graphName string, input T, opts ...compose.Option) (V, error)
InvokeGraph invokes a compiled graph with trace callbacks enabled. This is a convenience function that automatically adds WithTraceCallback to enable token usage tracking and execution logging based on GenericOps settings.
Parameters:
- rail: Execution context for logging
- genops: Generic operations config (controls trace callback behavior)
- graph: Compiled graph runnable
- graphName: Name of the graph for logging purposes
- input: Input to the graph
- opts: Additional compose options (e.g., callbacks, config)
Returns:
- Output from the graph
- Error if invocation fails
func WithTraceCallback ¶
func WithTraceCallback(name string, genops *GenericOps) compose.Option
Types ¶
type GenericOps ¶
type GenericOps struct {
MaxRunSteps int
RepeatPrompt bool // Propmt Repeation: https://arxiv.org/html/2512.14982v1
Now string
Language string
VisualizeDir string
LogOnStart bool
LogOnEnd bool
LogInputs bool
LogOutputs bool
}
func NewGenericOps ¶
func NewGenericOps() *GenericOps
type MermaidGenerator ¶
type MermaidGenerator struct {
// contains filtered or unexported fields
}
Credit: 2026-01-14, Copied from https://github.com/cloudwego/eino-examples/blob/main/devops/visualize/mermaid.go with modification.
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 := graph.NewMermaidGenerator(buf) // for Graph/Chain
// or
gen := graph.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".