一键话术增加语音聊天
This commit is contained in:
parent
1730d7c746
commit
3670e993ad
@ -131,11 +131,21 @@ public class GenerationController {
|
|||||||
// 历史消息上下文
|
// 历史消息上下文
|
||||||
List<ArchiveMessage> top15 = (messages == null || messages.isEmpty())
|
List<ArchiveMessage> top15 = (messages == null || messages.isEmpty())
|
||||||
? new ArrayList<>()
|
? new ArrayList<>()
|
||||||
: messages.stream().limit(15).collect(Collectors.toList());
|
: messages.stream()
|
||||||
|
.filter(msg -> !(
|
||||||
|
"voice".equals(msg.getMsgtype()) &&
|
||||||
|
msg.getContent() != null &&
|
||||||
|
!msg.getContent().contains("[语音]")
|
||||||
|
))
|
||||||
|
.limit(15)
|
||||||
|
.collect(Collectors.toList());
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
boolean is_external = true;
|
boolean is_external = true;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (ArchiveMessage msg : messages) {
|
for (ArchiveMessage msg : messages) {
|
||||||
|
if("voice".equals(msg.getMsgtype()) && msg.getContent() != null && !msg.getContent().contains("[语音]")){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
sb.append(msg.getCreatedAt()).append(" ").append(msg.getFromRole()).append(" ").append(msg.getContent()).append("\n");
|
sb.append(msg.getCreatedAt()).append(" ").append(msg.getFromRole()).append(" ").append(msg.getContent()).append("\n");
|
||||||
if ("EXTERNAL".equals(messages.get(0).getFromRole())){ //第一条消息是客户的消息 则继续
|
if ("EXTERNAL".equals(messages.get(0).getFromRole())){ //第一条消息是客户的消息 则继续
|
||||||
if(count<3){
|
if(count<3){
|
||||||
|
|||||||
@ -14,12 +14,12 @@ public interface ArchiveMessageMapper extends BaseMapper<ArchiveMessage> {
|
|||||||
@Select("<script>" +
|
@Select("<script>" +
|
||||||
"(SELECT msgtime,created_at, from_role, content FROM archive_messages " +
|
"(SELECT msgtime,created_at, from_role, content FROM archive_messages " +
|
||||||
"WHERE from_user = #{fromUser} AND to_user = #{toUser_m} " +
|
"WHERE from_user = #{fromUser} AND to_user = #{toUser_m} " +
|
||||||
"AND msgtime >= #{startTime} AND msgtime < #{endTime} AND msgtype='text' " +
|
"AND msgtime >= #{startTime} AND msgtime < #{endTime} AND msgtype in ('text','voice') " +
|
||||||
"AND content IS NOT NULL AND content != '' limit 100) " +
|
"AND content IS NOT NULL AND content != '' limit 100) " +
|
||||||
"UNION ALL " +
|
"UNION ALL " +
|
||||||
"(SELECT msgtime,created_at, from_role, content FROM archive_messages " +
|
"(SELECT msgtime,created_at, from_role, content FROM archive_messages " +
|
||||||
"WHERE from_user = #{toUser} AND to_user = #{fromUser_m} " +
|
"WHERE from_user = #{toUser} AND to_user = #{fromUser_m} " +
|
||||||
"AND msgtime >= #{startTime} AND msgtime < #{endTime} AND msgtype='text' " +
|
"AND msgtime >= #{startTime} AND msgtime < #{endTime} AND msgtype in ('text','voice') " +
|
||||||
"AND content IS NOT NULL AND content != '' limit 100)" +
|
"AND content IS NOT NULL AND content != '' limit 100)" +
|
||||||
"ORDER BY msgtime DESC" +
|
"ORDER BY msgtime DESC" +
|
||||||
"</script>")
|
"</script>")
|
||||||
@ -33,7 +33,7 @@ public interface ArchiveMessageMapper extends BaseMapper<ArchiveMessage> {
|
|||||||
|
|
||||||
@Select("SELECT created_at, from_role, content FROM archive_messages " +
|
@Select("SELECT created_at, from_role, content FROM archive_messages " +
|
||||||
"WHERE roomid = #{roomid} " +
|
"WHERE roomid = #{roomid} " +
|
||||||
"AND msgtime >= #{startTime} AND msgtime < #{endTime} AND msgtype='text' " +
|
"AND msgtime >= #{startTime} AND msgtime < #{endTime} AND msgtype in ('text','voice') " +
|
||||||
"AND content IS NOT NULL AND content != '' " +
|
"AND content IS NOT NULL AND content != '' " +
|
||||||
"ORDER BY msgtime DESC")
|
"ORDER BY msgtime DESC")
|
||||||
List<ArchiveMessage> selectGroupChatMessages(@Param("roomid") String roomid,
|
List<ArchiveMessage> selectGroupChatMessages(@Param("roomid") String roomid,
|
||||||
@ -45,7 +45,7 @@ public interface ArchiveMessageMapper extends BaseMapper<ArchiveMessage> {
|
|||||||
*/
|
*/
|
||||||
@Select("SELECT msgtime, created_at, from_user, to_user, from_role, content FROM archive_messages " +
|
@Select("SELECT msgtime, created_at, from_user, to_user, from_role, content FROM archive_messages " +
|
||||||
"WHERE (from_user = #{fromUser} OR to_user = #{fromUser}) " +
|
"WHERE (from_user = #{fromUser} OR to_user = #{fromUser}) " +
|
||||||
"AND msgtime >= #{startTime} AND msgtime < #{endTime} AND msgtype='text' " +
|
"AND msgtime >= #{startTime} AND msgtime < #{endTime} AND msgtype in ('text','voice') " +
|
||||||
"AND content IS NOT NULL AND content != '' " +
|
"AND content IS NOT NULL AND content != '' " +
|
||||||
"ORDER BY msgtime DESC LIMIT 100")
|
"ORDER BY msgtime DESC LIMIT 100")
|
||||||
List<ArchiveMessage> selectMessagesByFromUser(@Param("fromUser") String fromUser,
|
List<ArchiveMessage> selectMessagesByFromUser(@Param("fromUser") String fromUser,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user