|
@@ -66,7 +66,7 @@ public class ArticleCategoryService {
|
|
|
"\"20241030070010871546586\"]}")
|
|
|
private static List<String> producePlanIds;
|
|
|
@Value("${kimiCategoryPrompt:}")
|
|
|
- private String kimiCategoryPrompt;
|
|
|
+ private String categoryPrompt;
|
|
|
|
|
|
@Value("${category.active.version:1}")
|
|
|
private Integer activeVersion;
|
|
@@ -99,7 +99,7 @@ public class ArticleCategoryService {
|
|
|
addPromotionArticleCategoryByProducePlan();
|
|
|
// 视频内容池 添加品类处理任务
|
|
|
addVideoPoolArticleCategory();
|
|
|
- // 调用kimi进行内容分类
|
|
|
+ // 调用大模型进行内容分类
|
|
|
dealArticleCategory();
|
|
|
}
|
|
|
|
|
@@ -108,7 +108,7 @@ public class ArticleCategoryService {
|
|
|
List<List<ArticleCategory>> partitionList = Lists.partition(dealList, 20);
|
|
|
for (List<ArticleCategory> partition : partitionList) {
|
|
|
List<String> partitionTitles = partition.stream().map(ArticleCategory::getTitle).distinct().collect(Collectors.toList());
|
|
|
- String prompt = buildKimiPrompt(partitionTitles);
|
|
|
+ String prompt = buildCategoryPrompt(partitionTitles);
|
|
|
KimiResult kimiResult = deepSeekApiService.requestOfficialApi(prompt, null, null, true);
|
|
|
long now = System.currentTimeMillis();
|
|
|
JSONObject obj = null;
|
|
@@ -120,7 +120,7 @@ public class ArticleCategoryService {
|
|
|
}
|
|
|
}
|
|
|
for (ArticleCategory articleCategory : partition) {
|
|
|
- articleCategory.setKimiResult(kimiResult.getResponseStr());
|
|
|
+ articleCategory.setKimiResult(kimiResult.getResponseStr().trim());
|
|
|
articleCategory.setUpdateTimestamp(now);
|
|
|
if (kimiResult.isSuccess() && Objects.nonNull(obj) && obj.containsKey(articleCategory.getTitle())) {
|
|
|
articleCategory.setCategory(obj.getString(articleCategory.getTitle()));
|
|
@@ -164,6 +164,7 @@ public class ArticleCategoryService {
|
|
|
item.setTitle(vo.getTitle());
|
|
|
item.setTitleMd5(Md5Util.encoderByMd5(vo.getTitle()));
|
|
|
item.setCreateTimestamp(now);
|
|
|
+ item.setVersion(activeVersion);
|
|
|
saveList.add(item);
|
|
|
}
|
|
|
if (CollectionUtils.isNotEmpty(saveList)) {
|
|
@@ -231,7 +232,7 @@ public class ArticleCategoryService {
|
|
|
}
|
|
|
if (Objects.nonNull(category) && StringUtils.hasText(category.getCategory())) {
|
|
|
articleCategory.setCategory(category.getCategory());
|
|
|
- articleCategory.setKimiResult(category.getKimiResult());
|
|
|
+ articleCategory.setKimiResult(category.getKimiResult().trim());
|
|
|
articleCategory.setStatus(ArticleCategoryStatusEnum.SUCCESS.getCode());
|
|
|
}
|
|
|
}
|
|
@@ -253,6 +254,7 @@ public class ArticleCategoryService {
|
|
|
item.setTitle(videoSource.getArticleTitle());
|
|
|
item.setTitleMd5(Md5Util.encoderByMd5(videoSource.getArticleTitle()));
|
|
|
item.setCreateTimestamp(now);
|
|
|
+ item.setVersion(activeVersion);
|
|
|
saveList.add(item);
|
|
|
}
|
|
|
articleCategoryMapper.batchInsertArticleCategory(saveList);
|
|
@@ -291,14 +293,15 @@ public class ArticleCategoryService {
|
|
|
item.setTitle(title);
|
|
|
item.setTitleMd5(Md5Util.encoderByMd5(title));
|
|
|
item.setCreateTimestamp(now);
|
|
|
+ item.setVersion(activeVersion);
|
|
|
saveList.add(item);
|
|
|
}
|
|
|
}
|
|
|
return saveList;
|
|
|
}
|
|
|
|
|
|
- private String buildKimiPrompt(List<String> titleList) {
|
|
|
- StringBuilder prompt = new StringBuilder(kimiCategoryPrompt);
|
|
|
+ private String buildCategoryPrompt(List<String> titleList) {
|
|
|
+ StringBuilder prompt = new StringBuilder(categoryPrompt);
|
|
|
prompt.append("\n");
|
|
|
for (String title : titleList) {
|
|
|
prompt.append(title).append("\n");
|
|
@@ -310,7 +313,7 @@ public class ArticleCategoryService {
|
|
|
List<ArticleCategory> dealList = articleCategoryRepository.getByStatusAndRetryTimesLessThanAndVersion(ArticleCategoryStatusEnum.FAIL.getCode(), 3, activeVersion);
|
|
|
for (ArticleCategory articleCategory : dealList) {
|
|
|
List<String> partitionTitles = Collections.singletonList(articleCategory.getTitle());
|
|
|
- String prompt = buildKimiPrompt(partitionTitles);
|
|
|
+ String prompt = buildCategoryPrompt(partitionTitles);
|
|
|
KimiResult kimiResult = deepSeekApiService.requestOfficialApi(prompt, null, null, true);
|
|
|
long now = System.currentTimeMillis();
|
|
|
JSONObject obj = null;
|
|
@@ -321,7 +324,7 @@ public class ArticleCategoryService {
|
|
|
log.error(kimiResult.getResponse().getChoices().get(0).getMessage().getContent());
|
|
|
}
|
|
|
}
|
|
|
- articleCategory.setKimiResult(kimiResult.getResponseStr());
|
|
|
+ articleCategory.setKimiResult(kimiResult.getResponseStr().trim());
|
|
|
articleCategory.setUpdateTimestamp(now);
|
|
|
articleCategory.setRetryTimes(articleCategory.getRetryTimes() + 1);
|
|
|
if (kimiResult.isSuccess() && Objects.nonNull(obj)) {
|