1
This commit is contained in:
@@ -50,6 +50,63 @@ public class SocialMediaPromptController {
|
|||||||
put("xianyu:title_clean_regex", "闲鱼文案·标题/型号清洗正则\n从标题与型号备注中移除营销敏感片段;须为 Java 正则,匹配到的内容会被删除");
|
put("xianyu:title_clean_regex", "闲鱼文案·标题/型号清洗正则\n从标题与型号备注中移除营销敏感片段;须为 Java 正则,匹配到的内容会被删除");
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
/** Redis 无记录时与 SocialMediaService 默认一致,供前端回显参考 */
|
||||||
|
private static final Map<String, String> DEFAULT_PROMPT_TEMPLATES = new HashMap<String, String>() {{
|
||||||
|
put("keywords",
|
||||||
|
"请从以下商品标题中提取3-5个最核心的关键词,这些关键词要能突出商品的核心卖点和特色。\n"
|
||||||
|
+ "要求:\n"
|
||||||
|
+ "1. 每个关键词2-4个字\n"
|
||||||
|
+ "2. 关键词要能吸引小红书/抖音用户\n"
|
||||||
|
+ "3. 用逗号分隔,只返回关键词,不要其他内容\n"
|
||||||
|
+ "商品标题:%s");
|
||||||
|
put("content:xhs",
|
||||||
|
"请为小红书平台生成一篇商品推广文案,要求:\n"
|
||||||
|
+ "1. 风格:真实、种草、有温度\n"
|
||||||
|
+ "2. 开头:用emoji或感叹句吸引注意\n"
|
||||||
|
+ "3. 内容:突出商品亮点、使用场景、性价比\n"
|
||||||
|
+ "4. 结尾:引导行动(如:快冲、闭眼入等)\n"
|
||||||
|
+ "5. 长度:150-300字\n"
|
||||||
|
+ "6. 适当使用emoji和换行\n"
|
||||||
|
+ "\n商品信息:\n"
|
||||||
|
+ "商品名称:%s\n"
|
||||||
|
+ "%s"
|
||||||
|
+ "%s"
|
||||||
|
+ "\n请直接生成文案内容,不要添加其他说明:");
|
||||||
|
put("content:douyin",
|
||||||
|
"请为抖音平台生成一篇商品推广文案,要求:\n"
|
||||||
|
+ "1. 风格:直接、有冲击力、吸引眼球\n"
|
||||||
|
+ "2. 开头:用疑问句或对比句抓住注意力\n"
|
||||||
|
+ "3. 内容:强调价格优势、限时优惠、稀缺性\n"
|
||||||
|
+ "4. 结尾:制造紧迫感,引导立即行动\n"
|
||||||
|
+ "5. 长度:100-200字\n"
|
||||||
|
+ "6. 使用短句,节奏感强\n"
|
||||||
|
+ "\n商品信息:\n"
|
||||||
|
+ "商品名称:%s\n"
|
||||||
|
+ "%s"
|
||||||
|
+ "%s"
|
||||||
|
+ "\n请直接生成文案内容,不要添加其他说明:");
|
||||||
|
put("content:both",
|
||||||
|
"请生成一篇适合小红书和抖音平台的商品推广文案,要求:\n"
|
||||||
|
+ "1. 风格:真实、有吸引力\n"
|
||||||
|
+ "2. 突出商品亮点和价格优势\n"
|
||||||
|
+ "3. 长度:150-250字\n"
|
||||||
|
+ "\n商品信息:\n"
|
||||||
|
+ "商品名称:%s\n"
|
||||||
|
+ "%s"
|
||||||
|
+ "%s"
|
||||||
|
+ "\n请直接生成文案内容,不要添加其他说明:");
|
||||||
|
put("xianyu:wenan_base",
|
||||||
|
"全新未拆封正品,包邮包安装,支持查验后再签收。\n"
|
||||||
|
+ "运损可免费换新。\n"
|
||||||
|
+ "售后全部支持全国联保。");
|
||||||
|
put("xianyu:jiaonixiadan_extra",
|
||||||
|
"\n无偿提供下单方案,包价格成立:\n"
|
||||||
|
+ "只要告诉我【需要下单的型号 + 收货地址】,\n"
|
||||||
|
+ "我会根据你所在地区和需求,\n"
|
||||||
|
+ "优先回复你合适的下单渠道和详细步骤,让你安全省钱地完成下单。");
|
||||||
|
put("xianyu:title_clean_regex", "以旧|政府|换新|领取|国家|补贴|15%|20%|国补|立减|【|】");
|
||||||
|
}};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有提示词模板
|
* 获取所有提示词模板
|
||||||
*
|
*
|
||||||
@@ -66,9 +123,10 @@ public class SocialMediaPromptController {
|
|||||||
templateInfo.put("key", key);
|
templateInfo.put("key", key);
|
||||||
templateInfo.put("description", TEMPLATE_DESCRIPTIONS.get(key));
|
templateInfo.put("description", TEMPLATE_DESCRIPTIONS.get(key));
|
||||||
|
|
||||||
String template = getTemplateFromRedis(key);
|
String stored = getTemplateFromRedis(key);
|
||||||
templateInfo.put("template", template);
|
boolean isDefault = StrUtil.isBlank(stored);
|
||||||
templateInfo.put("isDefault", template == null);
|
templateInfo.put("template", isDefault ? DEFAULT_PROMPT_TEMPLATES.getOrDefault(key, "") : stored);
|
||||||
|
templateInfo.put("isDefault", isDefault);
|
||||||
|
|
||||||
templates.put(key, templateInfo);
|
templates.put(key, templateInfo);
|
||||||
}
|
}
|
||||||
@@ -100,12 +158,13 @@ public class SocialMediaPromptController {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
String template = getTemplateFromRedis(key);
|
String stored = getTemplateFromRedis(key);
|
||||||
|
boolean isDefault = StrUtil.isBlank(stored);
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
data.put("key", key);
|
data.put("key", key);
|
||||||
data.put("description", TEMPLATE_DESCRIPTIONS.get(key));
|
data.put("description", TEMPLATE_DESCRIPTIONS.get(key));
|
||||||
data.put("template", template);
|
data.put("template", isDefault ? DEFAULT_PROMPT_TEMPLATES.getOrDefault(key, "") : stored);
|
||||||
data.put("isDefault", template == null);
|
data.put("isDefault", isDefault);
|
||||||
|
|
||||||
response.put("code", 200);
|
response.put("code", 200);
|
||||||
response.put("msg", "操作成功");
|
response.put("msg", "操作成功");
|
||||||
@@ -227,7 +286,8 @@ public class SocialMediaPromptController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
String redisKey = REDIS_KEY_PREFIX + key;
|
String redisKey = REDIS_KEY_PREFIX + key;
|
||||||
return redisTemplate.opsForValue().get(redisKey);
|
String v = redisTemplate.opsForValue().get(redisKey);
|
||||||
|
return StrUtil.isBlank(v) ? null : v.trim();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("读取Redis模板失败: {}", key, e);
|
log.warn("读取Redis模板失败: {}", key, e);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user