RunnableRetry wraps a Runnable and retries it if it fails. It be created using runnable.withRetry().
By default, the runnable will be retried 3 times with exponential backoff strategy.
final chatModel = ChatOpenAI();
final chatModelWithRetry = chatModel.withRetry(maxRetries: 5);
final res = await chatModelWithRetry.invoke(...);
RunnableRetry can be used to retry any Runnable, including a chain of Runnables.
final promptTemplate = ChatPromptTemplate.fromTemplate('tell me a joke about {topic}');
final model = ChatOpenAI();
final chain = promptTemplate.pipe(model).withRetry();
final res = await chain.batch([
{'topic': 'bears'},
{'topic': 'cats'},
]);
Resolves #514
RunnableRetry
wraps aRunnable
and retries it if it fails. It be created usingrunnable.withRetry()
.By default, the runnable will be retried 3 times with exponential backoff strategy.
RunnableRetry
can be used to retry anyRunnable
, including a chain ofRunnable
s.