Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enhance Gemini usage tracking to collect comprehensive token data#1752

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Kludex merged 16 commits intopydantic:mainfromkiqaps:feat/gemini_tokens
May 28, 2025

Conversation

kiqaps
Copy link
Contributor

@kiqapskiqaps commentedMay 18, 2025
edited
Loading

When using Gemini, I noticed that some tokens (such as reasoning tokens and usage by modality) were not being collected. I made an adjustment so that all of these are included within the Usagedetails.

Since details is a dict fromstr toint, I couldn't simply throw them in there, so I created the dict in what I thought was the most intuitive way, but I'm not sure if it's the best approach.

I also had to add line breaks in this CLI test to make it pass on my PC (not sure why), but after pushing I saw that it broke the tests, so I removed them again :D

Now, every token documented here:https://ai.google.dev/api/generate-content#UsageMetadata is collected.

Also, when streaming, I'm retrieving usage data only from the last chunk and this shouldfix#1736

amiyapatanaik reacted with hooray emoji
@amiyapatanaik
Copy link

Thanks@kiqaps, much appreciated.

Copy link
Contributor

@DouweMDouweM left a comment

Choose a reason for hiding this comment

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

@kiqaps Thanks for picking this up! Just one suggestion.

@kiqapskiqaps requested a review fromDouweMMay 20, 2025 10:48
@Kludex
Copy link
Member

@kiqaps Would you mind checking thegoogle.py as well? (after rebase)

@kiqaps
Copy link
ContributorAuthor

@kiqaps Would you mind checking thegoogle.py as well? (after rebase)

yeah, sure, no problem

DouweM reacted with thumbs up emoji

@kiqaps
Copy link
ContributorAuthor

ok, its done... but i have done a more intrusive implementation to keep a single "token parser" for both providers (via genai or http), will you guys maintain both or http will be deprecated?

if you prefer, I can keep the parsing in both providers

@DouweMDouweM assignedKludex and unassignedDouweMMay 22, 2025
@DouweMDouweM requested a review fromKludexMay 22, 2025 20:01
@Kludex
Copy link
Member

The idea is to move forward with thegoogle-genai implementation, and at some point deprecate thehttpx one.

So I think it's better to have duplicated logic and not have a common file. Would you mind changing it? Sorry if this was not clear before.

@kiqaps
Copy link
ContributorAuthor

@Kludex done :)

amiyapatanaik reacted with hooray emoji

@KludexKludexenabled auto-merge (squash)May 28, 2025 12:56
@Kludex
Copy link
Member

Thanks!

@KludexKludex merged commit09606c0 intopydantic:mainMay 28, 2025
16 checks passed
Kludex added a commit that referenced this pull requestMay 30, 2025
)Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@KludexKludexKludex approved these changes

@DouweMDouweMAwaiting requested review from DouweM

Assignees

@KludexKludex

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Incorrect usage calculation for gemini models in stream mode
4 participants
@kiqaps@amiyapatanaik@Kludex@DouweM

[8]ページ先頭

©2009-2025 Movatter.jp