doncamilom commited on
Commit
9d7cf6b
1 Parent(s): 2513042

handle openai api erro

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -77,6 +77,9 @@ def run_prompt(prompt):
77
  st.write(response)
78
  except openai.error.AuthenticationError:
79
  st.write("Please input a valid OpenAI API key")
 
 
 
80
 
81
 
82
  pre_prompts = [
@@ -142,10 +145,6 @@ with st.sidebar:
142
  height=200
143
  )
144
 
145
-
146
-
147
- prompt = None
148
-
149
- # Determine the prompt to use
150
  if user_input := st.chat_input():
151
  run_prompt(user_input)
 
77
  st.write(response)
78
  except openai.error.AuthenticationError:
79
  st.write("Please input a valid OpenAI API key")
80
+ except openai.error.APIError:
81
+ # Handle specific API errors here
82
+ print("OpenAI API error, please try again!")
83
 
84
 
85
  pre_prompts = [
 
145
  height=200
146
  )
147
 
148
+ # Execute agent on user input
 
 
 
 
149
  if user_input := st.chat_input():
150
  run_prompt(user_input)