diff --git a/public/index.html b/public/index.html index 7be2c74..4535335 100644 --- a/public/index.html +++ b/public/index.html @@ -52,7 +52,7 @@ let mediaRecorder, chunks = [], userBlob = null; let isRecording = false, micAnalyser = null, micAnimId = null; - let audioContext = null, sessionSid = null; + let audioContext = null, chatHistory = []; let thinkStart = 0, thinkTimer = null; // История — массив {q, a, time} @@ -191,13 +191,15 @@ const cRes = await fetch('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ model: 'gpt-oss-120b', message: text, sid: sessionSid }), + body: JSON.stringify({ model: 'gpt-oss-120b', message: text, history: chatHistory }), signal: (() => { const a = new AbortController(); setTimeout(() => a.abort(), 120000); return a.signal; })(), }); stopThinkTimer(); const cData = await cRes.json(); - if (cData.sid) sessionSid = cData.sid; const resp = cData.response || cData.error || 'Ошибка'; + chatHistory.push({ role: 'user', content: text }); + chatHistory.push({ role: 'assistant', content: resp }); + if (chatHistory.length > 40) chatHistory = chatHistory.slice(-40); chat.innerHTML += '