diff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yaml index 1fdcc5e93..f00d5ec3e 100644 --- a/litellm/proxy/_new_secret_config.yaml +++ b/litellm/proxy/_new_secret_config.yaml @@ -1,7 +1,14 @@ model_list: - - model_name: "*" + - model_name: "gpt-3.5-turbo" litellm_params: - model: "*" + model: "gpt-3.5-turbo" + - model_name: "gpt-4" + litellm_params: + model: "gpt-4" + api_key: "bad_key" + - model_name: "gpt-4o" + litellm_params: + model: "gpt-4o" litellm_settings: - callbacks: ["lakera_prompt_injection"] + fallbacks: [{"gpt-3.5-turbo": ["gpt-4", "gpt-4o"]}] diff --git a/litellm/router.py b/litellm/router.py index a6ec01b06..5a4d83885 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -2317,8 +2317,10 @@ class Router: ) try: if mock_testing_fallbacks is not None and mock_testing_fallbacks is True: - raise Exception( - f"This is a mock exception for model={model_group}, to trigger a fallback. Fallbacks={fallbacks}" + raise litellm.InternalServerError( + model=model_group, + llm_provider="", + message=f"This is a mock exception for model={model_group}, to trigger a fallback. Fallbacks={fallbacks}", ) elif ( mock_testing_context_fallbacks is not None @@ -2348,6 +2350,7 @@ class Router: verbose_router_logger.debug(f"Traceback{traceback.format_exc()}") original_exception = e fallback_model_group = None + fallback_failure_exception_str = "" try: verbose_router_logger.debug("Trying to fallback b/w models") if ( @@ -2506,6 +2509,7 @@ class Router: await self._async_get_cooldown_deployments_with_debug_info(), ) ) + fallback_failure_exception_str = str(new_exception) if hasattr(original_exception, "message"): # add the available fallbacks to the exception @@ -2513,6 +2517,13 @@ class Router: model_group, fallback_model_group, ) + if len(fallback_failure_exception_str) > 0: + original_exception.message += ( + "\nError doing the fallback: {}".format( + fallback_failure_exception_str + ) + ) + raise original_exception async def async_function_with_retries(self, *args, **kwargs):