pipeline

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package pipeline provides a flexible framework for composing and executing sequences of operations (Steps) for LLM workflows like RAG and data processing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hook

type Hook interface {
	// OnStepStart is called before a step executes.
	OnStepStart(ctx context.Context, step Step, state *State)

	// OnStepError is called if a step returns an error.
	OnStepError(ctx context.Context, step Step, state *State, err error)

	// OnStepComplete is called after a step successfully executes.
	OnStepComplete(ctx context.Context, step Step, state *State)
}

Hook allows observing pipeline execution.

type Pipeline

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

Pipeline manages a sequence of steps.

func New

func New() *Pipeline

New creates a new, empty pipeline.

func (*Pipeline) AddHook

func (p *Pipeline) AddHook(hook Hook) *Pipeline

AddHook appends an observer hook to the pipeline.

func (*Pipeline) AddStep

func (p *Pipeline) AddStep(step Step) *Pipeline

AddStep appends a step to the pipeline.

func (*Pipeline) Execute

func (p *Pipeline) Execute(ctx context.Context, state *State) error

Execute runs all steps sequentially. If any step fails or the context is canceled, execution stops and the error is returned.

type State

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

State is a thread-safe container for data passed between pipeline steps.

func NewState

func NewState() *State

NewState creates a new, empty pipeline state.

func (*State) Clone

func (s *State) Clone() *State

Clone creates a shallow copy of the current state.

func (*State) Delete

func (s *State) Delete(key string)

Delete removes a key from the state.

func (*State) Get

func (s *State) Get(key string) (interface{}, bool)

Get retrieves a value from the state. Returns nil and false if the key does not exist.

func (*State) GetString

func (s *State) GetString(key string) string

GetString is a helper to retrieve a string value. Returns empty string if missing or wrong type.

func (*State) Set

func (s *State) Set(key string, value interface{})

Set stores a value in the state.

type Step

type Step interface {
	// Name returns the name of the step for logging and debugging.
	Name() string

	// Execute performs the step's operation, reading from and writing to the State.
	Execute(ctx context.Context, state *State) error
}

Step defines an individual operation in the pipeline.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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