Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,17 @@
|
|
1 |
import streamlit as st
|
2 |
import openai
|
3 |
from dotenv import load_dotenv
|
4 |
-
import os
|
5 |
|
6 |
# Streamlit UI for input
|
7 |
st.title("Generate an Image with DALL-E 3")
|
8 |
|
9 |
# Input for OpenAI API key
|
10 |
-
api_key = st.text_input("Enter your OpenAI API Key:",type="password")
|
11 |
|
12 |
# Check if API key is provided
|
13 |
if api_key:
|
14 |
-
# Set the API key
|
15 |
-
|
16 |
load_dotenv() # Load environment variables if needed
|
17 |
|
18 |
# Prompt input field
|
@@ -20,7 +19,7 @@ if api_key:
|
|
20 |
|
21 |
if prompt:
|
22 |
st.write("Generating image...")
|
23 |
-
|
24 |
# Call the OpenAI API to generate the image
|
25 |
try:
|
26 |
response = openai.Image.create(
|
|
|
1 |
import streamlit as st
|
2 |
import openai
|
3 |
from dotenv import load_dotenv
|
|
|
4 |
|
5 |
# Streamlit UI for input
|
6 |
st.title("Generate an Image with DALL-E 3")
|
7 |
|
8 |
# Input for OpenAI API key
|
9 |
+
api_key = st.text_input("Enter your OpenAI API Key:", type="password")
|
10 |
|
11 |
# Check if API key is provided
|
12 |
if api_key:
|
13 |
+
# Set the API key directly in the OpenAI library
|
14 |
+
openai.api_key = api_key
|
15 |
load_dotenv() # Load environment variables if needed
|
16 |
|
17 |
# Prompt input field
|
|
|
19 |
|
20 |
if prompt:
|
21 |
st.write("Generating image...")
|
22 |
+
|
23 |
# Call the OpenAI API to generate the image
|
24 |
try:
|
25 |
response = openai.Image.create(
|