di-sukharev / opencommit

Generate conventional git commit messages with AI in 1 second 🤯🔫
https://www.npmjs.com/package/opencommit
MIT License
5.98k stars 318 forks source link

Committed Multiple files, Received 400 #89

Open imrantechwiz opened 1 year ago

imrantechwiz commented 1 year ago

Error: Request failed with status code 400

Screenshot 2023-03-29 at 8 04 21 PM
rodrigooler commented 1 year ago

Error: Request failed with status code 400

Screenshot 2023-03-29 at 8 04 21 PM

Same problem here, I tested it here in some cases and got this error 400

Screenshot 2023-03-29 at 1 31 41 PM

aliharis commented 1 year ago

+1 running into the same issue

eudard commented 1 year ago

+1 same error when oc multiple files

ProfeJulianLasso commented 1 year ago

+1 running into the same issue

di-sukharev commented 1 year ago

should be fixed with a coming PR, thanks <3

rodrigooler commented 1 year ago

Wow, you're doing a great job! @di-sukharev

wywywywy commented 1 year ago

@di-sukharev

should be fixed with a coming PR, thanks <3

Which PR is it? I still have the same problem with the latest version.

Speaking of latest version, the current 1.1.36 on npm seems to be published incorrectly. When you install it with npm i opencommit@1.1.36 and then do oc --version, it shows as 1.1.35.

There's probably a mistake made during packaging. Maybe it's time to consider using GitHub Actions.

kenryu42 commented 1 year ago

Running into the same issues and as @wywywywy said, oc --version still shows as 1.1.35.

di-sukharev commented 1 year ago

@wywywywy this is a known issue, idk how to config it.. but anyway the 35 version is same as 36. bug is not fixed, but we diagnosed the issue, gonna merge the PR soon.

di-sukharev commented 1 year ago

should be fixed now, pls update npm i -g opencommit

MartinPaulEve commented 1 year ago

Hmm. With apologies, I updated to 1.1.48 (opencommit --version) and am still getting:

└ ✖ Error: Request failed with status code 400

Kevdome3000 commented 1 year ago

same here after running npm i -g opencommit

KenMercusLai commented 1 year ago

same on 1.1.50

di-sukharev commented 1 year ago

yep, this error persists, could anybody investigate and make a PR?

mathsgod commented 1 year ago

One of the possible reasons for this problem is that the token has exceeded the limit of 4096. In the code, result of git diff is split and submitted to the openai API by line breaks if over MAX_REQ_TOKENS. However, there is a possibility that even after splitting, one sentence still exceeds the limit, which will result in this error.

mathsgod commented 1 year ago

You can try the following step to re-create the error:

  1. create an empty folder, run git init
  2. create a text file and write very long string without line breaks (token must be over 4096) , You can go here to check token size.
  3. run oc
jlopezlira commented 1 year ago

Same results with 1.1.50

codeagencybe commented 1 year ago

I also still have the same problem with version 1.1.50/2.0.0, but I can confirm it only happens with "many changes". It's not about file size. As soon as I touch many changes to multiple files, at some point it will result in err 400, most likely due to MAX_REQ_TOKENS with limit 4096 from openai API limits. If I do small simple commits, it never happens with errors.

For now, I work around this by doing commits earlier after changes instead of waiting until 1 "larger" commit. It's not ideal as multi commits = multiple builds that get triggered, causing more computation expenses etc... I would prefer to do only 1 commit where I really need it.

is there a way to work around that 4096 limit? Can openAI accept bigger? I'm ok with paying more for upgrading something at openai if that solves the problem. But I don't know if something like that is even available.

I'm happy to help where possible, testing, etc... I just don't where to start or how.

Thanks.

HarryAdney commented 1 year ago

Any update on this? It's pretty useless for me at the moment, tbh.

di-sukharev commented 1 year ago

we tried 3 PRs and nothing healed it, if anybody wants to be the HERO who solves this — please do the shot and save us here 🙏 🦺

jlopezlira commented 1 year ago

@di-sukharev I'm going to tackle this topic, I'll give it a try.

codeagencybe commented 1 year ago

@di-sukharev I'm going to tackle this topic, I'll give it a try.

@jlopezlira Did you find working solution?

HarryAdney commented 1 year ago

You sir, are a gentleman and a scholar.

codeagencybe commented 1 year ago

@di-sukharev

Does this update from openAI may be helpful to resolve this issue? They now seem to support up to 16k tokens at a slightly higher price.

image
github-actions[bot] commented 1 year ago

Stale issue message

codeagencybe commented 1 year ago

@di-sukharev why is issue closed as "completed"? Because this issue is still existing.

Is this project still ongoing?

HarryAdney commented 1 year ago

@di-sukharev why is issue closed as "completed"? Because this issue is still existing.

Is this project still ongoing?

No recent messages since your last one on Jun 14, so the github-actions bot closed it.

di-sukharev commented 7 months ago

sorry for closing, will add a bigger model context and validate myself