Skip to content

Conversation

msampathkumar
Copy link
Member

Description

Fixes b_443755237

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

@msampathkumar msampathkumar requested review from a team as code owners October 14, 2025 16:43
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Oct 14, 2025
Copy link
Contributor

Summary of Changes

Hello @msampathkumar, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the genai module by integrating new local tokenizer samples for both 'Count' and 'Compute' functionalities. It includes the addition of the sentencepiece library as a new dependency to support these features and extends the test suite with corresponding validation tests. The primary goal is to provide more robust and flexible token counting examples, particularly for scenarios requiring local tokenization.

Highlights

  • New Local Tokenizer Samples: Introduced new code samples demonstrating local tokenization capabilities for 'Count' and 'Compute' operations within the genai module.
  • New Dependency Added: The sentencepiece library (version 0.2.1) has been added to the requirements.txt file, indicating its necessity for the new local tokenizer functionalities.
  • Expanded Test Coverage: New test cases have been added to test_count_tokens_examples.py to validate the functionality of the newly introduced local tokenizer samples.
  • Example Output Correction: A minor correction was made to an example output comment in counttoken_with_txt.py, updating the total_tokens value from 10 to 9.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new samples for local tokenization with GenAI, including adding the sentencepiece dependency and new test cases. The changes are generally good, but I've identified a couple of areas for improvement in the new test code. Specifically, the function names in the new sample modules are identical to the module names, which is unconventional and can be confusing. I've suggested renaming them to be more descriptive and consistent with the existing codebase. This will improve code readability and maintainability.



def test_counttoken_localtokenizer_with_txt() -> None:
assert counttoken_localtokenizer_with_txt.counttoken_localtokenizer_with_txt()
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The function name counttoken_localtokenizer_with_txt is the same as its module name, which can be confusing. For better readability and consistency with other examples in this file (e.g., counttoken_with_txt.count_tokens()), consider renaming the function within the counttoken_localtokenizer_with_txt module to something more descriptive, like count_tokens().



def test_counttoken_localtokenizer_compute_with_txt() -> None:
assert counttoken_localtokenizer_compute_with_txt.counttoken_localtokenizer_compute_with_txt()
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the other new test, the function name counttoken_localtokenizer_compute_with_txt is identical to its module name. This is unconventional and reduces clarity. To maintain consistency with other examples like counttoken_compute_with_txt.compute_tokens_example(), please consider renaming the function inside the counttoken_localtokenizer_compute_with_txt module to something like compute_tokens_example() or compute_tokens_locally().

@msampathkumar msampathkumar marked this pull request as draft October 14, 2025 17:07
@msampathkumar msampathkumar marked this pull request as ready for review October 15, 2025 16:09
Copy link

snippet-bot bot commented Oct 16, 2025

Here is the summary of changes.

You are about to add 2 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants