Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix missing usage metadata in GoogleAIGeminiChatGenerator #1195

Merged
merged 2 commits into from
Nov 19, 2024

Conversation

theoohoho
Copy link
Contributor

Related Issues

Proposed Changes:

How did you test it?

Notes for the reviewer

Checklist

@theoohoho theoohoho requested a review from a team as a code owner November 15, 2024 13:54
@theoohoho theoohoho requested review from anakin87 and removed request for a team November 15, 2024 13:54
@CLAassistant
Copy link

CLAassistant commented Nov 15, 2024

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added integration:google-ai type:documentation Improvements or additions to documentation labels Nov 15, 2024
Copy link
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey!

Thanks for the contribution.

Please sign the CLA and take my considerations into account.
Feel free to discuss them if anything is unclear.

Comment on lines 320 to 327
# align openai api response
usage_metadata = metadata.get("usage_metadata")
if usage_metadata:
candidate_metadata["usage"] = {
"prompt_tokens": usage_metadata["prompt_token_count"],
"completion_tokens": usage_metadata["candidates_token_count"],
"total_tokens": usage_metadata["total_token_count"],
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I was wrong. Google documentation is a bit confusing.

Copy link
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

In practice, I used your solution, added a comment + a test.

@anakin87 anakin87 merged commit d00e7d9 into deepset-ai:main Nov 19, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration:google-ai type:documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GoogleAIGeminiChatGenerator doesn't include usage metadata
3 participants