From 7f6e933372ce8f23cf585e8b67ff0880847bface Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 13 May 2024 10:17:32 -0700 Subject: [PATCH] fix(router.py): give an 'info' log when fallbacks work successfully --- litellm/router.py | 6 ++++++ litellm/tests/test_router_debug_logs.py | 1 + 2 files changed, 7 insertions(+) diff --git a/litellm/router.py b/litellm/router.py index b345a2f25db..f1e590545c1 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -1444,6 +1444,9 @@ class Router: response = await self.async_function_with_retries( *args, **kwargs ) + verbose_router_logger.info( + "Successful fallback b/w models." + ) return response except Exception as e: pass @@ -1478,6 +1481,9 @@ class Router: response = await self.async_function_with_fallbacks( *args, **kwargs ) + verbose_router_logger.info( + "Successful fallback b/w models." + ) return response except Exception as e: raise e diff --git a/litellm/tests/test_router_debug_logs.py b/litellm/tests/test_router_debug_logs.py index 202038d9798..1d908abe81b 100644 --- a/litellm/tests/test_router_debug_logs.py +++ b/litellm/tests/test_router_debug_logs.py @@ -85,6 +85,7 @@ def test_async_fallbacks(caplog): "litellm.acompletion(model=gpt-3.5-turbo)\x1b[31m Exception OpenAIException - Error code: 401 - {'error': {'message': 'Incorrect API key provided: bad-key. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}} \nModel: gpt-3.5-turbo\nAPI Base: https://api.openai.com\nMessages: [{'content': 'Hello, how are you?', 'role': 'user'}]\nmodel_group: gpt-3.5-turbo\n\ndeployment: gpt-3.5-turbo\n\x1b[0m", "Falling back to model_group = azure/gpt-3.5-turbo", "litellm.acompletion(model=azure/chatgpt-v-2)\x1b[32m 200 OK\x1b[0m", + "Successful fallback b/w models.", ] # Assert that the captured logs match the expected log messages