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