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]

use tenacity for langsmith

Ishaan Jaff0a6a437e642d
diff --git a/litellm/integrations/langsmith.py b/litellm/integrations/langsmith.py
index 424d18b6f6d..13d91d55bd9 100644
--- a/litellm/integrations/langsmith.py
+++ b/litellm/integrations/langsmith.py
@@ -9,13 +9,16 @@ import uuid
from datetime import datetime, timezone
from typing import Any, List, Optional, Union
-import backoff
import dotenv # type: ignore
import httpx
import requests # type: ignore
-from backoff import on_exception
-from backoff._typing import Details
from pydantic import BaseModel # type: ignore
+from tenacity import (
+ retry,
+ retry_if_exception_type,
+ stop_after_attempt,
+ wait_exponential,
+)
import litellm
from litellm._logging import verbose_logger
@@ -58,12 +61,6 @@ def is_serializable(value):
return not isinstance(value, non_serializable_types)
-def on_backoff(details: Details) -> None:
- verbose_logger.warning(
- f"Langsmith batch send failed. Retrying in {details['wait']} seconds. Attempt {details['tries']}/3"
- )
-
-
class LangsmithLogger(CustomLogger):
def __init__(self):
self.langsmith_api_key = os.getenv("LANGSMITH_API_KEY")
@@ -290,8 +287,10 @@ class LangsmithLogger(CustomLogger):
except:
verbose_logger.error(f"Langsmith Layer Error - {traceback.format_exc()}")
- @on_exception(
- backoff.expo, (httpx.HTTPError, Exception), max_tries=3, on_backoff=on_backoff
+ @retry(
+ stop=stop_after_attempt(3),
+ wait=wait_exponential(multiplier=1, min=4, max=10),
+ retry=retry_if_exception_type((httpx.HTTPStatusError, Exception)),
)
async def _async_send_batch(self):
"""