diff --git a/python/langsmith/client.py b/python/langsmith/client.py index 854239e4..6fe4d33c 100644 --- a/python/langsmith/client.py +++ b/python/langsmith/client.py @@ -827,6 +827,7 @@ def request_with_retries( *(retry_on or ()), *( ls_utils.LangSmithConnectionError, + ls_utils.LangSmithRequestTimeout, ls_utils.LangSmithAPIError, ), ) @@ -870,6 +871,11 @@ def request_with_retries( f" LangSmith API. {repr(e)}" f"{_context}" ) + elif response.status_code == 408: + raise ls_utils.LangSmithRequestTimeout( + f"Client took too long to send request to {method}" + f"{pathname} {_context}" + ) elif response.status_code == 429: raise ls_utils.LangSmithRateLimitError( f"Rate limit exceeded for {pathname}. {repr(e)}" diff --git a/python/langsmith/utils.py b/python/langsmith/utils.py index b63c65b5..4be0ce8f 100644 --- a/python/langsmith/utils.py +++ b/python/langsmith/utils.py @@ -52,6 +52,10 @@ class LangSmithAPIError(LangSmithError): """Internal server error while communicating with LangSmith.""" +class LangSmithRequestTimeout(LangSmithError): + """Client took too long to send request body.""" + + class LangSmithUserError(LangSmithError): """User error caused an exception when communicating with LangSmith."""