From 41c10f5688fe5e9993ec16723f1191b07798b9c0 Mon Sep 17 00:00:00 2001 From: qingxu fu <505030475@qq.com> Date: Sat, 1 Jul 2023 02:28:32 +0800 Subject: [PATCH] report image generation error in UI --- crazy_functions/图片生成.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crazy_functions/图片生成.py b/crazy_functions/图片生成.py index 5bf8bc4..1bf53f4 100644 --- a/crazy_functions/图片生成.py +++ b/crazy_functions/图片生成.py @@ -27,8 +27,10 @@ def gen_image(llm_kwargs, prompt, resolution="256x256"): } response = requests.post(url, headers=headers, json=data, proxies=proxies) print(response.content) - image_url = json.loads(response.content.decode('utf8'))['data'][0]['url'] - + try: + image_url = json.loads(response.content.decode('utf8'))['data'][0]['url'] + except: + raise RuntimeError(response.content.decode()) # 文件保存到本地 r = requests.get(image_url, proxies=proxies) file_path = 'gpt_log/image_gen/'