withFallbacks method
RunnableWithFallback<PromptValue, ChatResult>
withFallbacks(
- List<
Runnable< fallbacksPromptValue, RunnableOptions, ChatResult> >
inherited
Adds fallback runnables to be invoked if the primary runnable fails.
This method creates a RunnableWithFallback
instance that wraps the
current Runnable
. If the initial invocation of the current Runnable
fails, the fallbacks
runnables are attempted in the order they are
provided. This process continues until a runnable succeeds or all
fallbacks fail. The result of the first successful runnable is returned,
or an error is thrown if all runnables fail.
fallbacks
- A list ofRunnable
instances to be used as fallbacks.
Implementation
RunnableWithFallback<RunInput, RunOutput> withFallbacks(
List<Runnable<RunInput, RunnableOptions, RunOutput>> fallbacks,
) {
return RunnableWithFallback<RunInput, RunOutput>(
mainRunnable: this,
fallbacks: fallbacks,
);
}