RunnableRouter<RunInput extends Object, RunOutput extends Object>  class 
 
A RunnableRouter takes the input it receives and routes it to the runnable returned by the router function.
You can create a RunnableRouter using the Runnable.fromRouter static method.
When you call invoke on a RunnableRouter, it will invoke the router function, passing the input to it. Then, the returned runnable will be invoked with the input.
Example:
final router = Runnable.fromRouter((Map<String, dynamic> input, _) {
  return switch(input['topic'] as String) {
    'langchain' => langchainChain,
    'anthropic' => anthropicChain,
    _ => generalChain,
  };
});
final fullChain = Runnable.fromMap({
      'topic': classificationChain,
      'question': Runnable.getItemFromMap('question'),
    }).pipe(router);
final res2 = await fullChain.invoke({
  'question': 'how do I use Anthropic?',
});
print(res2);
// As Dario Amodei told me, using Anthropic is a straightforward process that...
- Inheritance
- 
    - Object
- Runnable<RunInput, RunnableOptions, RunOutput> 
- RunnableRouter
 
- Available extensions
Constructors
- 
          RunnableRouter(FutureOr<Runnable< router(RunInput input, RunnableOptions? options))RunInput, RunnableOptions, RunOutput> >
- 
          A RunnableRouter takes the input it receives and routes it to the runnable
returned by the router function.
            const
Properties
- defaultOptions → RunnableOptions
- 
  The default options to use when invoking the Runnable.
  finalinherited
- hashCode → int
- 
  The hash code for this object.
  no setterinherited
- 
  router
  → FutureOr<Runnable< Function(RunInput input, RunnableOptions? options)RunInput, RunnableOptions, RunOutput> >
- 
  The function that will be called to determine the runnable to use.
  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 optionsif they are compatible with the Runnable, otherwise returnsnull.inherited
- 
  invoke(RunInput input, {RunnableOptions? options}) → Future< RunOutput> 
- 
  Invokes the Runnable 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.override
- 
  streamFromInputStream(Stream< RunInput> inputStream, {RunnableOptions? options}) → Stream<RunOutput> 
- 
  Streams the output of invoking the Runnable on the given inputStream.override
- 
  toString() → String 
- 
  A string representation of this object.
  inherited
- 
  withFallbacks(List< Runnable< fallbacks) → RunnableWithFallback<RunInput, RunnableOptions, RunOutput> >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< Pipes the output of this Runnable into another Runnable.RunInput, CallOptions, RunOutput> , provided by the RunnableX extension