mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-20 11:31:58 +00:00
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
This commit is contained in:
parent
da96c511d1
commit
f406dc3872
@ -56,14 +56,14 @@ class RunnableRetry(RunnableBindingBase[Input, Output]):
|
|||||||
|
|
||||||
def foo(input) -> None:
|
def foo(input) -> None:
|
||||||
'''Fake function that raises an exception.'''
|
'''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 = RunnableLambda(foo)
|
||||||
|
|
||||||
runnable_with_retries = runnable.with_retry(
|
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
|
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:
|
# The method invocation above is equivalent to the longer form below:
|
||||||
|
Loading…
Reference in New Issue
Block a user