取消消息限制
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2m57s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2m57s
This commit is contained in:
parent
929d6887ba
commit
6e7ab83091
@ -61,13 +61,13 @@ function updateHistoryMessage(userInput, assistantResponse) {
|
||||
);
|
||||
|
||||
// 可选:限制历史消息数量,保持最近的对话
|
||||
const maxMessages = 20; // 保留最近10轮对话(20条消息)
|
||||
if (historyMessage.length > maxMessages) {
|
||||
// 保留系统消息和最近的对话
|
||||
const systemMessages = historyMessage.filter(msg => msg.role === 'system');
|
||||
const recentMessages = historyMessage.slice(-maxMessages + systemMessages.length);
|
||||
historyMessage = [...systemMessages, ...recentMessages.filter(msg => msg.role !== 'system')];
|
||||
}
|
||||
// const maxMessages = 20; // 保留最近10轮对话(20条消息)
|
||||
// if (historyMessage.length > maxMessages) {
|
||||
// // 保留系统消息和最近的对话
|
||||
// const systemMessages = historyMessage.filter(msg => msg.role === 'system');
|
||||
// const recentMessages = historyMessage.slice(-maxMessages + systemMessages.length);
|
||||
// historyMessage = [...systemMessages, ...recentMessages.filter(msg => msg.role !== 'system')];
|
||||
// }
|
||||
}
|
||||
|
||||
// 保存消息到服务端
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user