-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Extract google model usage using genai-prices #3466
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
Conversation
| usage=RequestUsage( | ||
| input_tokens=46, | ||
| output_tokens=528, | ||
| output_tokens=1429, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these increases are because toolUsePromptTokenCount is meant to be counted too, see pydantic/genai-prices#200. For example here 1429-528==901 which is the value of tool_use_prompt_tokens just below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR upgrades the genai-prices dependency from version 0.0.35 to 0.0.40 and refactors Google model usage extraction to leverage the new library's capabilities. The manual audio token calculation logic has been replaced with a call to RequestUsage.extract(), which automatically handles usage extraction from provider responses.
Key changes:
- Upgraded genai-prices from 0.0.35 to 0.0.40
- Refactored
_metadata_as_usage()to useRequestUsage.extract()method - Updated test expectations for output token counts to reflect the new calculation method
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| uv.lock | Updated genai-prices package from 0.0.35 to 0.0.40 with new checksums and added Windows wheels for ruamel.yaml.clib |
| pydantic_ai_slim/pyproject.toml | Updated genai-prices dependency requirement from >=0.0.35 to >=0.0.40 |
| pydantic_ai_slim/pydantic_ai/models/google.py | Refactored _metadata_as_usage() to accept provider parameters and use RequestUsage.extract(), removing manual audio token calculation logic |
| tests/models/test_google.py | Updated test assertions with new output token values and added provider/provider_url parameters to function calls |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Docs Preview
|
No description provided.