优化prmpt

This commit is contained in:
2026-07-29 11:15:27 +08:00
parent 905973d739
commit cd41676ee3
2 changed files with 58 additions and 89 deletions

View File

@@ -7,7 +7,7 @@ const { broadcastToRoom } = require('./ws');
// 对话历史(内存)
const conversationHistory = new Map();
function getHistory(roomId) { if (!conversationHistory.has(roomId)) conversationHistory.set(roomId, []); return conversationHistory.get(roomId); }
function addToHistory(roomId, role, content) { var h = getHistory(roomId); h.push({ role: role, content: content }); if (h.length > 60) conversationHistory.set(roomId, h.slice(-30)); }
function addToHistory(roomId, role, content) { var h = getHistory(roomId); h.push({ role: role, content: content }); if (h.length > 16) conversationHistory.set(roomId, h.slice(-8)); }
// 待处理操作
const pendingActions = new Map();