提示词提示

This commit is contained in:
litianxiang
2025-10-31 11:48:02 +08:00
parent bc75bf9fb7
commit cb1a7df925

View File

@@ -491,12 +491,13 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
com.alibaba.fastjson.JSONObject candidate = candidates.getJSONObject(0);
String finishReason = candidate.getString("finishReason");
if (!"STOP".equals(finishReason)) {
String finishMessage = candidate.getString("finishMessage");
if ("IMAGE_SAFETY".equals(finishReason)) {
log.error("图片安全检查失败,请尝试修改提示词或图片");
throw new BusinessException("Image safety check failed", "图片安全检查失败", ResultEnum.ERROR.getCode());
if (finishReason != null && finishReason.equals("IMAGE_SAFETY")){
if (finishMessage != null && finishMessage.contains("Try rephrasing the prompt")) {
finishMessage = "Try rephrasing the prompt.If you think this was an error, send feedback.";
throw new BusinessException(finishMessage, "请尝试重新表述提示词。若您认为这是误判,可提交反馈。", ResultEnum.ERROR.getCode());
}
}
log.error("生成失败: {}", finishMessage);
throw new BusinessException("Image generation failed", "图片生成失败", ResultEnum.ERROR.getCode());