增加视频回复

dev_2.0.0
liu 1 year ago
parent f5f91244fc
commit 4ff3c6bf31

@ -12,6 +12,7 @@
<result property="question" column="question" jdbcType="ARRAY"
typeHandler="com.supervision.handler.StringListTypeHandler"/>
<result property="defaultAnswer" column="default_answer" jdbcType="VARCHAR"/>
<result property="defaultAnswerResourceId" column="default_answer_resources_id" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
@ -21,7 +22,7 @@
<sql id="Base_Column_List">
id
,dict_id,code,description,
question,default_answer,create_user_id,
question,default_answer,default_answer_resources_id,create_user_id,
create_time,update_user_id,update_time
</sql>

@ -2,6 +2,7 @@ package com.supervision.controller;
import com.supervision.pojo.vo.TalkReqVO;
import com.supervision.pojo.vo.TalkResultResVO;
import com.supervision.pojo.vo.TalkVideoReqVO;
import com.supervision.service.AskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -36,7 +37,7 @@ public class AskController {
@ApiOperation("使用本地视频的形式来做")
@PostMapping("/talkByVideo")
public TalkResultResVO talkByVideo(@RequestBody TalkReqVO talkReqVO, HttpServletResponse response) throws IOException {
public TalkResultResVO talkByVideo(@RequestBody TalkVideoReqVO talkReqVO, HttpServletResponse response) throws IOException {
return askService.talkByVideo(talkReqVO,response);
}

@ -0,0 +1,15 @@
package com.supervision.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class TalkVideoReqVO {
@ApiModelProperty("对话内容")
private String text;
@ApiModelProperty("流程ID")
private String processId;
}

@ -2,6 +2,7 @@ package com.supervision.service;
import com.supervision.pojo.vo.TalkReqVO;
import com.supervision.pojo.vo.TalkResultResVO;
import com.supervision.pojo.vo.TalkVideoReqVO;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
@ -16,7 +17,7 @@ public interface AskService {
TalkResultResVO talk(TalkReqVO talkReqVO) throws IOException;
TalkResultResVO talkByVideo(TalkReqVO talkReqVO, HttpServletResponse response) throws IOException;
TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO, HttpServletResponse response) throws IOException;
}

@ -1,19 +1,17 @@
package com.supervision.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.MD5;
import com.supervision.exception.BusinessException;
import com.supervision.model.*;
import com.supervision.model.Process;
import com.supervision.model.*;
import com.supervision.pojo.vo.TalkReqVO;
import com.supervision.pojo.vo.TalkResultResVO;
import com.supervision.pojo.vo.TalkVideoReqVO;
import com.supervision.service.*;
import com.supervision.util.*;
import io.minio.MinioClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@ -24,7 +22,6 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Optional;
@ -196,11 +193,12 @@ public class AskServiceImpl implements AskService {
}
@Override
public TalkResultResVO talkByVideo(TalkReqVO talkReqVO, HttpServletResponse response) throws IOException {
public TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO, HttpServletResponse response) throws IOException {
// 根据processId找到对应的病人
Process process = Optional.ofNullable(processService.getById(talkReqVO.getProcessId())).orElseThrow(() -> new BusinessException("未找到诊疗进程"));
// 调用rasa获取文字内容
String rasaResult = RasaUtil.talkRasa(talkReqVO.getText(), UserUtil.getUser().getId(), process.getPatientId());
log.info("rasa的回复是:{}",rasaResult);
// 如果rasa没有识别出来,则返回默认值
if (StrUtil.isBlank(rasaResult)) {
downloadTalkVideo(defaultNoMatchId, response);
@ -221,7 +219,6 @@ public class AskServiceImpl implements AskService {
return talkResultResVO;
}
} else {
String roomId = HumanUtil.queryRoomId(talkReqVO.getRoomKey(), talkReqVO.getRoomToken());
AskTemplateQuestionLibrary library = askTemplateQuestionLibraryService.getById(rasaResult);
if (ObjectUtil.isEmpty(library)) {
log.info("{}:未从问题库中找到,回答未识别语句", rasaResult);
@ -242,7 +239,7 @@ public class AskServiceImpl implements AskService {
log.info("{}:找到了默认答案:{}", rasaResult, talkReqVO.getText());
} else {
log.info("{}:没有从默认答案中找到找到默认内容,回复未识别语句", rasaResult);
HumanUtil.textDriven("您好,我没有听懂您说什么", roomId);
downloadTalkVideo(library.getDefaultAnswerResourceId(), response);
saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), library, "您好,我没有听懂您说什么");
}
} else {

@ -84,4 +84,4 @@ ws:
nginx-ip: 192.168.10.138
nginx-port: 443
# 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID
defaultNoMatchId: 1
defaultNoMatchId: 1739173836351885313

@ -85,4 +85,4 @@ ws:
nginx-ip: 192.168.10.138
nginx-port: 443
# 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID
defaultNoMatchId: 1
defaultNoMatchId: 1739173836351885313
Loading…
Cancel
Save