Skip to content
Discussion options

You must be logged in to vote

Solution: Create Separate Observations for Each DSPy Call

The issue is that both my_llm_pipeline() and my_llm_pipeline222() are updating the same generation (the main function decorated with @observe(as_type="generation")). To track token usage separately for each DSPy call, you need to create separate observations (spans or generations) for each call(1).

Recommended Approach: Use @observe() Decorator

Wrap each DSPy pipeline function with the @observe() decorator to create separate spans with their own token usage tracking(1):

from langfuse import observe, propagate_attributes, get_client

langfuse = get_client()

@observe(as_type="generation", name="llm-infer-call")
async def my_llm_pip…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@HwJhx
Comment options

Answer selected by HwJhx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant