retry.py — langchain Source File
Architecture documentation for retry.py, a python file in the langchain codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 4b1ae7cc_f0e0_3b9c_39b8_cde719e2067d["retry.py"] feec1ec4_6917_867b_d228_b134d0ff8099["typing"] 4b1ae7cc_f0e0_3b9c_39b8_cde719e2067d --> feec1ec4_6917_867b_d228_b134d0ff8099 95c52e7f_10c7_6e61_0929_b2c359db94fd["tenacity"] 4b1ae7cc_f0e0_3b9c_39b8_cde719e2067d --> 95c52e7f_10c7_6e61_0929_b2c359db94fd f85fae70_1011_eaec_151c_4083140ae9e5["typing_extensions"] 4b1ae7cc_f0e0_3b9c_39b8_cde719e2067d --> f85fae70_1011_eaec_151c_4083140ae9e5 15b6f2ac_8a3b_5719_0e4d_4652995195ed["langchain_core.runnables.base"] 4b1ae7cc_f0e0_3b9c_39b8_cde719e2067d --> 15b6f2ac_8a3b_5719_0e4d_4652995195ed a8ec7563_2814_99b3_c6da_61c599efc542["langchain_core.runnables.config"] 4b1ae7cc_f0e0_3b9c_39b8_cde719e2067d --> a8ec7563_2814_99b3_c6da_61c599efc542 b4920617_3c91_2457_3f8c_84ba49f64322["langchain_core.runnables.utils"] 4b1ae7cc_f0e0_3b9c_39b8_cde719e2067d --> b4920617_3c91_2457_3f8c_84ba49f64322 e61aa479_9dc0_09a0_8864_cbf23b8b506c["langchain_core.callbacks.manager"] 4b1ae7cc_f0e0_3b9c_39b8_cde719e2067d --> e61aa479_9dc0_09a0_8864_cbf23b8b506c style 4b1ae7cc_f0e0_3b9c_39b8_cde719e2067d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""`Runnable` that retries a `Runnable` if it fails."""
from typing import (
TYPE_CHECKING,
Any,
TypeVar,
cast,
)
from tenacity import (
AsyncRetrying,
RetryCallState,
RetryError,
Retrying,
retry_if_exception_type,
stop_after_attempt,
wait_exponential_jitter,
)
from typing_extensions import TypedDict, override
from langchain_core.runnables.base import RunnableBindingBase
from langchain_core.runnables.config import RunnableConfig, patch_config
from langchain_core.runnables.utils import Input, Output
if TYPE_CHECKING:
from langchain_core.callbacks.manager import (
AsyncCallbackManagerForChainRun,
CallbackManagerForChainRun,
)
T = TypeVar("T", CallbackManagerForChainRun, AsyncCallbackManagerForChainRun)
U = TypeVar("U")
class ExponentialJitterParams(TypedDict, total=False):
"""Parameters for `tenacity.wait_exponential_jitter`."""
initial: float
"""Initial wait."""
max: float
"""Maximum wait."""
exp_base: float
"""Base for exponential backoff."""
jitter: float
"""Random additional wait sampled from random.uniform(0, jitter)."""
class RunnableRetry(RunnableBindingBase[Input, Output]): # type: ignore[no-redef]
"""Retry a Runnable if it fails.
RunnableRetry can be used to add retry logic to any object
that subclasses the base Runnable.
Such retries are especially useful for network calls that may fail
due to transient errors.
The RunnableRetry is implemented as a RunnableBinding. The easiest
way to use it is through the `.with_retry()` method on all Runnables.
Example:
// ... (320 more lines)
Domain
Subdomains
Functions
Dependencies
- langchain_core.callbacks.manager
- langchain_core.runnables.base
- langchain_core.runnables.config
- langchain_core.runnables.utils
- tenacity
- typing
- typing_extensions
Source
Frequently Asked Questions
What does retry.py do?
retry.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, Runnables subdomain.
What functions are defined in retry.py?
retry.py defines 1 function(s): langchain_core.
What does retry.py depend on?
retry.py imports 7 module(s): langchain_core.callbacks.manager, langchain_core.runnables.base, langchain_core.runnables.config, langchain_core.runnables.utils, tenacity, typing, typing_extensions.
Where is retry.py in the architecture?
retry.py is located at libs/core/langchain_core/runnables/retry.py (domain: LangChainCore, subdomain: Runnables, directory: libs/core/langchain_core/runnables).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free