Google Cloud Vertex AI | ๐ฆ๐ LangChain
Yes they provide token counts but looks like only if using the Langchain
generate()
method to call. See: https://python.langchain.com/docs/integrations/llms/google_vertex_ai_palm/
GenerationChunk can return the following
Can langfuse capture token counts from the langchain GenerationChunk on vertex AI models? Any pointers where to start?Google Cloud Vertex AI | ๐ฆ๏ธ๐ LangChain
Note: This is separate from the Google Generative AI integration,
6 Replies
Any guidance on the above?
@Marc
sorry for slow response here
this is good to know, I'll create an issue to add this to our langchain js integration
added this here: https://github.com/langfuse/langfuse/issues/2032
GitHub
feat: capture token counts from google vertex in langchain-python ยท...
When using generate the GenerationChunk object contains usage_metadata. It'd be useful to capture the token counts from there. Example: [[GenerationChunk([...] generation_info={'usage_metad...
If you want to contribute to this, we're happy to support
no worries @Marc! thanks for creating the issue - I would be happy to contribute this to langchain-python. just need some pointers to where does token capturing typically occur and happy to figure out the rest!
created a PR here: https://github.com/langfuse/langfuse-python/pull/683
GitHub
add token usage parsing for Google Vertex AI models by shenghann ยท ...
Fixes: langfuse/langfuse#2032