mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
Merge pull request #15220 from prilosac/allow_auto_gpt_image_1
fix: Allowing 'auto' for IMAGE_SIZE on gpt-image-1
This commit is contained in:
commit
9b2c3dec3a
@ -303,8 +303,14 @@ async def update_image_config(
|
|||||||
):
|
):
|
||||||
set_image_model(request, form_data.MODEL)
|
set_image_model(request, form_data.MODEL)
|
||||||
|
|
||||||
|
if (form_data.IMAGE_SIZE == "auto" and form_data.MODEL != 'gpt-image-1'):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail=ERROR_MESSAGES.INCORRECT_FORMAT(" (auto is only allowed with gpt-image-1).")
|
||||||
|
)
|
||||||
|
|
||||||
pattern = r"^\d+x\d+$"
|
pattern = r"^\d+x\d+$"
|
||||||
if re.match(pattern, form_data.IMAGE_SIZE):
|
if form_data.IMAGE_SIZE == "auto" or re.match(pattern, form_data.IMAGE_SIZE):
|
||||||
request.app.state.config.IMAGE_SIZE = form_data.IMAGE_SIZE
|
request.app.state.config.IMAGE_SIZE = form_data.IMAGE_SIZE
|
||||||
else:
|
else:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
@ -472,7 +478,14 @@ async def image_generations(
|
|||||||
form_data: GenerateImageForm,
|
form_data: GenerateImageForm,
|
||||||
user=Depends(get_verified_user),
|
user=Depends(get_verified_user),
|
||||||
):
|
):
|
||||||
width, height = tuple(map(int, request.app.state.config.IMAGE_SIZE.split("x")))
|
# if IMAGE_SIZE = 'auto', default WidthxHeight to the 512x512 default
|
||||||
|
# This is only relevant when the user has set IMAGE_SIZE to 'auto' with an
|
||||||
|
# image model other than gpt-image-1, which is warned about on settings save
|
||||||
|
width, height = (
|
||||||
|
tuple(map(int, request.app.state.config.IMAGE_SIZE.split("x")))
|
||||||
|
if 'x' in request.app.state.config.IMAGE_SIZE
|
||||||
|
else (512, 512)
|
||||||
|
)
|
||||||
|
|
||||||
r = None
|
r = None
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user