Zhengqbbb / cz-git

cz-git | czg 🛠️ DX first and more engineered, lightweight, customizable, standard output format Commitizen adapter and CLI
https://cz-git.qbb.sh
MIT License
1.06k stars 40 forks source link

[Bug report] AI commits cannot distinguish add / delete contents. #101

Closed Lodour closed 1 year ago

Lodour commented 1 year ago

✅ Checklist

📄 System Info

System:
    OS: macOS 13.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 8.25 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.7.0 - /opt/homebrew/bin/node
    npm: 9.6.1 - /opt/homebrew/bin/npm
  npmGlobalPackages:
    czg: 1.5.3

🔎 Description

Concise Description

czg ai produces the same commit message (shown below) no matter when I add or delete a badge from README.

docs: add Python version badge to README.md

It seems that czg ai cannot send the correct add / delete diff to OpenAI, as aicommits does not have this issue.

Expected behavior

The AI-generated message should reflect if I am adding or deleting content.

Steps to reproduce

  1. Initialize the repo and README.md with the following content:

    # my repo
    
    ![Python](https://img.shields.io/badge/Python-3.11-ff69b4)
    ![License](https://img.shields.io/badge/license-MIT-blue)
  2. Remove the badge so the file becomes:

    # my repo
    
    ![License](https://img.shields.io/badge/license-MIT-blue)
  3. Check the diff and then run git add .:

    Changes to be committed:
    diff --git a/README.md b/README.md
    index 2d40328..24326e0 100644
    --- a/README.md
    +++ b/README.md
    @@ -1,5 +1,4 @@
     # my repo
    
    -![Python](https://img.shields.io/badge/Python-3.11-ff69b4)
     ![License](https://img.shields.io/badge/license-MIT-blue)
  4. Run czg ai, check the commit message and abort (note the "add"):

    ? Select the type of change that you're committing: docs:     Documentation only changes
    ℹ Generating your AI commit subject...
    
    ###--------------------------------------------------------###
    docs: add Python version badge to README
    ###--------------------------------------------------------###
    
    ? Are you sure you want to proceed with the commit above? Abort commit
    [info]>>>: Commit has been canceled.
  5. Run aicommits, check the commit message and abort (note the "Remove"):

    ┌   aicommits
    │
    ◇  Detected 1 staged file:
         README.md
    │
    ◇  Changes analyzed
    │
    ◆  Use this commit message?
    
       Remove Python badge from README.md
    
    │  ● Yes / ○ No
    └

Screenshots or Screen Recording(if possible)

🔗 Reproduction link / repo:

No response

Zhengqbbb commented 1 year ago
image

There is indeed a message sent to OpenAI But currently I am using the turbo-3.5 model, while aicommits uses the davinci-3 model. Although turbo is cheaper and faster than davinci, the accuracy of the messages is still to be checked, I will come up with prompt edit feature in the next version to improve this problem.

Zhengqbbb commented 1 year ago

I think I will also add the configuration of switching models (davinci or turbo) in the next version 🧐

Zhengqbbb commented 1 year ago

@Lodour The latest version 🌟(v1.6.0)🌟 should be resolve this issue request , please have a try. 💪 👀 Let me know if there are still any issues.

  1. Add aiType option can choose AI model => https://cz-git.qbb.sh/config/engineer#aitype Note the consumption of tokens if choose davinci model
  2. Support modify or additional AI generated message with prompt on AI message confirm

https://user-images.githubusercontent.com/40693636/224511957-7738f3ac-f1a4-4e91-aecf-371a16a57dab.mp4

Lodour commented 1 year ago

@Zhengqbbb Updated! Thanks for the prompt update!