From d12b6cda4e811d4112a76151169ee938fb52fb92 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 20 Sep 2024 03:16:08 +0200 Subject: [PATCH 1/2] refac: openai image async gen --- backend/open_webui/apps/images/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/apps/images/main.py b/backend/open_webui/apps/images/main.py index 1074e2cb0..768f13954 100644 --- a/backend/open_webui/apps/images/main.py +++ b/backend/open_webui/apps/images/main.py @@ -470,7 +470,9 @@ async def image_generations( "response_format": "b64_json", } - r = requests.post( + # Use asyncio.to_thread for the requests.post call + r = await asyncio.to_thread( + requests.post, url=f"{app.state.config.OPENAI_API_BASE_URL}/images/generations", json=data, headers=headers, From b7ad82757debabd21049296f1f2f64f55473d69e Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 20 Sep 2024 03:18:14 +0200 Subject: [PATCH 2/2] refac --- backend/open_webui/apps/images/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/open_webui/apps/images/main.py b/backend/open_webui/apps/images/main.py index 768f13954..d3cbd4d91 100644 --- a/backend/open_webui/apps/images/main.py +++ b/backend/open_webui/apps/images/main.py @@ -147,17 +147,17 @@ async def update_config(form_data: ConfigForm, user=Depends(get_admin_user)): app.state.config.AUTOMATIC1111_CFG_SCALE = ( float(form_data.automatic1111.AUTOMATIC1111_CFG_SCALE) - if form_data.automatic1111.AUTOMATIC1111_CFG_SCALE != "" + if form_data.automatic1111.AUTOMATIC1111_CFG_SCALE else None ) app.state.config.AUTOMATIC1111_SAMPLER = ( form_data.automatic1111.AUTOMATIC1111_SAMPLER - if form_data.automatic1111.AUTOMATIC1111_SAMPLER != "" + if form_data.automatic1111.AUTOMATIC1111_SAMPLER else None ) app.state.config.AUTOMATIC1111_SCHEDULER = ( form_data.automatic1111.AUTOMATIC1111_SCHEDULER - if form_data.automatic1111.AUTOMATIC1111_SCHEDULER != "" + if form_data.automatic1111.AUTOMATIC1111_SCHEDULER else None )