jackMort / ChatGPT.nvim

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

Unexplained errors on ChatGPT and ChatGPTEditWithInstructions #242

Closed SMT-Przemyslaw-Janik closed 8 months ago

SMT-Przemyslaw-Janik commented 1 year ago

I installed ChatGPT.nvim. I'm trying to execute ChatGPTEditWithInstructions command and I'm getting this error:

Error executing Lua callback: vim/shared.lua:0: after the second argument: expected table, got nil While trying to execute ChatGPT command, I'm getting this:

Error executing Lua callback: vim/plugged/ChatGPT.nvim/lua/chatgpt/flows/chat/base.lua:47: attempt to index field 'popup_layout' (a nil value) How to fix this?

camAtGitHub commented 1 year ago

Using vim-plug this is my config:

Plug 'MunifTanjim/nui.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim', { 'commit': '776b509f80dd49d8205b9b0d94485568236d1192' }
Plug 'jackMort/ChatGPT.nvim'

after call plug#end() put:

lua require('chatgpt').setup()

That might fix the error.

SMT-Przemyslaw-Janik commented 1 year ago

@camAtGitHub thank you, that fixed the issue is there a way to set config settings for ChatGPT.nvim in my .vimrc (e.g. set model to 'gpt-4'), or do I have to edit plugin files?

camAtGitHub commented 1 year ago

The easy way is copy the (already set) defaults from the readme put them in your init.vim and then change what you want. eg. delete the line: lua require('chatgpt').setup() and replace it with:

Click here to expand code ``` lua <" }, yank_last = "", yank_last_code = "", scroll_up = "", scroll_down = "", new_session = "", cycle_windows = "", cycle_modes = "", select_session = "", rename_session = "r", delete_session = "d", draft_message = "", toggle_settings = "", toggle_message_role = "", toggle_system_role_open = "", }, }, popup_layout = { default = "center", center = { width = "80%", height = "80%", }, right = { width = "30%", width_settings_open = "50%", }, }, popup_window = { border = { highlight = "FloatBorder", style = "rounded", text = { top = " ChatGPT ", }, }, win_options = { wrap = true, linebreak = true, foldcolumn = "1", winhighlight = "Normal:Normal,FloatBorder:FloatBorder", }, buf_options = { filetype = "markdown", }, }, system_window = { border = { highlight = "FloatBorder", style = "rounded", text = { top = " SYSTEM ", }, }, win_options = { wrap = true, linebreak = true, foldcolumn = "2", winhighlight = "Normal:Normal,FloatBorder:FloatBorder", }, }, popup_input = { prompt = "  ", border = { highlight = "FloatBorder", style = "rounded", text = { top_align = "center", top = " Prompt ", }, }, win_options = { winhighlight = "Normal:Normal,FloatBorder:FloatBorder", }, submit = "", submit_n = "", }, settings_window = { border = { style = "rounded", text = { top = " Settings ", }, }, win_options = { winhighlight = "Normal:Normal,FloatBorder:FloatBorder", }, }, openai_params = { model = "gpt-3.5-turbo", frequency_penalty = 0, presence_penalty = 0, max_tokens = 300, temperature = 0, top_p = 1, n = 1, }, openai_edit_params = { model = "code-davinci-edit-001", temperature = 0, top_p = 1, n = 1, }, actions_paths = {}, show_quickfixes_cmd = "Trouble quickfix", predefined_chat_gpt_prompts = "https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv", } }) EOF ```

Change gpt-3.5-turbo to gpt-4 and any other settings you want to modify. Good Luck