diff options
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() |