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

UsageMetadata - add cachedContentTokenCount field #178

Merged
merged 3 commits into from
Jun 24, 2024

Conversation

DellaBitta
Copy link
Collaborator

@DellaBitta DellaBitta commented Jun 21, 2024

Add a cachedContentTokenCount field to the UsageMetadata interface returned by generateContent responses.

@DellaBitta DellaBitta marked this pull request as ready for review June 21, 2024 14:31
@DellaBitta DellaBitta requested a review from hsubox76 June 21, 2024 14:31
@DellaBitta DellaBitta changed the title UsageMetaData - add cachedContentTokenCount field UsageMetadata - add cachedContentTokenCount field Jun 21, 2024
@@ -98,6 +98,8 @@ export interface UsageMetadata {
candidatesTokenCount: number;
/** Total token count for the generation request (prompt + candidates). */
totalTokenCount: number;
/** Total token count in the cached part of the prompt, i.e. in the cached content. */
cachedContentTokenCount: number;
Copy link
Collaborator

Choose a reason for hiding this comment

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

One thing just occurred to me, are these in fact always populated? (I'm not even sure about the previously existing fields here.) I know the proto doesn't list any of these as optional but it doesn't seem like these would always be populated in actual practice. If not we should probably make it optional. I did a quick test against autopush not using cached content and I got back the 3 other properties but not this one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it's not always populated. I figured if this was a problem then the non-cached-content integration tests would have failed.

I can make it optional.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@DellaBitta DellaBitta requested a review from hsubox76 June 21, 2024 21:49
@DellaBitta DellaBitta merged commit fb1c0f2 into main Jun 24, 2024
8 checks passed
@DellaBitta DellaBitta deleted the ddb-cached-content-token-count branch June 24, 2024 15:41
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.

2 participants