MadMarx37 commited on
Commit
e8f7b94
·
1 Parent(s): d4e3439

add exception

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -25,8 +25,10 @@ def generate_example_prompt():
25
  with gr.Blocks(title = "LLM Code injection", ) as demo:
26
  if not os.environ.get("OPENAI_API_KEY"):
27
  api_key_input = gr.Textbox(lines = 1, label = "OpenAI API Key", placeholder = "Enter your OpenAI API key", autofocus=True)
28
- if api_key_input.value:
29
  os.environ["OPENAI_API_KEY"] = api_key_input.value
 
 
30
 
31
  # Add a noninteractive image
32
  #gr.Image(image_path, interactive=False, label="Demonstration Image")
 
25
  with gr.Blocks(title = "LLM Code injection", ) as demo:
26
  if not os.environ.get("OPENAI_API_KEY"):
27
  api_key_input = gr.Textbox(lines = 1, label = "OpenAI API Key", placeholder = "Enter your OpenAI API key", autofocus=True)
28
+ try:
29
  os.environ["OPENAI_API_KEY"] = api_key_input.value
30
+ except ValueError:
31
+ Exception("Invalid API key")
32
 
33
  # Add a noninteractive image
34
  #gr.Image(image_path, interactive=False, label="Demonstration Image")