Spaces:
Sleeping
Sleeping
Umang Chaudhry
commited on
Commit
·
b899970
1
Parent(s):
6648371
Merge pull request #82 from vanderbilt-data-science/issue-32
Browse files
app.py
CHANGED
@@ -10,7 +10,9 @@ from free_speech_app.DataLoadDb import *
|
|
10 |
from free_speech_app.FreeSpeechPromptsResponses import *
|
11 |
from langchain.chat_models import ChatOpenAI
|
12 |
|
13 |
-
|
|
|
|
|
14 |
deta = Deta(st.secrets["deta_key"])
|
15 |
db = deta.Base("user_data")
|
16 |
|
@@ -42,7 +44,6 @@ def get_user_data(user):
|
|
42 |
return person
|
43 |
return None
|
44 |
|
45 |
-
|
46 |
def encrypt(api_key: str, fernet) -> bytes:
|
47 |
"""Encrypt the API key."""
|
48 |
return fernet.encrypt(api_key.encode())
|
@@ -168,6 +169,9 @@ if authentication_status:
|
|
168 |
os.environ["OPENAI_API_KEY"] = st.secrets["dsi_openai_key4"]
|
169 |
chat_mdl = ChatOpenAI(model_name='gpt-4', temperature=0.1)
|
170 |
|
|
|
|
|
|
|
171 |
if chat_mdl is not None:
|
172 |
if user_data is None:
|
173 |
|
@@ -277,6 +281,7 @@ elif authentication_status is None:
|
|
277 |
except Exception as e:
|
278 |
st.error(e)
|
279 |
|
|
|
280 |
with open('config.yaml', 'w') as file:
|
281 |
yaml.dump(config, file, default_flow_style=False)
|
282 |
|
|
|
10 |
from free_speech_app.FreeSpeechPromptsResponses import *
|
11 |
from langchain.chat_models import ChatOpenAI
|
12 |
|
13 |
+
|
14 |
+
#connect to/create Deta user database
|
15 |
+
|
16 |
deta = Deta(st.secrets["deta_key"])
|
17 |
db = deta.Base("user_data")
|
18 |
|
|
|
44 |
return person
|
45 |
return None
|
46 |
|
|
|
47 |
def encrypt(api_key: str, fernet) -> bytes:
|
48 |
"""Encrypt the API key."""
|
49 |
return fernet.encrypt(api_key.encode())
|
|
|
169 |
os.environ["OPENAI_API_KEY"] = st.secrets["dsi_openai_key4"]
|
170 |
chat_mdl = ChatOpenAI(model_name='gpt-4', temperature=0.1)
|
171 |
|
172 |
+
else:
|
173 |
+
st.warning('Please enter Open AI API Key')
|
174 |
+
|
175 |
if chat_mdl is not None:
|
176 |
if user_data is None:
|
177 |
|
|
|
281 |
except Exception as e:
|
282 |
st.error(e)
|
283 |
|
284 |
+
|
285 |
with open('config.yaml', 'w') as file:
|
286 |
yaml.dump(config, file, default_flow_style=False)
|
287 |
|