Spaces:
Sleeping
Sleeping
MartinKosela
commited on
Commit
•
665fd62
1
Parent(s):
fdb24ec
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,16 @@ from openai.error import OpenAIError
|
|
5 |
import os
|
6 |
|
7 |
# Securely fetch the OpenAI API key
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
KNOWN_MODELS = [
|
11 |
# General ML models
|
@@ -122,4 +131,6 @@ if st.session_state.rec_model_pressed:
|
|
122 |
st.write("Contact [email protected] or call (857) 600-0180 to learn how we can fine-tune and host this app for you.")
|
123 |
|
124 |
else:
|
125 |
-
st.warning("Please provide a description.")
|
|
|
|
|
|
5 |
import os
|
6 |
|
7 |
# Securely fetch the OpenAI API key
|
8 |
+
try:
|
9 |
+
openai.api_key = os.getenv('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')
|
10 |
+
except openai.APIError as e:
|
11 |
+
# Log the error for debugging purposes
|
12 |
+
st.error("An error occurred while communicating with the OpenAI API.")
|
13 |
+
# Optionally, log more detailed information for debugging
|
14 |
+
print("Error details:", e)
|
15 |
+
# You might also want to implement additional logic here, like retrying the request,
|
16 |
+
# sending a notification to an administrator, or providing a default response.
|
17 |
+
|
18 |
|
19 |
KNOWN_MODELS = [
|
20 |
# General ML models
|
|
|
131 |
st.write("Contact [email protected] or call (857) 600-0180 to learn how we can fine-tune and host this app for you.")
|
132 |
|
133 |
else:
|
134 |
+
st.warning("Please provide a description.")
|
135 |
+
|
136 |
+
|