Skip to content

Conversation

@jdomingr
Copy link
Contributor

@jdomingr jdomingr commented Dec 4, 2025

Add new samples:

  • Provisioned throughput with text input.
  • Controlled generation with enum schema.

Also, I fixed some comments in TextGenWithPdf.cs and TextGenWithPdf.cs.

All local tests have passed

@jdomingr jdomingr requested review from a team as code owners December 4, 2025 21:44
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Dec 4, 2025
@snippet-bot
Copy link

snippet-bot bot commented Dec 4, 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
@gemini-code-assist
Copy link

Summary of Changes

Hello @jdomingr, 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 expands the Generative AI C# samples by introducing two new functionalities: controlled generation, which guides model output to specific enum values, and provisioned throughput, which optimizes performance for text generation. Additionally, it includes minor documentation improvements by fixing typos in existing sample comments.

Highlights

  • New Sample: Controlled Generation with Enum Schema: A new C# sample has been added to demonstrate controlled generation using an enum schema, ensuring model responses adhere to a predefined set of string values.
  • New Sample: Provisioned Throughput for Text Generation: A new C# sample showcases how to utilize provisioned throughput for text input, allowing for dedicated capacity for generative AI models.
  • Comment Fixes: Minor typographical errors in comments within existing text generation samples (TextGenWithPdf.cs and TextGenWithTxt.cs) have been corrected.
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

@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 adds two new C# samples for the GenAI library, demonstrating provisioned throughput and controlled generation, along with their corresponding tests. It also includes minor typo fixes in existing files. The new samples are a good addition. My review focuses on improving the correctness and robustness of these new samples. I've pointed out that the provisioned throughput sample is misleadingly configured for the pay-as-you-go model. Additionally, I've suggested changes to make the response handling safer in both new samples to avoid potential runtime exceptions.

string projectId = "your-project-id",
string location = "us-central1",
string model = "gemini-2.5-flash")
{

Choose a reason for hiding this comment

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

Some of the samples have a try-catch to catch the errors. I think that we should aim for that here as well just to 1. showcase some simple error handling, and 2. keep consistency with other languages that have a try-catch as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, but as far as I know, it is not necessary to implement exception handling in the samples, unless there are specific error handling cases that we need to show, which, in my opinion, does not apply in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

in general, we recommend it so that if there is some kind of issue with the service that you can print that out rather than the user assuming something is broken with the sample. This reduces frustration and gives the user a path to move forward.

@iennae iennae added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 13, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 13, 2025
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.

6 participants