Update app.py
Browse files
app.py
CHANGED
@@ -194,9 +194,9 @@ def get_ai_response(prompt, history):
|
|
194 |
)
|
195 |
return response.choices[0].message.content
|
196 |
|
197 |
-
except openai.
|
198 |
return f"Authentication error: {str(auth_err)}. Check your API key."
|
199 |
-
except openai.
|
200 |
return f"Invalid request: {str(inv_err)}. The model '{model}' might not be available with your API key."
|
201 |
except Exception as e:
|
202 |
return f"An error occurred: {str(e)}. Please try a different model or check your setup."
|
@@ -369,4 +369,4 @@ with main_content:
|
|
369 |
time.sleep(0.005)
|
370 |
message_placeholder.markdown(full_response)
|
371 |
messages.append({"role": "assistant", "content": full_response})
|
372 |
-
st.rerun()
|
|
|
194 |
)
|
195 |
return response.choices[0].message.content
|
196 |
|
197 |
+
except openai.AuthenticationError as auth_err:
|
198 |
return f"Authentication error: {str(auth_err)}. Check your API key."
|
199 |
+
except openai.InvalidRequestError as inv_err:
|
200 |
return f"Invalid request: {str(inv_err)}. The model '{model}' might not be available with your API key."
|
201 |
except Exception as e:
|
202 |
return f"An error occurred: {str(e)}. Please try a different model or check your setup."
|
|
|
369 |
time.sleep(0.005)
|
370 |
message_placeholder.markdown(full_response)
|
371 |
messages.append({"role": "assistant", "content": full_response})
|
372 |
+
st.rerun()
|