Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,18 +15,17 @@ openai_key = os.environ.get("OPENAI_KEY")
|
|
| 15 |
|
| 16 |
def generate_image(text):
|
| 17 |
try:
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
response = client.images.generate(
|
| 21 |
model="dall-e-3",
|
| 22 |
-
prompt="Create an illustration that accurately depicts the character and the setting of
|
| 23 |
n=1,
|
| 24 |
size="1024x1024"
|
| 25 |
)
|
| 26 |
except Exception as error:
|
| 27 |
print(str(error))
|
| 28 |
-
raise gr.Error("An error occurred while generating
|
| 29 |
|
|
|
|
| 30 |
return response.data[0].url
|
| 31 |
|
| 32 |
|
|
|
|
| 15 |
|
| 16 |
def generate_image(text):
|
| 17 |
try:
|
| 18 |
+
response = openai.images.generate(
|
|
|
|
|
|
|
| 19 |
model="dall-e-3",
|
| 20 |
+
prompt="Create an illustration that accurately depicts the character and the setting of a story:"+text,
|
| 21 |
n=1,
|
| 22 |
size="1024x1024"
|
| 23 |
)
|
| 24 |
except Exception as error:
|
| 25 |
print(str(error))
|
| 26 |
+
raise gr.Error("An error occurred while generating the image. Please check your API key and try again.")
|
| 27 |
|
| 28 |
+
|
| 29 |
return response.data[0].url
|
| 30 |
|
| 31 |
|