From 4ff7e721901883aef1946b3afa7c55e379eaf91e Mon Sep 17 00:00:00 2001 From: Yanyutin753 <132346501+Yanyutin753@users.noreply.github.com> Date: Mon, 27 May 2024 20:30:28 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AD=90=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=87=8C=E7=9A=84URL=E8=AE=BF=E9=97=AE=E5=87=BA=E9=94=99?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=B6=88=E6=81=AF=E6=97=A0=E6=B3=95=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/files.py | 3 ++- chatgpt/ChatService.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/api/files.py b/api/files.py index 2ec0b2c..2357be0 100644 --- a/api/files.py +++ b/api/files.py @@ -15,7 +15,8 @@ async def get_file_content(url): client = Client() try: r = await client.get(url) - r.raise_for_status() + if r.status_code != 200: + return None, None file_content = r.content mime_type = r.headers.get('Content-Type', '').split(';')[0].strip() return file_content, mime_type diff --git a/chatgpt/ChatService.py b/chatgpt/ChatService.py index 3e27f20..70063d2 100644 --- a/chatgpt/ChatService.py +++ b/chatgpt/ChatService.py @@ -410,6 +410,9 @@ class ChatService: return False async def upload_file(self, file_content, mime_type): + if not file_content or not mime_type: + return None + width, height = None, None if mime_type.startswith("image/"): try: