fix(google): count Gemini thinking tokens in usage.output_tokens 馃馃馃馃 - #2653
fix(google): count Gemini thinking tokens in usage.output_tokens 馃馃馃馃#2653davidberenstein1957 wants to merge 3 commits into
Conversation
GoogleChatTranslator.from_google mapped output_tokens to candidates_token_count only, but google-genai defines total_token_count as prompt + candidates + tool_use_prompt + thoughts. When the model thinks, thoughts_token_count is generated (and billed) output that the mapping dropped, so input_tokens + output_tokens != total_tokens on the same Usage object. Fold thoughts_token_count into output_tokens and tool_use_prompt_token_count into input_tokens so the sum matches total_tokens, per Google's own definition. Add a regression test covering a thinking response.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
CI installs latest ruff via uv tool install, which formats Python fenced blocks in Markdown. Align docs with that so make check passes.
|
#2686 and #2674 both landed on main since this branch was cut, and between them they cover the formatting work here. Four of the five markdown files ( The two functional files, |
Summary
Formatted follow-up of #2622 (@ebarkhordar).
Same change as #2622, plus ruff format/lint fixes so CI
make checkcan get past format/import sorting.Why
#2622 was blocked on CI lint (typically
check-formaton README markdown fences; for some PRs alsoruff checkimport sorting).Supersedes
Please close #2622 in favor of this PR once CI is green.
Test plan