From 1897a1ee46b993c3e47c4e986e19ac8530bed761 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Thu, 5 Oct 2023 19:36:39 -0700 Subject: [PATCH] fix(llmonitor callback): correctly set user_id --- litellm/integrations/llmonitor.py | 2 +- litellm/tests/test_llmonitor_integration.py | 1 + litellm/utils.py | 4 ++-- pyproject.toml | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/litellm/integrations/llmonitor.py b/litellm/integrations/llmonitor.py index 22acf874c..761b12c9e 100644 --- a/litellm/integrations/llmonitor.py +++ b/litellm/integrations/llmonitor.py @@ -109,7 +109,7 @@ class LLMonitorLogger: }, ] - # print_verbose(f"LLMonitor Logging - final data object: {data}") + print_verbose(f"LLMonitor Logging - final data object: {data}") response = requests.post( self.api_url + "/api/report", diff --git a/litellm/tests/test_llmonitor_integration.py b/litellm/tests/test_llmonitor_integration.py index a3183bf8f..9a13d949a 100644 --- a/litellm/tests/test_llmonitor_integration.py +++ b/litellm/tests/test_llmonitor_integration.py @@ -20,6 +20,7 @@ def test_chat_openai(): response = completion( model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Hi 👋 - i'm openai"}], + user="ishaan_from_litellm" ) print(response) diff --git a/litellm/utils.py b/litellm/utils.py index 82a1ee8e8..ea33ed858 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -1831,7 +1831,7 @@ def handle_failure(exception, traceback_exception, start_time, end_time, args, k llmonitorLogger.log_event( type=type, event="error", - user_id=litellm._thread_context.user, + user_id=kwargs.get("user", "default"), model=model, input=input, error=traceback_exception, @@ -1951,7 +1951,7 @@ def handle_success(args, kwargs, result, start_time, end_time): event="end", model=model, input=input, - user_id=litellm._thread_context.user, + user_id=kwargs.get("user", "default"), response_obj=result, start_time=start_time, end_time=end_time, diff --git a/pyproject.toml b/pyproject.toml index 7e85d4bd3..af2f96350 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm" -version = "0.1.822" +version = "0.1.823" description = "Library to easily interface with LLM API providers" authors = ["BerriAI"] license = "MIT License"