VertexAI usage metadata parsing#1171
Closed
ReneFabricius wants to merge 2 commits intolangfuse:mainfrom
Closed
Conversation
Contributor
There was a problem hiding this comment.
LGTM
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
Contributor
There was a problem hiding this comment.
LGTM
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
Contributor
There was a problem hiding this comment.
LGTM
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
Author
|
Hi @hassiebp , could you please look at this when you get a chance? |
Contributor
|
Thanks a lot for your contribution! Closing this in favor of #1181 |
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.
Some ChatVertexAI responses contain empty
usage_metadataingeneration_infowhilemessagecontains valid one. Breaking here does not allow for processing of the valid one and results in returning None.Added processing of tokens details for ChatVertexAI as they have different name and different format than the currently processed details.
Keeping the details unprocessed leads to Pydantic validation error further down the line -> langfuse/langfuse#5468
Important
Improves
usage_metadataparsing in ChatVertexAI responses by handling empty metadata and processing token details inlangfuse/callback/langchain.py._parse_usageinlangfuse/callback/langchain.pyto use.get('usage_metadata', None)for safer access.usage_metadatais empty in ChatVertexAI responses.messagefield whengeneration_infometadata is empty._parse_usage_modelto handleprompt_tokens_detailsandcandidates_tokens_detailsfor ChatVertexAI.This description was created by
for 10ceef6. You can customize this summary. It will automatically update as commits are pushed.
Greptile Summary
Disclaimer: Experimental PR review
Enhanced ChatVertexAI usage metadata parsing to handle empty metadata cases and properly process token details in different formats.
_parse_usageinlangfuse/callback/langchain.pyto safely handle empty usage_metadata using.get()methodprompt_tokens_detailsandcandidates_tokens_details💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!