Repository navigation
fix(client): keep embedding type when updating the current generation - #2147
Open
caiotheodoro wants to merge 1 commit into
Open
caiotheodoro wants to merge 1 commit into
caiotheodoro wants to merge 1 commit into
Conversation
update_current_generation() wrapped the active span in LangfuseGeneration, whose constructor writes langfuse.observation.type = "generation". Inside an embedding observation that overwrote "embedding" with "generation" whenever no later update re-set the type, e.g. start_as_current_observation( as_type="embedding") or @observe(as_type="embedding", capture_output=False). Generation-like types now keep their wrapper class, as update_current_span() already does since langfuse#1705. Other types still become "generation", so model and usage keep being recorded there.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
update_current_generation()always wraps the current span inLangfuseGeneration, whose constructor sets the observation type to"generation". Inside anas_type="embedding"observation, that turns the embedding into a generation unless a later update writes the type again. You see it withstart_as_current_observation(as_type="embedding")or@observe(as_type="embedding", capture_output=False).Generation-like types (
generation,embedding) now keep their class, which is whatupdate_current_span()has done since #1705. Other types still become"generation".Fixes langfuse/langfuse#11187
Type of change
Verification
tests/unit/test_observe.pyfails on main ('generation' == 'embedding') and passes here.uv run --frozen pytest -n auto tests/unit: 1038 passed.test_prompt.pyneeds theLANGFUSE_*env vars, same as on main.ruff check,ruff format --checkandmypy langfuseare clean.Checklist
code_review.md.Drafted with Devin (Claude Opus 5.5, SWE-2).