chain

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 10 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

func Apply added in v0.0.2

func Apply(ctx context.Context, chain golc.Chain, inputs []golc.ChainValues) ([]golc.ChainValues, error)

func Call added in v0.0.2

func Call(ctx context.Context, chain golc.Chain, inputs golc.ChainValues) (golc.ChainValues, error)

func Run added in v0.0.2

func Run(ctx context.Context, chain golc.Chain, input any) (string, error)

Types

type LLMBashChain added in v0.0.3

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

func NewLLMBashChain added in v0.0.3

func NewLLMBashChain(chain *LLMChain) (*LLMBashChain, error)

func NewLLMBashChainFromLLM added in v0.0.3

func NewLLMBashChainFromLLM(llm golc.LLM) (*LLMBashChain, error)

func (*LLMBashChain) Call added in v0.0.3

func (lc *LLMBashChain) Call(ctx context.Context, values golc.ChainValues) (golc.ChainValues, error)

func (*LLMBashChain) InputKeys added in v0.0.3

func (lc *LLMBashChain) InputKeys() []string

InputKeys returns the expected input keys.

func (*LLMBashChain) OutputKeys added in v0.0.3

func (lc *LLMBashChain) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

type LLMBashChainOptions added in v0.0.3

type LLMBashChainOptions struct {
	InputKey  string
	OutputKey string
}

type LLMChain

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

func NewLLMChain

func NewLLMChain(llm golc.LLM, prompt *prompt.Template) (*LLMChain, error)

func (*LLMChain) Call added in v0.0.2

func (c *LLMChain) Call(ctx context.Context, values golc.ChainValues) (golc.ChainValues, error)

func (*LLMChain) InputKeys added in v0.0.2

func (c *LLMChain) InputKeys() []string

InputKeys returns the expected input keys.

func (*LLMChain) OutputKeys added in v0.0.2

func (c *LLMChain) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

func (*LLMChain) Predict

func (c *LLMChain) Predict(ctx context.Context, values golc.ChainValues) (string, error)

func (*LLMChain) Prompt added in v0.0.3

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

type LLMChainOptions

type LLMChainOptions struct {
	Callbacks    []golc.Callback
	OutputKey    string
	OutputParser golc.OutputParser[any]
	Verbose      bool
}

type RefineDocumentsChain

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

func NewRefineDocumentsChain

func NewRefineDocumentsChain(llmChain *LLMChain, refineLLMChain *LLMChain) (*RefineDocumentsChain, error)

func NewRefineSummarizationChain

func NewRefineSummarizationChain(llm golc.LLM) (*RefineDocumentsChain, error)

func (*RefineDocumentsChain) Call added in v0.0.2

func (*RefineDocumentsChain) InputKeys added in v0.0.2

func (refine *RefineDocumentsChain) InputKeys() []string

InputKeys returns the expected input keys.

func (*RefineDocumentsChain) OutputKeys added in v0.0.2

func (refine *RefineDocumentsChain) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

type RefineDocumentsOptions

type RefineDocumentsOptions struct {
	InputKey             string
	DocumentVariableName string
	InitialResponseName  string
	DocumentPrompt       *prompt.Template
	OutputKey            string
}

type RetrievalQA added in v0.0.2

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

func NewRetrievalQA added in v0.0.2

func NewRetrievalQA(chain *StuffDocumentsChain, retriever golc.Retriever) (*RetrievalQA, error)

func NewRetrievalQAFromLLM added in v0.0.2

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

func (*RetrievalQA) Call added in v0.0.2

func (qa *RetrievalQA) Call(ctx context.Context, values golc.ChainValues) (golc.ChainValues, error)

func (*RetrievalQA) InputKeys added in v0.0.2

func (qa *RetrievalQA) InputKeys() []string

InputKeys returns the expected input keys.

func (*RetrievalQA) OutputKeys added in v0.0.2

func (qa *RetrievalQA) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

type RetrievalQAOptions added in v0.0.2

type RetrievalQAOptions struct {
	InputKey              string
	ReturnSourceDocuments bool
}

type StuffDocumentsChain

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

func NewStuffDocumentsChain

func NewStuffDocumentsChain(llmChain *LLMChain) (*StuffDocumentsChain, error)

func NewStuffSummarizationChain

func NewStuffSummarizationChain(llm golc.LLM) (*StuffDocumentsChain, error)

func (*StuffDocumentsChain) Call added in v0.0.2

func (*StuffDocumentsChain) InputKeys added in v0.0.2

func (stuff *StuffDocumentsChain) InputKeys() []string

InputKeys returns the expected input keys.

func (*StuffDocumentsChain) OutputKeys added in v0.0.2

func (stuff *StuffDocumentsChain) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

type StuffDocumentsOptions

type StuffDocumentsOptions struct {
	InputKey             string
	DocumentVariableName string
	Separator            string
}

Jump to

Keyboard shortcuts

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