pipeline

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package pipeline provides internal pipeline construction for the SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(cfg *Config) (*stage.StreamPipeline, error)

Build creates a stage-based streaming pipeline.

Stage order:

  1. StateStoreLoadStage - Load conversation history (if configured)
  2. VariableProviderStage - Dynamic variable resolution (if configured)
  3. PromptAssemblyStage - Load and assemble prompt from registry
  4. TemplateStage - Prepare system prompt for provider
  5. ProviderStage/DuplexProviderStage - LLM call with streaming support
  6. ValidationStage - Validate responses (if configured)
  7. StateStoreSaveStage - Save conversation state (if configured)

This matches the runtime pipeline used by Arena.

func BuildStreamPipeline added in v1.1.6

func BuildStreamPipeline(cfg *Config) (*stage.StreamPipeline, error)

BuildStreamPipeline is deprecated, use Build instead. Kept for backward compatibility.

Types

type Config

type Config struct {
	// Provider for LLM calls
	Provider providers.Provider

	// ToolRegistry for tool execution (optional)
	ToolRegistry *tools.Registry

	// PromptRegistry for loading prompts (required for PromptAssemblyStage)
	PromptRegistry *prompt.Registry

	// TaskType is the prompt ID/task type to load from the registry
	TaskType string

	// Variables for template substitution
	Variables map[string]string

	// VariableProviders for dynamic variable resolution (optional)
	VariableProviders []variables.Provider

	// ToolPolicy for tool usage constraints (optional)
	ToolPolicy *rtpipeline.ToolPolicy

	// TokenBudget for context management (0 = no limit)
	TokenBudget int

	// TruncationStrategy for context management ("sliding", "summarize", or "relevance")
	TruncationStrategy string

	// RelevanceConfig for embedding-based truncation (optional, used with "relevance" strategy)
	RelevanceConfig *stage.RelevanceConfig

	// ValidatorRegistry for creating validators (optional)
	ValidatorRegistry *validators.Registry

	// ValidatorConfigs from the pack (optional)
	ValidatorConfigs []validators.ValidatorConfig

	// SuppressValidationErrors when true, validation failures don't return errors
	SuppressValidationErrors bool

	// MaxTokens for LLM response
	MaxTokens int

	// Temperature for LLM response
	Temperature float32

	// ResponseFormat for JSON mode output (optional)
	ResponseFormat *providers.ResponseFormat

	// StateStore for conversation history persistence (optional)
	// When provided, StateStoreLoad/Save stages will be added to the pipeline
	StateStore statestore.Store

	// ConversationID for state store operations
	ConversationID string

	// StreamInputProvider for duplex streaming (ASM mode) (optional)
	// When provided with StreamInputConfig, DuplexProviderStage will be used.
	// The stage creates the session lazily using system_prompt from element metadata.
	StreamInputProvider providers.StreamInputSupport

	// StreamInputConfig for duplex streaming session creation (ASM mode) (optional)
	// Base config for session - system prompt is added from pipeline element metadata.
	StreamInputConfig *providers.StreamingInputConfig

	// UseStages is deprecated and ignored - stages are always used.
	// This field is kept for backward compatibility but has no effect.
	UseStages bool

	// VADConfig configures the AudioTurnStage for VAD mode
	VADConfig *stage.AudioTurnConfig

	// STTService for speech-to-text in VAD mode
	STTService stt.Service

	// STTConfig configures the STTStage
	STTConfig *stage.STTStageConfig

	// TTSService for text-to-speech in VAD mode
	TTSService tts.Service

	// TTSConfig configures the TTSStageWithInterruption
	TTSConfig *stage.TTSStageWithInterruptionConfig

	// InterruptionHandler shared between AudioTurnStage and TTSStage for barge-in support
	InterruptionHandler *audio.InterruptionHandler

	// ImagePreprocessConfig configures image preprocessing (resizing, optimization)
	// When non-nil, ImagePreprocessStage is added before the provider stage
	ImagePreprocessConfig *stage.ImagePreprocessConfig

	// EventEmitter for emitting provider call events (optional)
	// When provided, ProviderStage will emit ProviderCallStarted/Completed/Failed events
	EventEmitter *events.Emitter
}

Config holds configuration for building a pipeline.

Jump to

Keyboard shortcuts

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