Skip to content

Commit 13bf0ca

Browse files
committed
v1.8.8-beta4 retry upload
1 parent 36f5cc5 commit 13bf0ca

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

chatgpt/ChatService.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -463,26 +463,24 @@ async def get_upload_url(self, file_name, file_size, use_case="multimodal"):
463463
return "", ""
464464

465465
async def upload(self, upload_url, file_content, mime_type):
466-
headers = self.base_headers.copy()
467-
headers.update(
468-
{
469-
'accept': 'application/json, text/plain, */*',
470-
'content-type': mime_type,
471-
'x-ms-blob-type': 'BlockBlob',
472-
'x-ms-version': '2020-04-08',
473-
}
474-
)
475-
headers.pop('authorization', None)
476-
headers.pop('oai-device-id', None)
477-
headers.pop('oai-language', None)
478-
try:
479-
r = await self.s.put(upload_url, headers=headers, data=file_content, timeout=120)
480-
if r.status_code == 201:
481-
return True
482-
else:
483-
raise HTTPException(status_code=r.status_code, detail=r.text)
484-
except Exception as e:
485-
logger.error(f"Failed to upload file: {e}")
466+
for i in range(3):
467+
try:
468+
headers = self.base_headers.copy()
469+
headers.update({
470+
'accept': 'application/json, text/plain, */*',
471+
'content-type': mime_type,
472+
'x-ms-blob-type': 'BlockBlob',
473+
'x-ms-version': '2020-04-08',
474+
})
475+
r = await self.s.put(upload_url, headers=headers, data=file_content, timeout=120)
476+
if r.status_code == 201:
477+
return True
478+
else:
479+
raise HTTPException(status_code=r.status_code, detail=r.text)
480+
except Exception as e:
481+
logger.error(f"Failed to upload file: {e}")
482+
else:
483+
logger.error(f"Failed to upload file after 3 attempts")
486484
return False
487485

488486
async def upload_file(self, file_content, mime_type):

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.8.8-beta3
1+
1.8.8-beta4

0 commit comments

Comments
 (0)