|
@@ -26,6 +26,10 @@ public class ChatLogServiceImpl implements ChatLogService {
|
|
|
@Override
|
|
|
public ResponseJson<ChatCompletionResponse> getAnswer(Integer userId, String question) {
|
|
|
log.info("dto------------->" + question);
|
|
|
+ Integer count = chatMapper.findLogCount(userId);
|
|
|
+ if (count > 10) {
|
|
|
+ return ResponseJson.error(-3, "今日对话轮次上限");
|
|
|
+ }
|
|
|
ApiRequest chatRequest = new ApiRequest();
|
|
|
ApiRequest.Message message = new ApiRequest.Message();
|
|
|
question = question + ",内容不超过350字";
|
|
@@ -106,7 +110,7 @@ public class ChatLogServiceImpl implements ChatLogService {
|
|
|
@Override
|
|
|
public ResponseJson<ChatCompletionResponse> getSecondAnswer(Integer chatId, Integer userId, String question) {
|
|
|
List<ChatHistoryMessage> historyMessage = chatMapper.findHistoryQuestion(chatId, userId);
|
|
|
- if(historyMessage.size()<1){
|
|
|
+ if (historyMessage.size() < 1) {
|
|
|
return ResponseJson.error("无历史记录");
|
|
|
}
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
@@ -122,6 +126,9 @@ public class ChatLogServiceImpl implements ChatLogService {
|
|
|
ApiRequest.Message resMes = new ApiRequest.Message();
|
|
|
resMes.role("assistant").content(chatResp.getResult());
|
|
|
messages.add(resMes);
|
|
|
+ if (messages.size() >= 20) {
|
|
|
+ return ResponseJson.error(-2, "超出对话轮次上限");
|
|
|
+ }
|
|
|
/**
|
|
|
* 正常轮次提问
|
|
|
*/
|