Documentation
¶
Index ¶
- func ConcatAggregator(separator string) func(results map[string]*agent.Message) (*agent.Message, error)
- func FirstSuccessAggregator() func(results map[string]*agent.Message) (*agent.Message, error)
- func MajorityVoteAggregator() func(results map[string]*agent.Message) (*agent.Message, error)
- type BaseOrchestrator
- func (b *BaseOrchestrator) Execute(ctx context.Context, input *agent.Message) (*agent.Message, error)
- func (b *BaseOrchestrator) Name() string
- func (b *BaseOrchestrator) Pattern() string
- func (b *BaseOrchestrator) Ready() bool
- func (b *BaseOrchestrator) Runtime() agent.Runtime
- func (b *BaseOrchestrator) SetReady(ready bool)
- func (b *BaseOrchestrator) Start(ctx context.Context) error
- func (b *BaseOrchestrator) Stop(ctx context.Context) error
- type ConversationTurn
- type Ensemble
- func NewContentModerationEnsemble(name string, runtime agent.Runtime, models []string) *Ensemble
- func NewEnsemble(name string, runtime agent.Runtime, models []string, opts ...EnsembleOption) *Ensemble
- func NewFinancialForecastEnsemble(name string, runtime agent.Runtime, models []string) *Ensemble
- func NewMedicalDiagnosisEnsemble(name string, runtime agent.Runtime, models []string) *Ensemble
- type EnsembleOption
- type HandoffInstruction
- type Hierarchical
- func NewEnterpriseWorkflow(name string, runtime agent.Runtime, departments map[string][]string) *Hierarchical
- func NewHierarchical(name string, runtime agent.Runtime, manager string, teams map[string][]string, ...) *Hierarchical
- func NewProjectManager(name string, runtime agent.Runtime) *Hierarchical
- type HierarchicalOption
- type Orchestrator
- type Parallel
- type ParallelOption
- type RAG
- func NewConversationalRAG(name string, runtime agent.Runtime, retriever, generator string, ...) *RAG
- func NewHybridRAG(name string, runtime agent.Runtime, ...) *RAG
- func NewMultiQueryRAG(name string, runtime agent.Runtime, queryExpander, retriever, generator string) *RAG
- func NewRAG(name string, runtime agent.Runtime, retriever, generator string, ...) *RAG
- type RAGOption
- type Reflection
- func NewMultiCriticReflection(name string, runtime agent.Runtime, generator string, critics []string, ...) *Reflection
- func NewReflection(name string, runtime agent.Runtime, generator, critic string, ...) *Reflection
- func NewSelfReflection(name string, runtime agent.Runtime, agent string, maxIterations int) *Reflection
- type ReflectionOption
- type Router
- func NewCostOptimizingRouter(name string, runtime agent.Runtime, classifier string) *Router
- func NewIntentRouter(name string, runtime agent.Runtime, classifier string, ...) *Router
- func NewRouter(name string, runtime agent.Runtime, classifier string, ...) *Router
- func NewSkillRouter(name string, runtime agent.Runtime, classifier string, ...) *Router
- type RouterOption
- type Swarm
- type SwarmOption
- type VotingStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConcatAggregator ¶
func ConcatAggregator(separator string) func(results map[string]*agent.Message) (*agent.Message, error)
ConcatAggregator concatenates all text results
func FirstSuccessAggregator ¶
FirstSuccessAggregator returns the first successful result
Types ¶
type BaseOrchestrator ¶
type BaseOrchestrator struct {
// contains filtered or unexported fields
}
BaseOrchestrator provides common functionality for orchestrators
func NewBaseOrchestrator ¶
func NewBaseOrchestrator(name, pattern string, runtime agent.Runtime) *BaseOrchestrator
NewBaseOrchestrator creates a new base orchestrator
func (*BaseOrchestrator) Execute ¶
func (b *BaseOrchestrator) Execute(ctx context.Context, input *agent.Message) (*agent.Message, error)
Execute provides a default implementation that returns an error
func (*BaseOrchestrator) Name ¶
func (b *BaseOrchestrator) Name() string
Name returns the orchestrator identifier
func (*BaseOrchestrator) Pattern ¶
func (b *BaseOrchestrator) Pattern() string
Pattern returns the pattern type
func (*BaseOrchestrator) Ready ¶
func (b *BaseOrchestrator) Ready() bool
Ready returns true if the orchestrator is ready
func (*BaseOrchestrator) Runtime ¶
func (b *BaseOrchestrator) Runtime() agent.Runtime
Runtime returns the runtime
func (*BaseOrchestrator) SetReady ¶
func (b *BaseOrchestrator) SetReady(ready bool)
SetReady sets the ready state
type ConversationTurn ¶ added in v0.4.0
ConversationTurn represents a single turn in conversation history
type Ensemble ¶
type Ensemble struct {
*BaseOrchestrator
// contains filtered or unexported fields
}
Ensemble implements multi-model voting for improved accuracy. Multiple models generate outputs and vote on the best result. Provides 25-50% error reduction in high-stakes decisions.
Use cases: - Medical diagnosis - Financial forecasting - Content moderation - Critical decision-making
func NewContentModerationEnsemble ¶
NewContentModerationEnsemble creates an ensemble for content moderation
func NewEnsemble ¶
func NewEnsemble(name string, runtime agent.Runtime, models []string, opts ...EnsembleOption) *Ensemble
NewEnsemble creates a new Ensemble orchestrator
func NewFinancialForecastEnsemble ¶
NewFinancialForecastEnsemble creates an ensemble for financial forecasting
func NewMedicalDiagnosisEnsemble ¶
NewMedicalDiagnosisEnsemble creates an ensemble for medical diagnosis
type EnsembleOption ¶
type EnsembleOption func(*Ensemble)
EnsembleOption configures an Ensemble orchestrator
func WithAgreementThreshold ¶
func WithAgreementThreshold(threshold float64) EnsembleOption
WithAgreementThreshold sets the minimum agreement threshold
func WithVotingStrategy ¶
func WithVotingStrategy(strategy VotingStrategy) EnsembleOption
WithVotingStrategy sets the voting strategy
type HandoffInstruction ¶
HandoffInstruction represents a handoff instruction from an agent
type Hierarchical ¶
type Hierarchical struct {
*BaseOrchestrator
// contains filtered or unexported fields
}
Hierarchical implements multi-level delegation pattern. Managers delegate to sub-managers who delegate to workers. Perfect for complex task decomposition and organizational hierarchies.
Use cases: - Enterprise workflows - Project management - Complex multi-step processes - Organizational hierarchies
func NewEnterpriseWorkflow ¶
func NewEnterpriseWorkflow(name string, runtime agent.Runtime, departments map[string][]string) *Hierarchical
NewEnterpriseWorkflow creates a hierarchical orchestrator for enterprise workflows
func NewHierarchical ¶
func NewHierarchical(name string, runtime agent.Runtime, manager string, teams map[string][]string, opts ...HierarchicalOption) *Hierarchical
NewHierarchical creates a new Hierarchical orchestrator
func NewProjectManager ¶
func NewProjectManager(name string, runtime agent.Runtime) *Hierarchical
NewProjectManager creates a hierarchical orchestrator for project management
type HierarchicalOption ¶
type HierarchicalOption func(*Hierarchical)
HierarchicalOption configures a Hierarchical orchestrator
func WithMaxDepth ¶
func WithMaxDepth(depth int) HierarchicalOption
WithMaxDepth sets the maximum delegation depth
type Orchestrator ¶
type Orchestrator interface {
// Name returns the orchestrator identifier
Name() string
// Pattern returns the pattern type (e.g., "parallel", "router", "rag")
Pattern() string
// Execute runs the orchestration pattern synchronously
Execute(ctx context.Context, input *agent.Message) (*agent.Message, error)
// Start runs the orchestration pattern asynchronously
Start(ctx context.Context) error
// Stop gracefully shuts down the orchestrator
Stop(ctx context.Context) error
// Ready returns true if the orchestrator is ready
Ready() bool
}
Orchestrator defines the interface for agent orchestration patterns. All orchestration patterns implement this interface.
type Parallel ¶
type Parallel struct {
*BaseOrchestrator
// contains filtered or unexported fields
}
Parallel executes multiple agents concurrently and aggregates results. Provides 3-4× speedup for independent tasks compared to sequential execution.
Use cases: - Multi-source research - Batch processing - A/B testing - Independent data gathering
func NewParallel ¶
func NewParallel(name string, runtime agent.Runtime, agents []string, opts ...ParallelOption) *Parallel
NewParallel creates a new Parallel orchestrator
type ParallelOption ¶
type ParallelOption func(*Parallel)
ParallelOption configures a Parallel orchestrator
func WithAggregateFunc ¶
func WithAggregateFunc(fn func(results map[string]*agent.Message) (*agent.Message, error)) ParallelOption
WithAggregateFunc sets a custom aggregation function
func WithFailFast ¶
func WithFailFast(enabled bool) ParallelOption
WithFailFast enables fail-fast mode (stop on first error)
type RAG ¶
type RAG struct {
*BaseOrchestrator
// contains filtered or unexported fields
}
RAG implements Retrieval-Augmented Generation pattern. Retrieves relevant documents from a vector store, then generates grounded answers. Most common enterprise pattern for chatbots and Q&A systems.
Use cases: - Enterprise chatbots - Documentation Q&A - Knowledge retrieval - Context-aware generation
func NewConversationalRAG ¶
func NewConversationalRAG(name string, runtime agent.Runtime, retriever, generator string, historyAgent string) *RAG
NewConversationalRAG creates a RAG with conversation history tracking
func NewHybridRAG ¶
func NewHybridRAG(name string, runtime agent.Runtime, semanticRetriever, keywordRetriever, generator string) *RAG
NewHybridRAG creates a RAG with both semantic and keyword search
func NewMultiQueryRAG ¶
func NewMultiQueryRAG(name string, runtime agent.Runtime, queryExpander, retriever, generator string) *RAG
NewMultiQueryRAG creates a RAG that generates multiple queries for retrieval
type RAGOption ¶
type RAGOption func(*RAG)
RAGOption configures a RAG orchestrator
func WithReranker ¶
WithReranker enables reranking with the specified agent
type Reflection ¶
type Reflection struct {
*BaseOrchestrator
// contains filtered or unexported fields
}
Reflection implements iterative refinement with self-critique. Generator creates output, critic reviews it, generator refines. Provides 20-50% quality improvement through iterative refinement.
Use cases: - Code generation with review - Content creation with editing - Complex reasoning tasks - Quality assurance
func NewMultiCriticReflection ¶
func NewMultiCriticReflection(name string, runtime agent.Runtime, generator string, critics []string, maxIterations int) *Reflection
NewMultiCriticReflection creates a reflection with multiple critics
func NewReflection ¶
func NewReflection(name string, runtime agent.Runtime, generator, critic string, opts ...ReflectionOption) *Reflection
NewReflection creates a new Reflection orchestrator
func NewSelfReflection ¶
func NewSelfReflection(name string, runtime agent.Runtime, agent string, maxIterations int) *Reflection
NewSelfReflection creates a reflection where generator acts as its own critic
type ReflectionOption ¶
type ReflectionOption func(*Reflection)
ReflectionOption configures a Reflection orchestrator
func WithImprovementThreshold ¶
func WithImprovementThreshold(threshold float64) ReflectionOption
WithImprovementThreshold sets the minimum improvement threshold
func WithMaxIterations ¶
func WithMaxIterations(max int) ReflectionOption
WithMaxIterations sets the maximum number of refinement iterations
type Router ¶
type Router struct {
*BaseOrchestrator
// contains filtered or unexported fields
}
Router routes requests to different agents based on classification. Provides 25-50% cost reduction by routing simple queries to cheaper models.
Use cases: - Cost optimization (simple → cheap, complex → expensive models) - Intent-based routing - Skill-based agent selection - Load balancing
func NewCostOptimizingRouter ¶
NewCostOptimizingRouter creates a router that optimizes for cost Simple queries → cheap models (gpt-3.5, claude-haiku) Complex queries → expensive models (gpt-4, claude-opus)
func NewIntentRouter ¶
func NewIntentRouter(name string, runtime agent.Runtime, classifier string, intentMap map[string]string) *Router
NewIntentRouter creates a router based on user intent
func NewRouter ¶
func NewRouter(name string, runtime agent.Runtime, classifier string, routes map[string]string, opts ...RouterOption) *Router
NewRouter creates a new Router orchestrator
type RouterOption ¶
type RouterOption func(*Router)
RouterOption configures a Router orchestrator
func WithDefaultRoute ¶
func WithDefaultRoute(agent string) RouterOption
WithDefaultRoute sets the fallback agent
type Swarm ¶
type Swarm struct {
*BaseOrchestrator
// contains filtered or unexported fields
}
Swarm implements decentralized agent handoffs based on conversational context. Agents decide when to hand off to other agents dynamically. Popularized by OpenAI Swarm.
Use cases: - Customer service handoffs (general → billing → technical) - Adaptive routing based on conversation flow - Collaborative problem-solving
type SwarmOption ¶
type SwarmOption func(*Swarm)
SwarmOption configures a Swarm orchestrator
func WithMaxHandoffs ¶
func WithMaxHandoffs(max int) SwarmOption
WithMaxHandoffs sets the maximum number of handoffs
type VotingStrategy ¶
type VotingStrategy string
VotingStrategy defines how ensemble votes are aggregated
const ( VotingMajority VotingStrategy = "majority" // Simple majority vote VotingUnanimous VotingStrategy = "unanimous" // All must agree VotingWeighted VotingStrategy = "weighted" // Weighted by model confidence VotingConfidence VotingStrategy = "confidence" // Highest confidence wins )