RunnableMapInput<RunInput extends Object, RunOutput extends Object> class

A RunnableMapInput allows you to map the input to a different value.

You can create a RunnableMapInput using the Runnable.mapInput static method.

When you call invoke on a RunnableMapInput, it will take the input it receives and returns the output returned by the given inputMapper function.

Example:

final agent = Agent.fromRunnable(
  Runnable.mapInput(
    (final AgentPlanInput planInput) => <String, dynamic>{
      'input': planInput.inputs['input'],
      'agent_scratchpad': buildScratchpad(planInput.intermediateSteps),
    },
  ).pipe(prompt).pipe(model).pipe(outputParser),
  tools: [tool],
);
Inheritance
Available extensions

Constructors

RunnableMapInput(FutureOr<RunOutput> inputMapper(RunInput input))
A RunnableMapInput allows you to map the input to a different value.
const

Properties

defaultOptions RunnableOptions
The default options to use when invoking the Runnable.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
inputMapper FutureOr<RunOutput> Function(RunInput input)
A function that maps RunInput to RunOutput.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

batch(List<RunInput> inputs, {List<RunnableOptions>? options}) Future<List<RunOutput>>
Batches the invocation of the Runnable on the given inputs.
inherited
bind(RunnableOptions options) RunnableBinding<RunInput, RunnableOptions, RunOutput>
Binds the Runnable to the given options.
inherited
close() → void
Cleans up any resources associated with it the Runnable.
inherited
getCompatibleOptions(RunnableOptions? options) RunnableOptions?
Returns the given options if they are compatible with the Runnable, otherwise returns null.
inherited
invoke(RunInput input, {RunnableOptions? options}) Future<RunOutput>
Invokes the RunnableMapInput on the given input.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pipe<NewRunOutput extends Object?, NewCallOptions extends RunnableOptions>(Runnable<RunOutput, NewCallOptions, NewRunOutput> next) RunnableSequence<RunInput, NewRunOutput>
Pipes the output of this Runnable into another Runnable using a RunnableSequence.
inherited
stream(RunInput input, {RunnableOptions? options}) Stream<RunOutput>
Streams the output of invoking the Runnable on the given input.
inherited
streamFromInputStream(Stream<RunInput> inputStream, {RunnableOptions? options}) Stream<RunOutput>
Streams the output of invoking the Runnable on the given inputStream.
inherited
toString() String
A string representation of this object.
inherited
withFallbacks(List<Runnable<RunInput, RunnableOptions, RunOutput>> fallbacks) RunnableWithFallback<RunInput, RunOutput>
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<RunInput, RunOutput>
Adds retry logic to an existing runnable.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator |(Runnable<RunOutput, RunnableOptions, NewRunOutput> next) RunnableSequence<RunInput, NewRunOutput>

Available on Runnable<RunInput, CallOptions, RunOutput>, provided by the RunnableX extension

Pipes the output of this Runnable into another Runnable.