Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(router): import retry helpers inside their functions to break CodeQL import cycles

yassin10be7e01d4ac
diff --git a/litellm/router.py b/litellm/router.py
index a46ffa83b05..31ea81e35be 100644
--- a/litellm/router.py
+++ b/litellm/router.py
@@ -241,7 +241,6 @@ from litellm.types.router import (
ModelGroupInfo,
OptionalPreCallChecks,
PreRoutingStrategy,
- RetryAttemptRecord,
RetryPolicy,
RouterCacheEnum,
RouterErrors,
@@ -8362,6 +8361,8 @@ class Router:
"""
When a retry or fallback happens, record which model group, deployment and attempt just failed and why
"""
+ from litellm.types.router import RetryAttemptRecord
+
_metadata_var: Final = "litellm_metadata" if "litellm_metadata" in kwargs else "metadata"
request_metadata: Final[Mapping[str, object]] = kwargs[_metadata_var]
model_group: Final = kwargs.get("model")
diff --git a/litellm/utils.py b/litellm/utils.py
index a0e910a1616..cc1c52d1c78 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -81,7 +81,7 @@ from litellm.constants import (
PROVIDERS_THAT_AUTHENTICATE_ON_PROVIDER_INFO,
TOOL_CHOICE_OBJECT_TOKEN_COUNT,
)
-from litellm.litellm_core_utils.core_helpers import max_retries_per_request_hit, normalize_drop_params
+from litellm.litellm_core_utils.core_helpers import normalize_drop_params
from litellm.litellm_core_utils.fallback_generalizations import (
match_capability_generalizations,
)
@@ -1500,6 +1500,8 @@ def post_call_processing(
def client(original_function):
+ from litellm.litellm_core_utils.core_helpers import max_retries_per_request_hit
+
Rules: Final = litellm_utils.Rules
rules_obj: Final = Rules()