Documentation
¶
Index ¶
- Variables
- func FunctionToDefinition(af AgentFunction) llm.Function
- func ProcessAndPrintResponse(response Response)
- func RunDemoLoop(client *Swarm, agent *Agent)
- func RunDemoLoopWithConfig(client *Swarm, agent *Agent, config *DemoLoopConfig)
- type Agent
- func (a *Agent) WithConfig(config *ClientConfig) *Agent
- func (a *Agent) WithFunctions(functions []AgentFunction) *Agent
- func (a *Agent) WithInstructions(instructions string) *Agent
- func (a *Agent) WithInstructionsFunc(f func(map[string]interface{}) string) *Agent
- func (a *Agent) WithParallelToolCalls(enabled bool) *Agent
- type AgentConfig
- type AgentFunction
- type AgentSpec
- type ClientConfig
- type ConcurrentResult
- type ConcurrentSwarm
- type ConditionFunc
- type Config
- type CycleHandling
- type DataFlowSpec
- type DefaultStreamHandler
- type DemoLoopConfig
- type DynamicWorkflowCreator
- func (dwc *DynamicWorkflowCreator) BuildWorkflow(spec *WorkflowSpec) (*Workflow, error)
- func (dwc *DynamicWorkflowCreator) CreateAndExecuteWorkflow(ctx context.Context, userTask string) (*WorkflowResult, error)
- func (dwc *DynamicWorkflowCreator) CreateWorkflowFromTask(ctx context.Context, userTask string) (*WorkflowSpec, error)
- func (dwc *DynamicWorkflowCreator) RegisterBaseAgent(name string, agent *Agent)
- type Edge
- type EdgeType
- type FailureHandler
- type Graph
- func (g *Graph) AddAgentNode(id NodeID, name string, agent *Agent) *Node
- func (g *Graph) AddConditionalEdge(from NodeID, to NodeID, condition ConditionFunc) error
- func (g *Graph) AddDirectedEdge(from NodeID, to NodeID) error
- func (g *Graph) AddEventHook(event string, hook func(state GraphState))
- func (g *Graph) AddExitPoint(nodeID NodeID) error
- func (g *Graph) AddNode(id NodeID, name string, process NodeFunc) *Node
- func (g *Graph) ExecuteGraph(ctx context.Context, initialState GraphState) (GraphState, error)
- func (g *Graph) SetEntryPoint(nodeID NodeID) error
- type GraphBuilder
- func (b *GraphBuilder) Build() *Graph
- func (b *GraphBuilder) WithAgent(id NodeID, name string, agent *Agent) *GraphBuilder
- func (b *GraphBuilder) WithConditionalEdge(from NodeID, to NodeID, condition ConditionFunc) *GraphBuilder
- func (b *GraphBuilder) WithEdge(from NodeID, to NodeID) *GraphBuilder
- func (b *GraphBuilder) WithEntryPoint(nodeID NodeID) *GraphBuilder
- func (b *GraphBuilder) WithExitPoint(nodeID NodeID) *GraphBuilder
- func (b *GraphBuilder) WithNode(id NodeID, name string, process NodeFunc) *GraphBuilder
- type GraphRunner
- type GraphState
- type LogLevel
- type Memory
- type MemoryStore
- func (ms *MemoryStore) AddMemory(memory Memory)
- func (ms *MemoryStore) GetRecentMemories(n int) []Memory
- func (ms *MemoryStore) LoadMemories(data []byte) error
- func (ms *MemoryStore) SearchMemories(memoryType string, context map[string]interface{}) []Memory
- func (ms *MemoryStore) SerializeMemories() ([]byte, error)
- type Node
- func CreateAgentNode(g *Graph, id NodeID, name string, instructions string, model string, ...) *Node
- func CreateHumanInputNode(g *Graph, id NodeID, prompt string) *Node
- func CreateParallelNode(g *Graph, id NodeID, parallelProcesses []NodeFunc) *Node
- func CreateRouterNode(g *Graph, id NodeID, destinations map[string]NodeID) *Node
- type NodeFunc
- type NodeID
- type RateLimitStrategy
- type Response
- type Result
- type StateKey
- type StepResult
- type StreamHandler
- type Swarm
- func NewSwarm(apiKey string, provider llm.LLMProvider) *Swarm
- func NewSwarmWithConfig(apiKey string, provider llm.LLMProvider, config *Config) *Swarm
- func NewSwarmWithCustomProvider(providerImpl llm.LLM, config *Config) *Swarm
- func NewSwarmWithHost(apiKey, host string, provider llm.LLMProvider) *Swarm
- func (s *Swarm) IsInitialized() bool
- func (s *Swarm) Run(ctx context.Context, agent *Agent, messages []llm.Message, ...) (Response, error)
- func (s *Swarm) SetTokenCounter(counter func(string) int)
- func (s *Swarm) StreamingResponse(ctx context.Context, agent *Agent, messages []llm.Message, ...) error
- func (s *Swarm) ValidateConnection(ctx context.Context) error
- type TeamType
- type ToolResult
- type Workflow
- func (wf *Workflow) AddAgent(agent *Agent)
- func (wf *Workflow) AddAgentToTeam(agent *Agent, team TeamType)
- func (wf *Workflow) ConnectAgents(fromAgent, toAgent string) error
- func (wf *Workflow) Execute(startAgent string, userRequest string) (*WorkflowResult, error)
- func (wf *Workflow) GetAgents() map[string]*Agent
- func (wf *Workflow) GetAllStepResults() []StepResult
- func (wf *Workflow) GetConnections() map[string][]string
- func (wf *Workflow) GetCurrentAgent() string
- func (wf *Workflow) GetLastStepResult() (*StepResult, error)
- func (wf *Workflow) GetRoutingLog() []string
- func (wf *Workflow) GetStepResult(stepNumber int) (*StepResult, error)
- func (wf *Workflow) GetTeamLeaders() map[TeamType]string
- func (wf *Workflow) GetTeams() map[TeamType][]*Agent
- func (wf *Workflow) SetCycleCallback(callback func(from, to string) (bool, error))
- func (wf *Workflow) SetCycleHandling(handling CycleHandling)
- func (wf *Workflow) SetTeamLeader(agentName string, team TeamType) error
- type WorkflowResult
- type WorkflowSpec
- type WorkflowType
Constants ¶
This section is empty.
Variables ¶
var ( // DemoLoop specific errors ErrDemoLoopInterrupted = errors.New("demo loop interrupted by user") ErrAgentExecutionFailed = errors.New("agent execution failed") )
var ( // Define common errors for better error handling ErrNilAgent = errors.New("agent cannot be nil") ErrEmptyMessages = errors.New("message history cannot be empty") ErrLLMClientNotReady = errors.New("LLM client is not initialized") ErrInvalidProvider = errors.New("invalid LLM provider specified") ErrNoChoicesInResp = errors.New("no choices in LLM response") ErrMessageTooLong = errors.New("message exceeds maximum token limit") )
Functions ¶
func FunctionToDefinition ¶
func FunctionToDefinition(af AgentFunction) llm.Function
FunctionToDefinition converts an AgentFunction to a llm.Function
func ProcessAndPrintResponse ¶
func ProcessAndPrintResponse(response Response)
ProcessAndPrintResponse processes and prints the response from the LLM. It uses different colors for different roles: blue for "assistant" and magenta for "function" or "tool".
func RunDemoLoop ¶
RunDemoLoop starts an interactive CLI loop for conversing with an agent
func RunDemoLoopWithConfig ¶
func RunDemoLoopWithConfig(client *Swarm, agent *Agent, config *DemoLoopConfig)
RunDemoLoopWithConfig starts an interactive CLI loop with custom configuration
Types ¶
type Agent ¶
type Agent struct {
Name string // The name of the agent.
Model string // The model identifier.
Provider llm.LLMProvider // The LLM provider to use.
Config *ClientConfig // Provider-specific configuration.
Instructions string // Static instructions for the agent.
InstructionsFunc func(contextVariables map[string]interface{}) string // Function to generate dynamic instructions based on context.
Functions []AgentFunction // A list of functions the agent can perform.
Memory *MemoryStore // Memory store for the agent.
ParallelToolCalls bool // Whether to allow parallel tool calls.
}
Agent represents an entity with specific attributes and behaviors.
func NewAgent ¶
func NewAgent(name, model string, provider llm.LLMProvider) *Agent
NewAgent creates a new agent with initialized memory store
func (*Agent) WithConfig ¶
func (a *Agent) WithConfig(config *ClientConfig) *Agent
WithConfig sets the configuration for the agent
func (*Agent) WithFunctions ¶
func (a *Agent) WithFunctions(functions []AgentFunction) *Agent
WithFunctions sets the functions available to the agent
func (*Agent) WithInstructions ¶
WithInstructions sets the static instructions for the agent
func (*Agent) WithInstructionsFunc ¶
WithInstructionsFunc sets the dynamic instructions function for the agent
func (*Agent) WithParallelToolCalls ¶
WithParallelToolCalls enables or disables parallel tool calls
type AgentConfig ¶
type AgentConfig struct {
Agent *Agent
Messages []llm.Message
ContextVariables map[string]interface{}
ModelOverride string
Stream bool
Debug bool
MaxTurns int
ExecuteTools bool
}
AgentConfig holds the configuration for a single agent execution
type AgentFunction ¶
type AgentFunction struct {
Name string // The name of the function.
Description string // Description of what the function does.
Parameters map[string]interface{} // Parameters for the function.
Function func(args map[string]interface{}, contextVariables map[string]interface{}) Result // The actual function implementation.
}
AgentFunction represents a function that can be performed by an agent
type AgentSpec ¶
type AgentSpec struct {
Name string `json:"name"`
Role string `json:"role"`
Instructions string `json:"instructions"`
Model string `json:"model"`
Connections []string `json:"connections"`
}
AgentSpec represents a specification for an agent
type ClientConfig ¶
type ClientConfig struct {
Provider llm.LLMProvider
AuthToken string
BaseURL string
OrgID string
APIVersion string
AssistantVersion string
ModelMapperFunc func(model string) string // replace model to provider-specific deployment name
HTTPClient *http.Client
EmptyMessagesLimit uint
Options map[string]interface{} // Additional provider-specific options
}
ClientConfig represents the configuration for an LLM client
type ConcurrentResult ¶
ConcurrentResult represents the result from a single agent's execution
type ConcurrentSwarm ¶
type ConcurrentSwarm struct {
*Swarm
}
ConcurrentSwarm manages concurrent execution of multiple agents
func NewConcurrentSwarm ¶
func NewConcurrentSwarm(apiKey string, provider llm.LLMProvider) *ConcurrentSwarm
NewConcurrentSwarm creates a new ConcurrentSwarm instance
func (*ConcurrentSwarm) RunConcurrent ¶
func (cs *ConcurrentSwarm) RunConcurrent(ctx context.Context, configs map[string]AgentConfig) []ConcurrentResult
RunConcurrent executes multiple agents concurrently and returns their results
func (*ConcurrentSwarm) RunConcurrentOrdered ¶
func (cs *ConcurrentSwarm) RunConcurrentOrdered(ctx context.Context, orderedConfigs []struct { Name string Config AgentConfig }) []ConcurrentResult
RunConcurrentOrdered executes multiple agents concurrently and returns their results in the order specified
type ConditionFunc ¶
type ConditionFunc func(state GraphState) (NodeID, error)
ConditionFunc determines which edge to follow from a node
type Config ¶
type Config struct {
MaxRetries int
RetryBackoff time.Duration
RequestTimeout time.Duration
MaxTokens int
DefaultModel string
Debug bool
LogLevel LogLevel
TokenLimits map[string]int // Model-specific token limits
FailureHandlers []FailureHandler
RateLimitStrategy RateLimitStrategy
}
Config holds configuration options for Swarm
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns default configuration values
type CycleHandling ¶
type CycleHandling int
CycleHandling represents how to handle detected cycles
const ( StopOnCycle CycleHandling = iota ContinueOnCycle )
type DataFlowSpec ¶
type DataFlowSpec struct {
From string `json:"from"`
To string `json:"to"`
Description string `json:"description"`
}
DataFlowSpec represents a data flow between agents
type DefaultStreamHandler ¶
type DefaultStreamHandler struct{}
DefaultStreamHandler provides a basic implementation of StreamHandler
func (*DefaultStreamHandler) OnComplete ¶
func (h *DefaultStreamHandler) OnComplete(message llm.Message)
func (*DefaultStreamHandler) OnError ¶
func (h *DefaultStreamHandler) OnError(err error)
func (*DefaultStreamHandler) OnStart ¶
func (h *DefaultStreamHandler) OnStart()
func (*DefaultStreamHandler) OnToken ¶
func (h *DefaultStreamHandler) OnToken(token string)
func (*DefaultStreamHandler) OnToolCall ¶
func (h *DefaultStreamHandler) OnToolCall(toolCall llm.ToolCall)
type DemoLoopConfig ¶
type DemoLoopConfig struct {
Timeout time.Duration // Timeout for each agent execution
MaxHistoryMessages int // Maximum number of messages to keep in history
MaxInputLength int // Maximum length of user input
ShowFunctionResults bool // Whether to display function results
ColorOutput bool // Whether to use color in output
Debug bool // Whether to show debug information
SaveHistory bool // Whether to save conversation history to file
HistoryFile string // Path to file for saving history
}
DemoLoopConfig contains configuration options for the demo loop
func DefaultDemoLoopConfig ¶
func DefaultDemoLoopConfig() *DemoLoopConfig
DefaultDemoLoopConfig returns default configuration for demo loop
type DynamicWorkflowCreator ¶
type DynamicWorkflowCreator struct {
// contains filtered or unexported fields
}
DynamicWorkflowCreator helps construct workflows dynamically based on user tasks
func NewDynamicWorkflowCreator ¶
func NewDynamicWorkflowCreator(apiKey string, provider llm.LLMProvider) *DynamicWorkflowCreator
NewDynamicWorkflowCreator creates a new workflow creator
func (*DynamicWorkflowCreator) BuildWorkflow ¶
func (dwc *DynamicWorkflowCreator) BuildWorkflow(spec *WorkflowSpec) (*Workflow, error)
BuildWorkflow creates a concrete Workflow instance from a WorkflowSpec
func (*DynamicWorkflowCreator) CreateAndExecuteWorkflow ¶
func (dwc *DynamicWorkflowCreator) CreateAndExecuteWorkflow(ctx context.Context, userTask string) (*WorkflowResult, error)
CreateAndExecuteWorkflow is a convenience method to create and execute a workflow in one step
func (*DynamicWorkflowCreator) CreateWorkflowFromTask ¶
func (dwc *DynamicWorkflowCreator) CreateWorkflowFromTask(ctx context.Context, userTask string) (*WorkflowSpec, error)
CreateWorkflowFromTask generates a workflow specification based on a user task
func (*DynamicWorkflowCreator) RegisterBaseAgent ¶
func (dwc *DynamicWorkflowCreator) RegisterBaseAgent(name string, agent *Agent)
RegisterBaseAgent adds a pre-defined agent template
type Edge ¶
type Edge struct {
From NodeID
To NodeID
Type EdgeType
Condition ConditionFunc // For conditional edges
Metadata map[string]interface{}
}
Edge represents a connection between nodes
type FailureHandler ¶
FailureHandler defines a function to handle specific failures
type Graph ¶
type Graph struct {
ID string
Name string
Description string
Nodes map[NodeID]*Node
Edges map[NodeID][]Edge
EntryPoint NodeID
ExitPoints []NodeID // Optional exit points
// contains filtered or unexported fields
}
Graph represents the workflow graph
func (*Graph) AddAgentNode ¶
AddAgentNode adds a node with an associated agent
func (*Graph) AddConditionalEdge ¶
func (g *Graph) AddConditionalEdge(from NodeID, to NodeID, condition ConditionFunc) error
AddConditionalEdge adds an edge with a condition
func (*Graph) AddDirectedEdge ¶
AddDirectedEdge adds a simple directed edge between nodes
func (*Graph) AddEventHook ¶
func (g *Graph) AddEventHook(event string, hook func(state GraphState))
AddEventHook adds a hook for graph events
func (*Graph) AddExitPoint ¶
AddExitPoint adds an exit point to the graph
func (*Graph) ExecuteGraph ¶
func (g *Graph) ExecuteGraph(ctx context.Context, initialState GraphState) (GraphState, error)
ExecuteGraph runs the workflow graph from the entry point
func (*Graph) SetEntryPoint ¶
SetEntryPoint sets the entry point for the graph
type GraphBuilder ¶
type GraphBuilder struct {
// contains filtered or unexported fields
}
GraphBuilder provides a fluent interface for building graphs
func NewGraphBuilder ¶
func NewGraphBuilder(name, description string) *GraphBuilder
NewGraphBuilder creates a new graph builder
func (*GraphBuilder) Build ¶
func (b *GraphBuilder) Build() *Graph
Build returns the constructed graph
func (*GraphBuilder) WithAgent ¶
func (b *GraphBuilder) WithAgent(id NodeID, name string, agent *Agent) *GraphBuilder
WithAgent adds an agent node to the graph
func (*GraphBuilder) WithConditionalEdge ¶
func (b *GraphBuilder) WithConditionalEdge(from NodeID, to NodeID, condition ConditionFunc) *GraphBuilder
WithConditionalEdge adds a conditional edge between nodes
func (*GraphBuilder) WithEdge ¶
func (b *GraphBuilder) WithEdge(from NodeID, to NodeID) *GraphBuilder
WithEdge adds a directed edge between nodes
func (*GraphBuilder) WithEntryPoint ¶
func (b *GraphBuilder) WithEntryPoint(nodeID NodeID) *GraphBuilder
WithEntryPoint sets the entry point for the graph
func (*GraphBuilder) WithExitPoint ¶
func (b *GraphBuilder) WithExitPoint(nodeID NodeID) *GraphBuilder
WithExitPoint adds an exit point to the graph
func (*GraphBuilder) WithNode ¶
func (b *GraphBuilder) WithNode(id NodeID, name string, process NodeFunc) *GraphBuilder
WithNode adds a generic node to the graph
type GraphRunner ¶
type GraphRunner struct {
// contains filtered or unexported fields
}
GraphRunner handles the execution of workflow graphs
func (*GraphRunner) ExecuteGraph ¶
func (r *GraphRunner) ExecuteGraph(ctx context.Context, graphID string, initialState GraphState) (GraphState, error)
ExecuteGraph runs a graph with the given initial state
func (*GraphRunner) RegisterGraph ¶
func (r *GraphRunner) RegisterGraph(graph *Graph)
RegisterGraph adds a graph to the runner
type GraphState ¶
type GraphState map[StateKey]interface{}
GraphState represents the current state of the workflow
func (GraphState) Clone ¶
func (s GraphState) Clone() GraphState
Clone creates a deep copy of the state
func (GraphState) Get ¶
func (s GraphState) Get(key StateKey) interface{}
Get retrieves a value from state, with type assertion
func (GraphState) GetBool ¶
func (s GraphState) GetBool(key StateKey) (bool, bool)
GetBool gets a boolean value from state
func (GraphState) GetString ¶
func (s GraphState) GetString(key StateKey) (string, bool)
GetString gets a string value from state
func (GraphState) UpdateState ¶
func (s GraphState) UpdateState(updates GraphState)
UpdateState updates the state with new values
type Memory ¶
type Memory struct {
Content string `json:"content"` // The actual memory content
Type string `json:"type"` // Type of memory (e.g., "conversation", "fact", "task")
Context map[string]interface{} `json:"context"` // Associated context
Timestamp time.Time `json:"timestamp"` // When the memory was created
Importance float64 `json:"importance"` // Importance score (0-1)
References []string `json:"references"` // References to related memories
}
Memory represents a single memory entry
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore manages agent memories
func NewMemoryStore ¶
func NewMemoryStore(maxShortTerm int) *MemoryStore
NewMemoryStore creates a new memory store with default settings
func (*MemoryStore) AddMemory ¶
func (ms *MemoryStore) AddMemory(memory Memory)
AddMemory adds a new memory to both short and long-term storage
func (*MemoryStore) GetRecentMemories ¶
func (ms *MemoryStore) GetRecentMemories(n int) []Memory
GetRecentMemories retrieves the n most recent memories
func (*MemoryStore) LoadMemories ¶
func (ms *MemoryStore) LoadMemories(data []byte) error
LoadMemories loads memories from JSON data
func (*MemoryStore) SearchMemories ¶
func (ms *MemoryStore) SearchMemories(memoryType string, context map[string]interface{}) []Memory
SearchMemories searches for memories based on type and context
func (*MemoryStore) SerializeMemories ¶
func (ms *MemoryStore) SerializeMemories() ([]byte, error)
SerializeMemories serializes all memories to JSON
type Node ¶
type Node struct {
ID NodeID
Name string
Description string
Process NodeFunc
Agent *Agent // Optional agent associated with this node
Metadata map[string]interface{}
}
Node represents a node in the workflow graph
func CreateAgentNode ¶
func CreateAgentNode(g *Graph, id NodeID, name string, instructions string, model string, functions []AgentFunction, provider llm.LLMProvider) *Node
CreateAgentNode is a helper function to create common agent node types
func CreateHumanInputNode ¶
CreateHumanInputNode creates a node that collects input from a human
func CreateParallelNode ¶
CreateParallelNode creates a node that processes tasks in parallel
type NodeFunc ¶
type NodeFunc func(ctx context.Context, state GraphState) (GraphState, error)
NodeFunc is a function that processes state and returns updates
type NodeID ¶
type NodeID string
NodeID represents a unique identifier for a node in the workflow graph
type RateLimitStrategy ¶
type RateLimitStrategy int
RateLimitStrategy defines how rate limits are handled
const ( RateLimitRetry RateLimitStrategy = iota RateLimitFail RateLimitQueue )
type Response ¶
type Response struct {
Messages []llm.Message
Agent *Agent
ContextVariables map[string]interface{}
ToolResults []ToolResult // Results from tool calls
}
Response represents the response from an agent
type Result ¶
type Result struct {
Success bool // Whether the function execution was successful
Data interface{} // Any data returned by the function
Error error // Any error that occurred during execution
Agent *Agent // Active agent
}
Result represents the result of a function execution
type StateKey ¶
type StateKey string
StateKey represents a key in the state map
const MessageKey StateKey = "messages"
MessageKey is the default key for storing messages in state
type StepResult ¶
type StepResult struct {
AgentName string
Input []llm.Message
Output []llm.Message
Error error
StartTime time.Time
EndTime time.Time
NextAgent string
StepNumber int
}
StepResult represents the outcome of a single workflow step
type StreamHandler ¶
type StreamHandler interface {
OnStart()
OnToken(token string)
OnToolCall(toolCall llm.ToolCall)
OnComplete(message llm.Message)
OnError(err error)
}
StreamHandler represents a handler for streaming responses
type Swarm ¶
type Swarm struct {
// contains filtered or unexported fields
}
Swarm represents the main structure
func NewSwarm ¶
func NewSwarm(apiKey string, provider llm.LLMProvider) *Swarm
NewSwarm initializes a new Swarm instance with an LLM client
func NewSwarmWithConfig ¶
func NewSwarmWithConfig(apiKey string, provider llm.LLMProvider, config *Config) *Swarm
NewSwarmWithConfig initializes a new Swarm with custom configuration
func NewSwarmWithCustomProvider ¶
NewSwarmWithCustomProvider creates a Swarm with a custom LLM provider implementation
func NewSwarmWithHost ¶
func NewSwarmWithHost(apiKey, host string, provider llm.LLMProvider) *Swarm
NewSwarmWithHost creates a Swarm with a custom host
func (*Swarm) IsInitialized ¶
IsInitialized returns whether the Swarm is properly initialized
func (*Swarm) Run ¶
func (s *Swarm) Run( ctx context.Context, agent *Agent, messages []llm.Message, contextVariables map[string]interface{}, modelOverride string, stream bool, debug bool, maxTurns int, executeTools bool, ) (Response, error)
Run is the main entry point for agent execution
func (*Swarm) SetTokenCounter ¶
SetTokenCounter sets a function to count tokens in messages
type ToolResult ¶
type ToolResult struct {
ToolName string // Name of the tool that was called
Args interface{} // Arguments passed to the tool
Result Result // Result returned by the tool
}
ToolResult represents the result of a tool call
type Workflow ¶
type Workflow struct {
// contains filtered or unexported fields
}
Workflow represents a collection of agents and their connections.
func NewWorkflow ¶
func NewWorkflow(apikey string, provider llm.LLMProvider, workflowType WorkflowType) *Workflow
NewWorkflow initializes a new Workflow instance.
func (*Workflow) AddAgentToTeam ¶
AddAgentToTeam adds an agent to a specific team
func (*Workflow) ConnectAgents ¶
ConnectAgents creates a connection between two agents.
func (*Workflow) Execute ¶
func (wf *Workflow) Execute(startAgent string, userRequest string) (*WorkflowResult, error)
Execute runs the workflow and returns detailed results including step outcomes
func (*Workflow) GetAllStepResults ¶
func (wf *Workflow) GetAllStepResults() []StepResult
GetAllStepResults returns all step results
func (*Workflow) GetConnections ¶
GetConnections returns all connections in the workflow
func (*Workflow) GetCurrentAgent ¶
GetCurrentAgent returns the currently active agent
func (*Workflow) GetLastStepResult ¶
func (wf *Workflow) GetLastStepResult() (*StepResult, error)
GetLastStepResult returns the result of the last executed step
func (*Workflow) GetRoutingLog ¶
GetRoutingLog returns the routing history
func (*Workflow) GetStepResult ¶
func (wf *Workflow) GetStepResult(stepNumber int) (*StepResult, error)
GetStepResult returns the result of a specific step
func (*Workflow) GetTeamLeaders ¶
GetTeamLeaders returns all team leaders in the workflow
func (*Workflow) SetCycleCallback ¶
SetCycleCallback sets a callback function to be called when a cycle is detected
func (*Workflow) SetCycleHandling ¶
func (wf *Workflow) SetCycleHandling(handling CycleHandling)
SetCycleHandling sets how cycles should be handled
type WorkflowResult ¶
type WorkflowResult struct {
Steps []StepResult
FinalOutput []llm.Message
Error error
StartTime time.Time
EndTime time.Time
}
WorkflowResult represents the complete workflow execution result
type WorkflowSpec ¶
type WorkflowSpec struct {
MainGoal string `json:"mainGoal"`
WorkflowType string `json:"workflowType"`
Agents []AgentSpec `json:"agents"`
DataFlow []DataFlowSpec `json:"dataFlow"`
EntryPoint string `json:"entryPoint"`
}
WorkflowSpec represents the specification for a dynamic workflow
type WorkflowType ¶
type WorkflowType int
WorkflowType defines the type of agent interaction pattern
const ( CollaborativeWorkflow WorkflowType = iota SupervisorWorkflow HierarchicalWorkflow )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
agenthandoff
command
|
|
|
basic
command
|
|
|
collaborative
command
|
|
|
contextvariables
command
|
|
|
customproivder
command
|
|
|
deepseekagent
command
|
|
|
dynamicworkflow
command
|
|
|
file_analyzer_stream
command
|
|
|
fileanalyzer2
command
|
|
|
functioncall
command
|
|
|
gemini
command
|
|
|
hierarchical
command
|
|
|
memory_demo
command
|
|
|
ollama
command
|
|
|
openrouter
command
|
|
|
openrouter/fileanalyzer
command
|
|
|
personalshopper
command
|
|
|
sdlc-agents
command
|
|
|
streaming_example
command
|
|
|
supervisor
command
|
|
|
swarmgraph_complex
command
|
|
|
taskmanager
command
|
|
|
toolresults
command
|
|
|
triageagent
command
|
|
|
weatheragent
command
|
|
