Skip to content

Commit 0910622

Browse files
authored
[Fix]: Handle non-serializable objects in Langfuse logging (#15148)
* fix: safe_deep_copy * fix: import copy
1 parent 7b8426a commit 0910622

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

litellm/integrations/langfuse/langfuse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#### What this does ####
22
# On success, logs events to Langfuse
3-
import copy
43
import os
54
import traceback
65
from datetime import datetime
@@ -11,6 +10,7 @@
1110
import litellm
1211
from litellm._logging import verbose_logger
1312
from litellm.constants import MAX_LANGFUSE_INITIALIZED_CLIENTS
13+
from litellm.litellm_core_utils.core_helpers import safe_deep_copy
1414
from litellm.litellm_core_utils.redact_messages import redact_user_api_key_info
1515
from litellm.llms.custom_httpx.http_handler import _get_httpx_client
1616
from litellm.secret_managers.main import str_to_bool
@@ -222,7 +222,7 @@ def log_event_on_langfuse(
222222
litellm_params.get("metadata", {}) or {}
223223
) # if litellm_params['metadata'] == None
224224
metadata = self.add_metadata_from_header(litellm_params, metadata)
225-
optional_params = copy.deepcopy(kwargs.get("optional_params", {}))
225+
optional_params = safe_deep_copy(kwargs.get("optional_params", {}))
226226

227227
prompt = {"messages": kwargs.get("messages")}
228228

0 commit comments

Comments
 (0)