From aad0bbb08ccea31928ee3075c56f65aaf0b2d800 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Thu, 1 Aug 2024 12:27:01 -0700 Subject: [PATCH] fix(cost_calculator.py): respect litellm.suppress_debug_info for cost calc Fixes https://github.com/BerriAI/litellm/issues/4818#issuecomment-2263795765 --- litellm/cost_calculator.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/litellm/cost_calculator.py b/litellm/cost_calculator.py index 7b8bfb0d9..5545b8428 100644 --- a/litellm/cost_calculator.py +++ b/litellm/cost_calculator.py @@ -735,9 +735,16 @@ def response_cost_calculator( ) return None except Exception as e: - verbose_logger.warning( - "litellm.cost_calculator.py::response_cost_calculator - Returning None. Exception occurred - {}/n{}".format( - str(e), traceback.format_exc() + if litellm.suppress_debug_info: # allow cli tools to suppress this information. + verbose_logger.debug( + "litellm.cost_calculator.py::response_cost_calculator - Returning None. Exception occurred - {}/n{}".format( + str(e), traceback.format_exc() + ) + ) + else: + verbose_logger.warning( + "litellm.cost_calculator.py::response_cost_calculator - Returning None. Exception occurred - {}/n{}".format( + str(e), traceback.format_exc() + ) ) - ) return None