Spaces:
Sleeping
Sleeping
update app.py to handle secret key
Browse files
app.py
CHANGED
@@ -70,9 +70,15 @@ system_template = {
|
|
70 |
"content": init_prompt,
|
71 |
}
|
72 |
|
73 |
-
#
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|