Repository: ai-genie/chatgpt-vscode

Issue #35: invalid_request_error (Exceeded max_tokens allowed by the model)
Created: 2023-03-28T10:37:11Z
Verify it's not a duplicate bug report

 I searched for similar bugs reported on GitHub and nobody has reported a similar issue. Search all issuees.
 I read Troubleshooting guide on Readme and there is not a guide on how to solve my problem.

Describe the Bug
HTTP 400 Bad Request. You may have exhausted your OpenAI subscription allowance or have an expired account. You can clear your API Key from VS Code's secrets storage with Genie: Clear API Key command. Check your allowance and account's expiration date here: https://platform.openai.com/account/usage
{
"error": {
"message": "This model's maximum context length is 4097 tokens. However, you requested 4790 tokens (2742 in the messages, 2048 in the completion). Please reduce the length of the messages or completion.",
"type": "invalid_request_error",
"param": "messages",
"code": "context_length_exceeded"
}
}
Please tell us if you have customized any of the extension settings or whether you are using the defaults.
gpt-3.5-turbo
Additional context
No response

Duplicate issue #40: context length tokens 4097 violated when request is simply 2 words
Created: 2023-03-30T15:24:59Z
Verify it's not a duplicate bug report
Maybe related to closed issue reported here?
#35

 I searched for similar bugs reported on GitHub and nobody has reported a similar issue. Search all issuees.
 I read Troubleshooting guide on Readme and there is not a guide on how to solve my problem.

Describe the Bug
Complete a series of small date value typescript manipulation requests, even when code change does not exceed three lines of code.
Bug after a 5 or so operations you get the following error but no large requests have been made.
HTTP 400 Bad Request. You may have exhausted your OpenAI subscription allowance or have an expired account. You can clear your API Key from VS Code's secrets storage with Genie: Clear API Key command. Check your allowance and account's expiration date here: https://platform.openai.com/account/usage
{
"error": {
"message": "This model's maximum context length is 4097 tokens. However, you requested 4274 tokens (2226 in the messages, 2048 in the completion). Please reduce the length of the messages or completion.",
"type": "invalid_request_error",
"param": "messages",
"code": "context_length_exceeded"
}
}
Please tell us if you have customized any of the extension settings or whether you are using the defaults.
N/A
Additional context
here's a list of the commands I made
request 1:
what should this code return?
const fourteenDaysLater =
new Date().setDate(new Date().getDate() + 14) && new Date().setHours(0, 0, 0, 0);
request 2:
it looks like setHours is doing nothing in this code. it should updates forteenDaysLater variable
const fourteenDaysLater = new Date();
fourteenDaysLater.setDate(fourteenDaysLater.getDate() + 14);
fourteenDaysLater.setHours(0, 0, 0, 0);
request 3:
trim the value fourteenDaysLater so it looks like this '2023-04-13'
request 4:
can we use dateFormat library to do this instead?
request 5:
you don't have to explain the code in future answers, thank you.



ERROR 400 happens here.

Closing comment (2023-03-31T11:51:42Z): Dupe of #35