Hiya, I'm using the langchain
Hiya, I'm using the langchain OpenAiEmbeddings I want to track the calls to this using langfuse but I'm not sure whether this is supported/how to inject the CallbackHandler. Cheers
7 Replies
I would be interested in this as well
Unfortunately, Langchain's callback system does not support embeddings :/
https://github.com/langchain-ai/langchain/issues/945
GitHub
Total token count of openai callback does not count embedding usage...
When using embeddings, the total_tokens count of a callback is wrong, e.g. the following example currently returns 0 even though it shouldn't: from langchain.callbacks import get_openai_callbac...
We are currently working on a more generalized solution to embedding tracking and will then figure out how to make this easy to use for Langchain users
Definetly on the radar
Ahh great. Thanks for letting me know.
Is there a way to track cost by embeddings you currently recommend?
yes, if you have access to the used tokens, you can use the generation object to track embeddings. Costs are then calculated based on the token amounts
Let me give you an example, 1 sec
instead of promptTokens, completionTokens, you can here also just use
usage=Usage(totalTokens=50)
let me know if this works for youThat worked. That's a lot
Perfect 👍
Let me know if you have other questions