Versions in this module Expand all Collapse all v0 v0.1.12 Aug 22, 2024 Changes in this version + var ErrChainInitialization = errors.New("error initializing chain") + var ErrConvert = errors.New("cannot convert to string") + var ErrInputValuesWrongType = errors.New("input key is of wrong type") + var ErrInvalidInputNumberInSimpleSeq = errors.New("single input expected for chains supplied to SimpleSequentialChain") + var ErrInvalidInputValues = errors.New("invalid input values") + var ErrInvalidOutputNumberInSimpleSeq = errors.New("single output expected for chains supplied to SimpleSequentialChain") + var ErrInvalidOutputValues = errors.New("missing key in output values") + var ErrMemoryValuesWrongType = errors.New("memory key is of wrong type") + var ErrMissingInputValues = errors.New("missing key in input values") + var ErrMissingMemoryKeyValues = errors.New("missing memory key in input values") + var ErrMultipleInputsInRun = errors.New("run not supported in chain with more then one expected input") + var ErrMultipleOutputsInPredict = errors.New("predict is not supported with a chain that returns multiple values") + var ErrMultipleOutputsInRun = errors.New("run not supported in chain with more then one expected output") + var ErrNotFound = errors.New("result not found") + var ErrOutputNotStringInPredict = errors.New("predict is not supported with a chain that does not return a string") + var ErrWrongOutputTypeInRun = errors.New("run not supported in chain that returns value that is not string") + func Apply(ctx context.Context, c Chain, inputValues []map[string]any, maxWorkers int, ...) ([]map[string]any, error) + func Call(ctx context.Context, c Chain, inputValues map[string]any, ...) (map[string]any, error) + func Predict(ctx context.Context, c Chain, inputValues map[string]any, ...) (string, error) + func Run(ctx context.Context, c Chain, input any, options ...ChainCallOption) (string, error) + type APIChain struct + AnswerChain *LLMChain + Request HTTPRequest + RequestChain *LLMChain + func NewAPIChain(llm llms.Model, request HTTPRequest) APIChain + func (a APIChain) Call(ctx context.Context, values map[string]any, opts ...ChainCallOption) (map[string]any, error) + func (a APIChain) GetInputKeys() []string + func (a APIChain) GetMemory() schema.Memory + func (a APIChain) GetOutputKeys() []string + type Chain interface + Call func(ctx context.Context, inputs map[string]any, options ...ChainCallOption) (map[string]any, error) + GetInputKeys func() []string + GetMemory func() schema.Memory + GetOutputKeys func() []string + type ChainCallOption func(*chainCallOption) + func WithCallback(callbackHandler callbacks.Handler) ChainCallOption + func WithMaxLength(maxLength int) ChainCallOption + func WithMaxTokens(maxTokens int) ChainCallOption + func WithMinLength(minLength int) ChainCallOption + func WithModel(model string) ChainCallOption + func WithRepetitionPenalty(repetitionPenalty float64) ChainCallOption + func WithSeed(seed int) ChainCallOption + func WithStopWords(stopWords []string) ChainCallOption + func WithStreamingFunc(streamingFunc func(ctx context.Context, chunk []byte) error) ChainCallOption + func WithTemperature(temperature float64) ChainCallOption + func WithTopK(topK int) ChainCallOption + func WithTopP(topP float64) ChainCallOption + type ConditionalPromptSelector struct + Conditionals []struct{ ... } + DefaultPrompt prompts.PromptTemplate + func (s ConditionalPromptSelector) GetPrompt(llm llms.Model) prompts.PromptTemplate + type Constitutional struct + func NewConstitutional(llm llms.Model, chain LLMChain, ...) *Constitutional + func (c *Constitutional) Call(ctx context.Context, inputs map[string]any, options ...ChainCallOption) (map[string]any, error) + func (c *Constitutional) GetInputKeys() []string + func (c *Constitutional) GetMemory() schema.Memory + func (c *Constitutional) GetOutputKeys() []string + type ConstitutionalExample struct + type ConstitutionalPrinciple struct + func NewConstitutionalPrinciple(critique, revision string, names ...string) ConstitutionalPrinciple + type ConversationalRetrievalQA struct + CombineDocumentsChain Chain + CondenseQuestionChain Chain + InputKey string + Memory schema.Memory + OutputKey string + RephraseQuestion bool + Retriever schema.Retriever + ReturnGeneratedQuestion bool + ReturnSourceDocuments bool + func NewConversationalRetrievalQA(combineDocumentsChain Chain, condenseQuestionChain Chain, ...) ConversationalRetrievalQA + func NewConversationalRetrievalQAFromLLM(llm llms.Model, retriever schema.Retriever, memory schema.Memory) ConversationalRetrievalQA + func (c ConversationalRetrievalQA) Call(ctx context.Context, values map[string]any, options ...ChainCallOption) (map[string]any, error) + func (c ConversationalRetrievalQA) GetInputKeys() []string + func (c ConversationalRetrievalQA) GetMemory() schema.Memory + func (c ConversationalRetrievalQA) GetOutputKeys() []string + type HTTPRequest interface + Do func(req *http.Request) (*http.Response, error) + type LLMChain struct + CallbacksHandler callbacks.Handler + LLM llms.Model + Memory schema.Memory + OutputKey string + OutputParser schema.OutputParser[any] + Prompt prompts.FormatPrompter + func LoadCondenseQuestionGenerator(llm llms.Model) *LLMChain + func NewConversation(llm llms.Model, memory schema.Memory) LLMChain + func NewLLMChain(llm llms.Model, prompt prompts.FormatPrompter, opts ...ChainCallOption) *LLMChain + func (c LLMChain) Call(ctx context.Context, values map[string]any, options ...ChainCallOption) (map[string]any, error) + func (c LLMChain) GetCallbackHandler() callbacks.Handler + func (c LLMChain) GetInputKeys() []string + func (c LLMChain) GetMemory() schema.Memory + func (c LLMChain) GetOutputKeys() []string + type LLMMathChain struct + LLMChain *LLMChain + func NewLLMMathChain(llm llms.Model) LLMMathChain + func (c LLMMathChain) Call(ctx context.Context, values map[string]any, options ...ChainCallOption) (map[string]any, error) + func (c LLMMathChain) GetInputKeys() []string + func (c LLMMathChain) GetMemory() schema.Memory + func (c LLMMathChain) GetOutputKeys() []string + type MapReduceDocuments struct + InputKey string + LLMChain *LLMChain + LLMChainInputVariableName string + MaxNumberOfConcurrent int + Memory schema.Memory + ReduceChain Chain + ReduceDocumentVariableName string + ReturnIntermediateSteps bool + func LoadMapReduceQA(llm llms.Model) MapReduceDocuments + func LoadMapReduceSummarization(llm llms.Model) MapReduceDocuments + func NewMapReduceDocuments(llmChain *LLMChain, reduceChain Chain) MapReduceDocuments + func (c MapReduceDocuments) Call(ctx context.Context, values map[string]any, options ...ChainCallOption) (map[string]any, error) + func (c MapReduceDocuments) GetInputKeys() []string + func (c MapReduceDocuments) GetMemory() schema.Memory + func (c MapReduceDocuments) GetOutputKeys() []string + type MapRerankDocuments struct + AnswerKey string + DocumentVariableName string + InputKey string + LLMChain *LLMChain + LLMChainInputVariableName string + MaxConcurrentWorkers int + OutputKey string + RankKey string + ReturnIntermediateSteps bool + func LoadMapRerankQA(llm llms.Model) MapRerankDocuments + func NewMapRerankDocuments(mapRerankLLMChain *LLMChain) *MapRerankDocuments + func (c MapRerankDocuments) Call(ctx context.Context, values map[string]any, options ...ChainCallOption) (map[string]any, error) + func (c MapRerankDocuments) GetInputKeys() []string + func (c MapRerankDocuments) GetMemory() schema.Memory + func (c MapRerankDocuments) GetOutputKeys() []string + type Pair struct + type PromptSelector interface + GetPrompt func(llm llms.Model) prompts.PromptTemplate + type RefineDocuments struct + DocumentPrompt prompts.PromptTemplate + DocumentVariableName string + InitialResponseName string + InputKey string + LLMChain *LLMChain + OutputKey string + RefineLLMChain *LLMChain + func LoadRefineQA(llm llms.Model) RefineDocuments + func LoadRefineSummarization(llm llms.Model) RefineDocuments + func NewRefineDocuments(initialLLMChain, refineLLMChain *LLMChain) RefineDocuments + func (c RefineDocuments) Call(ctx context.Context, values map[string]any, options ...ChainCallOption) (map[string]any, error) + func (c RefineDocuments) GetInputKeys() []string + func (c RefineDocuments) GetMemory() schema.Memory + func (c RefineDocuments) GetOutputKeys() []string + type RetrievalQA struct + CombineDocumentsChain Chain + InputKey string + Retriever schema.Retriever + ReturnSourceDocuments bool + func NewRetrievalQA(combineDocumentsChain Chain, retriever schema.Retriever) RetrievalQA + func NewRetrievalQAFromLLM(llm llms.Model, retriever schema.Retriever) RetrievalQA + func (c RetrievalQA) Call(ctx context.Context, values map[string]any, options ...ChainCallOption) (map[string]any, error) + func (c RetrievalQA) GetInputKeys() []string + func (c RetrievalQA) GetMemory() schema.Memory + func (c RetrievalQA) GetOutputKeys() []string + type SQLDatabaseChain struct + Database *sqldatabase.SQLDatabase + LLMChain *LLMChain + OutputKey string + TopK int + func NewSQLDatabaseChain(llm llms.Model, topK int, database *sqldatabase.SQLDatabase) *SQLDatabaseChain + func (s SQLDatabaseChain) Call(ctx context.Context, inputs map[string]any, options ...ChainCallOption) (map[string]any, error) + func (s SQLDatabaseChain) GetInputKeys() []string + func (s SQLDatabaseChain) GetMemory() schema.Memory + func (s SQLDatabaseChain) GetOutputKeys() []string + type SequentialChain struct + func NewSequentialChain(chains []Chain, inputKeys []string, outputKeys []string, ...) (*SequentialChain, error) + func (c *SequentialChain) Call(ctx context.Context, inputs map[string]any, options ...ChainCallOption) (map[string]any, error) + func (c *SequentialChain) GetInputKeys() []string + func (c *SequentialChain) GetMemory() schema.Memory + func (c *SequentialChain) GetOutputKeys() []string + type SequentialChainOption func(*SequentialChain) + func WithSeqChainMemory(memory schema.Memory) SequentialChainOption + type SimpleSequentialChain struct + func NewSimpleSequentialChain(chains []Chain) (*SimpleSequentialChain, error) + func (c *SimpleSequentialChain) Call(ctx context.Context, inputs map[string]any, options ...ChainCallOption) (map[string]any, error) + func (c *SimpleSequentialChain) GetInputKeys() []string + func (c *SimpleSequentialChain) GetMemory() schema.Memory + func (c *SimpleSequentialChain) GetOutputKeys() []string + type StuffDocuments struct + DocumentVariableName string + InputKey string + LLMChain *LLMChain + Separator string + func LoadStuffQA(llm llms.Model) StuffDocuments + func LoadStuffSummarization(llm llms.Model) StuffDocuments + func NewStuffDocuments(llmChain *LLMChain) StuffDocuments + func (c StuffDocuments) Call(ctx context.Context, values map[string]any, options ...ChainCallOption) (map[string]any, error) + func (c StuffDocuments) GetInputKeys() []string + func (c StuffDocuments) GetMemory() schema.Memory + func (c StuffDocuments) GetOutputKeys() []string + type Transform struct + InputKeys []string + Memory schema.Memory + OutputKeys []string + Transform TransformFunc + func NewTransform(f TransformFunc, inputVariables []string, outputVariables []string) Transform + func (c Transform) Call(ctx context.Context, inputs map[string]any, options ...ChainCallOption) (map[string]any, error) + func (c Transform) GetInputKeys() []string + func (c Transform) GetMemory() schema.Memory + func (c Transform) GetOutputKeys() []string + type TransformFunc func(context.Context, map[string]any, ...ChainCallOption) (map[string]any, error)