From c04fa54d1956e102efe5281e10c6e8df780fe14b Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 8 Jan 2024 07:42:17 +0530 Subject: [PATCH] fix(utils.py): fix exception raised --- litellm/utils.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/litellm/utils.py b/litellm/utils.py index ff09390dad..0a8c410ea0 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -4123,7 +4123,19 @@ def get_llm_provider( ) return model, custom_llm_provider, dynamic_api_key, api_base except Exception as e: - raise Exception(f"GetLLMProvider Exception - {str(e)}\n\noriginal model: {model}") + if isinstance(e, litellm.exceptions.BadRequestError): + raise e + else: + raise litellm.exceptions.BadRequestError( # type: ignore + message=f"GetLLMProvider Exception - {str(e)}\n\noriginal model: {model}", + model=model, + response=httpx.Response( + status_code=400, + content=error_str, + request=httpx.request(method="completion", url="https://github.com/BerriAI/litellm"), # type: ignore + ), + llm_provider="", + ) def get_api_key(llm_provider: str, dynamic_api_key: Optional[str]):