mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-17 23:51:30 +00:00
Fix: Problem with langfuse_tags when using litellm proxy with langfus… (#7825)
* Fix: Problem with langfuse_tags when using litellm proxy with langfuse integration (#7801) * Refactor: Create method get_langfuse_tags * Fix: Exception Handling
This commit is contained in:
parent
3dc74c6670
commit
7b3863b304
1 changed files with 10 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#### What this does ####
|
||||
# On success, logs events to Langfuse
|
||||
import copy
|
||||
import json
|
||||
import os
|
||||
import traceback
|
||||
from collections.abc import MutableMapping, MutableSequence, MutableSet
|
||||
|
|
@ -457,7 +458,7 @@ class LangFuseLogger:
|
|||
supports_costs = langfuse_version >= Version("2.7.3")
|
||||
supports_completion_start_time = langfuse_version >= Version("2.7.3")
|
||||
|
||||
tags = metadata.pop("tags", []) if supports_tags else []
|
||||
tags = self._get_langfuse_tags(metadata) if supports_tags else []
|
||||
|
||||
standard_logging_object: Optional[StandardLoggingPayload] = cast(
|
||||
Optional[StandardLoggingPayload],
|
||||
|
|
@ -732,6 +733,14 @@ class LangFuseLogger:
|
|||
verbose_logger.error(f"Langfuse Layer Error - {traceback.format_exc()}")
|
||||
return None, None
|
||||
|
||||
@staticmethod
|
||||
def _get_langfuse_tags(metadata: dict) -> list[str]:
|
||||
try:
|
||||
return json.loads(metadata.pop("tags", "[]"))
|
||||
except Exception as e:
|
||||
verbose_logger.exception("error getting langfuse tags %s", str(e))
|
||||
return []
|
||||
|
||||
def add_default_langfuse_tags(self, tags, kwargs, metadata):
|
||||
"""
|
||||
Helper function to add litellm default langfuse tags
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue