From 846509bf9fc1a925c27e800fb975e78e4b920e4c Mon Sep 17 00:00:00 2001 From: "Davi S. Zucon" Date: Mon, 10 Mar 2025 15:59:08 -0300 Subject: [PATCH 1/3] fix url value when response contains url tag When the response contains b64 json, the "url" tag still exists but comes as null, the logic is to resolve this point where it contains the url tag, but empty, thus directing to b64_json --- backend/open_webui/routers/images.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/routers/images.py b/backend/open_webui/routers/images.py index c51d2f996..e4ed9b62d 100644 --- a/backend/open_webui/routers/images.py +++ b/backend/open_webui/routers/images.py @@ -517,9 +517,9 @@ async def image_generations( images = [] for image in res["data"]: - if "url" in image: + if image_url := image.get("url",None): image_data, content_type = load_url_image_data( - image["url"], headers + image_url, headers ) else: image_data, content_type = load_b64_image_data(image["b64_json"]) From 453200ca1e2a7ac0ccf955c01b2c8c58d77342f4 Mon Sep 17 00:00:00 2001 From: "Davi S. Zucon" Date: Tue, 11 Mar 2025 12:39:15 -0300 Subject: [PATCH 2/3] fix code format fix code format --- backend/open_webui/routers/images.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/open_webui/routers/images.py b/backend/open_webui/routers/images.py index e4ed9b62d..fa124e8fe 100644 --- a/backend/open_webui/routers/images.py +++ b/backend/open_webui/routers/images.py @@ -518,9 +518,7 @@ async def image_generations( for image in res["data"]: if image_url := image.get("url",None): - image_data, content_type = load_url_image_data( - image_url, headers - ) + image_data, content_type = load_url_image_data(image_url, headers) else: image_data, content_type = load_b64_image_data(image["b64_json"]) From b1224b6839e88fec57c3869e453240c6f7c64f6d Mon Sep 17 00:00:00 2001 From: "Davi S. Zucon" Date: Tue, 11 Mar 2025 12:40:31 -0300 Subject: [PATCH 3/3] fix code format --- backend/open_webui/routers/images.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/open_webui/routers/images.py b/backend/open_webui/routers/images.py index fa124e8fe..275704f34 100644 --- a/backend/open_webui/routers/images.py +++ b/backend/open_webui/routers/images.py @@ -517,7 +517,7 @@ async def image_generations( images = [] for image in res["data"]: - if image_url := image.get("url",None): + if image_url := image.get("url", None): image_data, content_type = load_url_image_data(image_url, headers) else: image_data, content_type = load_b64_image_data(image["b64_json"])