tom-doerr / vim_codex

Supercharge your Vim editor with AI-powered code completion using OpenAI Codex. Boost productivity and save time with intelligent suggestions.
MIT License
258 stars 28 forks source link

Error while processing function CreateCompletion #20

Open User1391 opened 1 year ago

User1391 commented 1 year ago

Here is the error message when running CreateCompletion

Error detected while processing function CreateCompletion: Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'plugin' is not defined

tom-doerr commented 1 year ago

How did you add the plugin to vim?

User1391 commented 1 year ago

Using Plug

tom-doerr commented 1 year ago

No idea what the issue is, maybe you could just reinstall it. If that doesn't work, please send me the exact Plug line, path of the installed plugin on the filesystem and the output of the ls -la * command in that path.

nhejazi commented 1 year ago

I just ran into this issue as well, and uninstalling + reinstalling didn't fix it. I'm using vim-plug to install in the usual way, and I see that an error flashes across the installation screen when this happens (too quick for me to read). my macOS Vim installation seems to have python3 support,

$ vim --version | grep "+python"
+cmdline_info      +libcall           +python3           +virtualedit

but I'm also seeing that the plugin seems to look for the openai installation in a way that is incompatible with pyenv, i.e., I've just done pip install openai, which installs the package in my "global" virtualenv -- not sure if this is related.

I guess https://github.com/tom-doerr/vim_codex/blob/main/plugin/vim_codex.vim#L20 is what's obviously failing but I'm not sure why

tom-doerr commented 1 year ago

Could you try installing openai in a virtualenv and running vim inside that?

pooyaww commented 1 year ago

@tom-doerr I faced the same problem. But it happens randomly. When I ask for an auto completion with "Ctrl+X" and then I continue asking again then it randomly appears and goes away if I give it a pause. I think it should be about handling some errors/statuses that the API returns.

tothlac commented 1 year ago

Actually I have the same problem. I've just installed vim_codex, using the way specified in the documentation, so it is in my ~/.vim/bundle/vim_codex directory. Then I installed openai, and I have the same error.

pooyaww commented 1 year ago

In my case it seems there is a limitation on API calls and not related to NameError: name plugin is not defined:

raise self.handle_error_response(
openai.error.RateLimitError: Rate limit reached for default-codex in organization org-xOr2p41SW53e8dvuSWUTdryJ on requests per min. Limit: 20.
000000 / min. Current: 30.000000 / min. Contact support@openai.com if you continue to have issues or if you’d like to request an increase. Ple
ase add a payment method to your account to increase your rate limit. Visit https://platform.openai.com/account/billing to add a payment metho
d.