stuffdocumentschain

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain struct {
	// Next is the Chain called after formatting the documents.
	Next llm.Chain

	// Input key is the input key the StuffDocuments chain expects the
	//  documents to be in.
	InputKey string

	// DocumentVariableName is the variable name used in the llm_chain to put
	// the documents in.
	DocumentVariableName string

	// Separator is the string used to join the documents.
	Separator string
}

Chain that combines documents with a separator and uses the stuffed documents in an llm.Chain. The input values to the llm chain contains all input values given to this chain, and the stuffed document as a string in the key specified by the "DocumentVariableName" field that is by default set to "context".

func New

func New(next llm.Chain, options ...func(*Chain)) Chain

New creates a new stuff documents chain with an LLM chain used after formatting the documents.

func (Chain) Call

func (c Chain) Call(ctx context.Context, values map[string]any, options ...llm.ChainOption) (map[string]any, error)

Call handles the inner logic of the StuffDocuments chain.

func (Chain) InputKeys

func (c Chain) InputKeys() []string

InputKeys returns the expected input keys, by default "input_documents".

func (Chain) Memory

func (c Chain) Memory() llm.Memory

Memory returns empty memory.

func (Chain) OutputKeys

func (c Chain) OutputKeys() []string

OutputKeys returns the output keys the chain will return.

Jump to

Keyboard shortcuts

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