RunnablePassthrough<RunInput extends Object> class

A RunnablePassthrough takes the input it receives and passes it through as output.

You can create a RunnablePassthrough using the Runnable.passthrough static method.

When you call invoke on a RunnablePassthrough, it will return the input it receives.

Example:

final openaiApiKey = Platform.environment['OPENAI_API_KEY'];
final model = ChatOpenAI(apiKey: openaiApiKey);

final promptTemplate = ChatPromptTemplate.fromTemplate(
  'Tell me a joke about {foo}',
);

final map = Runnable.fromMap({
  'foo': Runnable.passthrough(),
});
final chain = map | promptTemplate | model | StringOutputParser();

final res = await chain.invoke('bears');
print(res);
// Why don't bears wear shoes? Because they have bear feet!
Inheritance
Available extensions

Constructors

RunnablePassthrough()
A RunnablePassthrough takes the input it receives and passes it through as output.
const

Properties

defaultOptions → RunnableOptions
The default options to use when invoking the Runnable.
finalinherited
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

batch(List<RunInput> inputs, {List<RunnableOptions>? options}) → Future<List<RunInput>>
Batches the invocation of the Runnable on the given inputs.
inherited
bind(RunnableOptions options) → RunnableBinding<RunInput, RunnableOptions, RunInput>
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<RunInput>
Invokes the RunnablePassthrough 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<RunInput, 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<RunInput>
Streams the output of invoking the Runnable on the given input.
inherited
streamFromInputStream(Stream<RunInput> inputStream, {RunnableOptions? options}) → Stream<RunInput>
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, RunInput>> fallbacks) → RunnableWithFallback<RunInput, RunInput>
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, RunInput>
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.