Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrStepConditionFailed indicates a step's condition check failed. ErrStepConditionFailed = stderror.New("step condition check failed") // ErrStepNotFound indicates a referenced step doesn't exist in workflow. ErrStepNotFound = stderror.New("step not found in workflow") // ErrInvalidInput indicates missing or invalid input parameters. ErrInvalidInput = stderror.New("invalid input parameters") // ErrDuplicateStepID indicates attempt to add step with existing ID. ErrDuplicateStepID = stderror.New("duplicate step ID") // ErrCyclicDependency indicates circular dependencies between steps. ErrCyclicDependency = stderror.New("cyclic dependency detected in workflow") )
Functions ¶
func WrapWorkflowError ¶ added in v0.13.0
Types ¶
type BaseWorkflow ¶
type BaseWorkflow struct {
// contains filtered or unexported fields
}
BaseWorkflow provides common workflow functionality.
func NewBaseWorkflow ¶
func NewBaseWorkflow(memory agents.Memory) *BaseWorkflow
func (*BaseWorkflow) AddStep ¶
func (w *BaseWorkflow) AddStep(step *Step) error
func (*BaseWorkflow) GetSteps ¶
func (w *BaseWorkflow) GetSteps() []*Step
func (*BaseWorkflow) ValidateWorkflow ¶
func (w *BaseWorkflow) ValidateWorkflow() error
ValidateWorkflow checks if the workflow structure is valid.
type ChainWorkflow ¶
type ChainWorkflow struct {
*BaseWorkflow
}
ChainWorkflow executes steps in a linear sequence, where each step's output can be used as input for subsequent steps.
func NewChainWorkflow ¶
func NewChainWorkflow(memory agents.Memory) *ChainWorkflow
type ParallelWorkflow ¶
type ParallelWorkflow struct {
*BaseWorkflow
// contains filtered or unexported fields
}
ParallelWorkflow executes multiple steps concurrently.
func NewParallelWorkflow ¶
func NewParallelWorkflow(memory agents.Memory, maxConcurrent int) *ParallelWorkflow
type RetryConfig ¶
type RetryConfig struct {
// MaxAttempts is the maximum number of retry attempts
MaxAttempts int
// BackoffMultiplier determines how long to wait between retries
BackoffMultiplier float64
}
RetryConfig defines how to handle step failures.
type RouterWorkflow ¶
type RouterWorkflow struct {
*BaseWorkflow
// contains filtered or unexported fields
}
RouterWorkflow directs inputs to different processing paths based on a classification step.
func NewRouterWorkflow ¶
func NewRouterWorkflow(memory agents.Memory, classifierStep *Step) *RouterWorkflow
type Step ¶
type Step struct {
// ID uniquely identifies this step within the workflow
ID string
// Module is the underlying DSPy module that performs the actual computation
// This could be a Predict, ChainOfThought, or any other DSPy module type
Module core.Module
// NextSteps contains the IDs of steps that should execute after this one
// This allows us to define branching and conditional execution paths
NextSteps []string
// Condition is an optional function that determines if this step should execute
// It can examine the current workflow state to make this decision
Condition func(state map[string]interface{}) bool
// RetryConfig specifies how to handle failures of this step
RetryConfig *RetryConfig
}
Step represents a single unit of computation in a workflow. Each step wraps a DSPy module and adds workflow-specific metadata and control logic.
type StepResult ¶
type StepResult struct {
// StepID identifies which step produced this result
StepID string
// Outputs contains the data produced by this step
Outputs map[string]interface{}
// Metadata contains additional information about the execution
Metadata map[string]interface{}
// NextSteps indicates which steps should run next (may be modified by step execution)
NextSteps []string
}
StepResult holds the outputs and metadata from executing a step.
type Workflow ¶
type Workflow interface {
// Execute runs the workflow with the provided inputs
Execute(ctx context.Context, inputs map[string]interface{}) (map[string]interface{}, error)
// GetSteps returns all steps in this workflow
GetSteps() []*Step
// AddStep adds a new step to the workflow
AddStep(step *Step) error
}
Workflow represents a sequence of steps that accomplish a task.