Skip to content

Update generation.py#9

Merged
MingzeDong merged 1 commit intomainfrom
MingzeDong-patch-2
Jan 9, 2026
Merged

Update generation.py#9
MingzeDong merged 1 commit intomainfrom
MingzeDong-patch-2

Conversation

@MingzeDong
Copy link
Copy Markdown
Collaborator

No description provided.

@MingzeDong MingzeDong merged commit af2cf62 into main Jan 9, 2026
@MingzeDong MingzeDong deleted the MingzeDong-patch-2 branch January 9, 2026 13:13
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @MingzeDong, 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 refines the in-context generation process by introducing a new minimum context ratio parameter and adjusting the default context ratio. These modifications aim to provide more precise control over the context window, potentially leading to improved generation outcomes or better resource utilization.

Highlights

  • New Parameter Introduction: A new parameter, context_ratio_min, has been introduced to specify the minimum value for the context ratio during in-context generation. This parameter is integrated into the _run_incontext_generation and generate functions, and is also available as a command-line argument --context-ratio-min with a default value of 0.2.
  • Default Context Ratio Update: The default value for the context_ratio parameter has been updated from 0.25 to 0.4 in the generate function and its corresponding command-line argument.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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
Copy Markdown

@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 a new parameter context_ratio_min to control the range of context ratios used in in-context generation, and updates the default value for context_ratio. The changes are correctly propagated through the CLI and function calls. My feedback includes a suggestion to improve the clarity of the new command-line argument's help text and to add validation to ensure context_ratio_min is not greater than context_ratio for robustness.

Comment on lines +299 to +300
context_ratio: float = 0.4,
context_ratio_min: float = 0.2,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

A validation check is missing to ensure context_ratio is greater than or equal to context_ratio_min. This could lead to unexpected behavior or errors if invalid parameter values are provided. Consider adding a check at the beginning of the generate function:

if context_ratio < context_ratio_min:
    raise ValueError("context_ratio must be greater than or equal to context_ratio_min")

Comment on lines +444 to +445
parser.add_argument("--context-ratio", type=float, default=0.4, help="Context ratio passed to in-context generation")
parser.add_argument("--context-ratio-min", type=float, default=0.2, help="Min value of context ratio")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The help texts for --context-ratio and --context-ratio-min could be more descriptive to clarify their relationship. Since a random ratio is likely sampled between these two values, it's helpful to state that --context-ratio is the maximum of that range.

Suggested change
parser.add_argument("--context-ratio", type=float, default=0.4, help="Context ratio passed to in-context generation")
parser.add_argument("--context-ratio-min", type=float, default=0.2, help="Min value of context ratio")
parser.add_argument("--context-ratio", type=float, default=0.4, help="Maximum context ratio for in-context generation. A random ratio is sampled between this and context-ratio-min.")
parser.add_argument("--context-ratio-min", type=float, default=0.2, help="Minimum context ratio for in-context generation.")

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.

1 participant