core

package
v1.4.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 5 Imported by: 0

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 AgentExecutor

type AgentExecutor interface {
	Execute(ctx context.Context, input any) (any, 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) (any, error)
}

HumanInputHandler 人工输入处理器抽象。

type LLMRequest

type LLMRequest struct {
	Model       string
	Prompt      string
	Temperature float64
	MaxTokens   int
	Metadata    map[string]string
}

LLMRequest 是 workflow 层面的 LLM 请求。

type LLMResponse

type LLMResponse struct {
	Content string
	Model   string
	Usage   *LLMUsage
}

LLMResponse 是 workflow 层面的 LLM 响应。

type LLMUsage

type LLMUsage struct {
	PromptTokens     int
	CompletionTokens int
	TotalTokens      int
}

LLMUsage 记录 token 用量。

type StepError

type StepError struct {
	StepID   string
	StepType StepType
	Cause    error
}

StepError 包装步骤执行错误,携带步骤 ID 和类型。

func NewStepError

func NewStepError(stepID string, stepType StepType, cause error) *StepError

NewStepError 创建步骤错误。

func (*StepError) Error

func (e *StepError) Error() string

func (*StepError) Unwrap

func (e *StepError) Unwrap() error

type StepInput

type StepInput struct {
	Data     map[string]any    // 上游步骤输出 / 用户输入
	Metadata map[string]string // trace_id/run_id/node_id 等
}

StepInput 步骤输入。

type StepOutput

type StepOutput struct {
	Data    map[string]any    // 输出数据
	Usage   *types.TokenUsage // 可选,LLM 步骤填充
	Latency time.Duration
}

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"
	StepTypeCode             StepType = "code"
	StepTypeAgent            StepType = "agent"
	StepTypeHybridRetrieve   StepType = "hybrid_retrieve"
	StepTypeMultiHopRetrieve StepType = "multi_hop_retrieve"
	StepTypeRerank           StepType = "rerank"
)

type ToolRegistry

type ToolRegistry interface {
	ExecuteTool(ctx context.Context, name string, params map[string]any) (any, error)
}

ToolRegistry 工具注册表抽象。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL