mirror of
https://github.com/hwchase17/langchain
synced 2024-11-04 06:00:26 +00:00
parent
2423f7f3b4
commit
1b0eebe1e3
@ -254,7 +254,7 @@ class Runnable(Generic[Input, Output], ABC):
|
||||
def with_retry(
|
||||
self,
|
||||
*,
|
||||
retry_if_exception_type: Tuple[Type[BaseException]] = (Exception,),
|
||||
retry_if_exception_type: Tuple[Type[BaseException], ...] = (Exception,),
|
||||
wait_exponential_jitter: bool = True,
|
||||
stop_after_attempt: int = 3,
|
||||
) -> Runnable[Input, Output]:
|
||||
@ -280,7 +280,7 @@ class Runnable(Generic[Input, Output], ABC):
|
||||
self,
|
||||
fallbacks: Sequence[Runnable[Input, Output]],
|
||||
*,
|
||||
exceptions_to_handle: Tuple[Type[BaseException]] = (Exception,),
|
||||
exceptions_to_handle: Tuple[Type[BaseException], ...] = (Exception,),
|
||||
) -> RunnableWithFallbacks[Input, Output]:
|
||||
return RunnableWithFallbacks(
|
||||
runnable=self,
|
||||
@ -653,7 +653,7 @@ class RunnableWithFallbacks(Serializable, Runnable[Input, Output]):
|
||||
|
||||
runnable: Runnable[Input, Output]
|
||||
fallbacks: Sequence[Runnable[Input, Output]]
|
||||
exceptions_to_handle: Tuple[Type[BaseException]] = (Exception,)
|
||||
exceptions_to_handle: Tuple[Type[BaseException], ...] = (Exception,)
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
|
@ -24,7 +24,7 @@ U = TypeVar("U")
|
||||
class RunnableRetry(RunnableBinding[Input, Output]):
|
||||
"""Retry a Runnable if it fails."""
|
||||
|
||||
retry_exception_types: Tuple[Type[BaseException]] = (Exception,)
|
||||
retry_exception_types: Tuple[Type[BaseException], ...] = (Exception,)
|
||||
|
||||
wait_exponential_jitter: bool = True
|
||||
|
||||
|
@ -1507,7 +1507,7 @@ async def test_async_retrying(mocker: MockerFixture) -> None:
|
||||
with pytest.raises(ValueError):
|
||||
await runnable.with_retry(
|
||||
stop_after_attempt=2,
|
||||
retry_if_exception_type=(ValueError,),
|
||||
retry_if_exception_type=(ValueError, KeyError),
|
||||
).ainvoke(1)
|
||||
|
||||
assert _lambda_mock.call_count == 2 # retried
|
||||
|
Loading…
Reference in New Issue
Block a user