From 1744176e63004ffc2160c86084ceba700323eea5 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 29 May 2024 18:03:13 -0700 Subject: [PATCH 1/3] feat - langfuse show _user_api_key_alias as generation nam --- litellm/integrations/langfuse.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/litellm/integrations/langfuse.py b/litellm/integrations/langfuse.py index a9c67547d..d1e8763c0 100644 --- a/litellm/integrations/langfuse.py +++ b/litellm/integrations/langfuse.py @@ -455,8 +455,14 @@ class LangFuseLogger: } generation_name = clean_metadata.pop("generation_name", None) if generation_name is None: - # just log `litellm-{call_type}` as the generation name - generation_name = f"litellm-{kwargs.get('call_type', 'completion')}" + # if `generation_name` is None, use sensible default values for generation_name + # If using litellm proxy user `key_alias` if not None + # If `key_alias` is None, just log `litellm-{call_type}` as the generation name + _user_api_key_alias = clean_metadata.get("user_api_key_alias", None) + generation_name = ( + _user_api_key_alias + or f"litellm-{kwargs.get('call_type', 'completion')}" + ) if response_obj is not None and "system_fingerprint" in response_obj: system_fingerprint = response_obj.get("system_fingerprint", None) From 67f1f374ecfe5b784b56ecaeebe1b35cc73c79f7 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 29 May 2024 18:10:45 -0700 Subject: [PATCH 2/3] fix comment --- litellm/integrations/langfuse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/integrations/langfuse.py b/litellm/integrations/langfuse.py index d1e8763c0..977db62d3 100644 --- a/litellm/integrations/langfuse.py +++ b/litellm/integrations/langfuse.py @@ -455,7 +455,7 @@ class LangFuseLogger: } generation_name = clean_metadata.pop("generation_name", None) if generation_name is None: - # if `generation_name` is None, use sensible default values for generation_name + # if `generation_name` is None, use sensible default values # If using litellm proxy user `key_alias` if not None # If `key_alias` is None, just log `litellm-{call_type}` as the generation name _user_api_key_alias = clean_metadata.get("user_api_key_alias", None) From 8c6a19d3abbe00a47b2db0bd8662a5e4380cc782 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 29 May 2024 18:40:53 -0700 Subject: [PATCH 3/3] fix put litellm prefix in generation name --- litellm/integrations/langfuse.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/litellm/integrations/langfuse.py b/litellm/integrations/langfuse.py index 977db62d3..12b20f3d3 100644 --- a/litellm/integrations/langfuse.py +++ b/litellm/integrations/langfuse.py @@ -459,10 +459,9 @@ class LangFuseLogger: # If using litellm proxy user `key_alias` if not None # If `key_alias` is None, just log `litellm-{call_type}` as the generation name _user_api_key_alias = clean_metadata.get("user_api_key_alias", None) - generation_name = ( - _user_api_key_alias - or f"litellm-{kwargs.get('call_type', 'completion')}" - ) + generation_name = f"litellm-{kwargs.get('call_type', 'completion')}" + if _user_api_key_alias is not None: + generation_name = f"litellm:{_user_api_key_alias}" if response_obj is not None and "system_fingerprint" in response_obj: system_fingerprint = response_obj.get("system_fingerprint", None)