From 882ac0476b71642694e764d81df2fb215238c65d Mon Sep 17 00:00:00 2001 From: Martin Bielik Date: Mon, 13 Mar 2023 18:07:01 +0100 Subject: chat streaming, more py3 integration --- py/utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 py/utils.py (limited to 'py/utils.py') 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() -- cgit v1.2.3