diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2023-04-12 19:01:11 +0200 |
|---|---|---|
| committer | Martin Bielik <mx.bielik@gmail.com> | 2023-04-12 19:01:11 +0200 |
| commit | 0058b3f6509ac2632b09048c02d3ff4fa17bdfa9 (patch) | |
| tree | e59ff44615874c1bf34a86659f7279c634700544 | |
| parent | b510e4d3ba081dd259d1c219ce139cfae908adc2 (diff) | |
| download | vim-ai-0058b3f6509ac2632b09048c02d3ff4fa17bdfa9.tar.gz | |
moving import openai check to python scripts
| -rw-r--r-- | plugin/vim-ai.vim | 17 | ||||
| -rw-r--r-- | py/chat.py | 2 | ||||
| -rw-r--r-- | py/complete.py | 2 | ||||
| -rw-r--r-- | py/utils.py | 5 |
4 files changed, 7 insertions, 19 deletions
diff --git a/plugin/vim-ai.vim b/plugin/vim-ai.vim index 451ef90..088ba3d 100644 --- a/plugin/vim-ai.vim +++ b/plugin/vim-ai.vim @@ -1,22 +1,9 @@ -" Ensure Python3 and OpenAI is available +" Ensure python3 is available if !has('python3') - echoerr "Python 3 support is required for Vim-AI plugin" + echoerr "Python 3 support is required for vim-ai plugin" finish endif -" Add ChatGPT dependencies -python3 << EOF -import sys -try: - import openai -except ImportError: - print("Error: OpenAI module not found. Please install with Pip.") - raise -import vim -import os - -EOF - let g:vim_ai_complete_default = { \ "engine": "complete", \ "options": { @@ -1,5 +1,3 @@ -import openai - # import utils plugin_root = vim.eval("s:plugin_root") vim.command(f"py3file {plugin_root}/py/utils.py") diff --git a/py/complete.py b/py/complete.py index eea2add..f42cebc 100644 --- a/py/complete.py +++ b/py/complete.py @@ -1,5 +1,3 @@ -import openai - # import utils plugin_root = vim.eval("s:plugin_root") vim.command(f"py3file {plugin_root}/py/utils.py") diff --git a/py/utils.py b/py/utils.py index 56686c3..a0003a0 100644 --- a/py/utils.py +++ b/py/utils.py @@ -2,6 +2,11 @@ import datetime import sys import os +try: + import openai +except ImportError: + raise Exception("OpenAI module not found. Please install it with pip.") + is_debugging = vim.eval("g:vim_ai_debug") == "1" debug_log_file = vim.eval("g:vim_ai_debug_log_file") |