添加触发切换条件
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3m57s

This commit is contained in:
宋居成 2025-08-12 16:12:22 +08:00
parent a43429789c
commit ea3841a690
2 changed files with 15 additions and 12 deletions

View File

@ -60,13 +60,13 @@ function updateHistoryMessage(userInput, assistantResponse) {
); );
// 可选:限制历史消息数量,保持最近的对话 // 可选:限制历史消息数量,保持最近的对话
const maxMessages = 20; // 保留最近10轮对话20条消息 // const maxMessages = 20; // 保留最近10轮对话20条消息
if (historyMessage.length > maxMessages) { // if (historyMessage.length > maxMessages) {
// 保留系统消息和最近的对话 // // 保留系统消息和最近的对话
const systemMessages = historyMessage.filter(msg => msg.role === 'system'); // const systemMessages = historyMessage.filter(msg => msg.role === 'system');
const recentMessages = historyMessage.slice(-maxMessages + systemMessages.length); // const recentMessages = historyMessage.slice(-maxMessages + systemMessages.length);
historyMessage = [...systemMessages, ...recentMessages.filter(msg => msg.role !== 'system')]; // historyMessage = [...systemMessages, ...recentMessages.filter(msg => msg.role !== 'system')];
} // }
} }
// 保存消息到服务端 // 保存消息到服务端

View File

@ -88,13 +88,16 @@ async function processAudioQueue() {
isProcessingQueue = false; isProcessingQueue = false;
// 等待当前音频播放完成后再切换回默认视频 // 等待当前音频播放完成后再切换回默认视频
while (isPlaying) { // while (isPlaying) {
await new Promise(resolve => setTimeout(resolve, 100)); // console.log("触发音频等待")
} // await new Promise(resolve => setTimeout(resolve, 1000));
// }
// console.log("触发音频等待")
// await new Promise(resolve => setTimeout(resolve, 300));
const text = 'default' const text = 'default'
console.log("音频结束------------------------", window.webrtcApp.currentVideoTag, isPlaying) console.log("音频结束------------------------", window.webrtcApp.currentVideoTag, isPlaying)
if (window.webrtcApp.currentVideoTag != text) { if (window.webrtcApp.currentVideoTag != text && !isPlaying) {
isFirstChunk = true isFirstChunk = true
window.webrtcApp.currentVideoTag = text window.webrtcApp.currentVideoTag = text
window.webrtcApp.switchVideoStream(window.webrtcApp.defaultVideo, 'audio', text); window.webrtcApp.switchVideoStream(window.webrtcApp.defaultVideo, 'audio', text);