支持生成图像为空时重试

This commit is contained in:
Vinlic 2024-03-27 22:17:56 +08:00
parent 6abc2d760f
commit a6a0806136
2 changed files with 5 additions and 1 deletions

View File

@ -6,5 +6,6 @@ export default {
API_FILE_URL_INVALID: [-2003, '远程文件URL非法'],
API_FILE_EXECEEDS_SIZE: [-2004, '远程文件超出大小'],
API_CHAT_STREAM_PUSHING: [-2005, '已有对话流正在输出'],
API_CONTENT_FILTERED: [-2006, '内容由于合规问题已被阻止生成']
API_CONTENT_FILTERED: [-2006, '内容由于合规问题已被阻止生成'],
API_IMAGE_GENERATION_FAILED: [-2007, '图像生成失败']
}

View File

@ -260,6 +260,9 @@ async function generateImages(
// 异步移除会话,如果消息不合规,此操作可能会抛出数据库错误异常,请忽略
removeConversation(convId, ticket).catch((err) => console.error(err));
if(imageUrls.length == 0)
throw new APIException(EX.API_IMAGE_GENERATION_FAILED);
return imageUrls;
})().catch((err) => {
if (retryCount < MAX_RETRY_COUNT) {