Skip to content

How to update generation cost and token usage? #4774

Answered by marcklingen
cimuletz asked this question in Support
Discussion options

You must be logged in to vote

This is partially correct.

You'd need to use the following in order to update an existing generation:

generations = self.langfuse.fetch_observations(trace_id = handler.trace.id, type = 'GENERATION')
generation_id = generations.data[0].id

langfuse.generation(id=generation_id, trace_id=trace_id, usage=usage)

If possible, I'd try to add the cost information at run-time of the dataset run in order to prevent this update.

Replies: 1 comment 1 reply

Comment options

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

Answer selected by marcklingen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants