Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Langfuse Integration ignore Embedding Output #4226

Merged
merged 3 commits into from
Jun 17, 2024

Conversation

hburrichter
Copy link
Contributor

Title

Langfuse Integration ignore Embedding Output

Relevant issues

Fixes #4225

Type

🐛 Bug Fix

Changes

  1. When handling a litellm.EmbeddingResponse, set the Langfuse output to Null to avoid Langfuse counting the embedding vector as the observation/generation output.

  2. Also I fixed one Langfuse test function create_async_task in which the Azure api version parameter was missing. Without the api version, the test fails:

E           Failed: An exception occurred - litellm.APIError: AzureException APIError - litellm.APIConnectionError: list index out of range
E           Traceback (most recent call last):
E             File "/Users/hannes/Repositories/litellm/litellm/main.py", line 834, in completion
E               optional_params = get_optional_params(
E                                 ^^^^^^^^^^^^^^^^^^^^
E             File "/Users/hannes/Repositories/litellm/litellm/utils.py", line 3149, in get_optional_params
E               optional_params = litellm.AzureOpenAIConfig().map_openai_params(
E                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E             File "/Users/hannes/Repositories/litellm/litellm/llms/azure.py", line 169, in map_openai_params
E               api_version_month = api_version_times[1]
E                                   ~~~~~~~~~~~~~~~~~^^^
E           IndexError: list index out of range
E           
E           During handling of the above exception, another exception occurred:
E           
E           Traceback (most recent call last):
E             File "/Users/hannes/Repositories/litellm/litellm/utils.py", line 6943, in exception_type
E               message=f"{exception_provider} APIConnectionError - {message}",
E                          ^^^^^^^^^^^^^^^^^^
E           UnboundLocalError: cannot access local variable 'exception_provider' where it is not associated with a value

test_alangfuse.py:146: Failed

[REQUIRED] Testing

Screenshot 2024-06-16 at 16 09 54

Copy link

vercel bot commented Jun 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 16, 2024 2:17pm

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hburrichter why make this change ? Litellm users will no longer see embedding output

@hburrichter
Copy link
Contributor Author

@ishaan-jaff, thanks for the reply!

I want to make this change because the current output token count is inaccurate. As shown in the image I added to the linked issue, the Langfuse UI displays 28,410 output tokens. However, the actual number of generated tokens is only 10 + 278 = 288. Langfuse incorrectly includes the embedding output, a long floating-point vector, in the generated token count.

This makes it difficult to accurately track the number of tokens used in a trace, which is an important metric.

Additionally, I do not see any value in displaying the floating-point vector with all its values in the UI.

@krrishdholakia krrishdholakia merged commit 8bb459f into BerriAI:main Jun 17, 2024
2 checks passed
@krrishdholakia
Copy link
Contributor

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Langfuse Integration counts Embedding Response as Output Tokens
3 participants