diff --git a/litellm/integrations/langfuse.py b/litellm/integrations/langfuse.py index 5bde546d6f..12cb231dad 100644 --- a/litellm/integrations/langfuse.py +++ b/litellm/integrations/langfuse.py @@ -36,7 +36,7 @@ class LangFuseLogger: print_verbose( f"Langfuse Logging - Enters logging function for model {kwargs}" ) - metadata = kwargs.get("metadata", {}) + metadata = kwargs["litellm_params"].get("metadata", {}) prompt = [kwargs.get('messages')] optional_params = kwargs.get("optional_params", {}) @@ -50,7 +50,6 @@ class LangFuseLogger: pass # end of processing langfuse ######################## - self.Langfuse.generation(InitialGeneration( name=metadata.get("generation_name", "litellm-completion"), startTime=start_time, diff --git a/litellm/tests/test_langfuse.py b/litellm/tests/test_langfuse.py index b861888d60..16fd90b1c2 100644 --- a/litellm/tests/test_langfuse.py +++ b/litellm/tests/test_langfuse.py @@ -22,7 +22,7 @@ def test_langfuse_logging_async(): messages=[{"role": "user", "content":"This is a test"}], max_tokens=1000, temperature=0.7, - timeout=5 + timeout=5, ) response = asyncio.run(_test_langfuse()) print(f"response: {response}") @@ -35,13 +35,15 @@ def test_langfuse_logging_async(): def test_langfuse_logging(): try: + # litellm.set_verbose = True response = completion(model="claude-instant-1.2", messages=[{ "role": "user", "content": "Hi 👋 - i'm claude" }], max_tokens=10, - temperature=0.2 + temperature=0.2, + metadata={"langfuse/key": "foo"} ) print(response) except litellm.Timeout as e: @@ -49,7 +51,7 @@ def test_langfuse_logging(): except Exception as e: print(e) -# test_langfuse_logging() +test_langfuse_logging() def test_langfuse_logging_stream():