|
|
|
@ -43,24 +43,21 @@ public class ItemExtractHandler {
|
|
|
|
|
* @param question 问题
|
|
|
|
|
* @return 提取结果
|
|
|
|
|
*/
|
|
|
|
|
public List<String> itemExtractByPossibleItem(String question, Collection<String> possible) {
|
|
|
|
|
// TODO 这里暂时没办法,暂时先当做是退休
|
|
|
|
|
// List<MessageDTO> messageList = new ArrayList<>();
|
|
|
|
|
// messageList.add(new MessageDTO("system", "假设你是一个命名实体识别模型且精通社保实体识别." +
|
|
|
|
|
// "现在我会给你一个句子,请根据我的要求识别出句子中的实体数据在社保业务中属于哪一类业务事项,并给我事项名称,同时,我会给你一些事项可供参考,尽量从这些事项中进行匹配.如果未找到事项,就回复:未找到;其他什么都不要说!"));
|
|
|
|
|
// messageList.add(new MessageDTO("assistant", "好的"));
|
|
|
|
|
// messageList.add(new MessageDTO("user", StrUtil.format("可能的事项有:[{}]", CollUtil.join(possible, ";"))));
|
|
|
|
|
// messageList.add(new MessageDTO("user", "句子是:" + question + ";请识别这句话中的社保业务事项,如果识别出多个,请用;分隔.除了识别到的业务事项,其他什么都不要说"));
|
|
|
|
|
// log.info("itemExtractByPossibleItem查询语句为:{}", JSONUtil.toJsonStr(messageList));
|
|
|
|
|
// String item = AiUtil.chatByMessage(messageList);
|
|
|
|
|
// if (StrUtil.equals("未找到", item)) {
|
|
|
|
|
// throw new ItemExtractException("未从问题中找到事项");
|
|
|
|
|
// }
|
|
|
|
|
// if (StrUtil.contains(item, ";")){
|
|
|
|
|
// return Arrays.asList(item.split(";"));
|
|
|
|
|
// }
|
|
|
|
|
// return Collections.singletonList(item);
|
|
|
|
|
return Collections.singletonList("退休");
|
|
|
|
|
public List<String> itemExtractByPossibleItem(String question, List<String> possible) {
|
|
|
|
|
String template = "请根据以下事项列表,从句子中识别并标注出对应的社保业务事项名称。若句子中不能直接对应到任何事项,就找可能性最高的事项。请确保只识别并标注一种可能性最高的社保业务事项。" +
|
|
|
|
|
"事项名称列表:\n" +
|
|
|
|
|
"{}" +
|
|
|
|
|
"句子是:{}";
|
|
|
|
|
List<MessageDTO> messageList = new ArrayList<>();
|
|
|
|
|
messageList.add(new MessageDTO("user", StrUtil.format(template, CollUtil.join(possible, ";"), question)));
|
|
|
|
|
|
|
|
|
|
log.info("itemExtractByPossibleItem查询语句为:{}", JSONUtil.toJsonStr(messageList));
|
|
|
|
|
String item = AiUtil.chatByMessage(messageList);
|
|
|
|
|
log.info("itemExtractByPossibleItem结果为:{}", item);
|
|
|
|
|
if (StrUtil.equals("未找到", item)) {
|
|
|
|
|
throw new ItemExtractException("未从问题中找到事项");
|
|
|
|
|
}
|
|
|
|
|
return Collections.singletonList(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String itemExtractBusiness(String question) {
|
|
|
|
|