From 418caf800d6c0161107fd3b9f89fc75d4d24bbc2 Mon Sep 17 00:00:00 2001 From: hughcrt Date: Tue, 11 Jun 2024 21:30:11 -0300 Subject: [PATCH 1/3] fix: lunary callback tags --- litellm/integrations/lunary.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/litellm/integrations/lunary.py b/litellm/integrations/lunary.py index 141ea64884c..096888feb9a 100644 --- a/litellm/integrations/lunary.py +++ b/litellm/integrations/lunary.py @@ -105,19 +105,17 @@ class LunaryLogger: end_time=datetime.now(timezone.utc), error=None, ): - # Method definition try: print_verbose(f"Lunary Logging - Logging request for model {model}") litellm_params = kwargs.get("litellm_params", {}) optional_params = kwargs.get("optional_params", {}) - metadata = litellm_params.get("metadata", {}) or {} + metadata = litellm_params.get("metadata", {}) if optional_params: - # merge into extra extra = {**extra, **optional_params} - tags = litellm_params.pop("tags", None) or [] + tags = metadata.get("metadata", None) if extra: extra.pop("extra_body", None) From 9927d1e42707ca169b0bfbfe6fd3c0155ed09510 Mon Sep 17 00:00:00 2001 From: Hugues Chocart Date: Wed, 12 Jun 2024 09:55:23 -0300 Subject: [PATCH 2/3] fix last commit --- litellm/integrations/lunary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/integrations/lunary.py b/litellm/integrations/lunary.py index 096888feb9a..f6b025c670e 100644 --- a/litellm/integrations/lunary.py +++ b/litellm/integrations/lunary.py @@ -115,7 +115,7 @@ class LunaryLogger: if optional_params: extra = {**extra, **optional_params} - tags = metadata.get("metadata", None) + tags = metadata.get("tags", None) if extra: extra.pop("extra_body", None) From e0608eae72f6cb3abe92e38f95e0402b036afd93 Mon Sep 17 00:00:00 2001 From: hughcrt Date: Thu, 13 Jun 2024 15:10:24 -0300 Subject: [PATCH 3/3] add tests --- litellm/integrations/lunary.py | 2 +- litellm/tests/test_lunary.py | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/litellm/integrations/lunary.py b/litellm/integrations/lunary.py index f6b025c670e..f9b2f25e704 100644 --- a/litellm/integrations/lunary.py +++ b/litellm/integrations/lunary.py @@ -110,7 +110,7 @@ class LunaryLogger: litellm_params = kwargs.get("litellm_params", {}) optional_params = kwargs.get("optional_params", {}) - metadata = litellm_params.get("metadata", {}) + metadata = litellm_params.get("metadata", {}) or {} if optional_params: extra = {**extra, **optional_params} diff --git a/litellm/tests/test_lunary.py b/litellm/tests/test_lunary.py index c9a8afd57f1..cd068d9900f 100644 --- a/litellm/tests/test_lunary.py +++ b/litellm/tests/test_lunary.py @@ -24,8 +24,7 @@ def test_lunary_logging(): except Exception as e: print(e) - -# test_lunary_logging() +test_lunary_logging() def test_lunary_template(): @@ -38,8 +37,7 @@ def test_lunary_template(): except Exception as e: print(e) - -# test_lunary_template() +test_lunary_template() def test_lunary_logging_with_metadata(): @@ -52,16 +50,16 @@ def test_lunary_logging_with_metadata(): metadata={ "run_name": "litellmRUN", "project_name": "litellm-completion", + "tags": ["tag1", "tag2"] }, ) print(response) except Exception as e: print(e) -#test_lunary_logging_with_metadata() +test_lunary_logging_with_metadata() def test_lunary_with_tools(): - import litellm messages = [{"role": "user", "content": "What's the weather like in San Francisco, Tokyo, and Paris?"}] @@ -97,7 +95,7 @@ def test_lunary_with_tools(): print("\nLLM Response:\n", response.choices[0].message) -#test_lunary_with_tools() +test_lunary_with_tools() def test_lunary_logging_with_streaming_and_metadata(): try: @@ -117,5 +115,4 @@ def test_lunary_logging_with_streaming_and_metadata(): except Exception as e: print(e) - -# test_lunary_logging_with_streaming_and_metadata() +test_lunary_logging_with_streaming_and_metadata()