omkarenator commited on
Commit
a685d80
1 Parent(s): b8cdbfb

gracefully handle gpt4 limitation

Browse files
Files changed (1) hide show
  1. autoagents/spaces/app.py +3 -0
autoagents/spaces/app.py CHANGED
@@ -106,6 +106,9 @@ async def run():
106
  if isinstance(output, Exception):
107
  if isinstance(output, openai.error.AuthenticationError):
108
  await cleanup(f"AuthenticationError: Invalid OpenAI API key.")
 
 
 
109
  elif isinstance(output, openai.error.OpenAIError):
110
  await cleanup(output)
111
  elif isinstance(output, RuntimeWarning):
 
106
  if isinstance(output, Exception):
107
  if isinstance(output, openai.error.AuthenticationError):
108
  await cleanup(f"AuthenticationError: Invalid OpenAI API key.")
109
+ elif isinstance(output, openai.error.InvalidRequestError) \
110
+ and output._message == "The model: `gpt-4` does not exist":
111
+ await cleanup(f"The free API key does not support GPT-4. Please switch to GPT-3.5-turbo or input your own API key.")
112
  elif isinstance(output, openai.error.OpenAIError):
113
  await cleanup(output)
114
  elif isinstance(output, RuntimeWarning):