Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -157,20 +157,21 @@ if selected_app == "1) Create CSVs":
|
|
157 |
if st.session_state.submit:
|
158 |
if uploaded_files:
|
159 |
client = OpenAI(api_key=openai_api_key)
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
174 |
|
175 |
with st.spinner("Loading, please be patient with us ... π"):
|
176 |
textify_output = read_and_textify_advanced(uploaded_files, sentence_chunks)
|
|
|
157 |
if st.session_state.submit:
|
158 |
if uploaded_files:
|
159 |
client = OpenAI(api_key=openai_api_key)
|
160 |
+
|
161 |
+
with st.spinner("Loading, please be patient with us ... π"):
|
162 |
+
# test api key
|
163 |
+
try:
|
164 |
+
response = client.chat.completions.create(
|
165 |
+
model="gpt-4o-mini",
|
166 |
+
messages=[
|
167 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
168 |
+
{"role": "user", "content": "Say this is a test"}
|
169 |
+
]
|
170 |
+
)
|
171 |
+
except:
|
172 |
+
st.session_state.clear()
|
173 |
+
st.session_state.error = "OpenAI API key is invalid"
|
174 |
+
st.rerun()
|
175 |
|
176 |
with st.spinner("Loading, please be patient with us ... π"):
|
177 |
textify_output = read_and_textify_advanced(uploaded_files, sentence_chunks)
|