|
|
|
@ -1,12 +1,15 @@
|
|
|
|
|
package com.supervision.rasa.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.supervision.exception.BusinessException;
|
|
|
|
|
import com.supervision.model.RasaModelInfo;
|
|
|
|
|
import com.supervision.rasa.pojo.dto.RasaReqDTO;
|
|
|
|
|
import com.supervision.rasa.pojo.dto.RasaResDTO;
|
|
|
|
|
import com.supervision.rasa.pojo.dto.Text2vecMatchesReq;
|
|
|
|
|
import com.supervision.rasa.pojo.dto.Text2vecMatchesRes;
|
|
|
|
|
import com.supervision.rasa.service.Text2vecService;
|
|
|
|
|
import com.supervision.vo.rasa.RasaTalkVo;
|
|
|
|
|
import com.supervision.rasa.service.RasaTalkService;
|
|
|
|
|
import com.supervision.service.RasaModeService;
|
|
|
|
@ -27,6 +30,8 @@ public class RasaTalkServiceImpl implements RasaTalkService {
|
|
|
|
|
private String rasaUrl;
|
|
|
|
|
|
|
|
|
|
private final RasaModeService rasaModeService;
|
|
|
|
|
|
|
|
|
|
private final Text2vecService text2vecService;
|
|
|
|
|
@Override
|
|
|
|
|
public List<String> talkRasa(RasaTalkVo rasaTalkVo) {
|
|
|
|
|
|
|
|
|
@ -44,8 +49,12 @@ public class RasaTalkServiceImpl implements RasaTalkService {
|
|
|
|
|
|
|
|
|
|
List<RasaResDTO> list = JSONUtil.toList(post, RasaResDTO.class);
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(list)){
|
|
|
|
|
return list.stream().map(RasaResDTO::getText).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
return text2vecService.matches(new Text2vecMatchesReq(rasaTalkVo.getQuestion()))
|
|
|
|
|
.stream().map(Text2vecMatchesRes::getSentence).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getRasaUrl(int port){
|
|
|
|
|
|
|
|
|
|