Documentation
¶
Index ¶
- type AgentDef
- type ErrorDef
- type LoopDef
- type NodeDef
- type Parser
- func (p *Parser) Parse(data []byte) (*workflow.DAGWorkflow, error)
- func (p *Parser) ParseFile(filename string) (*workflow.DAGWorkflow, error)
- func (p *Parser) RegisterCondition(name string, fn workflow.ConditionFunc)
- func (p *Parser) RegisterStep(name string, factory func(config map[string]any) (workflow.Step, error))
- type StepDef
- type ToolDef
- type Validator
- type VariableDef
- type WorkflowDSL
- type WorkflowNodesDef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentDef ¶
type AgentDef struct {
Model string `yaml:"model" json:"model"`
Provider string `yaml:"provider,omitempty" json:"provider,omitempty"`
SystemPrompt string `yaml:"system_prompt,omitempty" json:"system_prompt,omitempty"`
Temperature float64 `yaml:"temperature,omitempty" json:"temperature,omitempty"`
MaxTokens int `yaml:"max_tokens,omitempty" json:"max_tokens,omitempty"`
Tools []string `yaml:"tools,omitempty" json:"tools,omitempty"` // 引用 tools 中定义的工具
Metadata map[string]string `yaml:"metadata,omitempty" json:"metadata,omitempty"`
}
AgentDef Agent 定义
type ErrorDef ¶
type ErrorDef struct {
Strategy string `yaml:"strategy" json:"strategy"` // fail_fast, skip, retry
MaxRetries int `yaml:"max_retries,omitempty" json:"max_retries,omitempty"`
RetryDelayMs int `yaml:"retry_delay_ms,omitempty" json:"retry_delay_ms,omitempty"`
FallbackValue any `yaml:"fallback_value,omitempty" json:"fallback_value,omitempty"`
}
ErrorDef 错误处理定义
type LoopDef ¶
type LoopDef struct {
Type string `yaml:"type" json:"type"` // while, for, foreach
Condition string `yaml:"condition,omitempty" json:"condition,omitempty"` // 条件表达式
MaxIterations int `yaml:"max_iterations,omitempty" json:"max_iterations,omitempty"` // 最大迭代次数
Collection string `yaml:"collection,omitempty" json:"collection,omitempty"` // foreach 的集合表达式
ItemVar string `yaml:"item_var,omitempty" json:"item_var,omitempty"` // foreach 的迭代变量名
}
LoopDef 循环定义
type NodeDef ¶
type NodeDef struct {
ID string `yaml:"id" json:"id"`
Type string `yaml:"type" json:"type"` // action, condition, loop, parallel, subgraph, checkpoint
Step string `yaml:"step,omitempty" json:"step,omitempty"` // 引用 steps 中的步骤
StepDef *StepDef `yaml:"step_def,omitempty" json:"step_def,omitempty"` // 内联步骤定义
Next []string `yaml:"next,omitempty" json:"next,omitempty"`
Condition string `yaml:"condition,omitempty" json:"condition,omitempty"` // 条件表达式
OnTrue []string `yaml:"on_true,omitempty" json:"on_true,omitempty"`
OnFalse []string `yaml:"on_false,omitempty" json:"on_false,omitempty"`
Loop *LoopDef `yaml:"loop,omitempty" json:"loop,omitempty"`
Parallel []string `yaml:"parallel,omitempty" json:"parallel,omitempty"`
SubGraph *WorkflowNodesDef `yaml:"subgraph,omitempty" json:"subgraph,omitempty"`
Error *ErrorDef `yaml:"error,omitempty" json:"error,omitempty"`
Metadata map[string]any `yaml:"metadata,omitempty" json:"metadata,omitempty"`
}
NodeDef 节点定义
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser DSL 解析器
func (*Parser) Parse ¶
func (p *Parser) Parse(data []byte) (*workflow.DAGWorkflow, error)
Parse 从 YAML 字节解析 DSL
func (*Parser) ParseFile ¶
func (p *Parser) ParseFile(filename string) (*workflow.DAGWorkflow, error)
ParseFile 从文件解析 DSL
func (*Parser) RegisterCondition ¶
func (p *Parser) RegisterCondition(name string, fn workflow.ConditionFunc)
RegisterCondition 注册命名条件
type StepDef ¶
type StepDef struct {
Type string `yaml:"type" json:"type"` // llm, tool, human_input, code, passthrough
Agent string `yaml:"agent,omitempty" json:"agent,omitempty"` // 引用 agents 中的 agent
Tool string `yaml:"tool,omitempty" json:"tool,omitempty"` // 引用 tools 中的工具
Prompt string `yaml:"prompt,omitempty" json:"prompt,omitempty"` // 支持 ${variable} 插值
Config map[string]any `yaml:"config,omitempty" json:"config,omitempty"`
}
StepDef 步骤定义
type ToolDef ¶
type ToolDef struct {
Type string `yaml:"type" json:"type"` // builtin, mcp, http, code
Description string `yaml:"description" json:"description"`
Config map[string]any `yaml:"config,omitempty" json:"config,omitempty"`
InputSchema map[string]any `yaml:"input_schema,omitempty" json:"input_schema,omitempty"`
}
ToolDef 工具定义
type Validator ¶
type Validator struct{}
Validator DSL 验证器
func (*Validator) Validate ¶
func (v *Validator) Validate(dsl *WorkflowDSL) []error
Validate 验证 DSL 定义
type VariableDef ¶
type VariableDef struct {
Type string `yaml:"type" json:"type"` // string, int, float, bool, list, map
Default any `yaml:"default,omitempty" json:"default,omitempty"` // 默认值
Description string `yaml:"description,omitempty" json:"description,omitempty"` // 描述
Required bool `yaml:"required,omitempty" json:"required,omitempty"` // 是否必填
}
VariableDef 变量定义
type WorkflowDSL ¶
type WorkflowDSL struct {
// Version DSL 版本
Version string `yaml:"version" json:"version"`
// Name 工作流名称
Name string `yaml:"name" json:"name"`
// Description 工作流描述
Description string `yaml:"description" json:"description"`
// Variables 全局变量定义
Variables map[string]VariableDef `yaml:"variables,omitempty" json:"variables,omitempty"`
// Agents Agent 定义
Agents map[string]AgentDef `yaml:"agents,omitempty" json:"agents,omitempty"`
// Tools 工具定义
Tools map[string]ToolDef `yaml:"tools,omitempty" json:"tools,omitempty"`
// Steps 步骤定义(可复用)
Steps map[string]StepDef `yaml:"steps,omitempty" json:"steps,omitempty"`
// Workflow 工作流节点定义
Workflow WorkflowNodesDef `yaml:"workflow" json:"workflow"`
// Metadata 元数据
Metadata map[string]any `yaml:"metadata,omitempty" json:"metadata,omitempty"`
}
WorkflowDSL 工作流 DSL 顶层结构
type WorkflowNodesDef ¶
type WorkflowNodesDef struct {
Entry string `yaml:"entry" json:"entry"`
Nodes []NodeDef `yaml:"nodes" json:"nodes"`
}
WorkflowNodesDef 工作流节点定义
Click to show internal directories.
Click to hide internal directories.