Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
6ba62cf2
Commit
6ba62cf2
authored
Mar 08, 2024
by
Timothy J. Baek
Browse files
fix: dalle3 issue
parent
19700e90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
backend/apps/images/main.py
backend/apps/images/main.py
+5
-5
No files found.
backend/apps/images/main.py
View file @
6ba62cf2
...
@@ -250,7 +250,7 @@ class GenerateImageForm(BaseModel):
...
@@ -250,7 +250,7 @@ class GenerateImageForm(BaseModel):
model
:
Optional
[
str
]
=
None
model
:
Optional
[
str
]
=
None
prompt
:
str
prompt
:
str
n
:
int
=
1
n
:
int
=
1
size
:
str
=
"512x512"
size
:
Optional
[
str
]
=
None
negative_prompt
:
Optional
[
str
]
=
None
negative_prompt
:
Optional
[
str
]
=
None
...
@@ -278,8 +278,7 @@ def generate_image(
...
@@ -278,8 +278,7 @@ def generate_image(
user
=
Depends
(
get_current_user
),
user
=
Depends
(
get_current_user
),
):
):
print
(
form_data
)
r
=
None
try
:
try
:
if
app
.
state
.
ENGINE
==
"openai"
:
if
app
.
state
.
ENGINE
==
"openai"
:
...
@@ -291,10 +290,9 @@ def generate_image(
...
@@ -291,10 +290,9 @@ def generate_image(
"model"
:
app
.
state
.
MODEL
if
app
.
state
.
MODEL
!=
""
else
"dall-e-2"
,
"model"
:
app
.
state
.
MODEL
if
app
.
state
.
MODEL
!=
""
else
"dall-e-2"
,
"prompt"
:
form_data
.
prompt
,
"prompt"
:
form_data
.
prompt
,
"n"
:
form_data
.
n
,
"n"
:
form_data
.
n
,
"size"
:
form_data
.
size
,
"size"
:
form_data
.
size
if
form_data
.
size
else
app
.
state
.
IMAGE_SIZE
,
"response_format"
:
"b64_json"
,
"response_format"
:
"b64_json"
,
}
}
r
=
requests
.
post
(
r
=
requests
.
post
(
url
=
f
"https://api.openai.com/v1/images/generations"
,
url
=
f
"https://api.openai.com/v1/images/generations"
,
json
=
data
,
json
=
data
,
...
@@ -359,4 +357,6 @@ def generate_image(
...
@@ -359,4 +357,6 @@ def generate_image(
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
print
(
e
)
if
r
:
print
(
r
.
json
())
raise
HTTPException
(
status_code
=
400
,
detail
=
ERROR_MESSAGES
.
DEFAULT
(
e
))
raise
HTTPException
(
status_code
=
400
,
detail
=
ERROR_MESSAGES
.
DEFAULT
(
e
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment