From 6873229bbfca95ec6a05dff88e313e2a5598446f Mon Sep 17 00:00:00 2001 From: Itay Etelis Date: Wed, 18 Sep 2024 13:39:04 +0300 Subject: [PATCH] Support lists in `retry_on` for RetryPolicy Previously, `retry_on` in `RetryPolicy` accepted only exception classes, tuples of exception classes, or callables. Update the `retry_on` type annotation to include `List[Type[Exception]]` Changes: - Updated `retry_on` in `RetryPolicy` to accept `List[Type[Exception]]`. --- libs/langgraph/langgraph/pregel/types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/langgraph/langgraph/pregel/types.py b/libs/langgraph/langgraph/pregel/types.py index 589ed43ab..ca548ba64 100644 --- a/libs/langgraph/langgraph/pregel/types.py +++ b/libs/langgraph/langgraph/pregel/types.py @@ -1,5 +1,5 @@ from collections import deque -from typing import Any, Callable, Literal, NamedTuple, Optional, Type, Union +from typing import Any, Callable, Literal, NamedTuple, Optional, Type, Union, List from langchain_core.runnables import Runnable, RunnableConfig @@ -52,7 +52,7 @@ class RetryPolicy(NamedTuple): jitter: bool = True """Whether to add random jitter to the interval between retries.""" retry_on: Union[ - Type[Exception], tuple[Type[Exception], ...], Callable[[Exception], bool] + Type[Exception], List[Type[Exception]], tuple[Type[Exception], ...], Callable[[Exception], bool] ] = default_retry_on """List of exception classes that should trigger a retry, or a callable that returns True for exceptions that should trigger a retry."""