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

Include full GenerateContentRequest for countTokens #169

Merged
merged 8 commits into from
May 22, 2024

Conversation

natebosch
Copy link
Collaborator

This will make the counted tokens aligned with what the model will count
if the same request were made to generateContent.

Extract the JSON conversion to a separate method and call it from
generateContent, generateContentStream, and countTokens.

This will make the counted tokens aligned with what the model will count
if the same request were made to `generateContent`.

Extract the JSON conversion to a separate method and call it from
`generateContent`, `generateContentStream`, and `countTokens`.
This is a member of the proto, but the backend reports an error if it is
used in `countTokens`.

Soften the changelog entry - since we are not sending the _exact_ same
JSON to the backend I'm less confident making the promise that the
behavior is aligned.
Also add `model` to the general `GenerateContentRequest`. It is required
when using that pattern for counting tokens.
@natebosch natebosch requested a review from devoncarew May 22, 2024 21:04
pkgs/google_generative_ai/CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Devon Carew <devoncarew@google.com>
@natebosch natebosch merged commit 1f2b428 into main May 22, 2024
7 checks passed
@natebosch natebosch deleted the count-tool-tokens branch May 22, 2024 22:32
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.

None yet

2 participants