hitl

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemoryInterruptStore

type InMemoryInterruptStore struct {
	// contains filtered or unexported fields
}

在MemoryInterruptStore中为中断提供内存.

func NewInMemoryInterruptStore

func NewInMemoryInterruptStore() *InMemoryInterruptStore

New InMemory InterruptStore 创建了新的内存中断商店.

func (*InMemoryInterruptStore) List

func (s *InMemoryInterruptStore) List(ctx context.Context, workflowID string, status InterruptStatus) ([]*Interrupt, error)

func (*InMemoryInterruptStore) Load

func (s *InMemoryInterruptStore) Load(ctx context.Context, interruptID string) (*Interrupt, error)

func (*InMemoryInterruptStore) Save

func (s *InMemoryInterruptStore) Save(ctx context.Context, interrupt *Interrupt) error

func (*InMemoryInterruptStore) Update

func (s *InMemoryInterruptStore) Update(ctx context.Context, interrupt *Interrupt) error

type Interrupt

type Interrupt struct {
	ID           string          `json:"id"`
	WorkflowID   string          `json:"workflow_id"`
	NodeID       string          `json:"node_id"`
	Type         InterruptType   `json:"type"`
	Status       InterruptStatus `json:"status"`
	Title        string          `json:"title"`
	Description  string          `json:"description"`
	Data         any             `json:"data,omitempty"`
	Options      []Option        `json:"options,omitempty"`
	InputSchema  json.RawMessage `json:"input_schema,omitempty"`
	Response     *Response       `json:"response,omitempty"`
	CreatedAt    time.Time       `json:"created_at"`
	ResolvedAt   *time.Time      `json:"resolved_at,omitempty"`
	Timeout      time.Duration   `json:"timeout"`
	CheckpointID string          `json:"checkpoint_id,omitempty"`
	Metadata     map[string]any  `json:"metadata,omitempty"`
}

中断代表工作流程中断点.

type InterruptHandler

type InterruptHandler func(ctx context.Context, interrupt *Interrupt) error

中断汉德勒处理中断事件.

type InterruptManager

type InterruptManager struct {
	// contains filtered or unexported fields
}

中断管理者管理工作流程中断 。

func NewInterruptManager

func NewInterruptManager(store InterruptStore, logger *zap.Logger) *InterruptManager

新干扰管理器创建了新的中断管理器 。

func (*InterruptManager) CancelInterrupt

func (m *InterruptManager) CancelInterrupt(ctx context.Context, interruptID string) error

取消中断取消待决中断 。

func (*InterruptManager) CreateInterrupt

func (m *InterruptManager) CreateInterrupt(ctx context.Context, opts InterruptOptions) (*Response, error)

创建中断创建并等待中断解决 。

func (*InterruptManager) GetPendingInterrupts

func (m *InterruptManager) GetPendingInterrupts(workflowID string) []*Interrupt

获得待定 中断返回工作流程中所有待处理中断 。

func (*InterruptManager) RegisterHandler

func (m *InterruptManager) RegisterHandler(interruptType InterruptType, handler InterruptHandler)

登记 Handler 为中断类型登记处理器 。

func (*InterruptManager) ResolveInterrupt

func (m *InterruptManager) ResolveInterrupt(ctx context.Context, interruptID string, response *Response) error

解析中断解决待决中断 。

type InterruptOptions

type InterruptOptions struct {
	WorkflowID   string
	NodeID       string
	Type         InterruptType
	Title        string
	Description  string
	Data         any
	Options      []Option
	InputSchema  json.RawMessage
	Timeout      time.Duration
	CheckpointID string
	Metadata     map[string]any
}

中断选项配置中断创建 。

type InterruptStatus

type InterruptStatus string

中断状态代表中断状态.

const (
	InterruptStatusPending  InterruptStatus = "pending"
	InterruptStatusResolved InterruptStatus = "resolved"
	InterruptStatusRejected InterruptStatus = "rejected"
	InterruptStatusTimeout  InterruptStatus = "timeout"
	InterruptStatusCanceled InterruptStatus = "canceled"
)

type InterruptStore

type InterruptStore interface {
	Save(ctx context.Context, interrupt *Interrupt) error
	Load(ctx context.Context, interruptID string) (*Interrupt, error)
	List(ctx context.Context, workflowID string, status InterruptStatus) ([]*Interrupt, error)
	Update(ctx context.Context, interrupt *Interrupt) error
}

InterruptStore定义了中断的存储接口.

type InterruptType

type InterruptType string

中断Type定义了工作流程中断的类型.

const (
	InterruptTypeApproval   InterruptType = "approval"
	InterruptTypeInput      InterruptType = "input"
	InterruptTypeReview     InterruptType = "review"
	InterruptTypeBreakpoint InterruptType = "breakpoint"
	InterruptTypeError      InterruptType = "error"
)

type Option

type Option struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
	IsDefault   bool   `json:"is_default,omitempty"`
}

备选办法是可选择的核准中断的备选办法。

type Response

type Response struct {
	OptionID  string         `json:"option_id,omitempty"`
	Input     any            `json:"input,omitempty"`
	Comment   string         `json:"comment,omitempty"`
	Approved  bool           `json:"approved"`
	Timestamp time.Time      `json:"timestamp"`
	UserID    string         `json:"user_id,omitempty"`
	Metadata  map[string]any `json:"metadata,omitempty"`
}

反应代表了人类对中断的反应。

Jump to

Keyboard shortcuts

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