|
|
|
@ -303,12 +303,14 @@ public class AskServiceImpl implements AskService {
|
|
|
|
|
if (ObjectUtil.isEmpty(qaSimilarityQuestionAnswer)) {
|
|
|
|
|
String talk = aiService.talk(talkReqVO.getText(), medicalRec.getMedicalRecordAi());
|
|
|
|
|
talkVideoTtsResultResVO.setAnswerMessage(talk);
|
|
|
|
|
saveAiRecord(process.getId(), talkReqVO.getText(), talkVideoTtsResultResVO.getAnswerMessage());
|
|
|
|
|
} else {
|
|
|
|
|
// 如果阈值过低,也走大模型
|
|
|
|
|
if (qaSimilarityQuestionAnswer.getMatchScore() < 0.5) {
|
|
|
|
|
log.info("{}:匹配到的结果阈值过低,走大模型回答", qaSimilarityQuestionAnswer);
|
|
|
|
|
String talk = aiService.talk(talkReqVO.getText(), medicalRec.getMedicalRecordAi());
|
|
|
|
|
talkVideoTtsResultResVO.setAnswerMessage(talk);
|
|
|
|
|
saveAiRecord(process.getId(), talkReqVO.getText(), talkVideoTtsResultResVO.getAnswerMessage());
|
|
|
|
|
} else {
|
|
|
|
|
// 如果查到的问题不在问题库中,走大模型回答
|
|
|
|
|
AskTemplateQuestionLibrary library = askTemplateQuestionLibraryService.getById(qaSimilarityQuestionAnswer.getMatchQuestionCode());
|
|
|
|
@ -316,6 +318,7 @@ public class AskServiceImpl implements AskService {
|
|
|
|
|
log.info("{}:未从问题库中找到,走大模型回答", qaSimilarityQuestionAnswer);
|
|
|
|
|
String talk = aiService.talk(talkReqVO.getText(), medicalRec.getMedicalRecordAi());
|
|
|
|
|
talkVideoTtsResultResVO.setAnswerMessage(talk);
|
|
|
|
|
saveAiRecord(process.getId(), talkReqVO.getText(), talkVideoTtsResultResVO.getAnswerMessage());
|
|
|
|
|
} else {
|
|
|
|
|
// 根据问题找这个病历配置的答案
|
|
|
|
|
AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, process.getMedicalRecId())
|
|
|
|
@ -325,20 +328,19 @@ public class AskServiceImpl implements AskService {
|
|
|
|
|
String resText = askPatientAnswer.getAnswer();
|
|
|
|
|
log.info("{}:找到了病历配置的回答语句:{},回答内容:{},走病历回答", qaSimilarityQuestionAnswer.getMatchQuestionCode(), askPatientAnswer.getId(), resText);
|
|
|
|
|
talkVideoTtsResultResVO.setAnswerMessage(resText);
|
|
|
|
|
// 保存记录
|
|
|
|
|
// 保存记录到问答记录表
|
|
|
|
|
saveQaRecord(talkReqVO.getProcessId(), "patient", askPatientAnswer.getId(), talkReqVO.getText(), library, resText);
|
|
|
|
|
} else {
|
|
|
|
|
// 如果问题的答案没有配置,还是走大模型的回答
|
|
|
|
|
log.info("{}:病历配置,从AskPatientAnswer中未找到回答结果,走大模型", qaSimilarityQuestionAnswer.getMatchQuestionCode());
|
|
|
|
|
String talk = aiService.talk(talkReqVO.getText(), medicalRec.getMedicalRecordAi());
|
|
|
|
|
talkVideoTtsResultResVO.setAnswerMessage(talk);
|
|
|
|
|
|
|
|
|
|
saveAiRecord(process.getId(), talkReqVO.getText(), talkVideoTtsResultResVO.getAnswerMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
talkVideoTtsResultResVO.setVoiceBase64(TtsUtil.ttsTransform(talkVideoTtsResultResVO.getAnswerMessage()));
|
|
|
|
|
saveAiRecord(process.getId(), talkReqVO.getText(), talkVideoTtsResultResVO.getAnswerMessage());
|
|
|
|
|
return talkVideoTtsResultResVO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|