Spaces:
Sleeping
Sleeping
add exception
Browse files
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 |
-
|
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")
|