From 986a5267907b4263db6af8c86b462aff2808cdd8 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Fri, 8 Mar 2024 16:25:54 -0800 Subject: [PATCH] (feat) disable logging per request --- litellm/main.py | 2 ++ litellm/utils.py | 15 +++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/litellm/main.py b/litellm/main.py index 63649844a3f..76742eb064c 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -563,6 +563,7 @@ def completion( "caching_groups", "ttl", "cache", + "no-log", ] default_params = openai_params + litellm_params non_default_params = { @@ -2417,6 +2418,7 @@ def embedding( "caching_groups", "ttl", "cache", + "no-log", ] default_params = openai_params + litellm_params non_default_params = { diff --git a/litellm/utils.py b/litellm/utils.py index 38836a4bcea..01fab699ad6 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2985,12 +2985,15 @@ def client(original_function): print_verbose( f"Async Wrapper: Completed Call, calling async_success_handler: {logging_obj.async_success_handler}" ) - asyncio.create_task( - logging_obj.async_success_handler(result, start_time, end_time) - ) - threading.Thread( - target=logging_obj.success_handler, args=(result, start_time, end_time) - ).start() + # check if user does not want this to be logged + if kwargs.get("no-log", False) == False: + asyncio.create_task( + logging_obj.async_success_handler(result, start_time, end_time) + ) + threading.Thread( + target=logging_obj.success_handler, + args=(result, start_time, end_time), + ).start() # RETURN RESULT if hasattr(result, "_hidden_params"):