提交 f5510d77 作者: 925993793@qq.com

定制自定义专题优化

上级 d9b8f8e9
...@@ -81,6 +81,7 @@ public class LLmConfigController { ...@@ -81,6 +81,7 @@ public class LLmConfigController {
String eventId = eventLlmConfig.getEventId(); String eventId = eventLlmConfig.getEventId();
EventVO event = eventService.queryInfo(eventId); EventVO event = eventService.queryInfo(eventId);
String eventName = event.getEventName(); String eventName = event.getEventName();
log.info("{}-事件分析【{}】重新生成逻辑完成。", eventName, analysisColumnEnum.getName());
String content = "事件标题;" + eventName + "\n事件摘要:" + event.getEventDescribe(); String content = "事件标题;" + eventName + "\n事件摘要:" + event.getEventDescribe();
//调用大模型更细结果 //调用大模型更细结果
String llmResult = analysisService.llmResult(eventId,content, null, null, eventLlmConfig.getColumnCode()); String llmResult = analysisService.llmResult(eventId,content, null, null, eventLlmConfig.getColumnCode());
......
...@@ -12,10 +12,10 @@ import com.zzsn.event.external.entity.ExternalSubjectInfoSourceMap; ...@@ -12,10 +12,10 @@ import com.zzsn.event.external.entity.ExternalSubjectInfoSourceMap;
import com.zzsn.event.external.service.ExternalSubjectInfoSourceMapService; import com.zzsn.event.external.service.ExternalSubjectInfoSourceMapService;
import com.zzsn.event.external.vo.SubjectInfoVO; import com.zzsn.event.external.vo.SubjectInfoVO;
import com.zzsn.event.external.vo.SubjectVO; import com.zzsn.event.external.vo.SubjectVO;
import com.zzsn.event.llm.LlmService;
import com.zzsn.event.service.CommonService; import com.zzsn.event.service.CommonService;
import com.zzsn.event.service.SubjectSimpleService; import com.zzsn.event.service.SubjectSimpleService;
import com.zzsn.event.util.HttpUtil; import com.zzsn.event.util.HttpUtil;
import com.zzsn.event.util.LLMUtil;
import com.zzsn.event.vo.SubjectDetailVO; import com.zzsn.event.vo.SubjectDetailVO;
import com.zzsn.event.vo.SubjectSimpleVO; import com.zzsn.event.vo.SubjectSimpleVO;
import com.zzsn.event.xxljob.service.IXxlJobInfoService; import com.zzsn.event.xxljob.service.IXxlJobInfoService;
...@@ -53,6 +53,8 @@ public class ExternalController { ...@@ -53,6 +53,8 @@ public class ExternalController {
private ExternalSubjectInfoSourceMapService externalSubjectInfoSourceMapService; private ExternalSubjectInfoSourceMapService externalSubjectInfoSourceMapService;
@Autowired @Autowired
private CommonService commonService; private CommonService commonService;
@Autowired
private LlmService llmService;
@Value("${caiji.keywordCrawler.url:}") @Value("${caiji.keywordCrawler.url:}")
private String keywordCrawlerUrl; private String keywordCrawlerUrl;
...@@ -102,7 +104,22 @@ public class ExternalController { ...@@ -102,7 +104,22 @@ public class ExternalController {
*/ */
@GetMapping("/crawlerWordRecommend") @GetMapping("/crawlerWordRecommend")
public Result<?> crawlerWordRecommend(@RequestParam String remark) { public Result<?> crawlerWordRecommend(@RequestParam String remark) {
return Result.OK(LLMUtil.crawlerWord(remark)); String prompt = "你是一个专业信息采集助手,根据用户提供的专题描述,精准提取核心实体和主题,生成符合以下规则的关键词表达式:\n" +
"1. 用 `+` 表示 **与** 关系(必须同时出现)\n" +
"2. 用 `|` 表示 **或** 关系(任一出现即可)\n" +
"3. +两端的关键词组用 `()` 框选\n" +
"4. 关键词必须直接来自描述或合理扩展的同义/关联词\n" +
"5. 输出仅含表达式,无额外解释\n" +
"6.+号使用不超过2个\n" +
"7.不要把时间提取进表达式\n" +
"8.输入输出为日语时,检查拼写是否有误,不要包含特殊字符,输出书面表达\n" +
"\n" +
"\n" +
"### 示例\n" +
"专题描述:\"星动纪元、云深处科技分别完成近5亿元融资,用于人形机器人研发与量产\" \n" +
"输出:(星动纪元|云深处科技)+(融资|量产)";
String crawlerWord = llmService.crawlerWord("qwen-max-latest", prompt, remark);
return Result.OK(crawlerWord);
} }
/** /**
......
...@@ -14,4 +14,15 @@ public interface LlmService { ...@@ -14,4 +14,15 @@ public interface LlmService {
* @return 大模型响应结果 * @return 大模型响应结果
*/ */
String model(String model, String system, String content); String model(String model, String system, String content);
/**
* 采集词推荐(定制自定义专题)
*
* @param modelName 模型名称
* @param prompt 提示词
* @param content 输入的内容
* @author lkg
* @date 2025/8/16
*/
String crawlerWord(String modelName, String prompt, String content);
} }
...@@ -62,6 +62,15 @@ public class LlmServiceImpl implements LlmService { ...@@ -62,6 +62,15 @@ public class LlmServiceImpl implements LlmService {
return null; return null;
} }
@Override
public String crawlerWord(String modelName, String prompt, String content) {
LlmProperties.ModelConfig modelConfig = llmProperties.getModelConfig("qwen");
if (StringUtils.isNotEmpty(modelName)) {
modelConfig.setDefaultModel(modelName);
}
return qwenModel(modelConfig, prompt, content);
}
/** /**
* glm模型调用 * glm模型调用
* *
......
...@@ -312,25 +312,7 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -312,25 +312,7 @@ public class AnalysisServiceImpl implements AnalysisService {
return null; return null;
} }
String result = llmService.model(llmConfig.getLlmName(), llmConfig.getLlmPrompt(), content); String result = llmService.model(llmConfig.getLlmName(), llmConfig.getLlmPrompt(), content);
AnalysisColumnEnum analysisColumnEnum = AnalysisColumnEnum.getByCode(llmConfig.getColumnCode()); result = result.replaceAll("```json","").replaceAll("```","");
String startHeader = null;
if (analysisColumnEnum != null) {
String resType = analysisColumnEnum.getResType();
if (resType.equals("array")) {
startHeader = "[";
} else if (resType.equals("object")) {
startHeader = "{";
}
}
if (startHeader != null && !result.startsWith(startHeader)) {
if (result.startsWith("```json")) {
result = result.substring(7, result.length() - 3);
} else if (result.startsWith("```")) {
result = result.substring(3, result.length() - 3);
} else if (result.contains(startHeader)){
result = result.substring(result.indexOf(startHeader));
}
}
if (llmConfig.getColumnCode().equals(AnalysisColumnEnum.IMPACT_ASSESSMENT.getCode())) { if (llmConfig.getColumnCode().equals(AnalysisColumnEnum.IMPACT_ASSESSMENT.getCode())) {
EventLlmConfig detailConfig = eventLlmConfigService.getConfig(event.getId(), AnalysisColumnEnum.IMPACT_ASSESSMENT_DETAIL.getCode()); EventLlmConfig detailConfig = eventLlmConfigService.getConfig(event.getId(), AnalysisColumnEnum.IMPACT_ASSESSMENT_DETAIL.getCode());
List<JSONObject> impactList = JSON.parseArray(result, JSONObject.class); List<JSONObject> impactList = JSON.parseArray(result, JSONObject.class);
......
...@@ -12,6 +12,7 @@ import org.apache.commons.collections4.CollectionUtils; ...@@ -12,6 +12,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -101,6 +102,7 @@ public class EventLlmConfigServiceImpl extends ServiceImpl<EventLlmConfigMapper, ...@@ -101,6 +102,7 @@ public class EventLlmConfigServiceImpl extends ServiceImpl<EventLlmConfigMapper,
} }
eventLlmConfig.setYnDefault(0); eventLlmConfig.setYnDefault(0);
collect.add(eventLlmConfig); collect.add(eventLlmConfig);
collect.sort(Comparator.comparingInt(EventLlmConfig::getColumnCode));
this.saveBatch(collect); this.saveBatch(collect);
} else { } else {
LambdaUpdateWrapper<EventLlmConfig> update = Wrappers.lambdaUpdate(); LambdaUpdateWrapper<EventLlmConfig> update = Wrappers.lambdaUpdate();
......
...@@ -43,7 +43,7 @@ public class SynClbEventDataTask { ...@@ -43,7 +43,7 @@ public class SynClbEventDataTask {
/** /**
* 同步克虏宝中事件信息到研究中心数据库 * 同步克虏宝中事件信息到研究中心数据库
*/ */
@Scheduled(cron = "0 15 0/1 * * ?") //@Scheduled(cron = "0 15 0/1 * * ?")
public void synEventData () { public void synEventData () {
if(!yjzxEnable){ if(!yjzxEnable){
return; return;
......
...@@ -75,6 +75,7 @@ public class LLMUtil { ...@@ -75,6 +75,7 @@ public class LLMUtil {
"5. 输出仅含表达式,无额外解释\n" + "5. 输出仅含表达式,无额外解释\n" +
"6.+号使用不超过2个\n" + "6.+号使用不超过2个\n" +
"7.不要把时间提取进表达式\n" + "7.不要把时间提取进表达式\n" +
"8.输入输出为日语时,检查拼写是否有误,不要包含特殊字符,输出书面表达\n" +
"\n" + "\n" +
"\n" + "\n" +
"### 示例\n" + "### 示例\n" +
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论