Skip to content

Conversation

@alexmojaki
Copy link
Contributor

No description provided.

usage=RequestUsage(
input_tokens=46,
output_tokens=528,
output_tokens=1429,
Copy link
Contributor Author

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.

@alexmojaki alexmojaki requested a review from Copilot November 18, 2025 18:33
Copilot finished reviewing on behalf of alexmojaki November 18, 2025 18:35
Copy link
Contributor

Copilot AI left a 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 use RequestUsage.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.

@alexmojaki alexmojaki requested a review from DouweM November 18, 2025 18:46
@github-actions
Copy link

github-actions bot commented Nov 18, 2025

Docs Preview

commit: 39dcec5
Preview URL: https://7f08ea06-pydantic-ai-previews.pydantic.workers.dev

@alexmojaki alexmojaki enabled auto-merge (squash) November 18, 2025 20:25
@alexmojaki alexmojaki merged commit 230d018 into main Nov 18, 2025
29 checks passed
@alexmojaki alexmojaki deleted the alex/google-genai-prices branch November 18, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants