petalflow

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 6 Imported by: 0

README

PetalFlow

codecov

A lightweight Go workflow graph runtime for building AI agent workflows. Chain LLM calls, tools, routers, and data transformations into directed graphs.

Installation

go get github.com/petal-labs/petalflow

Quick Start

package main

import (
    "context"
    "fmt"
    "strings"

    "github.com/petal-labs/petalflow"
)

func main() {
    // Create a graph
    g := petalflow.NewGraph("hello")

    // Add a node that transforms input
    node := petalflow.NewFuncNode("greet", func(ctx context.Context, env *petalflow.Envelope) (*petalflow.Envelope, error) {
        name := env.GetVarString("name")
        env.SetVar("greeting", fmt.Sprintf("Hello, %s!", strings.ToUpper(name)))
        return env, nil
    })

    g.AddNode(node)
    g.SetEntry("greet")

    // Create an envelope with input data
    env := petalflow.NewEnvelope().WithVar("name", "world")

    // Run the workflow
    runtime := petalflow.NewRuntime()
    result, _ := runtime.Run(context.Background(), g, env, petalflow.DefaultRunOptions())

    fmt.Println(result.GetVarString("greeting"))
    // Output: Hello, WORLD!
}

Core Concepts

Graph

A directed graph of nodes. You add nodes, connect them with edges, and set an entry point.

Node

A unit of execution. Each node receives an envelope, does work, and returns an envelope. Built-in node types:

Node Purpose
LLMNode Call an LLM with a prompt
ToolNode Execute a tool/function
RuleRouter Route based on conditions
LLMRouter Route using LLM classification
FilterNode Filter lists by criteria
TransformNode Reshape data
MergeNode Combine parallel branches
FuncNode Run custom Go code
Envelope

The data carrier that flows between nodes. Contains:

  • Vars - Key-value store for passing data
  • Messages - Chat-style messages for LLM context
  • Artifacts - Documents, files, or structured outputs
  • Trace - Run ID and timing info
Runtime

Executes the graph. Handles node ordering, parallel branches, retries, and step-through debugging.

Examples

See the examples/ directory:

Example Description
01_hello_world Minimal workflow with a single node
02_iris_integration Connect to LLMs via Iris providers
03_sentiment_router Conditional routing based on input
04_data_pipeline Filter and transform data
05_rag_workflow Retrieval-augmented generation pattern

LLM Integration with Iris

PetalFlow integrates with Iris for LLM access:

import (
    "github.com/petal-labs/iris/providers/openai"
    "github.com/petal-labs/petalflow"
    "github.com/petal-labs/petalflow/irisadapter"
)

// Create an Iris provider
provider := openai.New(openai.WithAPIKey("your-key"))

// Wrap it for PetalFlow
client := irisadapter.NewProviderAdapter(provider)

// Use in an LLMNode
llmNode := petalflow.NewLLMNode("chat", client, petalflow.LLMNodeConfig{
    Model:  "gpt-4",
    System: "You are a helpful assistant.",
    PromptTemplate: "{{.question}}",
    OutputKey: "answer",
})

License

MIT License - see LICENSE for details.

Documentation

Overview

Package petalflow provides a Go-native framework for building, orchestrating, and deploying AI agents and multimodal workflows.

This file provides backward-compatible re-exports for all types and constructors from the core, graph, runtime, and nodes subpackages. Existing code using petalflow.* imports will continue to work without modification.

For new code, consider importing subpackages directly for clearer dependencies:

import "github.com/petal-labs/petalflow/core"
import "github.com/petal-labs/petalflow/graph"
import "github.com/petal-labs/petalflow/runtime"
import "github.com/petal-labs/petalflow/nodes"

Index

Constants

View Source
const (
	NodeKindLLM       = core.NodeKindLLM
	NodeKindTool      = core.NodeKindTool
	NodeKindRouter    = core.NodeKindRouter
	NodeKindMerge     = core.NodeKindMerge
	NodeKindMap       = core.NodeKindMap
	NodeKindGate      = core.NodeKindGate
	NodeKindNoop      = core.NodeKindNoop
	NodeKindFilter    = core.NodeKindFilter
	NodeKindTransform = core.NodeKindTransform
	NodeKindGuardian  = core.NodeKindGuardian
	NodeKindCache     = core.NodeKindCache
	NodeKindSink      = core.NodeKindSink
	NodeKindHuman     = core.NodeKindHuman
)

NodeKind constants

View Source
const (
	ErrorPolicyFail     = core.ErrorPolicyFail
	ErrorPolicyContinue = core.ErrorPolicyContinue
	ErrorPolicyRecord   = core.ErrorPolicyRecord
)

ErrorPolicy constants

View Source
const (
	EventRunStarted    = runtime.EventRunStarted
	EventNodeStarted   = runtime.EventNodeStarted
	EventNodeOutput    = runtime.EventNodeOutput
	EventNodeFailed    = runtime.EventNodeFailed
	EventNodeFinished  = runtime.EventNodeFinished
	EventRouteDecision = runtime.EventRouteDecision
	EventRunFinished   = runtime.EventRunFinished
	EventStepPaused    = runtime.EventStepPaused
	EventStepResumed   = runtime.EventStepResumed
	EventStepSkipped   = runtime.EventStepSkipped
	EventStepAborted   = runtime.EventStepAborted
)

EventKind constants

View Source
const (
	StepActionContinue        = runtime.StepActionContinue
	StepActionSkipNode        = runtime.StepActionSkipNode
	StepActionAbort           = runtime.StepActionAbort
	StepActionRunToBreakpoint = runtime.StepActionRunToBreakpoint
)

StepAction constants

View Source
const (
	StepPointBeforeNode = runtime.StepPointBeforeNode
	StepPointAfterNode  = runtime.StepPointAfterNode
)

StepPoint constants

View Source
const (
	OpEquals      = nodes.OpEquals
	OpNotEquals   = nodes.OpNotEquals
	OpContains    = nodes.OpContains
	OpGreaterThan = nodes.OpGreaterThan
	OpLessThan    = nodes.OpLessThan
	OpExists      = nodes.OpExists
	OpNotExists   = nodes.OpNotExists
	OpIn          = nodes.OpIn
)

ConditionOp constants

View Source
const (
	GateActionBlock    = nodes.GateActionBlock
	GateActionSkip     = nodes.GateActionSkip
	GateActionRedirect = nodes.GateActionRedirect
)

GateAction constants

View Source
const (
	FilterOpTopN      = nodes.FilterOpTopN
	FilterOpThreshold = nodes.FilterOpThreshold
	FilterOpDedupe    = nodes.FilterOpDedupe
	FilterOpByType    = nodes.FilterOpByType
	FilterOpMatch     = nodes.FilterOpMatch
	FilterOpExclude   = nodes.FilterOpExclude
	FilterOpCustom    = nodes.FilterOpCustom
)

FilterOpType constants

View Source
const (
	FilterTargetArtifacts = nodes.FilterTargetArtifacts
	FilterTargetMessages  = nodes.FilterTargetMessages
	FilterTargetVar       = nodes.FilterTargetVar
)

FilterTarget constants

View Source
const (
	TransformPick      = nodes.TransformPick
	TransformOmit      = nodes.TransformOmit
	TransformRename    = nodes.TransformRename
	TransformFlatten   = nodes.TransformFlatten
	TransformMerge     = nodes.TransformMerge
	TransformTemplate  = nodes.TransformTemplate
	TransformStringify = nodes.TransformStringify
	TransformParse     = nodes.TransformParse
	TransformMap       = nodes.TransformMap
	TransformCustom    = nodes.TransformCustom
)

TransformType constants

View Source
const (
	GuardianCheckRequired  = nodes.GuardianCheckRequired
	GuardianCheckMaxLength = nodes.GuardianCheckMaxLength
	GuardianCheckMinLength = nodes.GuardianCheckMinLength
	GuardianCheckPattern   = nodes.GuardianCheckPattern
	GuardianCheckEnum      = nodes.GuardianCheckEnum
	GuardianCheckTypeCheck = nodes.GuardianCheckType_
	GuardianCheckRange     = nodes.GuardianCheckRange
	GuardianCheckPII       = nodes.GuardianCheckPII
	GuardianCheckSchema    = nodes.GuardianCheckSchema
	GuardianCheckCustom    = nodes.GuardianCheckCustom
)

GuardianCheckType constants

View Source
const (
	GuardianActionFail     = nodes.GuardianActionFail
	GuardianActionSkip     = nodes.GuardianActionSkip
	GuardianActionRedirect = nodes.GuardianActionRedirect
)

GuardianAction constants

View Source
const (
	PIITypeSSN         = nodes.PIITypeSSN
	PIITypeEmail       = nodes.PIITypeEmail
	PIITypePhone       = nodes.PIITypePhone
	PIITypeCreditCard  = nodes.PIITypeCreditCard
	PIITypeIPAddress   = nodes.PIITypeIPAddress
	PIITypeDateOfBirth = nodes.PIITypeDateOfBirth
)

PIIType constants

View Source
const (
	HumanRequestApproval = nodes.HumanRequestApproval
	HumanRequestChoice   = nodes.HumanRequestChoice
	HumanRequestEdit     = nodes.HumanRequestEdit
	HumanRequestInput    = nodes.HumanRequestInput
	HumanRequestReview   = nodes.HumanRequestReview
)

HumanRequestType constants

View Source
const (
	HumanTimeoutFail    = nodes.HumanTimeoutFail
	HumanTimeoutDefault = nodes.HumanTimeoutDefault
	HumanTimeoutSkip    = nodes.HumanTimeoutSkip
)

HumanTimeoutAction constants

View Source
const (
	SinkTypeFile    = nodes.SinkTypeFile
	SinkTypeWebhook = nodes.SinkTypeWebhook
	SinkTypeLog     = nodes.SinkTypeLog
	SinkTypeMetric  = nodes.SinkTypeMetric
	SinkTypeVar     = nodes.SinkTypeVar
	SinkTypeCustom  = nodes.SinkTypeCustom
)

SinkType constants

View Source
const (
	SinkErrorPolicyFail     = nodes.SinkErrorPolicyFail
	SinkErrorPolicyContinue = nodes.SinkErrorPolicyContinue
	SinkErrorPolicyRecord   = nodes.SinkErrorPolicyRecord
)

SinkErrorPolicy constants

Variables

View Source
var (
	NewEnvelope        = core.NewEnvelope
	NewBaseNode        = core.NewBaseNode
	NewNoopNode        = core.NewNoopNode
	NewFuncNode        = core.NewFuncNode
	NewFuncTool        = core.NewFuncTool
	NewToolRegistry    = core.NewToolRegistry
	DefaultRetryPolicy = core.DefaultRetryPolicy
)

Core package constructors

View Source
var (
	ErrNodeNotFound     = graph.ErrNodeNotFound
	ErrDuplicateNode    = graph.ErrDuplicateNode
	ErrInvalidEdge      = graph.ErrInvalidEdge
	ErrNoEntryNode      = graph.ErrNoEntryNode
	ErrCycleDetected    = graph.ErrCycleDetected
	ErrEmptyGraph       = graph.ErrEmptyGraph
	ErrNodeAlreadyAdded = graph.ErrNodeAlreadyAdded
)

Graph package errors

View Source
var (
	NewGraph          = graph.NewGraph
	NewGraphBuilder   = graph.NewGraphBuilder
	NewBranch         = graph.NewBranch
	NewPipelineBranch = graph.NewPipelineBranch
)

Graph package constructors

View Source
var (
	ErrMaxHopsExceeded     = runtime.ErrMaxHopsExceeded
	ErrRunCanceled         = runtime.ErrRunCanceled
	ErrNodeExecution       = runtime.ErrNodeExecution
	ErrStepAborted         = runtime.ErrStepAborted
	ErrStepRequestNotFound = runtime.ErrStepRequestNotFound
)

Runtime package errors

View Source
var (
	NewRuntime                  = runtime.NewRuntime
	DefaultRunOptions           = runtime.DefaultRunOptions
	NewEvent                    = runtime.NewEvent
	MultiEventHandler           = runtime.MultiEventHandler
	ChannelEventHandler         = runtime.ChannelEventHandler
	DefaultStepConfig           = runtime.DefaultStepConfig
	NewCallbackStepController   = runtime.NewCallbackStepController
	NewChannelStepController    = runtime.NewChannelStepController
	NewBreakpointStepController = runtime.NewBreakpointStepController
	NewAutoStepController       = runtime.NewAutoStepController
)

Runtime package constructors

View Source
var (
	NewLLMNode                = nodes.NewLLMNode
	NewToolNode               = nodes.NewToolNode
	NewToolNodeWithRegistry   = nodes.NewToolNodeWithRegistry
	NewRuleRouter             = nodes.NewRuleRouter
	NewLLMRouter              = nodes.NewLLMRouter
	NewMergeNode              = nodes.NewMergeNode
	NewJSONMergeStrategy      = nodes.NewJSONMergeStrategy
	NewConcatMergeStrategy    = nodes.NewConcatMergeStrategy
	NewBestScoreMergeStrategy = nodes.NewBestScoreMergeStrategy
	NewFuncMergeStrategy      = nodes.NewFuncMergeStrategy
	NewAllMergeStrategy       = nodes.NewAllMergeStrategy
	NewMapNode                = nodes.NewMapNode
	NewFilterNode             = nodes.NewFilterNode
	NewTransformNode          = nodes.NewTransformNode
	NewGateNode               = nodes.NewGateNode
	NewCacheNode              = nodes.NewCacheNode
	NewMemoryCacheStore       = nodes.NewMemoryCacheStore
	NewCacheKeyBuilder        = nodes.NewCacheKeyBuilder
	NewMockNode               = nodes.NewMockNode
	NewGuardianNode           = nodes.NewGuardianNode
	NewHumanNode              = nodes.NewHumanNode
	NewChannelHumanHandler    = nodes.NewChannelHumanHandler
	NewCallbackHumanHandler   = nodes.NewCallbackHumanHandler
	NewAutoApproveHandler     = nodes.NewAutoApproveHandler
	NewAutoRejectHandler      = nodes.NewAutoRejectHandler
	NewQueuedHumanHandler     = nodes.NewQueuedHumanHandler
	NewSinkNode               = nodes.NewSinkNode
	NewMockHTTPClient         = nodes.NewMockHTTPClient
	NewMockMetricRecorder     = nodes.NewMockMetricRecorder
)

Nodes package constructors

Functions

This section is empty.

Types

type AllMergeStrategy

type AllMergeStrategy = nodes.AllMergeStrategy

AllMergeStrategy collects all inputs into a single output.

type Artifact

type Artifact = core.Artifact

Artifact represents a document or derived data produced during a run.

type AutoApproveHandler

type AutoApproveHandler = nodes.AutoApproveHandler

AutoApproveHandler automatically approves or rejects requests.

type AutoStepController

type AutoStepController = runtime.AutoStepController

AutoStepController automatically continues with a configurable delay.

type BaseNode

type BaseNode = core.BaseNode

BaseNode provides common functionality for node implementations.

type BasicGraph

type BasicGraph = graph.BasicGraph

BasicGraph is a simple implementation of the Graph interface.

type BasicRuntime

type BasicRuntime = runtime.BasicRuntime

BasicRuntime is a simple sequential runtime implementation.

type BestScoreMergeConfig

type BestScoreMergeConfig = nodes.BestScoreMergeConfig

BestScoreMergeConfig configures a BestScoreMergeStrategy.

type BestScoreMergeStrategy

type BestScoreMergeStrategy = nodes.BestScoreMergeStrategy

BestScoreMergeStrategy selects the envelope with the best score.

type BreakpointStepController

type BreakpointStepController = runtime.BreakpointStepController

BreakpointStepController only pauses at specified breakpoints.

type Budget

type Budget = core.Budget

Budget is an optional guardrail for LLM calls to limit resource usage.

type CacheKeyBuilder

type CacheKeyBuilder = nodes.CacheKeyBuilder

CacheKeyBuilder helps build complex cache keys.

type CacheNode

type CacheNode = nodes.CacheNode

CacheNode wraps another node and caches its results.

type CacheNodeConfig

type CacheNodeConfig = nodes.CacheNodeConfig

CacheNodeConfig configures a CacheNode.

type CacheResult

type CacheResult = nodes.CacheResult

CacheResult contains metadata about a cache operation.

type CacheStore

type CacheStore = nodes.CacheStore

CacheStore is the interface for cache storage backends.

type CallbackHumanHandler

type CallbackHumanHandler = nodes.CallbackHumanHandler

CallbackHumanHandler uses a callback function.

type CallbackStepController

type CallbackStepController = runtime.CallbackStepController

CallbackStepController invokes a function at each step.

type ChannelHumanHandler

type ChannelHumanHandler = nodes.ChannelHumanHandler

ChannelHumanHandler uses Go channels for human interaction.

type ChannelStepController

type ChannelStepController = runtime.ChannelStepController

ChannelStepController uses Go channels for interactive debugging.

type ConcatMergeConfig

type ConcatMergeConfig = nodes.ConcatMergeConfig

ConcatMergeConfig configures a ConcatMergeStrategy.

type ConcatMergeStrategy

type ConcatMergeStrategy = nodes.ConcatMergeStrategy

ConcatMergeStrategy merges by concatenating values.

type ConditionFunc

type ConditionFunc = func(ctx context.Context, env *Envelope) (bool, error)

ConditionFunc is a convenience type for condition checking functions.

type ConditionOp

type ConditionOp = nodes.ConditionOp

ConditionOp is the operator for a route condition.

type Edge

type Edge = graph.Edge

Edge represents a directed connection between two nodes.

type EnvFunc

type EnvFunc = func(ctx context.Context, env *Envelope) (*Envelope, error)

EnvFunc is a convenience type for envelope transformation functions.

type Envelope

type Envelope = core.Envelope

Envelope is the single data structure passed between nodes.

func Run

func Run(ctx context.Context, g Graph, env *Envelope) (*Envelope, error)

Run is a convenience function to execute a graph with default options. It creates a new runtime, runs the graph, and returns the result.

func RunParallel

func RunParallel(ctx context.Context, g Graph, env *Envelope, concurrency int) (*Envelope, error)

RunParallel is a convenience function to execute a graph with parallel execution.

func RunWithHandler

func RunWithHandler(ctx context.Context, g Graph, env *Envelope, handler EventHandler) (*Envelope, error)

RunWithHandler is a convenience function to execute a graph with an event handler.

func RunWithOptions

func RunWithOptions(ctx context.Context, g Graph, env *Envelope, opts RunOptions) (*Envelope, error)

RunWithOptions is a convenience function to execute a graph with custom options.

type EnvelopeModification

type EnvelopeModification = runtime.EnvelopeModification

EnvelopeModification specifies changes to apply to the envelope.

type EnvelopeSnapshot

type EnvelopeSnapshot = runtime.EnvelopeSnapshot

EnvelopeSnapshot is a read-only view of the envelope state.

type ErrorPolicy

type ErrorPolicy = core.ErrorPolicy

ErrorPolicy defines how a node handles errors.

type Event

type Event = runtime.Event

Event is a structured, streamable record of what happened during execution.

type EventEmitter

type EventEmitter = runtime.EventEmitter

EventEmitter is a function type for emitting events.

type EventHandler

type EventHandler = runtime.EventHandler

EventHandler is a function type for handling events.

type EventKind

type EventKind = runtime.EventKind

EventKind identifies the type of event emitted by the runtime.

type FanOutBranch

type FanOutBranch = graph.FanOutBranch

FanOutBranch is a helper for building complex fan-out patterns.

type FilterNode

type FilterNode = nodes.FilterNode

FilterNode filters items based on conditions.

type FilterNodeConfig

type FilterNodeConfig = nodes.FilterNodeConfig

FilterNodeConfig configures a FilterNode.

type FilterOp

type FilterOp = nodes.FilterOp

FilterOp defines a filter operation.

type FilterOpType

type FilterOpType = nodes.FilterOpType

FilterOpType is the type of filter operation.

type FilterStats

type FilterStats = nodes.FilterStats

FilterStats tracks filter operation statistics.

type FilterTarget

type FilterTarget = nodes.FilterTarget

FilterTarget specifies what to filter.

type FuncMergeStrategy

type FuncMergeStrategy = nodes.FuncMergeStrategy

FuncMergeStrategy uses a custom function for merging.

type FuncNode

type FuncNode = core.FuncNode

FuncNode wraps a function as a Node.

type FuncTool

type FuncTool = core.FuncTool

FuncTool is a simple function-backed tool for PetalFlow.

type GateAction

type GateAction = nodes.GateAction

GateAction defines what happens when a gate condition fails.

type GateNode

type GateNode = nodes.GateNode

GateNode evaluates a condition and either passes execution or takes action.

type GateNodeConfig

type GateNodeConfig = nodes.GateNodeConfig

GateNodeConfig configures a GateNode.

type GateResult

type GateResult = nodes.GateResult

GateResult is stored in the envelope when ResultVar is set.

type Graph

type Graph = graph.Graph

Graph represents a directed graph of nodes connected by edges.

func BuildGraph

func BuildGraph(name string, nodes ...Node) (Graph, error)

BuildGraph is a convenience function to create a simple linear graph. It creates a builder, adds all nodes with edges between them, and builds.

func MustBuildGraph

func MustBuildGraph(name string, nodes ...Node) Graph

MustBuildGraph is like BuildGraph but panics on error. Useful in tests and examples.

type GraphBuilder

type GraphBuilder = graph.GraphBuilder

GraphBuilder provides a fluent API for constructing workflow graphs.

type GraphSnapshot

type GraphSnapshot = runtime.GraphSnapshot

GraphSnapshot provides read-only graph context.

type GuardianAction

type GuardianAction = nodes.GuardianAction

GuardianAction defines what happens when a check fails.

type GuardianCheck

type GuardianCheck = nodes.GuardianCheck

GuardianCheck defines a validation check.

type GuardianCheckType

type GuardianCheckType = nodes.GuardianCheckType

GuardianCheckType is the type of check to perform.

type GuardianFailure

type GuardianFailure = nodes.GuardianFailure

GuardianFailure records a single check failure.

type GuardianNode

type GuardianNode = nodes.GuardianNode

GuardianNode validates data against defined checks.

type GuardianNodeConfig

type GuardianNodeConfig = nodes.GuardianNodeConfig

GuardianNodeConfig configures a GuardianNode.

type GuardianResult

type GuardianResult = nodes.GuardianResult

GuardianResult contains the results of all checks.

type HTTPClient

type HTTPClient = nodes.HTTPClient

HTTPClient is the interface for HTTP requests.

type HumanCallbackFunc

type HumanCallbackFunc = func(ctx context.Context, req *HumanRequest) (*HumanResponse, error)

HumanCallbackFunc is a convenience type for human handler callbacks.

type HumanHandler

type HumanHandler = nodes.HumanHandler

HumanHandler processes human requests.

type HumanNode

type HumanNode = nodes.HumanNode

HumanNode requests human input or approval.

type HumanNodeConfig

type HumanNodeConfig = nodes.HumanNodeConfig

HumanNodeConfig configures a HumanNode.

type HumanOption

type HumanOption = nodes.HumanOption

HumanOption represents a choice option.

type HumanRequest

type HumanRequest = nodes.HumanRequest

HumanRequest represents a request for human input.

type HumanRequestType

type HumanRequestType = nodes.HumanRequestType

HumanRequestType identifies the type of human request.

type HumanResponse

type HumanResponse = nodes.HumanResponse

HumanResponse contains the human's response.

type HumanTimeoutAction

type HumanTimeoutAction = nodes.HumanTimeoutAction

HumanTimeoutAction defines what happens on timeout.

type JSONMergeConfig

type JSONMergeConfig = nodes.JSONMergeConfig

JSONMergeConfig configures a JSONMergeStrategy.

type JSONMergeStrategy

type JSONMergeStrategy = nodes.JSONMergeStrategy

JSONMergeStrategy merges envelopes by combining JSON data.

type LLMClient

type LLMClient = core.LLMClient

LLMClient abstracts a single provider/model backend for PetalFlow.

type LLMMessage

type LLMMessage = core.LLMMessage

LLMMessage is a chat message in PetalFlow format.

type LLMNode

type LLMNode = nodes.LLMNode

LLMNode calls a language model to process the envelope.

type LLMNodeConfig

type LLMNodeConfig = nodes.LLMNodeConfig

LLMNodeConfig configures an LLMNode.

type LLMReasoningOutput

type LLMReasoningOutput = core.LLMReasoningOutput

LLMReasoningOutput contains reasoning information from the model.

type LLMRequest

type LLMRequest = core.LLMRequest

LLMRequest is the request structure for LLM completion.

type LLMResponse

type LLMResponse = core.LLMResponse

LLMResponse captures the output from an LLM call.

type LLMRouter

type LLMRouter = nodes.LLMRouter

LLMRouter uses an LLM to make routing decisions.

type LLMRouterConfig

type LLMRouterConfig = nodes.LLMRouterConfig

LLMRouterConfig configures an LLMRouter.

type LLMTokenUsage

type LLMTokenUsage = core.LLMTokenUsage

LLMTokenUsage tracks token consumption for LLM calls.

type LLMToolCall

type LLMToolCall = core.LLMToolCall

LLMToolCall represents a tool invocation requested by the model.

type LLMToolResult

type LLMToolResult = core.LLMToolResult

LLMToolResult represents the result of executing a tool.

type MapNode

type MapNode = nodes.MapNode

MapNode applies a sub-node to each item in a collection.

type MapNodeConfig

type MapNodeConfig = nodes.MapNodeConfig

MapNodeConfig configures a MapNode.

type MemoryCacheStore

type MemoryCacheStore = nodes.MemoryCacheStore

MemoryCacheStore is an in-memory cache implementation.

type MergeCapable

type MergeCapable = core.MergeCapable

MergeCapable is implemented by nodes that can merge multiple input envelopes.

type MergeFunc

type MergeFunc = func(ctx context.Context, inputs []*Envelope) (*Envelope, error)

MergeFunc is a convenience type for custom merge functions.

type MergeNode

type MergeNode = nodes.MergeNode

MergeNode combines multiple input envelopes into one.

type MergeNodeConfig

type MergeNodeConfig = nodes.MergeNodeConfig

MergeNodeConfig configures a MergeNode.

type MergeStrategy

type MergeStrategy = nodes.MergeStrategy

MergeStrategy defines how to combine multiple envelopes.

type Message

type Message = core.Message

Message is a chat-style message used for LLM steps and auditing.

type MetricRecorder

type MetricRecorder = nodes.MetricRecorder

MetricRecorder is the interface for recording metrics.

type MockHTTPClient

type MockHTTPClient = nodes.MockHTTPClient

MockHTTPClient is a mock HTTP client for testing.

type MockMetric

type MockMetric = nodes.MockMetric

MockMetric represents a recorded metric.

type MockMetricRecorder

type MockMetricRecorder = nodes.MockMetricRecorder

MockMetricRecorder is a mock metric recorder for testing.

type MockNode

type MockNode = nodes.MockNode

MockNode is a simple node for testing.

type Node

type Node = core.Node

Node is the fundamental unit of execution in a PetalFlow graph.

type NodeError

type NodeError = core.NodeError

NodeError is recorded when nodes fail but the graph continues.

type NodeFunc

type NodeFunc = core.NodeFunc

NodeFunc is a convenience type for node functions.

type NodeKind

type NodeKind = core.NodeKind

NodeKind identifies the type of a node.

type NoopNode

type NoopNode = core.NoopNode

NoopNode is a node that passes the envelope through unchanged.

type PIIType

type PIIType = nodes.PIIType

PIIType identifies the type of PII detected.

type PetalTool

type PetalTool = core.PetalTool

PetalTool is the tool interface for PetalFlow.

type QueuedHumanHandler

type QueuedHumanHandler = nodes.QueuedHumanHandler

QueuedHumanHandler queues requests for later processing.

type RetryPolicy

type RetryPolicy = core.RetryPolicy

RetryPolicy configures retry behavior for nodes that call external systems.

type RouteCondition

type RouteCondition = nodes.RouteCondition

RouteCondition defines a condition for routing.

type RouteDecision

type RouteDecision = core.RouteDecision

RouteDecision is produced by RouterNode to indicate which targets to activate.

type RouteRule

type RouteRule = nodes.RouteRule

RouteRule defines a single routing rule.

type RouterNode

type RouterNode = core.RouterNode

RouterNode is a node that can select which edges to activate.

type RuleRouter

type RuleRouter = nodes.RuleRouter

RuleRouter routes based on configured rules.

type RuleRouterConfig

type RuleRouterConfig = nodes.RuleRouterConfig

RuleRouterConfig configures a RuleRouter.

type RunOptions

type RunOptions = runtime.RunOptions

RunOptions controls execution behavior.

func NewStepRunOptions

func NewStepRunOptions(controller StepController) RunOptions

NewStepRunOptions creates RunOptions configured for step-through debugging.

func NewStepRunOptionsWithConfig

func NewStepRunOptionsWithConfig(controller StepController, config *StepConfig) RunOptions

NewStepRunOptionsWithConfig creates RunOptions configured for step-through debugging with a custom step configuration.

func NewTimedRunOptions

func NewTimedRunOptions(now func() time.Time) RunOptions

NewTimedRunOptions creates RunOptions with a custom time function. Useful for testing time-sensitive behavior.

type Runtime

type Runtime = runtime.Runtime

Runtime executes graphs and emits events.

type ShouldPauseFunc

type ShouldPauseFunc = runtime.ShouldPauseFunc

ShouldPauseFunc is an optional predicate for CallbackStepController.

type SinkErrorPolicy

type SinkErrorPolicy = nodes.SinkErrorPolicy

SinkErrorPolicy defines how sink errors are handled.

type SinkNode

type SinkNode = nodes.SinkNode

SinkNode outputs data to external systems.

type SinkNodeConfig

type SinkNodeConfig = nodes.SinkNodeConfig

SinkNodeConfig configures a SinkNode.

type SinkResult

type SinkResult = nodes.SinkResult

SinkResult contains the results of sink operations.

type SinkTarget

type SinkTarget = nodes.SinkTarget

SinkTarget defines a single sink destination.

type SinkTargetResult

type SinkTargetResult = nodes.SinkTargetResult

SinkTargetResult contains the result of a single sink target.

type SinkType

type SinkType = nodes.SinkType

SinkType identifies the type of sink.

type SinkWriteFunc

type SinkWriteFunc = func(ctx context.Context, env *Envelope, target *SinkTarget) error

SinkWriteFunc is a convenience type for custom sink functions.

type StepAction

type StepAction = runtime.StepAction

StepAction specifies what the runtime should do at a step point.

type StepCallback

type StepCallback = runtime.StepCallback

StepCallback is the function signature for CallbackStepController.

type StepConfig

type StepConfig = runtime.StepConfig

StepConfig configures step-through behavior.

type StepController

type StepController = runtime.StepController

StepController is the interface for controlling step-through execution.

type StepHandler

type StepHandler = runtime.StepHandler

StepHandler is called when a breakpoint is hit.

type StepPoint

type StepPoint = runtime.StepPoint

StepPoint indicates when a step pause occurred.

type StepRequest

type StepRequest = runtime.StepRequest

StepRequest contains information about the current step point.

type StepResponse

type StepResponse = runtime.StepResponse

StepResponse contains the controller's decision.

type TokenUsage

type TokenUsage = core.TokenUsage

TokenUsage tracks token consumption for cost tracking and budgeting.

type ToolNode

type ToolNode = nodes.ToolNode

ToolNode executes a tool and stores the result.

type ToolNodeConfig

type ToolNodeConfig = nodes.ToolNodeConfig

ToolNodeConfig configures a ToolNode.

type ToolRegistry

type ToolRegistry = core.ToolRegistry

ToolRegistry holds a collection of tools for lookup by name.

type TraceInfo

type TraceInfo = core.TraceInfo

TraceInfo is propagated by the runtime for observability and replay.

type TransformFunc

type TransformFunc = func(ctx context.Context, env *Envelope) (*Envelope, error)

TransformFunc is a convenience type for custom transformation functions.

type TransformNode

type TransformNode = nodes.TransformNode

TransformNode reshapes or transforms data.

type TransformNodeConfig

type TransformNodeConfig = nodes.TransformNodeConfig

TransformNodeConfig configures a TransformNode.

type TransformType

type TransformType = nodes.TransformType

TransformType specifies the type of transformation.

type ValidateFunc

type ValidateFunc = func(ctx context.Context, env *Envelope, check *GuardianCheck) (bool, string, error)

ValidateFunc is a convenience type for custom validation functions.

Directories

Path Synopsis
Package core provides the foundational types and interfaces for PetalFlow workflows.
Package core provides the foundational types and interfaces for PetalFlow workflows.
Package graph provides the directed graph model for PetalFlow workflows.
Package graph provides the directed graph model for PetalFlow workflows.
Package nodes provides the node implementations for PetalFlow workflows.
Package nodes provides the node implementations for PetalFlow workflows.
Package runtime provides the execution engine for PetalFlow workflow graphs.
Package runtime provides the execution engine for PetalFlow workflow graphs.

Jump to

Keyboard shortcuts

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