From d136f2b8a705f8020af47fab9b8043812c541723 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 15 Jul 2024 21:26:47 -0700 Subject: [PATCH] fix(litellm_logging.py): fix circular reference --- litellm/litellm_core_utils/litellm_logging.py | 12 +++++------- litellm/tests/test_custom_callback_input.py | 5 +++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index a94e151f45..3fde07815e 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -659,7 +659,7 @@ class Logging: for callback in callbacks: if isinstance(callback, CustomLogger): - self.model_call_details["input"], result = callback.logging_hook( + self.model_call_details, result = callback.logging_hook( kwargs=self.model_call_details, result=result, call_type=self.call_type, @@ -1316,12 +1316,10 @@ class Logging: for callback in callbacks: if isinstance(callback, CustomLogger): - self.model_call_details["input"], result = ( - await callback.async_logging_hook( - kwargs=self.model_call_details, - result=result, - call_type=self.call_type, - ) + self.model_call_details, result = await callback.async_logging_hook( + kwargs=self.model_call_details, + result=result, + call_type=self.call_type, ) for callback in callbacks: diff --git a/litellm/tests/test_custom_callback_input.py b/litellm/tests/test_custom_callback_input.py index 5c1b8bb1cb..8514b237c8 100644 --- a/litellm/tests/test_custom_callback_input.py +++ b/litellm/tests/test_custom_callback_input.py @@ -165,6 +165,11 @@ class CompletionCustomHandler( def log_success_event(self, kwargs, response_obj, start_time, end_time): try: + print(f"\n\nkwargs={kwargs}\n\n") + print( + json.dumps(kwargs, default=str) + ) # this is a test to confirm no circular references are in the logging object + self.states.append("sync_success") ## START TIME assert isinstance(start_time, datetime)