|
|
@ -1,6 +1,7 @@
|
|
|
|
package com.supervision.police.service.impl;
|
|
|
|
package com.supervision.police.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import com.supervision.chat.client.LangChainChatService;
|
|
|
|
import com.supervision.chat.client.LangChainChatService;
|
|
|
|
import com.supervision.chat.client.dto.chat.ChatReqDTO;
|
|
|
|
import com.supervision.chat.client.dto.chat.ChatReqDTO;
|
|
|
|
import com.supervision.chat.client.dto.chat.ChatResDTO;
|
|
|
|
import com.supervision.chat.client.dto.chat.ChatResDTO;
|
|
|
@ -13,6 +14,9 @@ import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
@RequiredArgsConstructor
|
|
|
@ -39,8 +43,14 @@ public class ChatServiceImpl implements ChatService {
|
|
|
|
ChatResDTO chat = langChainChatService.chat(
|
|
|
|
ChatResDTO chat = langChainChatService.chat(
|
|
|
|
ChatReqDTO.create(chatReqVO.getQuery(), modelCase.getCaseNo(),chatReqVO.getHistory()));
|
|
|
|
ChatReqDTO.create(chatReqVO.getQuery(), modelCase.getCaseNo(),chatReqVO.getHistory()));
|
|
|
|
|
|
|
|
|
|
|
|
Assert.notNull(chat, "我暂时还不知道怎么回答,您可以尝试换一种问法!");
|
|
|
|
if (null ==chat){
|
|
|
|
Assert.notEmpty(chat.getAnswer(), "我暂时还不知道怎么回答,您可以尝试换一种问法!");
|
|
|
|
chat = new ChatResDTO();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StrUtil.isEmpty(chat.getAnswer())){
|
|
|
|
|
|
|
|
chat.setAnswer("我暂时还不知道怎么回答,您可以尝试换一种问法!");
|
|
|
|
|
|
|
|
chat.setDocs(new ArrayList<>(1));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
log.info("chat: caseNo:{},query{},answer:{}", modelCase.getCaseNo(), chatReqVO.getQuery(),chat.getAnswer());
|
|
|
|
log.info("chat: caseNo:{},query{},answer:{}", modelCase.getCaseNo(), chatReqVO.getQuery(),chat.getAnswer());
|
|
|
|
|
|
|
|
|
|
|
|
return new ChatResVO(chat);
|
|
|
|
return new ChatResVO(chat);
|
|
|
|