Documentation
¶
Index ¶
- func AggregateOutputs(results []ExecutionResult) string
- func GetFinalOutput(results []ExecutionResult) string
- type AgentClassification
- type AgentExecutor
- type AggregationConfig
- type AggregationMethod
- type AggregationPattern
- type AggregationResult
- type AggregationStrategy
- type ChainOfThoughtConfig
- type ChainOfThoughtPattern
- type ChainOfThoughtResult
- type ClassificationResult
- type Classifier
- type ClassifierConfig
- type ClassifierPattern
- type ErrorStrategy
- type ExecutionResult
- type MapReduceConfig
- type MapReducePattern
- type MultiClassifier
- type MultiClassifierConfig
- type MultiClassifierPattern
- type ParallelConfig
- type ParallelPattern
- type Plan
- type PlanStep
- type PlanValidator
- type Planner
- type PlanningConfig
- type PlanningPattern
- type PlanningResult
- type QualityAssessor
- type Reducer
- type ReflectionConfig
- type ReflectionPattern
- type ReflectionResult
- type Scorer
- type SequentialConfig
- type SequentialPattern
- type Splitter
- type StepResult
- type Summarizer
- type ThoughtStep
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AggregateOutputs ¶
func AggregateOutputs(results []ExecutionResult) string
AggregateOutputs combines outputs from all results
func GetFinalOutput ¶
func GetFinalOutput(results []ExecutionResult) string
GetFinalOutput returns the output of the last successful execution
Types ¶
type AgentClassification ¶
AgentClassification represents a classified agent with confidence
type AgentExecutor ¶
AgentExecutor is the function signature for executing an agent
type AggregationConfig ¶
type AggregationConfig struct {
Method AggregationMethod
Timeout time.Duration
ConcurrencyLimit int
Scorer Scorer // For AggregationBest
Summarizer Summarizer // For AggregationSummarize
Delimiter string // For AggregationMerge
MinimumResponses int // Minimum responses required
}
AggregationConfig configures the aggregation pattern
type AggregationMethod ¶
type AggregationMethod string
AggregationMethod defines how results are aggregated
const ( AggregationMerge AggregationMethod = "merge" // Combine all outputs AggregationVote AggregationMethod = "vote" // Majority voting AggregationSummarize AggregationMethod = "summarize" // Summarize via agent AggregationBest AggregationMethod = "best" // Select best based on scorer )
type AggregationPattern ¶
type AggregationPattern struct {
// contains filtered or unexported fields
}
AggregationPattern runs multiple agents and aggregates results
func NewAggregationPattern ¶
func NewAggregationPattern(executor AgentExecutor, config AggregationConfig) *AggregationPattern
NewAggregationPattern creates a new aggregation pattern
func (*AggregationPattern) Execute ¶
func (a *AggregationPattern) Execute(ctx context.Context, agents []string, input string) (*AggregationResult, error)
Execute runs all agents and aggregates their results
type AggregationResult ¶
type AggregationResult struct {
IndividualResults []ExecutionResult
AggregatedOutput string
Method AggregationMethod
Scores map[string]float64 // Agent scores if using scorer
}
AggregationResult contains execution and aggregation results
type AggregationStrategy ¶
type AggregationStrategy string
AggregationStrategy defines how to aggregate results from parallel execution
const ( AggregateAll AggregationStrategy = "all" // Wait for all results AggregateAny AggregationStrategy = "any" // Return first successful result AggregateMajority AggregationStrategy = "majority" // Return when majority complete )
type ChainOfThoughtConfig ¶
type ChainOfThoughtConfig struct {
ReasoningAgent string // Agent for reasoning steps
ExecutionAgent string // Agent for final execution
MaxSteps int // Maximum reasoning steps
Timeout time.Duration // Timeout per step
}
ChainOfThoughtConfig configures chain-of-thought reasoning
type ChainOfThoughtPattern ¶
type ChainOfThoughtPattern struct {
// contains filtered or unexported fields
}
ChainOfThoughtPattern implements chain-of-thought reasoning
func NewChainOfThoughtPattern ¶
func NewChainOfThoughtPattern(executor AgentExecutor, config ChainOfThoughtConfig) *ChainOfThoughtPattern
NewChainOfThoughtPattern creates a new chain-of-thought pattern
func (*ChainOfThoughtPattern) Execute ¶
func (c *ChainOfThoughtPattern) Execute(ctx context.Context, input string) (*ChainOfThoughtResult, error)
Execute runs chain-of-thought reasoning
type ChainOfThoughtResult ¶
type ChainOfThoughtResult struct {
Steps []ThoughtStep
FinalAnswer string
Error error
}
ChainOfThoughtResult contains the full reasoning chain
type ClassificationResult ¶
type ClassificationResult struct {
ClassifiedAgent string
Confidence float64
ExecutionResult
}
ClassificationResult contains the classification and execution result
type Classifier ¶
type Classifier func(ctx context.Context, input string) (agentName string, confidence float64, err error)
Classifier determines which agent should handle a task
type ClassifierConfig ¶
type ClassifierConfig struct {
Classifier Classifier // Function to classify input
ConfidenceThreshold float64 // Minimum confidence to proceed
DefaultAgent string // Agent to use if classification fails
Timeout time.Duration // Timeout per execution
}
ClassifierConfig configures the classifier pattern
type ClassifierPattern ¶
type ClassifierPattern struct {
// contains filtered or unexported fields
}
ClassifierPattern routes tasks to agents based on classification
func NewClassifierPattern ¶
func NewClassifierPattern(executor AgentExecutor, config ClassifierConfig) *ClassifierPattern
NewClassifierPattern creates a new classifier pattern
func (*ClassifierPattern) Execute ¶
func (c *ClassifierPattern) Execute(ctx context.Context, input string) (*ClassificationResult, error)
Execute classifies the input and routes to the appropriate agent
type ErrorStrategy ¶
type ErrorStrategy string
ErrorStrategy defines how to handle errors in sequential execution
const ( StopOnError ErrorStrategy = "stop" // Stop execution on first error ContinueOnError ErrorStrategy = "continue" // Continue despite errors )
type ExecutionResult ¶
type ExecutionResult struct {
AgentName string
Output string
Error error
Duration int64 // milliseconds
}
ExecutionResult represents the result of executing an agent
type MapReduceConfig ¶
type MapReduceConfig struct {
Splitter Splitter // Function to split input
Reducer Reducer // Function to reduce results
ConcurrencyLimit int // Max concurrent map operations
Timeout time.Duration // Timeout per map operation
}
MapReduceConfig configures the map-reduce pattern
type MapReducePattern ¶
type MapReducePattern struct {
// contains filtered or unexported fields
}
MapReducePattern implements map-reduce execution
func NewMapReducePattern ¶
func NewMapReducePattern(executor AgentExecutor, config MapReduceConfig) *MapReducePattern
NewMapReducePattern creates a new map-reduce pattern
func (*MapReducePattern) Execute ¶
func (m *MapReducePattern) Execute(ctx context.Context, agentName, input string) (string, []ExecutionResult, error)
Execute runs the map-reduce pattern
type MultiClassifier ¶
type MultiClassifier func(ctx context.Context, input string) (agents []AgentClassification, err error)
MultiClassifier determines multiple agents that should handle a task
type MultiClassifierConfig ¶
type MultiClassifierConfig struct {
Classifier MultiClassifier
ConfidenceThreshold float64
MaxAgents int // Maximum agents to execute
Timeout time.Duration // Timeout per agent
Parallel bool // Execute agents in parallel
}
MultiClassifierConfig configures multi-agent classification
type MultiClassifierPattern ¶
type MultiClassifierPattern struct {
// contains filtered or unexported fields
}
MultiClassifierPattern routes to multiple agents based on classification
func NewMultiClassifierPattern ¶
func NewMultiClassifierPattern(executor AgentExecutor, config MultiClassifierConfig) *MultiClassifierPattern
NewMultiClassifierPattern creates a new multi-classifier pattern
func (*MultiClassifierPattern) Execute ¶
func (m *MultiClassifierPattern) Execute(ctx context.Context, input string) ([]ClassificationResult, error)
Execute classifies and routes to multiple agents
type ParallelConfig ¶
type ParallelConfig struct {
ConcurrencyLimit int // Max concurrent executions (0 = unlimited)
Timeout time.Duration // Timeout per agent
Aggregation AggregationStrategy // How to aggregate results
}
ParallelConfig configures parallel execution
type ParallelPattern ¶
type ParallelPattern struct {
// contains filtered or unexported fields
}
ParallelPattern executes multiple agents concurrently
func NewParallelPattern ¶
func NewParallelPattern(executor AgentExecutor, config ParallelConfig) *ParallelPattern
NewParallelPattern creates a new parallel execution pattern
func (*ParallelPattern) Execute ¶
func (p *ParallelPattern) Execute(ctx context.Context, agents []string, input string) ([]ExecutionResult, error)
Execute runs all agents in parallel and aggregates results
type PlanStep ¶
type PlanStep struct {
ID string // Unique step identifier
AgentName string // Agent to execute
Input string // Input for this step
Dependencies []string // IDs of steps that must complete first
Metadata map[string]string // Optional metadata
}
PlanStep represents a single step in an execution plan
type PlanValidator ¶
PlanValidator validates a plan before execution
type PlanningConfig ¶
type PlanningConfig struct {
Planner Planner
Validator PlanValidator
Timeout time.Duration // Timeout per step
MaxSteps int // Maximum steps allowed
ContinueOnError bool // Continue executing if a step fails
ReplanOnFailure bool // Attempt to create new plan on failure
MaxReplanAttempts int
}
PlanningConfig configures the planning pattern
type PlanningPattern ¶
type PlanningPattern struct {
// contains filtered or unexported fields
}
PlanningPattern creates and executes plans
func NewPlanningPattern ¶
func NewPlanningPattern(executor AgentExecutor, config PlanningConfig) *PlanningPattern
NewPlanningPattern creates a new planning pattern
func (*PlanningPattern) Execute ¶
func (p *PlanningPattern) Execute(ctx context.Context, input string) (*PlanningResult, error)
Execute creates a plan and executes it
type PlanningResult ¶
type PlanningResult struct {
Plan *Plan
StepResults []StepResult
FinalOutput string
ReplanCount int
TotalDuration int64
}
PlanningResult contains the full planning and execution result
type QualityAssessor ¶
type QualityAssessor func(ctx context.Context, iteration int, output string) (score float64, continueIterating bool)
QualityAssessor evaluates output quality and determines if improvement is needed Returns a score (0.0-1.0) and whether to continue iterating
type Reducer ¶
type Reducer func(results []ExecutionResult) (string, error)
Reducer combines results from map phase
type ReflectionConfig ¶
type ReflectionConfig struct {
MaxIterations int // Maximum iterations
Timeout time.Duration // Timeout per iteration
QualityThreshold float64 // Stop when quality reaches this level
ConvergenceWindow int // Number of iterations to check for convergence
ConvergenceEpsilon float64 // Minimum improvement to not be considered converged
QualityAssessor QualityAssessor // Function to assess quality
}
ReflectionConfig configures the reflection pattern
type ReflectionPattern ¶
type ReflectionPattern struct {
// contains filtered or unexported fields
}
ReflectionPattern implements self-improvement through iterative feedback
func NewReflectionPattern ¶
func NewReflectionPattern(executor AgentExecutor, config ReflectionConfig) *ReflectionPattern
NewReflectionPattern creates a new reflection pattern
func (*ReflectionPattern) Execute ¶
func (r *ReflectionPattern) Execute(ctx context.Context, agentName, input string) ([]ReflectionResult, error)
Execute runs the reflection loop
type ReflectionResult ¶
type ReflectionResult struct {
Iteration int
Output string
Score float64
Error error
Duration int64
}
ReflectionResult represents the result of a reflection iteration
func GetBestResult ¶
func GetBestResult(results []ReflectionResult) *ReflectionResult
GetBestResult returns the result with the highest score
type SequentialConfig ¶
type SequentialConfig struct {
ErrorStrategy ErrorStrategy // How to handle errors
Timeout time.Duration // Timeout per agent
BranchFn func(string) string // Optional: determine next agent based on output
}
SequentialConfig configures sequential execution
type SequentialPattern ¶
type SequentialPattern struct {
// contains filtered or unexported fields
}
SequentialPattern executes agents in sequence, passing output as input
func NewSequentialPattern ¶
func NewSequentialPattern(executor AgentExecutor, config SequentialConfig) *SequentialPattern
NewSequentialPattern creates a new sequential execution pattern
func (*SequentialPattern) Execute ¶
func (s *SequentialPattern) Execute(ctx context.Context, agents []string, input string) ([]ExecutionResult, error)
Execute runs agents in sequence
type StepResult ¶
type StepResult struct {
StepID string
AgentName string
Output string
Error error
Duration int64
Skipped bool
}
StepResult represents the result of a plan step
type Summarizer ¶
Summarizer creates a summary from multiple outputs