chain

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoInputValues        = errors.New("no input values")
	ErrInvalidInputValues   = errors.New("invalid input values")
	ErrInputValuesWrongType = errors.New("input key is of wrong type")
	ErrMultipleInputsInRun  = errors.New("run not supported in chain with more then one expected input")
	ErrMultipleOutputsInRun = errors.New("run not supported in chain with more then one expected output")
	ErrWrongOutputTypeInRun = errors.New("run not supported in chain that returns value that is not string")
	ErrNoOutputParser       = errors.New("no output parser")
)

Functions

This section is empty.

Types

type Conversation added in v0.0.10

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

func NewConversation added in v0.0.10

func NewConversation(llm schema.LLM, optFns ...func(o *ConversationOptions)) (*Conversation, error)

func (Conversation) Apply added in v0.0.10

func (bc Conversation) Apply(ctx context.Context, inputs []schema.ChainValues) ([]schema.ChainValues, error)

func (Conversation) Call added in v0.0.10

func (bc Conversation) Call(ctx context.Context, inputs schema.ChainValues) (schema.ChainValues, error)

func (Conversation) InputKeys added in v0.0.10

func (bc Conversation) InputKeys() []string

InputKeys returns the expected input keys.

func (Conversation) OutputKeys added in v0.0.10

func (bc Conversation) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

func (*Conversation) Predict added in v0.0.10

func (c *Conversation) Predict(ctx context.Context, inputs schema.ChainValues) (string, error)

func (*Conversation) Prompt added in v0.0.10

func (c *Conversation) Prompt() *prompt.Template

func (Conversation) Run added in v0.0.10

func (bc Conversation) Run(ctx context.Context, input any) (string, error)

type ConversationOptions added in v0.0.10

type ConversationOptions struct {
	Prompt       *prompt.Template
	Memory       schema.Memory
	OutputKey    string
	OutputParser schema.OutputParser[any]
	// contains filtered or unexported fields
}

type LLMBash added in v0.0.11

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

func NewLLMBash added in v0.0.11

func NewLLMBash(llmChain *LLMChain, optFns ...func(o *LLMBashOptions)) (*LLMBash, error)

func NewLLMBashFromLLM added in v0.0.11

func NewLLMBashFromLLM(llm schema.LLM) (*LLMBash, error)

func (LLMBash) Apply added in v0.0.11

func (bc LLMBash) Apply(ctx context.Context, inputs []schema.ChainValues) ([]schema.ChainValues, error)

func (LLMBash) Call added in v0.0.11

func (bc LLMBash) Call(ctx context.Context, inputs schema.ChainValues) (schema.ChainValues, error)

func (LLMBash) InputKeys added in v0.0.11

func (bc LLMBash) InputKeys() []string

InputKeys returns the expected input keys.

func (LLMBash) OutputKeys added in v0.0.11

func (bc LLMBash) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

func (LLMBash) Run added in v0.0.11

func (bc LLMBash) Run(ctx context.Context, input any) (string, error)

type LLMBashOptions added in v0.0.11

type LLMBashOptions struct {
	InputKey  string
	OutputKey string
	// contains filtered or unexported fields
}

type LLMChain

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

func NewLLMChain

func NewLLMChain(llm schema.LLM, prompt *prompt.Template, optFns ...func(o *LLMChainOptions)) (*LLMChain, error)

func (LLMChain) Apply added in v0.0.8

func (bc LLMChain) Apply(ctx context.Context, inputs []schema.ChainValues) ([]schema.ChainValues, error)

func (LLMChain) Call added in v0.0.2

func (bc LLMChain) Call(ctx context.Context, inputs schema.ChainValues) (schema.ChainValues, error)

func (LLMChain) InputKeys added in v0.0.2

func (bc LLMChain) InputKeys() []string

InputKeys returns the expected input keys.

func (LLMChain) OutputKeys added in v0.0.2

func (bc LLMChain) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

func (*LLMChain) Predict

func (c *LLMChain) Predict(ctx context.Context, inputs schema.ChainValues) (string, error)

func (*LLMChain) Prompt added in v0.0.3

func (c *LLMChain) Prompt() *prompt.Template

func (LLMChain) Run added in v0.0.8

func (bc LLMChain) Run(ctx context.Context, input any) (string, error)

type LLMChainOptions

type LLMChainOptions struct {
	Memory       schema.Memory
	OutputKey    string
	OutputParser schema.OutputParser[any]
	// contains filtered or unexported fields
}

type LLMMath added in v0.0.11

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

func NewLLMMath added in v0.0.11

func NewLLMMath(llmChain *LLMChain, optFns ...func(o *LLMMathOptions)) (*LLMMath, error)

func NewLLMMathFromLLM added in v0.0.11

func NewLLMMathFromLLM(llm schema.LLM) (*LLMMath, error)

func (LLMMath) Apply added in v0.0.11

func (bc LLMMath) Apply(ctx context.Context, inputs []schema.ChainValues) ([]schema.ChainValues, error)

func (LLMMath) Call added in v0.0.11

func (bc LLMMath) Call(ctx context.Context, inputs schema.ChainValues) (schema.ChainValues, error)

func (LLMMath) InputKeys added in v0.0.11

func (bc LLMMath) InputKeys() []string

InputKeys returns the expected input keys.

func (LLMMath) OutputKeys added in v0.0.11

func (bc LLMMath) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

func (LLMMath) Run added in v0.0.11

func (bc LLMMath) Run(ctx context.Context, input any) (string, error)

type LLMMathOptions added in v0.0.11

type LLMMathOptions struct {
	InputKey  string
	OutputKey string
	// contains filtered or unexported fields
}

type RefineDocumentsChain

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

func NewRefineDocumentsChain

func NewRefineDocumentsChain(llmChain *LLMChain, refineLLMChain *LLMChain, optFns ...func(o *RefineDocumentsOptions)) (*RefineDocumentsChain, error)

func NewRefineSummarizationChain

func NewRefineSummarizationChain(llm schema.LLM, optFns ...func(o *RefineSummarizationChainOptions)) (*RefineDocumentsChain, error)

func (RefineDocumentsChain) Apply added in v0.0.8

func (bc RefineDocumentsChain) Apply(ctx context.Context, inputs []schema.ChainValues) ([]schema.ChainValues, error)

func (RefineDocumentsChain) Call added in v0.0.2

func (bc RefineDocumentsChain) Call(ctx context.Context, inputs schema.ChainValues) (schema.ChainValues, error)

func (RefineDocumentsChain) InputKeys added in v0.0.2

func (bc RefineDocumentsChain) InputKeys() []string

InputKeys returns the expected input keys.

func (RefineDocumentsChain) OutputKeys added in v0.0.2

func (bc RefineDocumentsChain) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

func (RefineDocumentsChain) Run added in v0.0.8

func (bc RefineDocumentsChain) Run(ctx context.Context, input any) (string, error)

type RefineDocumentsOptions

type RefineDocumentsOptions struct {
	InputKey             string
	DocumentVariableName string
	InitialResponseName  string
	DocumentPrompt       *prompt.Template
	OutputKey            string
	// contains filtered or unexported fields
}

type RefineSummarizationChainOptions added in v0.0.7

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

type RetrievalQA added in v0.0.2

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

func NewRetrievalQA added in v0.0.2

func NewRetrievalQA(stuffDocumentsChain *StuffDocumentsChain, retriever schema.Retriever, optFns ...func(o *RetrievalQAOptions)) (*RetrievalQA, error)

func NewRetrievalQAFromLLM added in v0.0.2

func NewRetrievalQAFromLLM(llm schema.LLM, retriever schema.Retriever) (*RetrievalQA, error)

func (RetrievalQA) Apply added in v0.0.8

func (bc RetrievalQA) Apply(ctx context.Context, inputs []schema.ChainValues) ([]schema.ChainValues, error)

func (RetrievalQA) Call added in v0.0.2

func (bc RetrievalQA) Call(ctx context.Context, inputs schema.ChainValues) (schema.ChainValues, error)

func (RetrievalQA) InputKeys added in v0.0.2

func (bc RetrievalQA) InputKeys() []string

InputKeys returns the expected input keys.

func (RetrievalQA) OutputKeys added in v0.0.2

func (bc RetrievalQA) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

func (RetrievalQA) Run added in v0.0.8

func (bc RetrievalQA) Run(ctx context.Context, input any) (string, error)

type RetrievalQAOptions added in v0.0.2

type RetrievalQAOptions struct {
	InputKey              string
	ReturnSourceDocuments bool
	// contains filtered or unexported fields
}

type StuffDocumentsChain

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

func NewStuffDocumentsChain

func NewStuffDocumentsChain(llmChain *LLMChain, optFns ...func(o *StuffDocumentsOptions)) (*StuffDocumentsChain, error)

func NewStuffSummarizationChain

func NewStuffSummarizationChain(llm schema.LLM, optFns ...func(o *StuffSummarizationChainOptions)) (*StuffDocumentsChain, error)

func (StuffDocumentsChain) Apply added in v0.0.8

func (bc StuffDocumentsChain) Apply(ctx context.Context, inputs []schema.ChainValues) ([]schema.ChainValues, error)

func (StuffDocumentsChain) Call added in v0.0.2

func (bc StuffDocumentsChain) Call(ctx context.Context, inputs schema.ChainValues) (schema.ChainValues, error)

func (StuffDocumentsChain) InputKeys added in v0.0.2

func (bc StuffDocumentsChain) InputKeys() []string

InputKeys returns the expected input keys.

func (StuffDocumentsChain) OutputKeys added in v0.0.2

func (bc StuffDocumentsChain) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

func (StuffDocumentsChain) Run added in v0.0.8

func (bc StuffDocumentsChain) Run(ctx context.Context, input any) (string, error)

type StuffDocumentsOptions

type StuffDocumentsOptions struct {
	InputKey             string
	DocumentVariableName string
	Separator            string
	// contains filtered or unexported fields
}

type StuffSummarizationChainOptions added in v0.0.7

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

type TransformChain added in v0.0.6

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

func NewTransformChain added in v0.0.6

func NewTransformChain(inputKeys, outputKeys []string, transform TransformFunc, optFns ...func(o *TransformChainOptions)) (*TransformChain, error)

func (TransformChain) Apply added in v0.0.8

func (bc TransformChain) Apply(ctx context.Context, inputs []schema.ChainValues) ([]schema.ChainValues, error)

func (TransformChain) Call added in v0.0.6

func (bc TransformChain) Call(ctx context.Context, inputs schema.ChainValues) (schema.ChainValues, error)

func (TransformChain) InputKeys added in v0.0.6

func (bc TransformChain) InputKeys() []string

InputKeys returns the expected input keys.

func (TransformChain) OutputKeys added in v0.0.6

func (bc TransformChain) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

func (TransformChain) Run added in v0.0.8

func (bc TransformChain) Run(ctx context.Context, input any) (string, error)

type TransformChainOptions added in v0.0.9

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

type TransformFunc added in v0.0.6

type TransformFunc func(inputs schema.ChainValues) (schema.ChainValues, error)

Jump to

Keyboard shortcuts

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