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

feat: Switch git commit to use gpt-35-turbo by default #59

Merged
merged 5 commits into from
May 8, 2023

Conversation

dciborow
Copy link
Collaborator

@dciborow dciborow commented May 8, 2023

Description

Testing

Additional context

@dciborow dciborow enabled auto-merge (rebase) May 8, 2023 18:03
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Summary by GPT-4

I have added the gpt4 and large arguments to the git commit command. The gpt4 argument is used to specify whether to use gpt-4 for generating commit messages instead of gpt-35-turbo, and the large argument is used to specify whether to use the gpt-4-32k model for generating commit messages. Both arguments are optional and default to False.

Here's a summary of the changes:

  1. Modified the _commit_message() function definition to accept two optional arguments: gpt4 and large.
  2. Updated the _commit() function definition to accept two optional arguments: gpt4 and large. These arguments are passed down to _commit_message().
  3. Added a new static method called load_arguments() in the GitCommandGroup class, which defines the new arguments for the "git commit" command.
  4. Updated test cases in tests/test_gpt_cli.py.

You can now use these new options with the git commit command like this:

gpt git commit --gpt4

or

gpt git commit --large

Suggestions

Here are some suggestions for improving the changes in this PR:

  1. Add docstrings for the _commit function to explain its purpose, arguments, and return value.
  2. In the load_arguments method, consider adding a more detailed help message for the gpt4 and large arguments to explain their effects on the commit message generation process.
  3. Add test cases for the new gpt4 and large arguments in the GIT_COMMANDS list.

Here's how the changes could look like:

def _commit(gpt4: bool = False, large: bool = False) -> Dict[str, str]:
    """
    Run git commit with a commit message generated by GPT.

    Args:
        gpt4 (bool): If True, use gpt-4 for generating commit messages instead of gpt-35-turbo.
        large (bool): If True, use gpt-4-32k model for generating commit messages.

    Returns:
        response (dict): The response from GPT-4.
    """
    message = _commit_message(gpt4=gpt4, large=large)
    # ...

# ...

def load_arguments(loader: CLICommandsLoader) -> None:
    with ArgumentsContext(loader, "git commit") as args:
        args.argument(
            "gpt4",
            help="Use gpt-4 for generating commit messages instead of gpt-35-turbo. This may result in more accurate but slower generation.",
            default=False,
            action="store_true",
        )
        args.argument(
            "large",
            help="Use gpt-4-32k model for generating commit messages. This may result in more accurate but slower generation.",
            default=False,
            action="store_true",
        )

# ...

GIT_COMMANDS = [
    CLICase("git commit --help"),
    # CLICase("git commit"),
    # CLICase("git commit --large"),
    # CLICase("git commit --gpt4"),
    # CLICase("git commit --gpt4 --large"),
]

These suggestions should improve code readability and provide better context to users when using the new arguments.

src/gpt_review/_git.py Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Merging #59 (e8355e2) into main (773cf6e) will decrease coverage by 1.31%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #59      +/-   ##
==========================================
- Coverage   86.47%   85.17%   -1.31%     
==========================================
  Files          13       13              
  Lines         392      398       +6     
  Branches       59       61       +2     
==========================================
  Hits          339      339              
- Misses         37       44       +7     
+ Partials       16       15       -1     
Flag Coverage Δ
integration ?
unittests 85.17% <100.00%> (+0.22%) ⬆️
unittests-3.10 85.17% <100.00%> (+0.22%) ⬆️
unittests-3.11 85.17% <100.00%> (+0.22%) ⬆️
unittests-3.8 85.17% <100.00%> (+0.22%) ⬆️
unittests-3.9 85.17% <100.00%> (+0.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/gpt_review/_git.py 89.47% <100.00%> (+1.97%) ⬆️

... and 2 files with indirect coverage changes

@dciborow dciborow merged commit 3b35edd into microsoft:main May 8, 2023
@dciborow dciborow deleted the dciborow/fast-git-commit branch May 8, 2023 21:45
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.

3 participants