Forbu14 commited on
Commit
052679b
1 Parent(s): 042f784

update app.py to handle secret key

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -70,9 +70,15 @@ system_template = {
70
  "content": init_prompt,
71
  }
72
 
73
- # read key.key file and set openai api key
74
- with open("key.key", "r") as f:
75
- key = f.read()
 
 
 
 
 
 
76
 
77
  # set api_key environment variable
78
  os.environ["api_key"] = key
 
70
  "content": init_prompt,
71
  }
72
 
73
+ # if file key.key exist read the key if note read the env variable OPENAI_TOKEN
74
+ if os.path.isfile("key.key"):
75
+
76
+ # read key.key file and set openai api key
77
+ with open("key.key", "r") as f:
78
+ key = f.read()
79
+ else:
80
+ key = os.environ["OPENAI_TOKEN"]
81
+
82
 
83
  # set api_key environment variable
84
  os.environ["api_key"] = key