Update request handling for original exceptions

This commit is contained in:
Shubham Pathak 2025-09-29 12:04:44 +05:30 • committed by GitHub
parent 0d738b2899
commit acdf9b64d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1498,7 +1498,7 @@ def exception_type( # type: ignore # noqa: PLR0915
message=f"CohereException - {original_exception.message}",
llm_provider="cohere",
model=model,
request=original_exception.request,
request=getattr(original_exception, "request", None),,
)
raise original_exception
elif custom_llm_provider == "huggingface":
@ -1573,7 +1573,7 @@ def exception_type( # type: ignore # noqa: PLR0915
message=f"HuggingfaceException - {original_exception.message}",
llm_provider="huggingface",
model=model,
request=original_exception.request,
request=getattr(original_exception, "request", None),,
)
elif custom_llm_provider == "ai21":
if hasattr(original_exception, "message"):
@ -1632,7 +1632,7 @@ def exception_type( # type: ignore # noqa: PLR0915
message=f"AI21Exception - {original_exception.message}",
llm_provider="ai21",
model=model,
request=original_exception.request,
request=getattr(original_exception, "request", None),,
)
elif custom_llm_provider == "nlp_cloud":
if "detail" in error_str:
@ -1659,7 +1659,7 @@ def exception_type( # type: ignore # noqa: PLR0915
message=f"NLPCloudException - {error_str}",
model=model,
llm_provider="nlp_cloud",
request=original_exception.request,
request=getattr(original_exception, "request", None),,
)
if hasattr(
original_exception, "status_code"
@ -1719,7 +1719,7 @@ def exception_type( # type: ignore # noqa: PLR0915
message=f"NLPCloudException - {original_exception.message}",
llm_provider="nlp_cloud",
model=model,
request=original_exception.request,
request=getattr(original_exception, "request", None),,
)
elif (
original_exception.status_code == 504
@ -1739,7 +1739,7 @@ def exception_type( # type: ignore # noqa: PLR0915
message=f"NLPCloudException - {original_exception.message}",
llm_provider="nlp_cloud",
model=model,
request=original_exception.request,
request=getattr(original_exception, "request", None),,
)
elif custom_llm_provider == "together_ai":
try:
@ -1848,7 +1848,7 @@ def exception_type( # type: ignore # noqa: PLR0915
message=f"TogetherAIException - {original_exception.message}",
llm_provider="together_ai",
model=model,
request=original_exception.request,
request=getattr(original_exception, "request", None),,
)
elif custom_llm_provider == "aleph_alpha":
if (
@ -1953,7 +1953,7 @@ def exception_type( # type: ignore # noqa: PLR0915
message=f"VLLMException - {original_exception.message}",
llm_provider="vllm",
model=model,
request=original_exception.request,
request=getattr(original_exception, "request", None),,
)
elif custom_llm_provider == "azure" or custom_llm_provider == "azure_text":
message = get_error_message(error_obj=original_exception)
@ -2208,7 +2208,7 @@ def exception_type( # type: ignore # noqa: PLR0915
message=f"APIError: {exception_provider} - {error_str}",
llm_provider=custom_llm_provider,
model=model,
request=original_exception.request,
request=getattr(original_exception, "request", None),,
litellm_debug_info=extra_information,
)
else:
@ -2243,7 +2243,7 @@ def exception_type( # type: ignore # noqa: PLR0915
message="{} - {}".format(exception_provider, error_str),
llm_provider=custom_llm_provider,
model=model,
request=original_exception.request,
request=getattr(original_exception, "request", None),,
)
else:
raise APIConnectionError(