You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
906 B
Java
27 lines
906 B
Java
2 years ago
|
package com.supervision.util;
|
||
2 years ago
|
|
||
|
import cn.hutool.http.HttpUtil;
|
||
|
import cn.hutool.json.JSONUtil;
|
||
2 years ago
|
import com.supervision.pojo.rasa.train.dto.RasaReqDTO;
|
||
|
import com.supervision.pojo.rasa.train.dto.RasaResDTO;
|
||
2 years ago
|
import org.springframework.core.env.Environment;
|
||
|
|
||
|
import java.util.List;
|
||
|
import java.util.stream.Collectors;
|
||
|
|
||
|
public class RasaUtil {
|
||
|
|
||
|
private static final String RASA_URL = SpringBeanUtil.getBean(Environment.class).getProperty("rasa.url");
|
||
|
|
||
|
public static List<String> talkRasa(String question, String sessionId) {
|
||
|
RasaReqDTO rasaReqDTO = new RasaReqDTO();
|
||
|
rasaReqDTO.setSender(sessionId);
|
||
|
rasaReqDTO.setMessage(question);
|
||
|
String post = HttpUtil.post(RASA_URL, JSONUtil.toJsonStr(rasaReqDTO));
|
||
|
List<RasaResDTO> list = JSONUtil.toList(post, RasaResDTO.class);
|
||
|
return list.stream().map(RasaResDTO::getText).collect(Collectors.toList());
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|