-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
29 lines (26 loc) · 882 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from kubernetes import config
from kubernetes.config.config_exception import ConfigException
import logging
import os
from dotenv import load_dotenv
# Load environment variables from .env
load_dotenv()
def load_kubernetes_config():
"""
Loads the Kubernetes configuration from the kubeconfig file.
"""
try:
config.load_kube_config()
logging.info("Success loading kubeconfig.")
except ConfigException as e:
logging.error(f"Failed to load kubeconfig: {e}")
# raise e
def get_openai_key():
"""
Retrieves the OpenAI API key from environment variables.
"""
api_key = os.getenv("OPENAI_API_KEY")
if not api_key:
logging.error("OPENAI_API_KEY not found in environment variables.")
raise EnvironmentError("OpenAI API key not found. Please set OPENAI_API_KEY in your environment.")
return api_key