Closed sunscreem closed 1 year ago
I'm wondering if I set something up wrong as that diff doesn't seem especially large?
@rocktimsaikia Wondering if we need to set a max here depending on the model?
I think we can get the max for each model from tiktoken.
Exact same issue here. It was working fine last night with larger diffs but this morning I've done some minimal work and run into this error. Strange.
Same here
I haven't had time to investigate this yet, but if anyone wants to, feel free to open a PR. I think it's basically setting a limit here: https://github.com/Nutlope/aicommits/blob/f53fb85dd75513d05fa6f1e73890684ff825e5e2/src/utils/openai.ts#L166
@privatenumber Sorry to report I've updated to 1.11.0 and I've still having the same issue.
npm list -g
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
/usr/local/lib
├── aicommits@1.11.0
├── corepack@0.10.0
├── eslint@7.14.0
├── n@9.0.0
├── npm-why@3.0.0
├── npm@8.11.0
├── prettier@2.7.1
├── webpack-cli@4.5.0
└── webpack@5.24.2
aicommits
│
◇ Detected 13 staged files:
app/Http/Integrations/TicketSource/Requests/GetDate.php
app/Http/Integrations/TicketSource/Requests/GetEvent.php
app/Http/Integrations/TicketSource/Requests/GetEventDates.php
app/Http/Integrations/TicketSource/Requests/GetEventVenues.php
app/Http/Integrations/TicketSource/Requests/GetVenue.php
app/Http/Integrations/TicketSource/Requests/GetVenueDates.php
tests/Fixtures/TicketSource/date.show.json
tests/Fixtures/TicketSource/event.dates.index.json
tests/Fixtures/TicketSource/event.show.json
tests/Fixtures/TicketSource/event.venues.index.json
tests/Fixtures/TicketSource/venue.dates.index.json
tests/Fixtures/TicketSource/venue.show.json
tests/Unit/TicketSourceAPITest.php
│
◇ Changes analyzed
│
└ ✖ OpenAI API Error: 400 - Bad Request
{
"error": {
"message": "This model's maximum context length is 4097 tokens. However, your messages resulted in 8332 tokens. Please reduce the length of the messages.",
"type": "invalid_request_error",
"param": "messages",
"code": "context_length_exceeded"
}
}
That's not the same error:
- "message": "This model's maximum context length is 4097 tokens. However, you requested 5838 tokens (2909 in the messages, 2929 in the completion). Please reduce the length of the messages or completion.",
+ "message": "This model's maximum context length is 4097 tokens. However, your messages resulted in 8332 tokens. Please reduce the length of the messages.",
Previously, we were requesting more tokens than we can. Which was just fixed.
In your case, your diff is too large. Would you mind filing a new issue for this?
@privatenumber I've been a bit busy lately. Will try to look into this soon.
Bug description
When running the command I get the following:
My changes aren't particularly big. I've create a text file and added a single new test to my test suite.
aicommits version
1.10.0
Environment
Can you contribute a fix?