Fix: Unified Context Memory between Web and Telegram
This commit is contained in:
@@ -853,6 +853,7 @@
|
||||
|
||||
<script>
|
||||
let webPassword = localStorage.getItem('vps_web_password') || '';
|
||||
let chatHistory = []; // Memória da conversa na Web
|
||||
|
||||
// Helper para chamadas de API com autenticação
|
||||
async function apiFetch(url, options = {}) {
|
||||
@@ -1011,7 +1012,7 @@
|
||||
const res = await apiFetch('/api/chat', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ text })
|
||||
body: JSON.stringify({ text, history: chatHistory })
|
||||
});
|
||||
const data = await res.json();
|
||||
processAIReply(data.reply);
|
||||
@@ -1059,6 +1060,14 @@
|
||||
div.textContent = text;
|
||||
box.appendChild(div);
|
||||
box.scrollTop = box.scrollHeight;
|
||||
|
||||
// Atualiza o histórico local (limita a 10 mensagens)
|
||||
if (sender === 'user') {
|
||||
chatHistory.push({ user: text, bot: "" });
|
||||
} else if (chatHistory.length > 0) {
|
||||
chatHistory[chatHistory.length - 1].bot = text;
|
||||
}
|
||||
if (chatHistory.length > 10) chatHistory.shift();
|
||||
}
|
||||
|
||||
async function loadConfig() {
|
||||
|
||||
Reference in New Issue
Block a user