提示词调试支持图谱提取

jinan_dev
yaxin
parent f9a36a2428
commit 88e5fbe0c1

@ -15,7 +15,7 @@ import com.supervision.minio.service.MinioService;
import com.supervision.police.domain.*;
import com.supervision.police.dto.LLMExtractDto;
import com.supervision.police.dto.NotePromptDTO;
import com.supervision.police.dto.NotePromptExtractAttributesDto;
import com.supervision.police.dto.TripleInfoDTO;
import com.supervision.police.mapper.NotePromptMapper;
import com.supervision.police.service.*;
import com.supervision.thread.TripleExtractTask;
@ -121,7 +121,7 @@ public class NotePromptServiceImpl extends ServiceImpl<NotePromptMapper, NotePro
public IPage<NotePromptDTO> listPrompt(NotePromptDTO notePromptDTO) {
Page<NotePromptDTO> notePromptDTOPage = notePromptMapper.selectNotePromptWithMatchNum(new Page<>(notePromptDTO.getPage(), notePromptDTO.getSize()), notePromptDTO);
for (NotePromptDTO record : notePromptDTOPage.getRecords()) {
if (StrUtil.isEmpty(record.getEvidenceCategoryId())){
if (StrUtil.isEmpty(record.getEvidenceCategoryId())) {
continue;
}
record.setExtractAttributes(caseEvidencePropertyService.findExtractAttributes(record.getEvidenceCategoryId()));
@ -164,6 +164,20 @@ public class NotePromptServiceImpl extends ServiceImpl<NotePromptMapper, NotePro
}
QARecordNodeDTO qaRecordNodeDTO = qaList.get(0);
HashMap<String, String> paramMap = new HashMap<>();
// 头结点-关系-尾结点关系赋值
List<TripleInfoDTO> tripleList = notePromptDTO.getTripleList();
for (TripleInfoDTO dto : tripleList) {
if ("头节点".equals(dto.getType())) {
notePromptDTO.setStartEntityType(dto.getValue());
} else if ("关系".equals(dto.getType())) {
notePromptDTO.setRelType(dto.getValue());
} else if ("尾节点".equals(dto.getType())) {
notePromptDTO.setEndEntityType(dto.getValue());
}
}
paramMap.put("headEntityType", notePromptDTO.getStartEntityType());
paramMap.put("relation", notePromptDTO.getRelType());
paramMap.put("tailEntityType", notePromptDTO.getEndEntityType());
@ -172,7 +186,7 @@ public class NotePromptServiceImpl extends ServiceImpl<NotePromptMapper, NotePro
paramMap.put("requirement", "");
log.info("开始尝试提取三元组:{}-{}-{}", notePromptDTO.getStartEntityType(), notePromptDTO.getRelType(), notePromptDTO.getEndEntityType());
String format = StrUtil.format(notePromptDTO.getPrompt(), paramMap);
log.info("提示词内容:{}", format);
log.info("提示词内容:\n{}", format);
ChatResponse call = chatClient.call(new Prompt(new UserMessage(format)));
String content = call.getResult().getOutput().getContent();
log.info("三元组提取结果:{}", content);
@ -197,7 +211,7 @@ public class NotePromptServiceImpl extends ServiceImpl<NotePromptMapper, NotePro
public NotePromptDTO getById(String id) {
NotePrompt notePrompt = super.getById(id);
if (null != notePrompt && StrUtil.isNotEmpty(notePrompt.getEvidenceCategoryId())){
if (null != notePrompt && StrUtil.isNotEmpty(notePrompt.getEvidenceCategoryId())) {
notePrompt.setExtractAttributes(caseEvidencePropertyService.findExtractAttributes(notePrompt.getEvidenceCategoryId()));
}

Loading…
Cancel
Save