SimpleSequentialChain constructor

SimpleSequentialChain({
  1. required List<BaseChain<BaseMemory>> chains,
  2. BaseMemory? memory,
  3. String inputKey = defaultInputKey,
  4. String outputKey = defaultOutputKey,
  5. bool trimOutputs = false,
})

SimpleSequentialChain is a simpler form of SequentialChain, where each step has a singular input/output, and the output of one step is the input to the next.

It is suitable for cases where you only need to pass a single string as an argument and get a single string as output for all steps in the chain.

Example:

final chain1 = FakeChain(
  inputVariables: {'foo'},
  outputVariables: {'bar'},
);
final chain2 = FakeChain(
  inputVariables: {'bar'},
  outputVariables: {'baz'},
);
final chain = SimpleSequentialChain(chains: [chain1, chain2]);
final output = await chain({'input': '123'});

Implementation

SimpleSequentialChain({
  required this.chains,
  super.memory,
  final String inputKey = defaultInputKey,
  final String outputKey = defaultOutputKey,
  this.trimOutputs = false,
}) : inputKeys = {inputKey},
     outputKeys = {outputKey} {
  assert(_isChainValid());
}