diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2023-03-13 18:07:01 +0100 |
|---|---|---|
| committer | Martin Bielik <mx.bielik@gmail.com> | 2023-03-13 18:07:01 +0100 |
| commit | 882ac0476b71642694e764d81df2fb215238c65d (patch) | |
| tree | 8b413325b91f810398a62043c72bf723fb0de052 /py/utils.py | |
| parent | 0faae7b1fbec281f5a645f25e5012d9deb307f56 (diff) | |
| download | vim-ai-882ac0476b71642694e764d81df2fb215238c65d.tar.gz | |
chat streaming, more py3 integration
Diffstat (limited to 'py/utils.py')
| -rw-r--r-- | py/utils.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/py/utils.py b/py/utils.py new file mode 100644 index 0000000..c9e88f2 --- /dev/null +++ b/py/utils.py @@ -0,0 +1,12 @@ +import sys +import os + +def load_api_key(): + config_file_path = os.path.join(os.path.expanduser("~"), ".config/openai.token") + api_key = os.getenv("OPENAI_API_KEY") + try: + with open(config_file_path, 'r') as file: + api_key = file.read() + except Exception: + pass + return api_key.strip() |