fffiloni commited on
Commit
41be210
1 Parent(s): 8e178ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -29,35 +29,35 @@ def infer(audio, openai_api_key):
29
  def try_api(message, openai_api_key):
30
  try:
31
  response = call_api(message, openai_api_key)
32
- return response, "<span style='color:green;'>no error</span>"
33
  except openai.error.Timeout as e:
34
  #Handle timeout error, e.g. retry or log
35
  print(f"OpenAI API request timed out: {e}")
36
- return "oups", f"OpenAI API request timed out: {e}"
37
  except openai.error.APIError as e:
38
  #Handle API error, e.g. retry or log
39
  print(f"OpenAI API returned an API Error: {e}")
40
- return "oups", f"OpenAI API returned an API Error: {e}"
41
  except openai.error.APIConnectionError as e:
42
  #Handle connection error, e.g. check network or log
43
  print(f"OpenAI API request failed to connect: {e}")
44
- return "oups", f"OpenAI API request failed to connect: {e}"
45
  except openai.error.InvalidRequestError as e:
46
  #Handle invalid request error, e.g. validate parameters or log
47
  print(f"OpenAI API request was invalid: {e}")
48
- return "oups", f"OpenAI API request was invalid: {e}"
49
  except openai.error.AuthenticationError as e:
50
  #Handle authentication error, e.g. check credentials or log
51
  print(f"OpenAI API request was not authorized: {e}")
52
- return "oups", f"<span style='color:green!important;'>OpenAI API request was not authorized: {e}</span>"
53
  except openai.error.PermissionError as e:
54
  #Handle permission error, e.g. check scope or log
55
  print(f"OpenAI API request was not permitted: {e}")
56
- return "oups", f"OpenAI API request was not permitted: {e}"
57
  except openai.error.RateLimitError as e:
58
  #Handle rate limit error, e.g. wait or log
59
  print(f"OpenAI API request exceeded rate limit: {e}")
60
- return "oups", f"OpenAI API request exceeded rate limit: {e}"
61
 
62
  def call_api(message, openai_api_key):
63
 
 
29
  def try_api(message, openai_api_key):
30
  try:
31
  response = call_api(message, openai_api_key)
32
+ return response, "<span class='openai_clear'>no error</span>"
33
  except openai.error.Timeout as e:
34
  #Handle timeout error, e.g. retry or log
35
  print(f"OpenAI API request timed out: {e}")
36
+ return "oups", f"<span class='openai_error'>OpenAI API request timed out: <br />{e}</span>"
37
  except openai.error.APIError as e:
38
  #Handle API error, e.g. retry or log
39
  print(f"OpenAI API returned an API Error: {e}")
40
+ return "oups", f"<span class='openai_error'>OpenAI API returned an API Error: <br />{e}</span>"
41
  except openai.error.APIConnectionError as e:
42
  #Handle connection error, e.g. check network or log
43
  print(f"OpenAI API request failed to connect: {e}")
44
+ return "oups", f"<span class='openai_error'>OpenAI API request failed to connect: <br />{e}</span>"
45
  except openai.error.InvalidRequestError as e:
46
  #Handle invalid request error, e.g. validate parameters or log
47
  print(f"OpenAI API request was invalid: {e}")
48
+ return "oups", f"<span class='openai_error'>OpenAI API request was invalid: <br />{e}</span>"
49
  except openai.error.AuthenticationError as e:
50
  #Handle authentication error, e.g. check credentials or log
51
  print(f"OpenAI API request was not authorized: {e}")
52
+ return "oups", f"<span class='openai_error'>OpenAI API request was not authorized: <br />{e}</span>"
53
  except openai.error.PermissionError as e:
54
  #Handle permission error, e.g. check scope or log
55
  print(f"OpenAI API request was not permitted: {e}")
56
+ return "oups", f"<span class='openai_error'>OpenAI API request was not permitted: {<br />e}</span>"
57
  except openai.error.RateLimitError as e:
58
  #Handle rate limit error, e.g. wait or log
59
  print(f"OpenAI API request exceeded rate limit: {e}")
60
+ return "oups", f"<span class='openai_error'>OpenAI API request exceeded rate limit: <br />{e}</span>"
61
 
62
  def call_api(message, openai_api_key):
63