RunnableRetry<RunInput extends Object?, RunOutput extends Object?> constructor

RunnableRetry<RunInput extends Object?, RunOutput extends Object?>({
  1. required Runnable<RunInput, RunnableOptions, RunOutput> runnable,
  2. required RunnableOptions defaultOptions,
  3. required RetryOptions retryOptions,
})

A Runnable that automatically retries the operation if it fails.

You can create a RunnableRetry using Runnable.withRetry, passing in the RetryOptions.

When invoke or batch is called on the runnable, if the initial attempt fails, it will be retried according to the specified RetryOptions.

Example usage:

final model = ChatOpenAI(...);
final modelWithRetry = model.withRetry(maxRetries: 2);
final res = await modelWithRetry.invoke(...);

Implementation

RunnableRetry({
  required this.runnable,
  required super.defaultOptions,
  required this.retryOptions,
});