SimpleSequentialChain class
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'});
- Inheritance
-
- Object
- Runnable<
ChainValues, ChainOptions, ChainValues> - BaseLangChain<
ChainValues, ChainOptions, ChainValues> - BaseChain<
BaseMemory> - SimpleSequentialChain
Constructors
-
SimpleSequentialChain.new({required List<
BaseChain< chains, BaseMemory? memory, String inputKey = defaultInputKey, String outputKey = defaultOutputKey, bool trimOutputs = false})BaseMemory> > - 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.
Properties
-
chains
→ List<
BaseChain< BaseMemory> > -
The chains to run sequentially.
final
- chainType → String
-
Return the string type key uniquely identifying this class of chain.
no setteroverride
- defaultOptions → ChainOptions
-
The default options to use when invoking the Runnable.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
inputKeys
↔ Set<
String> -
Input keys for this chain.
getter/setter pairoverride-getter
- memory → BaseMemory?
-
Memory to use for this chain.
finalinherited
-
outputKeys
↔ Set<
String> -
Output keys for this chain.
getter/setter pairoverride-getter
- 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
- trimOutputs → bool
-
Whether to trim the outputs of the chains before passing them to the next
chain. By default, the outputs are not trimmed.
final
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
-
getCompatibleOptions(
RunnableOptions? options) → ChainOptions? -
Returns the given
options
if they are compatible with the Runnable, otherwise returnsnull
.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
-
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< fallbacks) → RunnableWithFallback<ChainValues, RunnableOptions, ChainValues> >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 input key for the input of the chain.
- defaultOutputKey → const String
- Default output key for the output of the chain.