summaryrefslogtreecommitdiff
path: root/py/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'py/utils.py')
-rw-r--r--py/utils.py12
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()