BaseCombineDocumentsChain class abstract

Base interface for chains combining documents, such as StuffDocumentsChain.

Subclasses of this chain deal with combining documents in a variety of ways. This base class exists to add some uniformity in the interface these types of chains should expose. Namely, they expect an input key related to the documents to use (default defaultInputKey), and then also expose a method to calculate the length of a prompt from documents (useful for outside callers to use to determine whether it's safe to pass a list of documents into this chain or whether that will longer than the context length).

Inheritance
Implementers

Constructors

BaseCombineDocumentsChain.new({String inputKey = defaultInputKey, String outputKey = defaultOutputKey})
Base interface for chains combining documents, such as StuffDocumentsChain.
const

Properties

chainType String
Return the string type key uniquely identifying this class of chain.
no setterinherited
defaultOptions ChainOptions
The default options to use when invoking the Runnable.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
inputKey String
Key to use for input documents.
final
inputKeys Set<String>
Input keys for this chain.
no setteroverride
memory BaseMemory?
Memory to use for this chain.
finalinherited
outputKey String
Key to use for output text.
final
outputKeys Set<String>
Output keys for this chain.
no setteroverride
runOutputKey String
Output key from where the run method needs to take the return value.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

apply(List<ChainValues> inputs) Future<List<ChainValues>>
Call the chain on all inputs in the list.
inherited
batch(List<ChainValues> inputs, {List<ChainOptions>? options}) Future<List<ChainValues>>
Batches the invocation of the Runnable on the given inputs.
inherited
bind(ChainOptions options) RunnableBinding<ChainValues, ChainOptions, ChainValues>
Binds the Runnable to the given options.
inherited
call(dynamic input, {bool returnOnlyOutputs = false}) Future<ChainValues>
Runs the core logic of this chain with the given values. If memory is not null, it will be used to load and save values.
inherited
callInternal(ChainValues inputs) Future<ChainValues>
Call method to be implemented by subclasses (called by call). This is where the core logic of the chain should be implemented.
override
close() → void
Cleans up any resources associated with it the Runnable.
inherited
combineDocs(List<Document> docs, {InputValues inputs = const {}}) Future<ChainValues>
Combines the given docs into a single string.
formatDocument(Document doc, BasePromptTemplate prompt) String
Formats a document into a string based on a prompt template.
getCompatibleOptions(RunnableOptions? options) ChainOptions?
Returns the given options if they are compatible with the Runnable, otherwise returns null.
inherited
invoke(ChainValues input, {ChainOptions? options}) Future<ChainValues>
Runs the core logic of this chain with the given input.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pipe<NewRunOutput extends Object?, NewCallOptions extends RunnableOptions>(Runnable<ChainValues, NewCallOptions, NewRunOutput> next) RunnableSequence<ChainValues, NewRunOutput>
Pipes the output of this Runnable into another Runnable using a RunnableSequence.
inherited
promptLength(List<Document> docs, {InputValues inputs = const {}}) Future<int?>
Returns the prompt length (number of tokens) given the documents passed in.
run(dynamic input) Future<String>
Convenience method for executing chain when there's a single string output.
inherited
stream(ChainValues input, {ChainOptions? options}) Stream<ChainValues>
Streams the output of invoking the Runnable on the given input.
inherited
streamFromInputStream(Stream<ChainValues> inputStream, {ChainOptions? options}) Stream<ChainValues>
Streams the output of invoking the Runnable on the given inputStream.
inherited
toString() String
A string representation of this object.
inherited
withFallbacks(List<Runnable<ChainValues, RunnableOptions, ChainValues>> fallbacks) RunnableWithFallback<ChainValues, ChainValues>
Adds fallback runnables to be invoked if the primary runnable fails.
inherited
withRetry({int maxRetries = 3, FutureOr<bool> retryIf(Object e)?, List<Duration?>? delayDurations, bool addJitter = false}) RunnableRetry<ChainValues, ChainValues>
Adds retry logic to an existing runnable.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

defaultInputKey → const String
Default inputKey value.
defaultOutputKey → const String
Default outputKey value.
pageContentPromptVar → const String
Prompt variable to use for the page content.