mirror of
https://github.com/zongzibinbin/MallChat.git
synced 2026-03-13 21:53:41 +08:00
Merge remote-tracking branch 'origin/chat'
This commit is contained in:
@@ -65,11 +65,11 @@ wx:
|
|||||||
aesKey: ${mallchat.wx.aesKey} # 接口配置里的EncodingAESKey值
|
aesKey: ${mallchat.wx.aesKey} # 接口配置里的EncodingAESKey值
|
||||||
chatai:
|
chatai:
|
||||||
chatgpt:
|
chatgpt:
|
||||||
use: false
|
use: true
|
||||||
AIUserId: 10452
|
AIUserId: 10452
|
||||||
key: xxxxx
|
key: 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
|
||||||
chatglm2:
|
chatglm2:
|
||||||
use: false
|
use: true
|
||||||
url: xxxxx
|
url: http://vastmiao.natapp1.cc
|
||||||
minute: 3 # 每个用户每3分钟可以请求一次
|
minute: 3 # 每个用户每3分钟可以请求一次
|
||||||
AIUserId: 10451
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.abin.mallchat.custom.chatai.handler;
|
|||||||
|
|
||||||
import cn.hutool.http.HttpResponse;
|
import cn.hutool.http.HttpResponse;
|
||||||
import com.abin.mallchat.common.chat.domain.entity.Message;
|
import com.abin.mallchat.common.chat.domain.entity.Message;
|
||||||
|
import com.abin.mallchat.common.chat.domain.entity.msg.MessageExtra;
|
||||||
import com.abin.mallchat.common.common.constant.RedisKey;
|
import com.abin.mallchat.common.common.constant.RedisKey;
|
||||||
import com.abin.mallchat.common.common.utils.RedisUtils;
|
import com.abin.mallchat.common.common.utils.RedisUtils;
|
||||||
import com.abin.mallchat.custom.chatai.properties.ChatGLM2Properties;
|
import com.abin.mallchat.custom.chatai.properties.ChatGLM2Properties;
|
||||||
@@ -10,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -69,11 +71,11 @@ public class ChatGLM2Handler extends AbstractChatAIHandler {
|
|||||||
.prompt(content)
|
.prompt(content)
|
||||||
.timeout(glm2Properties.getTimeout())
|
.timeout(glm2Properties.getTimeout())
|
||||||
.send();
|
.send();
|
||||||
|
text = ChatGLM2Utils.parseText(response);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return getErrorText();
|
return getErrorText();
|
||||||
}
|
}
|
||||||
text = ChatGLM2Utils.parseText(response);
|
|
||||||
if (StringUtils.isNotBlank(text)) {
|
if (StringUtils.isNotBlank(text)) {
|
||||||
RedisUtils.set(RedisKey.getKey(USER_GLM2_TIME_LAST, uid), new Date(), glm2Properties.getMinute(), TimeUnit.MINUTES);
|
RedisUtils.set(RedisKey.getKey(USER_GLM2_TIME_LAST, uid), new Date(), glm2Properties.getMinute(), TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
@@ -116,17 +118,16 @@ public class ChatGLM2Handler extends AbstractChatAIHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* 前端传@信息后取消注释 */
|
/* 前端传@信息后取消注释 */
|
||||||
|
MessageExtra extra = message.getExtra();
|
||||||
// MessageExtra extra = message.getExtra();
|
if (extra == null) {
|
||||||
// if (extra == null) {
|
return false;
|
||||||
// return false;
|
}
|
||||||
// }
|
if (CollectionUtils.isEmpty(extra.getAtUidList())) {
|
||||||
// if (CollectionUtils.isEmpty(extra.getAtUidList())) {
|
return false;
|
||||||
// return false;
|
}
|
||||||
// }
|
if (!extra.getAtUidList().contains(glm2Properties.getAIUserId())) {
|
||||||
// if (!extra.getAtUidList().contains(glm2Properties.getAIUserId())) {
|
return false;
|
||||||
// return false;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
if (StringUtils.isBlank(message.getContent())) {
|
if (StringUtils.isBlank(message.getContent())) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ public class ChatAIServiceImpl implements IChatAIService {
|
|||||||
if (extra == null) {
|
if (extra == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AbstractChatAIHandler chatAI = ChatAIHandlerFactory.getChatAIHandlerByName(message.getContent());
|
// AbstractChatAIHandler chatAI = ChatAIHandlerFactory.getChatAIHandlerByName(message.getContent());
|
||||||
// AbstractChatAIHandler chatAI = ChatAIHandlerFactory.getChatAIHandlerById(extra.getAtUidList());
|
AbstractChatAIHandler chatAI = ChatAIHandlerFactory.getChatAIHandlerById(extra.getAtUidList());
|
||||||
if (chatAI != null) {
|
if (chatAI != null) {
|
||||||
chatAI.chat(message);
|
chatAI.chat(message);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user