瀏覽代碼

refac: images "url" fallback

Timothy Jaeryang Baek 2 月之前
父節點
當前提交
9c107f9d2d
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      backend/open_webui/routers/images.py

+ 7 - 1
backend/open_webui/routers/images.py

@@ -517,7 +517,13 @@ async def image_generations(
             images = []
             images = []
 
 
             for image in res["data"]:
             for image in res["data"]:
-                image_data, content_type = load_b64_image_data(image["b64_json"])
+                if "url" in image:
+                    image_data, content_type = load_url_image_data(
+                        image["url"], headers
+                    )
+                else:
+                    image_data, content_type = load_b64_image_data(image["b64_json"])
+
                 url = upload_image(request, data, image_data, content_type, user)
                 url = upload_image(request, data, image_data, content_type, user)
                 images.append({"url": url})
                 images.append({"url": url})
             return images
             return images