Comments (10)
I got this error message when my free tier ran out. When I set up billing, the plugin started working again. I have not changed any settings. Would be nice if the plugin hinted at what could be the issue.
from ai.vim.
This happens in case of error return from the api. In that case, the output does not contain data:
streaming lines, but just the error json.
from ai.vim.
This happens to me when I try to specify vim.g.ai_completions_model = "code-davinci-002"
or vim.g.ai_completions_model = "gpt-3.5-turbo"
and run the normal ctl-a action in normal mode
from ai.vim.
The message comes because the response from API on error is just a json, but response on normal operation starts with data:
prefix. The reading routine has to be fixed to properly handle response in case of error.
from ai.vim.
I still have the same problem, although I just subscribed to GPT-plus:
Error executing vim.schedule lua callback: /Users/tothlac/.vim/bundle/ai.vim/lua/_ai/openai.lua:83: Expected comma or object end but found T_END
at character 205
stack traceback:
[C]: in function 'decode'
/Users/tothlac/.vim/bundle/ai.vim/lua/_ai/openai.lua:83: in function 'on_stdout_chunk'
/Users/tothlac/.vim/bundle/ai.vim/lua/_ai/openai.lua:14: in function </Users/tothlac/.vim/bundle/ai.vim/lua/_ai/openai.lua:13>
Any ideas?
from ai.vim.
I just subscribed
Wait 5 min and try again.
from ai.vim.
It's still not working. Should I generate a new API key after subscribing to gpt plus, or do I need to do anything else to make it work again?
from ai.vim.
I made some observations and debugs in the code and solved the problem as follows.
After some analysis, debugs and code revisions I made some notes a little important but that will serve as future fixes. (as a helper I used the gun itself against herself to help me with the revisions) at the end of the file will be all the corresponding prints and videos.
- Your environment variable OPEN_API_KEY must be properly set and make sure there is no other overwriting it in the.zshrc or.bashrc files. e.g. in your.zshrc or.bashrc :
export OPENAI_API_KEY="sk-14MH4C53R4NDR350LV3DTH3PR063M". (obviously this key dont exist).
- There is a memory leak as the on_stdout_chunk function can accumulate chunks in the variable buffered_chunks, but it is never emptied. To address this, you can add a size limiter to the variable and empty it when the limit is reached or at the end of the process. (I'd say this problem is of medium priority... based on the response generated by OPENAI
I made this code to debug what was happening and the result is in the prin at the end of this review
vim.api.nvim_err_writeln(json_str)
local json = vim.json.decode(json_str)
if json.error then
on_complete(json.error.message)
buffered_chunks = ""
else
on_data(json)
end
- In the exec function, there is an error variable that is being assigned from the vim.loop.spawn call. However, error is a reserved word of the Moon and should not be used as a variable name. To fix this, we can rename the variable to something like spawn_error. I made this changes below:
local handle
local spawn_error
handle, spawn_error = vim.loop.spawn(cmd, {
args = args,
stdio = {nil, stdout, stderr},
}, function (code)
stdout:close()
stderr:close()
handle:close()
vim.schedule(function ()
if code ~= 0 then
on_complete(vim.trim(table.concat(stderr_chunks, "")))
else
on_complete()
end
end)
end)
if not handle then
on_complete(cmd .. " could not be started: " .. spawn_error)
else
4.The M.completions function (line 105: openai.lua) sets a default value for the stream key of the body table. However, if the stream value has already been set in the body table, the default value is ignored. It is best to use vim.tbl_deep_extend to ensure that the table is extended correctly.
- The vim.tbl_extend function (line336: shared.lua , line 106 and 119: openai.lua) is used to extend a table with default values. However, it modifies the original table. If the original table needs to be kept intact, it is best to create a new table and copy the values from the original table to the new table using vim.tbl_deep_extend.
myvideo.mp4
I will not make a pull request, because I believe that in the matter of correctly exporting the environment variavel would be a matter of user to user enqunato the other errors were debugged only by me in my machine without any kind of tests before, I will leave this issue to the created itself to take a look at the errors and solutions that I mentioned earlier, careful not to let these mistakes happen again. sorry for the bad english haha
from ai.vim.
I'm getting this error only from visual mode. Changing ai_edits_model
has not made a difference so far.
from ai.vim.
It looks like the edits API has been deprecated by OpenAI: https://openai.com/blog/gpt-4-api-general-availability
We'll need to look into porting parts of the plugin to the Chat Completions API.
from ai.vim.
Related Issues (20)
- Editing text removes empty lines
- Add Lua API
- ChatGPT Hard-Fork HOT 5
- Vim support HOT 2
- FR: diff with hunkwise accept / reject like cursor.so HOT 2
- Script won't load on startup when installed with Vundle plugin manager HOT 1
- Remap <CTRL-A> HOT 3
- Update to gpt-3.5-turbo? HOT 2
- Stop the completion with ctrl+c or some other shortcut
- nvim_buf_set_extmark bug.
- Allow received text to be updated in the event of timeout HOT 1
- JSON file error
- FR: Custom location of file with OpenAI API Key HOT 2
- Docs: Add info on what region of code is being evaluated HOT 1
- Some ideas... HOT 5
- work with Vim HOT 3
- question: use a keymapping that accepts AI input HOT 2
- ai.vim: You exceeded your current quota HOT 1
- Feature Request: Timeout HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ai.vim.