pipeline

package
v0.0.1-alpha3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package pipeline provides a way to chain multiple llm executions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDecoding       = errors.New("decoding input error")
	ErrInvalidLmmMode = errors.New("invalid LLM mode")
)

Functions

This section is empty.

Types

type Decoder

type Decoder interface {
	Decode(input string) (interface{}, error)
}

type Llm

type Llm struct {
	LlmEngine LlmEngine
	LlmMode   LlmMode
	Prompt    Prompt
	Chat      *chat.Chat
}

type LlmEngine

type LlmEngine interface {
	Completion(string) (string, error)
	Chat(chat *chat.Chat) (string, error)
}

type LlmMode

type LlmMode int
const (
	LlmModeChat LlmMode = iota
	LlmModeCompletion
)

type Memory

type Memory interface {
	Get(key string) interface{}
	Set(key string, value interface{}) error
	All() map[string]interface{}
	Delete(key string) error
	Clear() error
}

type Pipeline

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

func New

func New(steps ...*Step) Pipeline

func (*Pipeline) AddNext

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

func (Pipeline) Run

func (p Pipeline) Run(input interface{}) (interface{}, error)

Run chains the steps of the pipeline and returns the output of the last step.

type Prompt

type Prompt interface {
	Prompt() string
	Format(input interface{}) error
}

type Step

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

func NewStep

func NewStep(
	name string,
	llm Llm,
	outputDecoder Decoder,
	memory Memory,
) *Step

func (*Step) Run

func (s *Step) Run(input interface{}) (interface{}, error)

Run execute the step and return the output. The prompt is formatted with the input and the output of the prompt is used as input for the LLM. If the step has a memory, the output is stored in the memory.

Jump to

Keyboard shortcuts

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