新增对话上下文,限制上下文最多5000字

This commit is contained in:
weipengfei 2023-09-22 09:41:36 +08:00
parent f14b0b11be
commit fbdb8fe8c6
1 changed files with 55 additions and 29 deletions

View File

@ -49,7 +49,7 @@
return {
talkList: [],
ajax: {
rows: 100, //
rows: 15, //
page: 1, //
flag: false, //
loading: false, //
@ -350,7 +350,9 @@
// }
// }
// };
let params = this.TEXT
if (this.historyTextList.length > 8) this.historyTextList = this.historyTextList.splice(-8);
this.isSurpass();
let params = this.historyTextList;
realThis.socketTask.send({ // uni
data: JSON.stringify(params),
success() {
@ -404,6 +406,19 @@
}
})
},
//
isSurpass(){
let sum = this.historyTextList.reduce((accumulator, currentValue) => {
return accumulator + currentValue.content;
}, '');
if(sum.length>5000){
this.historyTextList.shift();
return this.isSurpass();
}else {
console.log(`本次发送${sum.length}`);
return sum;
}
},
//
getWebSocketUrl() {
return new Promise((resolve, reject) => {
@ -455,9 +470,17 @@
}
@keyframes blink {
0% { opacity: 1; }
50% { opacity: 0; }
100% { opacity: 1; }
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.blinking-box {
@ -521,8 +544,10 @@
border-top: #e5e5e5 solid 1px;
box-sizing: content-box;
background-color: #f5f5f5;
transform: translateY(0); /* 初始化 transform 属性 */
transition: transform 0.3s ease; /* 添加过渡效果 */
transform: translateY(0);
/* 初始化 transform 属性 */
transition: transform 0.3s ease;
/* 添加过渡效果 */
/* 兼容iPhoneX */
padding-bottom: 0;
@ -640,6 +665,7 @@
margin: 0 !important;
padding: 0 !important;
}
.placeholder {
width: 100vw;
background-color: #1573fb;