BaseChain<MemoryType extends BaseMemory> constructor

const BaseChain<MemoryType extends BaseMemory>({
  1. MemoryType? memory,
  2. ChainOptions? defaultOptions,
})

Base class for creating structured sequences of calls to components.

Chains should be used to encode a sequence of calls to components like models, document retrievers, other chains, etc., and provide a simple interface to this sequence.

The BaseChain interface makes it easy to create apps that are:

  • Stateful: add Memory to any Chain to give it state.
  • Observable: pass Callbacks to a Chain to execute additional functionality, like logging, outside the main sequence of component calls.
  • Composable: the Chain API is flexible enough that it is easy to combine Chains with other components, including other Chains.

The main methods exposed by chains are:

  • call Chains are callable. The call method is the primary way to execute a Chain. This takes inputs as a dictionary and returns a dictionary output.
  • run A convenience method that takes inputs and returns the output as a string. This method can only be used if the Chain has a single string output.

Implementation

const BaseChain({
  this.memory,
  final ChainOptions? defaultOptions,
}) : super(defaultOptions: defaultOptions ?? const ChainOptions());