From f406dc387256daecc6a2c8d02727f38ad2f2c1e1 Mon Sep 17 00:00:00 2001 From: Kapil Sachdeva Date: Wed, 17 Jan 2024 11:11:27 -0600 Subject: [PATCH] docs: in RunnableRetry, correct the example snippet that uses with_retry method on Runnable (#16108) The example code snippet for with_retry is using incorrect argument names. This PR fixes that --- libs/core/langchain_core/runnables/retry.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/core/langchain_core/runnables/retry.py b/libs/core/langchain_core/runnables/retry.py index f619c45f592..36a508776ce 100644 --- a/libs/core/langchain_core/runnables/retry.py +++ b/libs/core/langchain_core/runnables/retry.py @@ -56,14 +56,14 @@ class RunnableRetry(RunnableBindingBase[Input, Output]): def foo(input) -> None: '''Fake function that raises an exception.''' - raise ValueError("Invoking foo failed. At time {time.time()}") + raise ValueError(f"Invoking foo failed. At time {time.time()}") runnable = RunnableLambda(foo) runnable_with_retries = runnable.with_retry( - retry_exception_types=(ValueError,), # Retry only on ValueError + retry_if_exception_type=(ValueError,), # Retry only on ValueError wait_exponential_jitter=True, # Add jitter to the exponential backoff - max_attempt_number=2, # Try twice + stop_after_attempt=2, # Try twice ) # The method invocation above is equivalent to the longer form below: