chain

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 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")
	ErrNoOutputParser       = errors.New("no output parser")
)

Functions

func IsChatModel added in v0.0.14

func IsChatModel(model schema.Model) bool

IsChatModel checks if the given model is of type schema.ChatModel.

func IsLLM added in v0.0.14

func IsLLM(model schema.Model) bool

IsLLM checks if the given model is of type schema.LLM.

Types

type Conditional added in v0.0.14

type Conditional struct {
	Condition ConditionalFunc
	Prompt    *prompt.Template
}

Conditional represents a conditional prompt configuration.

type ConditionalFunc added in v0.0.14

type ConditionalFunc func(model schema.Model) bool

ConditionalFunc represents a function that evaluates a condition based on a model.

type ConditionalPromptSelector added in v0.0.14

type ConditionalPromptSelector struct {
	DefaultPrompt *prompt.Template
	Conditionals  []Conditional
}

ConditionalPromptSelector is a prompt selector that selects prompts based on conditions.

func (*ConditionalPromptSelector) GetPrompt added in v0.0.14

func (cps *ConditionalPromptSelector) GetPrompt(model schema.Model) *prompt.Template

GetPrompt selects a prompt template based on the provided model. It evaluates the conditions in order and returns the prompt associated with the first matching condition, or returns the default prompt if no condition is met.

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) Call added in v0.0.10

func (*Conversation) Callbacks added in v0.0.13

func (c *Conversation) Callbacks() []schema.Callback

func (*Conversation) InputKeys added in v0.0.10

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

InputKeys returns the expected input keys.

func (*Conversation) Memory added in v0.0.13

func (c *Conversation) Memory() schema.Memory

func (*Conversation) OutputKeys added in v0.0.10

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

OutputKeys returns the output keys the chain will return.

func (*Conversation) Prompt added in v0.0.10

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

func (*Conversation) Type added in v0.0.13

func (c *Conversation) Type() string

func (*Conversation) Verbose added in v0.0.13

func (c *Conversation) Verbose() bool

type ConversationOptions added in v0.0.10

type ConversationOptions struct {
	*schema.CallbackOptions
	Prompt       *prompt.Template
	Memory       schema.Memory
	OutputKey    string
	OutputParser schema.OutputParser[any]
}

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) Call added in v0.0.11

func (c *LLMBash) Call(ctx context.Context, values schema.ChainValues) (schema.ChainValues, error)

func (*LLMBash) Callbacks added in v0.0.13

func (c *LLMBash) Callbacks() []schema.Callback

func (*LLMBash) InputKeys added in v0.0.11

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

InputKeys returns the expected input keys.

func (*LLMBash) Memory added in v0.0.13

func (c *LLMBash) Memory() schema.Memory

func (*LLMBash) OutputKeys added in v0.0.11

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

OutputKeys returns the output keys the chain will return.

func (*LLMBash) Type added in v0.0.13

func (c *LLMBash) Type() string

func (*LLMBash) Verbose added in v0.0.13

func (c *LLMBash) Verbose() bool

type LLMBashOptions added in v0.0.11

type LLMBashOptions struct {
	*schema.CallbackOptions
	InputKey  string
	OutputKey string
}

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) Call added in v0.0.2

func (*LLMChain) Callbacks added in v0.0.13

func (c *LLMChain) Callbacks() []schema.Callback

func (*LLMChain) InputKeys added in v0.0.2

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

InputKeys returns the expected input keys.

func (*LLMChain) Memory added in v0.0.13

func (c *LLMChain) Memory() schema.Memory

func (*LLMChain) OutputKeys added in v0.0.2

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

OutputKeys returns the output keys the chain will return.

func (*LLMChain) Prompt added in v0.0.3

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

func (*LLMChain) Type added in v0.0.5

func (c *LLMChain) Type() string

func (*LLMChain) Verbose added in v0.0.13

func (c *LLMChain) Verbose() bool

type LLMChainOptions

type LLMChainOptions struct {
	*schema.CallbackOptions
	Memory       schema.Memory
	OutputKey    string
	OutputParser schema.OutputParser[any]
}

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) Call added in v0.0.11

func (c *LLMMath) Call(ctx context.Context, values schema.ChainValues) (schema.ChainValues, error)

func (*LLMMath) Callbacks added in v0.0.13

func (c *LLMMath) Callbacks() []schema.Callback

func (*LLMMath) InputKeys added in v0.0.11

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

InputKeys returns the expected input keys.

func (*LLMMath) Memory added in v0.0.13

func (c *LLMMath) Memory() schema.Memory

func (*LLMMath) OutputKeys added in v0.0.11

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

OutputKeys returns the output keys the chain will return.

func (*LLMMath) Type added in v0.0.13

func (c *LLMMath) Type() string

func (*LLMMath) Verbose added in v0.0.13

func (c *LLMMath) Verbose() bool

type LLMMathOptions added in v0.0.11

type LLMMathOptions struct {
	*schema.CallbackOptions
	InputKey  string
	OutputKey string
}

type PromptSelector added in v0.0.14

type PromptSelector interface {
	GetPrompt(model schema.Model) *prompt.Template
}

PromptSelector is an interface for selecting prompts based on a model.

type RefineDocuments added in v0.0.13

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

func NewRefineDocuments added in v0.0.13

func NewRefineDocuments(llmChain *LLMChain, refineLLMChain *LLMChain, optFns ...func(o *RefineDocumentsOptions)) (*RefineDocuments, error)

func NewRefineSummarization added in v0.0.13

func NewRefineSummarization(llm schema.LLM, optFns ...func(o *RefineSummarizationOptions)) (*RefineDocuments, error)

func (*RefineDocuments) Call added in v0.0.13

func (*RefineDocuments) Callbacks added in v0.0.13

func (c *RefineDocuments) Callbacks() []schema.Callback

func (*RefineDocuments) InputKeys added in v0.0.13

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

InputKeys returns the expected input keys.

func (*RefineDocuments) Memory added in v0.0.13

func (c *RefineDocuments) Memory() schema.Memory

func (*RefineDocuments) OutputKeys added in v0.0.13

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

OutputKeys returns the output keys the chain will return.

func (*RefineDocuments) Type added in v0.0.13

func (c *RefineDocuments) Type() string

func (*RefineDocuments) Verbose added in v0.0.13

func (c *RefineDocuments) Verbose() bool

type RefineDocumentsOptions

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

type RefineSummarizationOptions added in v0.0.13

type RefineSummarizationOptions struct {
	*schema.CallbackOptions
}

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 *StuffDocuments, 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) Call added in v0.0.2

func (*RetrievalQA) Callbacks added in v0.0.13

func (c *RetrievalQA) Callbacks() []schema.Callback

func (*RetrievalQA) InputKeys added in v0.0.2

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

InputKeys returns the expected input keys.

func (*RetrievalQA) Memory added in v0.0.13

func (c *RetrievalQA) Memory() schema.Memory

func (*RetrievalQA) OutputKeys added in v0.0.2

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

OutputKeys returns the output keys the chain will return.

func (*RetrievalQA) Type added in v0.0.13

func (c *RetrievalQA) Type() string

func (*RetrievalQA) Verbose added in v0.0.13

func (c *RetrievalQA) Verbose() bool

type RetrievalQAOptions added in v0.0.2

type RetrievalQAOptions struct {
	*schema.CallbackOptions
	InputKey              string
	ReturnSourceDocuments bool
}

type StuffDocuments added in v0.0.13

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

func NewStuffDocuments added in v0.0.13

func NewStuffDocuments(llmChain *LLMChain, optFns ...func(o *StuffDocumentsOptions)) (*StuffDocuments, error)

func NewStuffSummarization added in v0.0.13

func NewStuffSummarization(llm schema.LLM, optFns ...func(o *StuffSummarizationOptions)) (*StuffDocuments, error)

func (*StuffDocuments) Call added in v0.0.13

func (*StuffDocuments) Callbacks added in v0.0.13

func (c *StuffDocuments) Callbacks() []schema.Callback

func (*StuffDocuments) InputKeys added in v0.0.13

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

InputKeys returns the expected input keys.

func (*StuffDocuments) Memory added in v0.0.13

func (c *StuffDocuments) Memory() schema.Memory

func (*StuffDocuments) OutputKeys added in v0.0.13

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

OutputKeys returns the output keys the chain will return.

func (*StuffDocuments) Type added in v0.0.13

func (c *StuffDocuments) Type() string

func (*StuffDocuments) Verbose added in v0.0.13

func (c *StuffDocuments) Verbose() bool

type StuffDocumentsOptions

type StuffDocumentsOptions struct {
	*schema.CallbackOptions
	InputKey             string
	DocumentVariableName string
	Separator            string
}

type StuffSummarizationOptions added in v0.0.13

type StuffSummarizationOptions struct {
	*schema.CallbackOptions
}

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) Call added in v0.0.6

func (*TransformChain) Callbacks added in v0.0.13

func (c *TransformChain) Callbacks() []schema.Callback

func (*TransformChain) InputKeys added in v0.0.6

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

InputKeys returns the expected input keys.

func (*TransformChain) Memory added in v0.0.13

func (c *TransformChain) Memory() schema.Memory

func (*TransformChain) OutputKeys added in v0.0.6

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

OutputKeys returns the output keys the chain will return.

func (*TransformChain) Type added in v0.0.13

func (c *TransformChain) Type() string

func (*TransformChain) Verbose added in v0.0.13

func (c *TransformChain) Verbose() bool

type TransformChainOptions added in v0.0.9

type TransformChainOptions struct {
	*schema.CallbackOptions
}

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