Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrStepNotConfigured = errors.New("step dependency not configured") ErrStepValidation = errors.New("step validation failed") ErrStepExecution = errors.New("step execution failed") ErrStepTimeout = errors.New("step execution timed out") )
统一步骤错误。
Functions ¶
This section is empty.
Types ¶
type AgentExecutionMetadata ¶ added in v1.6.0
type AgentExecutionMetadata struct {
AgentID string `json:"agent_id,omitempty"`
TokensUsed int `json:"tokens_used,omitempty"`
Cost float64 `json:"cost,omitempty"`
Duration time.Duration `json:"duration,omitempty"`
FinishReason string `json:"finish_reason,omitempty"`
}
AgentExecutionMetadata carries execution metrics from an AgentStep back to the workflow layer for cost aggregation and observability.
type AgentExecutionOutput ¶ added in v1.6.0
type AgentExecutionOutput struct {
Content string `json:"content"`
TokensUsed int `json:"tokens_used,omitempty"`
Cost float64 `json:"cost,omitempty"`
Duration time.Duration `json:"duration,omitempty"`
FinishReason string `json:"finish_reason,omitempty"`
}
AgentExecutionOutput carries structured execution results from an agent step, eliminating type assertions for metadata extraction.
type AgentExecutor ¶
type AgentExecutor interface {
Execute(ctx context.Context, input map[string]any) (*AgentExecutionOutput, error)
}
AgentExecutor workflow 侧 agent 执行抽象。
type GatewayLike ¶
type GatewayLike interface {
Invoke(ctx context.Context, req *LLMRequest) (*LLMResponse, error)
}
GatewayLike 是 LLM Gateway 的抽象接口。 workflow 层通过此接口调用 LLM,不直接依赖 llm.Provider。
type HumanInputHandler ¶
type HumanInputHandler interface {
RequestInput(ctx context.Context, prompt string, inputType string, options []string) (*HumanInputResult, error)
}
HumanInputHandler 人工输入处理器抽象。
type HumanInputResult ¶ added in v1.6.0
type HumanInputResult struct {
Value string `json:"value"`
OptionID string `json:"option_id,omitempty"`
}
HumanInputResult 人工输入的结构化返回值。
type LLMRequest ¶
type LLMRequest struct {
Model string
Prompt string
Temperature float64
MaxTokens int
Metadata map[string]string
}
LLMRequest 是 workflow 层面的 LLM 请求。
type LLMResponse ¶
LLMResponse 是 workflow 层面的 LLM 响应。
type StepInput ¶
type StepInput struct {
// Data 上游步骤输出或用户输入。
// nil 时视为空 map,调用方应使用 len(Data) == 0 或 Data == nil 判断。
Data map[string]any
// Metadata trace_id、run_id、node_id 等追踪信息。
// nil 时视为空 map,调用方应使用 len(Metadata) == 0 或 Metadata == nil 判断。
Metadata map[string]string
}
StepInput 步骤输入。
type StepOutput ¶
type StepOutput struct {
Data map[string]any // 输出数据
Usage *types.TokenUsage // 可选,LLM 步骤填充
Latency time.Duration
Agent *AgentExecutionMetadata // 可选,Agent 步骤填充
}
StepOutput 步骤输出。
type StepProtocol ¶
type StepProtocol interface {
// ID 返回步骤唯一标识。
ID() string
// Type 返回步骤类型。
Type() StepType
// Execute 执行步骤。
Execute(ctx context.Context, input StepInput) (StepOutput, error)
// Validate 校验步骤配置是否合法。
Validate() error
}
StepProtocol 统一步骤协议(Command Pattern)。 所有步骤类型必须实现此接口。
type StepType ¶
type StepType string
StepType 步骤类型枚举。
const ( StepTypeLLM StepType = "llm" StepTypeTool StepType = "tool" StepTypeHuman StepType = "human" StepTypeHumanInput StepType = "human_input" // DSL 别名,与 StepTypeHuman 语义等价 StepTypeCode StepType = "code" StepTypeAgent StepType = "agent" StepTypeHybridRetrieve StepType = "hybrid_retrieve" StepTypeMultiHopRetrieve StepType = "multi_hop_retrieve" StepTypeRerank StepType = "rerank" StepTypeOrchestration StepType = "orchestration" StepTypeChain StepType = "chain" StepTypePassthrough StepType = "passthrough" )
Click to show internal directories.
Click to hide internal directories.