pipelines

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFallbackRetry

func NewFallbackRetry[T, U any](
	encoder jpf.Encoder[T],
	parser jpf.Parser[U],
	models []jpf.Model,
	opts ...ConstructionOpt[T, U],
) jpf.Pipeline[T, U]

Creates a [Pipeline] that first tries to ask the first model, and if that produces an invalid format will try to ask the next models until a valid format is found. This is useful, for example, to try a second time with a model that overwrites the cache.

func NewFeedbackRetry

func NewFeedbackRetry[T, U any](
	encoder jpf.Encoder[T],
	parser jpf.Parser[U],
	feedbackGenerator jpf.FeedbackGenerator,
	model jpf.Model,
	maxRetries int,
	opts ...ConstructionOpt[T, U],
) jpf.Pipeline[T, U]

NewFeedbackRetry creates a [Pipeline] that first runs the encoder, then the model, finally parsing the response with the decoder. However, it adds feedback to the conversation when errors are detected. It will only add to the conversation if the error returned from the parser is an [ErrInvalidResponse] (using errors.Is).

func NewOneShot

func NewOneShot[T, U any](
	encoder jpf.Encoder[T],
	parser jpf.Parser[U],
	model jpf.Model,
	opts ...ConstructionOpt[T, U],
) jpf.Pipeline[T, U]

NewOneShot creates a [Pipeline] that runs without retries. The validator may be nil.

Types

type ConstructionKwargs

type ConstructionKwargs[T, U any] struct {
	OutputFormat any
	Validator    jpf.Validator[T, U]
}

func GetConstructionKwargs

func GetConstructionKwargs[T, U any](opts ...ConstructionOpt[T, U]) ConstructionKwargs[T, U]

type ConstructionOpt

type ConstructionOpt[T, U any] func(*ConstructionKwargs[T, U])

func WithDefualtOutputFormat

func WithDefualtOutputFormat[T, U any]() ConstructionOpt[T, U]

func WithOutputFormat

func WithOutputFormat[T, U any](obj any) ConstructionOpt[T, U]

func WithValidator

func WithValidator[T, U any](validator jpf.Validator[T, U]) ConstructionOpt[T, U]

Jump to

Keyboard shortcuts

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