You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When integrating litellm proxy with langfuse, specifying langfuse_tags in the HTTP header is expected to populate the Tags field in langfuse. However, in practice, attempting this results in the proxy crashing with the following error message:
07:52:12 - LiteLLM:ERROR: langfuse.py:731 - Langfuse Layer Error - Traceback (most recent call last):
File "/home/ubuntu/work/xxx/venv/lib/python3.12/site-packages/litellm/integrations/langfuse/langfuse.py", line 499, in _log_langfuse_v2
tags.append(f"{key}:{value}")
^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'append'
This error occurs at line 500 in litellm/integrations/langfuse/langfuse.py and seems to be caused by the tags being treated as a string instead of being parsed into a list.
Proposed Solution:
I made the following change, which resolved the issue. By ensuring tags is properly parsed as a JSON list, the error no longer occurs.
Before:
Next Steps:
I plan to submit a pull request with this fix to address the issue. Please let me know if there are additional steps or considerations for this fix.
Relevant log output
The error behavior differs when litellm_config.yaml contains the following setting:
litellm_settings:
langfuse_default_tags: ["cache_hit", "cache_key", "proxy_base_url", "user_api_key_alias", "user_api_key_user_id", "user_api_key_user_email", "user_api_key_team_alias", "semantic-similarity", "proxy_base_url"]
Without setting langfuse_default_tags:
When this setting is not specified, the following error occurs:
```text07:48:27 - LiteLLM:DEBUG: langfuse.py:594 - trace: 01 validation error for TraceBodytags value is not a valid list (type=type_error.list)Traceback (most recent call last): File "/home/ubuntu/work/xxx/venv/lib/python3.12/site-packages/langfuse/client.py", line 1432, in trace new_body = TraceBody(**new_dict) ^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/work/xxx/venv/lib/python3.12/site-packages/pydantic/v1/main.py", line 341, in __init__ raise validation_errorpydantic.v1.error_wrappers.ValidationError: 1 validation error for TraceBodytags value is not a valid list (type=type_error.list)
With langfuse_default_tags set:
When the langfuse_default_tags setting is specified, the following error occurs instead:
07:52:12 - LiteLLM:ERROR: langfuse.py:731 - Langfuse Layer Error - Traceback (most recent call last):
File "/home/ubuntu/work/xxx/venv/lib/python3.12/site-packages/litellm/integrations/langfuse/langfuse.py", line 499, in _log_langfuse_v2
tags.append(f"{key}:{value}")
^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'append'
### Are you a ML Ops Team?
No
### What LiteLLM version are you on ?
v1.58.1
### Twitter / LinkedIn details
_No response_
The text was updated successfully, but these errors were encountered:
#7825)
* Fix: Problem with langfuse_tags when using litellm proxy with langfuse integration (#7801)
* Refactor: Create method get_langfuse_tags
* Fix: Exception Handling
What happened?
When integrating litellm proxy with langfuse, specifying langfuse_tags in the HTTP header is expected to populate the Tags field in langfuse. However, in practice, attempting this results in the proxy crashing with the following error message:
This error occurs at line 500 in litellm/integrations/langfuse/langfuse.py and seems to be caused by the tags being treated as a string instead of being parsed into a list.
Proposed Solution:
I made the following change, which resolved the issue. By ensuring tags is properly parsed as a JSON list, the error no longer occurs.
Before:
After
Next Steps:
I plan to submit a pull request with this fix to address the issue. Please let me know if there are additional steps or considerations for this fix.
Relevant log output
With langfuse_default_tags set:
When the langfuse_default_tags setting is specified, the following error occurs instead:
The text was updated successfully, but these errors were encountered: