|
|
|
@ -246,6 +246,31 @@ public class InteractiveServiceImpl implements IInteractiveService {
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 发起知识库问答 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public R knowledgeAsk(String question, String sessionId, String userId, String knowledge) { |
|
|
|
|
Map<String,Object> params = new HashMap<>(); |
|
|
|
|
params.put("id", sessionId); |
|
|
|
|
params.put("userid", userId); |
|
|
|
|
params.put("query", question); |
|
|
|
|
params.put("knowledge", knowledge); |
|
|
|
|
params.put("stationids", this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) |
|
|
|
|
.filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); |
|
|
|
|
params.put("projectids", this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId) |
|
|
|
|
.filter(Func::isNotEmpty).map(String::valueOf).toArray()); |
|
|
|
|
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantKnowledgeAsk()) |
|
|
|
|
.body(JSON.toJSONString(params)).execute(); |
|
|
|
|
logger.info("interactive:knowledgeAsk", "知识库问答传参为:" + JSON.toJSONString(params) + " 结果为:" + response.body()); |
|
|
|
|
if (response.getStatus() != HttpServletResponse.SC_OK) { |
|
|
|
|
log.error("远程调用大模型【发起知识库问答】接口失败!"); |
|
|
|
|
return R.fail("远程调用大模型【发起知识库问答】接口失败!"); |
|
|
|
|
} |
|
|
|
|
this.addQuestionSessionId(sessionId); |
|
|
|
|
return R.success("消息发送成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<DeptStationDTO> getStationPermissionsById(String userId) { |
|
|
|
|
R<List<DeptStationDTO>> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId)); |
|
|
|
|
Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> { |
|
|
|
|