jackMort / ChatGPT.nvim

ChatGPT Neovim Plugin: Effortless Natural Language Generation with OpenAI's ChatGPT API
Apache License 2.0
3.56k stars 307 forks source link

How to Reset Context for Messages and Code Completion in ChatGPT.nvim? #380

Open DenisIgnatenko opened 5 months ago

DenisIgnatenko commented 5 months ago

Hello,

I am using the ChatGPT.nvim plugin and have encountered an issue related to the maximum context length limitation. I am receiving the following error:

"This model's maximum context length is 128000 tokens. However, you requested 128347 tokens (347 in the messages, 128000 in the completion). Please reduce the length of the messages or completion."

I have sufficient funds in my account, it's not blocked, and I haven't exceeded any limits. I would like to know how to reset or manage the context for messages and code completion within this plugin to avoid such errors in the future.

Thank you in advance for your assistance!

engeir commented 5 months ago

As a workaround, it worked for me to delete the ~/.local/state/nvim/chatgpt/*.json file. As mentioned in #375, this is where the chat is stored (on linux at least...).

jackMort commented 5 months ago

If you talking about ChatGPT Command, you can use sessions: Ctrl+n to create new session, Ctrl+p list of sessions. full list of shortcuts: Ctrl+h

DenisIgnatenko commented 5 months ago

Thank you, guys, for feedback!

Unfortunately that didn't work for me. I've cleaned all sessions from ~/.local/state/nvim/chatgpt/*.json and also checked sessions list by Ctrl+p. Creating new session still returns me the same response.

This model's maximum context length is 128000 tokens. However, you requested 128062 tokens (62 in the messages, 128000 in the completion). Please reduce the length of the messages or completion.

The problem is definitely lies somewhere in completion mode. Is there a way to reset session in completion somehow?

Снимок экрана 2024-02-01 в 11 04 06
gopz commented 2 months ago

I have the same issue, but starting a new session works for me. I have a feeling it's sending the entire chat history for some reason because I start getting this error only after I've wracked up a big session. I haven't had time to debug it though as I just start a new session.