From 0058b3f6509ac2632b09048c02d3ff4fa17bdfa9 Mon Sep 17 00:00:00 2001 From: Martin Bielik Date: Wed, 12 Apr 2023 19:01:11 +0200 Subject: moving import openai check to python scripts --- py/chat.py | 2 -- py/complete.py | 2 -- py/utils.py | 5 +++++ 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'py') diff --git a/py/chat.py b/py/chat.py index 6e94665..9cb07c9 100644 --- a/py/chat.py +++ b/py/chat.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/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") -- cgit v1.2.3