|
@@ -1633,9 +1633,12 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
private void addPromptWordNew(List<ChatParam.Message> messageList,String count,Long extId,FastGptRole role,FastGptChatSession fastGptChatSession){
|
|
private void addPromptWordNew(List<ChatParam.Message> messageList,String count,Long extId,FastGptRole role,FastGptChatSession fastGptChatSession){
|
|
|
|
|
|
|
|
FastGptChatConversation conversation = new FastGptChatConversation();
|
|
FastGptChatConversation conversation = new FastGptChatConversation();
|
|
|
- conversation.setAiInfo(new com.alibaba.fastjson.JSONObject());
|
|
|
|
|
conversation.setUserInfo(new com.alibaba.fastjson.JSONObject());
|
|
conversation.setUserInfo(new com.alibaba.fastjson.JSONObject());
|
|
|
- conversation.setHistory(new com.alibaba.fastjson.JSONObject());
|
|
|
|
|
|
|
+ conversation.setHistory(new com.alibaba.fastjson.JSONArray());
|
|
|
|
|
+
|
|
|
|
|
+ if(role.getReminderWords() != null && !role.getReminderWords().isEmpty()){
|
|
|
|
|
+ conversation.setAiInfo(role.getReminderWords());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//组装客户信息
|
|
//组装客户信息
|
|
|
String sessionUserInfo = fastGptChatSession.getUserInfo();
|
|
String sessionUserInfo = fastGptChatSession.getUserInfo();
|
|
@@ -1666,7 +1669,7 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
|
|
|
|
|
List<FastGptChatMsg> msgs=fastGptChatMsgService.selectFastGptChatMsgByMsgSessionIdAndExtId(fastGptChatSession.getSessionId(),extId);
|
|
List<FastGptChatMsg> msgs=fastGptChatMsgService.selectFastGptChatMsgByMsgSessionIdAndExtId(fastGptChatSession.getSessionId(),extId);
|
|
|
if (!msgs.isEmpty()){
|
|
if (!msgs.isEmpty()){
|
|
|
- com.alibaba.fastjson.JSONObject history = conversation.getHistory();
|
|
|
|
|
|
|
+ com.alibaba.fastjson.JSONArray historyArray = new com.alibaba.fastjson.JSONArray();
|
|
|
Collections.reverse(msgs);
|
|
Collections.reverse(msgs);
|
|
|
msgs.remove(msgs.size() - 1);
|
|
msgs.remove(msgs.size() - 1);
|
|
|
for (FastGptChatMsg msg : msgs) {
|
|
for (FastGptChatMsg msg : msgs) {
|
|
@@ -1677,9 +1680,12 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- history.put(sendType==1?"user":"ai",content);
|
|
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject msgObj = new com.alibaba.fastjson.JSONObject();
|
|
|
|
|
+ msgObj.put("role", sendType==1?"user":"ai");
|
|
|
|
|
+ msgObj.put("content", content);
|
|
|
|
|
+ historyArray.add(msgObj);
|
|
|
}
|
|
}
|
|
|
- conversation.setHistory(history);
|
|
|
|
|
|
|
+ conversation.setHistory(historyArray);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (count!=null&& !count.isEmpty()){
|
|
if (count!=null&& !count.isEmpty()){
|
|
@@ -1698,9 +1704,8 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
private void addPromptWord(List<ChatParam.Message> messageList,String count,Long extId,String words,String countInfo,Long sessionId){
|
|
private void addPromptWord(List<ChatParam.Message> messageList,String count,Long extId,String words,String countInfo,Long sessionId){
|
|
|
|
|
|
|
|
FastGptChatConversation conversation = new FastGptChatConversation();
|
|
FastGptChatConversation conversation = new FastGptChatConversation();
|
|
|
- conversation.setAiInfo(new com.alibaba.fastjson.JSONObject());
|
|
|
|
|
conversation.setUserInfo(new com.alibaba.fastjson.JSONObject());
|
|
conversation.setUserInfo(new com.alibaba.fastjson.JSONObject());
|
|
|
- conversation.setHistory(new com.alibaba.fastjson.JSONObject());
|
|
|
|
|
|
|
+ conversation.setHistory(new com.alibaba.fastjson.JSONArray());
|
|
|
|
|
|
|
|
|
|
|
|
|
// 这里获取后台的提示词进行匹配
|
|
// 这里获取后台的提示词进行匹配
|
|
@@ -1756,19 +1761,23 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
|
|
|
|
|
List<FastGptChatMsg> msgs=fastGptChatMsgService.selectFastGptChatMsgByMsgSessionIdAndExtId(sessionId,extId);
|
|
List<FastGptChatMsg> msgs=fastGptChatMsgService.selectFastGptChatMsgByMsgSessionIdAndExtId(sessionId,extId);
|
|
|
if (!msgs.isEmpty()){
|
|
if (!msgs.isEmpty()){
|
|
|
- com.alibaba.fastjson.JSONObject history = conversation.getHistory();
|
|
|
|
|
|
|
+ com.alibaba.fastjson.JSONArray historyArray = new com.alibaba.fastjson.JSONArray();
|
|
|
Collections.reverse(msgs);
|
|
Collections.reverse(msgs);
|
|
|
msgs.remove(msgs.size() - 1);
|
|
msgs.remove(msgs.size() - 1);
|
|
|
for (FastGptChatMsg msg : msgs) {
|
|
for (FastGptChatMsg msg : msgs) {
|
|
|
Integer sendType = msg.getSendType();
|
|
Integer sendType = msg.getSendType();
|
|
|
String content = msg.getContent();
|
|
String content = msg.getContent();
|
|
|
if(sendType!=1){
|
|
if(sendType!=1){
|
|
|
- if (content!=null&&content.length()>150){
|
|
|
|
|
|
|
+ if (content!=null&&content.length()>500){
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- history.put(sendType==1?"user":"ai",content);
|
|
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject msgObj = new com.alibaba.fastjson.JSONObject();
|
|
|
|
|
+ msgObj.put("role", sendType==1?"user":"ai");
|
|
|
|
|
+ msgObj.put("content", content);
|
|
|
|
|
+ historyArray.add(msgObj);
|
|
|
}
|
|
}
|
|
|
|
|
+ conversation.setHistory(historyArray);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (count!=null&& !count.isEmpty()){
|
|
if (count!=null&& !count.isEmpty()){
|