Two small bugs
Hi, Interesting project!
It looks like this would be easier to extend than other projects, so I'm looking forward to playing with it.
I hope you don't mind a couple of bugs being reported. If you do mind, or are too busy no worries!
Bug1: Setup worked fine but I got the following error when calling require("gpt").prompt:
E5108: Error executing lua: /Users/<user>/.local/share/nvim/lazy/gpt.nvim/lua/gpt.lua:133: attempt to index local 'opts' (a nil value)
stack traceback:
/Users/<user>/.local/share/nvim/lazy/gpt.nvim/lua/gpt.lua:133: in function 'create_response_writer'
/Users/<user>/.local/share/nvim/lazy/gpt.nvim/lua/gpt.lua:241: in function </Users/<user>/.local/share/nvim/lazy/gpt.nvim/lua/gpt.lua:216>
E16: Invalid range
I was able to fix it by applying the following patch
diff --git a/lua/gpt.lua b/lua/gpt.lua
index 7bb1b0a..cd6feda 100644
--- a/lua/gpt.lua
+++ b/lua/gpt.lua
@@ -129,6 +129,7 @@ local function send_keys(keys)
end
local function create_response_writer(opts)
+ opts = opts or {}
local line_start = opts.line_no or vim.fn.line(".")
local bufnum = vim.api.nvim_get_current_buf()
local nsnum = vim.api.nvim_create_namespace("gpt")
Bug2: json_decode failed
I got the following error:
Vim:E474: Unexpected end of input: {
stack traceback:
^I[C]: in function 'json_decode'
^I/Users/<user>/.local/share/nvim/lazy/gpt.nvim/lua/gpt.lua:100: in function </Users/<user>/.local/share/nvim/lazy/gpt.nvim/lua/gpt.lua:92>
It looks like I'm getting the following back from OpenAI:
{
"error": {
"message": "The model: `gpt-4` does not exist",
"type": "invalid_request_error",
"param": null,
"code": "model_not_found"
}
}
I don't pay for the plus membership (yet), so it would be nice to be able to configure the model globally. Also it might be nice to detect the error :)
Finally I see there are some undocumented functions like require("gpt").open_chatwindow 👀.
It looks like it would be interesting, so if you get the time to make a demo that would be very cool!
Thanks!
I also had this issue. Adding opts = opts or {} solved it, thanks @Akeboshiwind!