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

E5108: Error executing lua: ...ck/lazy/opt/ChatGPT.nvim/lua/chatgpt/flows/chat/base.lua:782: attempt to index local 'msg' (a nil value) #369

Closed SymenTimmermans closed 6 months ago

SymenTimmermans commented 6 months ago

Using the most basic LunarVim setup, and the most basic ChatGPT.nvim setup (config from the README), I installed the plugin. Installation went fine. I was even able to open the :ChatGPT screen. But as soon as I press [C-y], I get a lua error:

E5108: Error executing lua: ...ck/lazy/opt/ChatGPT.nvim/lua/chatgpt/flows/chat/base.lua:782: attempt to index local 'msg' (a
 nil value)
stack traceback:
        ...ck/lazy/opt/ChatGPT.nvim/lua/chatgpt/flows/chat/base.lua:782: in function 'callback'
        ...vim/site/pack/lazy/opt/nvim-cmp/lua/cmp/utils/keymap.lua:159: in function 'callback'
        ...arvim/site/pack/lazy/opt/nvim-cmp/lua/cmp/utils/misc.lua:13: in function 'fallback'
        ...m/site/pack/lazy/opt/nvim-cmp/lua/cmp/config/mapping.lua:207: in function 'on_keymap'
        ...re/lunarvim/site/pack/lazy/opt/nvim-cmp/lua/cmp/core.lua:145: in function 'callback'
        ...vim/site/pack/lazy/opt/nvim-cmp/lua/cmp/utils/keymap.lua:133: in function <...vim/site/pack/lazy/opt/nvim-cmp/lua
/cmp/utils/keymap.lua:127>

NeoVim details:

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1702233742

I've even regenerated the OpenAI key, which didn't help.

SymenTimmermans commented 6 months ago

Even though I was able to create API keys on the OpenAPI website, it seems like these do not work if you are on a free tier (which I am).

See https://community.openai.com/t/openai-api-keys-in-free-account/348972/2

I will close this issue. Maybe it might be a good idea to improve the handling of the OpenAI API responses, since that might help a lot of people who want to use this plugin, but don't realize you need to pay for credits.