Documentation
¶
Overview ¶
Package graph provides YAML configuration parsing for graph workflows.
Package graph provides graph orchestration service implementation.
Index ¶
- Variables
- func BuildSimple(configYAML []byte) (*wfgraph.Graph, error)
- type Agent
- type Config
- type Edge
- type ExecuteRequest
- type ExecuteResponse
- type GraphBuilder
- type GraphConfig
- type GraphDefinition
- type GraphInfo
- type Node
- type RateLimit
- type Service
- func (s *Service) Execute(ctx context.Context, g *wfgraph.Graph, request *ExecuteRequest) (*ExecuteResponse, error)
- func (s *Service) ExecuteWithGraphBuilder(ctx context.Context, graphID string, ...) (*ExecuteResponse, error)
- func (s *Service) GetGraphInfo(g *wfgraph.Graph) *GraphInfo
- func (s *Service) ValidateGraph(g *wfgraph.Graph) error
- type ServiceConfig
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidConfig = errors.New("invalid configuration") ErrInvalidGraph = errors.New("invalid graph") ErrInvalidRequest = errors.New("invalid request") ErrInvalidBuilder = errors.New("invalid builder function") ErrMissingGraphID = errors.New("missing graph ID") )
Service errors.
Functions ¶
Types ¶
type Agent ¶
type Agent struct {
ID string `yaml:"id"`
Type string `yaml:"type"`
Name string `yaml:"name"`
Config map[string]interface{} `yaml:"config,omitempty"`
}
Agent defines an agent configuration
type Config ¶
type Config struct {
// RequestTimeout is the default request timeout.
RequestTimeout time.Duration
// MaxRetries is the maximum number of retries.
MaxRetries int
// RetryDelay is the delay between retries.
RetryDelay time.Duration
// Tracer is the observability tracer.
Tracer observability.Tracer
// Limiter is the rate limiter.
Limiter ratelimit.Limiter
}
Config represents service configuration.
type Edge ¶
type Edge struct {
From string `yaml:"from"`
To string `yaml:"to"`
Condition string `yaml:"condition,omitempty"` // expression or condition ID
}
Edge defines a connection between nodes
type ExecuteRequest ¶
type ExecuteRequest struct {
// GraphID is the graph identifier.
GraphID string
// State is the initial state for graph execution.
State map[string]any
// Timeout is the execution timeout.
Timeout time.Duration
}
ExecuteRequest represents a graph execution request.
type ExecuteResponse ¶
type ExecuteResponse struct {
// GraphID is the graph identifier.
GraphID string
// State is the final state after execution.
State map[string]any
// Duration is the execution duration.
Duration time.Duration
// Error is the execution error if any.
Error string
}
ExecuteResponse represents a graph execution response.
type GraphBuilder ¶
type GraphBuilder struct {
// contains filtered or unexported fields
}
GraphBuilder builds graph instances from configuration.
func NewGraphBuilder ¶
func NewGraphBuilder() *GraphBuilder
NewGraphBuilder creates a new graph builder.
func (*GraphBuilder) Build ¶
func (b *GraphBuilder) Build(config *GraphConfig) (*wfgraph.Graph, error)
Build builds a graph from configuration.
func (*GraphBuilder) RegisterAgent ¶
func (b *GraphBuilder) RegisterAgent(agent base.Agent)
RegisterAgent registers an agent for use in graph configuration.
func (*GraphBuilder) RegisterTool ¶
func (b *GraphBuilder) RegisterTool(id string, tool interface{})
RegisterTool registers a tool for use in graph configuration.
type GraphConfig ¶
type GraphConfig struct {
Graph GraphDefinition `yaml:"graph"`
}
GraphConfig represents the complete graph configuration from YAML
func ParseGraphConfig ¶
func ParseGraphConfig(data []byte) (*GraphConfig, error)
ParseGraphConfig parses a YAML configuration file
type GraphDefinition ¶
type GraphDefinition struct {
ID string `yaml:"id"`
StartNode string `yaml:"start_node"`
Nodes []Node `yaml:"nodes"`
Edges []Edge `yaml:"edges"`
Agents []Agent `yaml:"agents,omitempty"`
}
GraphDefinition defines a graph structure
func (*GraphDefinition) GetAgentByID ¶
func (g *GraphDefinition) GetAgentByID(id string) (*Agent, bool)
GetAgentByID retrieves an agent by its ID
func (*GraphDefinition) GetNodeByID ¶
func (g *GraphDefinition) GetNodeByID(id string) (*Node, bool)
GetNodeByID retrieves a node by its ID
type Node ¶
type Node struct {
ID string `yaml:"id"`
Type string `yaml:"type"` // function, agent, tool
Description string `yaml:"description,omitempty"`
Config map[string]interface{} `yaml:"config,omitempty"`
}
Node defines a graph node
type RateLimit ¶
type RateLimit struct {
Enabled bool `yaml:"enabled"`
Type string `yaml:"type"` // token_bucket
Config map[string]any `yaml:"config,omitempty"`
}
RateLimit defines rate limiting configuration
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides graph orchestration operations.
func BuildWithService ¶
BuildWithService creates a complete graph service from configuration.
func NewService ¶
NewService creates a new graph service instance. Args: config - service configuration. Returns new graph service instance or error.
func (*Service) Execute ¶
func (s *Service) Execute(ctx context.Context, g *wfgraph.Graph, request *ExecuteRequest) (*ExecuteResponse, error)
Execute executes a graph with the given request. Args: ctx - context for cancellation and timeout. graph - the graph to execute. request - execution parameters. Returns execution response or error.
func (*Service) ExecuteWithGraphBuilder ¶
func (s *Service) ExecuteWithGraphBuilder( ctx context.Context, graphID string, builder func(*wfgraph.Graph) *wfgraph.Graph, request *ExecuteRequest, ) (*ExecuteResponse, error)
ExecuteWithGraphBuilder executes a graph built with a builder function. Args: ctx - context for cancellation and timeout. graphID - graph identifier. builder - function to build the graph. request - execution parameters. Returns execution response or error.
func (*Service) GetGraphInfo ¶
GetGraphInfo returns information about a graph. Args: graph - the graph to inspect. Returns graph information.