rag

package
v0.0.45 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package rag provides functionality for Retrieval-Augmented Generation (RAG).

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

This section is empty.

Types

type ConversationalRetrieval

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

ConversationalRetrieval is a chain implementation for conversational retrieval.

func NewConversationalRetrieval

func NewConversationalRetrieval(llm schema.LLM, retriever schema.Retriever, optFns ...func(o *ConversationalRetrievalOptions)) (*ConversationalRetrieval, error)

NewConversationalRetrieval creates a new instance of the ConversationalRetrieval chain.

func (ConversationalRetrieval) Call

Call executes the ConversationalRetrieval chain with the given context and inputs. It returns the outputs of the chain or an error, if any.

func (ConversationalRetrieval) Callbacks

func (c ConversationalRetrieval) Callbacks() []schema.Callback

Callbacks returns the callbacks associated with the chain.

func (ConversationalRetrieval) InputKeys

func (c ConversationalRetrieval) InputKeys() []string

InputKeys returns the expected input keys.

func (ConversationalRetrieval) Memory

Memory returns the memory associated with the chain.

func (ConversationalRetrieval) OutputKeys

func (c ConversationalRetrieval) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

func (ConversationalRetrieval) Type

Type returns the type of the chain.

func (ConversationalRetrieval) Verbose

func (c ConversationalRetrieval) Verbose() bool

Verbose returns the verbosity setting of the chain.

type ConversationalRetrievalOptions

type ConversationalRetrievalOptions struct {
	*schema.CallbackOptions

	// Return the source documents
	ReturnSourceDocuments bool

	// Return the generated question
	ReturnGeneratedQuestion bool

	CondenseQuestionPrompt *prompt.Template
	StuffQAPrompt          *prompt.Template
	Memory                 schema.Memory
	InputKey               string
	OutputKey              string

	// If set, restricts the docs to return from store based on tokens, enforced only
	// for StuffDocumentsChain
	MaxTokenLimit uint
}

ConversationalRetrievalOptions represents the options for the ConversationalRetrieval chain.

type RefineDocuments

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

func NewRefineDocuments

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

func NewRefineSummarization

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

func (*RefineDocuments) Call

func (c *RefineDocuments) Call(ctx context.Context, values schema.ChainValues, optFns ...func(o *schema.CallOptions)) (schema.ChainValues, error)

Call executes the ConversationalRetrieval chain with the given context and inputs. It returns the outputs of the chain or an error, if any.

func (*RefineDocuments) Callbacks

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

Callbacks returns the callbacks associated with the chain.

func (*RefineDocuments) InputKeys

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

InputKeys returns the expected input keys.

func (*RefineDocuments) Memory

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

Memory returns the memory associated with the chain.

func (*RefineDocuments) OutputKeys

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

OutputKeys returns the output keys the chain will return.

func (*RefineDocuments) Type

func (c *RefineDocuments) Type() string

Type returns the type of the chain.

func (*RefineDocuments) Verbose

func (c *RefineDocuments) Verbose() bool

Verbose returns the verbosity setting of the chain.

type RefineDocumentsOptions

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

type RefineSummarizationOptions

type RefineSummarizationOptions struct {
	*schema.CallbackOptions
}

type RetrievalQA

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

func NewRetrievalQA

func NewRetrievalQA(llm schema.LLM, retriever schema.Retriever, optFns ...func(o *RetrievalQAOptions)) (*RetrievalQA, error)

func (*RetrievalQA) Call

func (c *RetrievalQA) Call(ctx context.Context, values schema.ChainValues, optFns ...func(o *schema.CallOptions)) (schema.ChainValues, error)

Call executes the ConversationalRetrieval chain with the given context and inputs. It returns the outputs of the chain or an error, if any.

func (*RetrievalQA) Callbacks

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

Callbacks returns the callbacks associated with the chain.

func (*RetrievalQA) InputKeys

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

InputKeys returns the expected input keys.

func (*RetrievalQA) Memory

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

Memory returns the memory associated with the chain.

func (*RetrievalQA) OutputKeys

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

OutputKeys returns the output keys the chain will return.

func (*RetrievalQA) Type

func (c *RetrievalQA) Type() string

Type returns the type of the chain.

func (*RetrievalQA) Verbose

func (c *RetrievalQA) Verbose() bool

Verbose returns the verbosity setting of the chain.

type RetrievalQAOptions

type RetrievalQAOptions struct {
	*schema.CallbackOptions
	StuffQAPrompt *prompt.Template
	InputKey      string

	// Return the source documents
	ReturnSourceDocuments bool

	// If set, restricts the docs to return from store based on tokens, enforced only
	// for StuffDocumentsChain
	MaxTokenLimit uint
}

type StuffDocuments

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

func NewStuffDocuments

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

func NewStuffSummarization

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

func (*StuffDocuments) Call

func (c *StuffDocuments) Call(ctx context.Context, values schema.ChainValues, optFns ...func(o *schema.CallOptions)) (schema.ChainValues, error)

Call executes the ConversationalRetrieval chain with the given context and inputs. It returns the outputs of the chain or an error, if any.

func (*StuffDocuments) Callbacks

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

Callbacks returns the callbacks associated with the chain.

func (*StuffDocuments) InputKeys

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

InputKeys returns the expected input keys.

func (*StuffDocuments) Memory

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

Memory returns the memory associated with the chain.

func (*StuffDocuments) OutputKeys

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

OutputKeys returns the output keys the chain will return.

func (*StuffDocuments) Type

func (c *StuffDocuments) Type() string

Type returns the type of the chain.

func (*StuffDocuments) Verbose

func (c *StuffDocuments) Verbose() bool

Verbose returns the verbosity setting of the chain.

type StuffDocumentsOptions

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

type StuffSummarizationOptions

type StuffSummarizationOptions struct {
	*schema.CallbackOptions
}

Jump to

Keyboard shortcuts

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