diff --git a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java index 4a40fa2b..30173584 100644 --- a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java @@ -1260,14 +1260,31 @@ public class GenerateServiceImpl extends ServiceImpl i modelAndPromptMap.put(ModelConstants.USE_MODEL, ModelConstants.LOCAL_MODEL); } } else if (ModelConstants.SKETCHBOARD.equals(generateDTO.getLevel1Type())) { - String[] split = generateDTO.getText().split(","); - String style = split[0].trim(); - if ("Lolita".equals( style)){ - style = "洛丽塔"; + String style = ""; + String userPrompt = ""; + // 找到第一个逗号的位置 + int firstCommaIndex = generateDTO.getText().indexOf(","); + if (firstCommaIndex != -1) { + // 截取第一个逗号前的内容作为style + style = generateDTO.getText().substring(0, firstCommaIndex).trim(); + // 截取第一个逗号后的所有内容作为userPrompt(去除首尾空格) + userPrompt = generateDTO.getText().substring(firstCommaIndex + 1).trim(); + + if ("Lolita".equals(style)) { + style = "洛丽塔"; + } + } else { + // 兼容无逗号的情况:style为空,全部内容作为userPrompt + userPrompt = generateDTO.getText().trim(); } - String userPrompt = split[1]; + String prompt = userPrompt + "rules:front view sketch only,plain white background, single garment only, orthographic, centered on white background, borderless canvas, thin monochrome black line art.\n" + - " No clothes hanger, no fake clothes hanger, no human-related lines, no color fill, no words, no text, no black background, no boundary or frame.sketch style:"+ style; + " No clothes hanger, no fake clothes hanger, no human-related lines, no color fill, no words, no text, no black background, no boundary or frame."; + + if (!style.trim().isEmpty() && !"all".equalsIgnoreCase(style)) { + prompt += ".sketch style:" + style.trim(); + } + modelAndPromptMap.put(ModelConstants.PROMPT, prompt); if (isUseImage) { if (ModelConstants.ADVANCED.equals(modelName)) {