判断机器人返回图片地址是否实际存在

This commit is contained in:
2024-01-04 17:34:49 +08:00
parent 71f1a2671e
commit 9405b0d630

View File

@@ -162,6 +162,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
String responseBody = response.body().string(); String responseBody = response.body().string();
JSONObject responseObject = JSON.parseObject(responseBody); JSONObject responseObject = JSON.parseObject(responseBody);
JSONObject data = responseObject.getJSONObject("data"); JSONObject data = responseObject.getJSONObject("data");
log.info(String.valueOf(data));
if (null != data) { if (null != data) {
ChatRobot chatRobot = new ChatRobot(); ChatRobot chatRobot = new ChatRobot();
chatRobot.setResponseType(data.getString("response_type")); chatRobot.setResponseType(data.getString("response_type"));
@@ -200,6 +201,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
String prefix = getPrefix(array.getString(i),chatSendDTO.getGender()); String prefix = getPrefix(array.getString(i),chatSendDTO.getGender());
String path = prefix; String path = prefix;
// String path = prefix + array.getString(i); // String path = prefix + array.getString(i);
if (minioUtil.doesObjectExist(bucketName,path)){
QueryWrapper<Library> qw = new QueryWrapper<>(); QueryWrapper<Library> qw = new QueryWrapper<>();
qw.lambda().eq(Library::getUrl, bucketName + "/" + path); qw.lambda().eq(Library::getUrl, bucketName + "/" + path);
qw.lambda().eq(Library::getAccountId, chatSendDTO.getUser_id()); qw.lambda().eq(Library::getAccountId, chatSendDTO.getUser_id());
@@ -213,7 +215,12 @@ public class ChatRobotServiceImpl implements ChatRobotService {
chatRobotLibraryVO.setPresignedUrl(aidaSysImage); chatRobotLibraryVO.setPresignedUrl(aidaSysImage);
chatRobotLibraryVOList.add(chatRobotLibraryVO); chatRobotLibraryVOList.add(chatRobotLibraryVO);
} }
}
if (!CollectionUtils.isEmpty(chatRobotLibraryVOList)){
chatRobotVO.setChatRobotLibraryList(chatRobotLibraryVOList); chatRobotVO.setChatRobotLibraryList(chatRobotLibraryVOList);
}else {
chatRobotVO.setOutput("I'm sorry, but I can't process your current request. Please rephrase it differently.");
}
} }
} else { } else {
chatRobot.setSuccessful(0); chatRobot.setSuccessful(0);