fffiloni commited on
Commit
61014ce
1 Parent(s): 51f8318

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -29,7 +29,7 @@ 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, Fore.GREEN + "no error"
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}")
@@ -49,7 +49,7 @@ def try_api(message, openai_api_key):
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"OpenAI API request was not authorized: {e}"
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}")
@@ -112,7 +112,7 @@ with gr.Blocks(css="style.css") as demo:
112
  loading_icon = gr.HTML(loading_icon_html)
113
  share_button = gr.Button("Share to community", elem_id="share-btn")
114
 
115
- error_handler = gr.Textbox(visible=False, show_label=False, elem_id="error_handler")
116
 
117
  with gr.Column(elem_id="col-container-2"):
118
  with gr.Row():
 
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}")
 
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}")
 
112
  loading_icon = gr.HTML(loading_icon_html)
113
  share_button = gr.Button("Share to community", elem_id="share-btn")
114
 
115
+ error_handler = gr.HTML(visible=False, show_label=False, elem_id="error_handler")
116
 
117
  with gr.Column(elem_id="col-container-2"):
118
  with gr.Row():